Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fdb1d5802 | |||
| 0caeb2ce88 | |||
| 2729f3f7c8 | |||
| dc6160db10 | |||
| b48a682a50 | |||
| 6a406df1f4 |
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.price.domain.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRecalcCommand;
|
||||
@@ -113,19 +112,6 @@ public class PayOrderController extends BaseController
|
||||
return success(payOrderListService.fees(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 给勾选订单批量增加手工费用。创建人取当前登录用户,来源为手工,并记新增日志。
|
||||
*
|
||||
* @param batch 订单和费用行
|
||||
* @return 写入的费用条数
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:feeBatch')")
|
||||
@PostMapping("/fees/batch")
|
||||
public AjaxResult addFees(@RequestBody PayOrderFeeBatch batch)
|
||||
{
|
||||
return success(payOrderListService.addManualFees(batch));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在某一段手工增加一行应付费用。创建人取当前登录用户。
|
||||
*
|
||||
|
||||
+7
@@ -167,6 +167,13 @@ public class ArBillController extends BaseController {
|
||||
return success(account);
|
||||
}
|
||||
|
||||
/** 生成账单时选择同币种启用账户,账号只返回脱敏值。 */
|
||||
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
|
||||
@GetMapping("/bank-account-options")
|
||||
public AjaxResult bankAccountOptions(@RequestParam(defaultValue = "CNY") String currency) {
|
||||
return success(billService.selectMaskedBankAccounts(currency));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询生成账单前的订单计费结果。
|
||||
*/
|
||||
|
||||
@@ -50,41 +50,11 @@ class PayCostCalculatorTest
|
||||
|
||||
PayOrderCostResult over = PayCostCalculator.calculate(product, new BigDecimal("7"),
|
||||
null, null, null, null, "Mainland / Mad High Density", null, 1);
|
||||
assertTrue(hasFee(over, "基础运费", "3.72"));
|
||||
assertTrue(over.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertTrue(hasFee(over, "基础运费", "3.18"));
|
||||
assertTrue(hasFee(over, "每公斤续重", "0.54"));
|
||||
assertEquals(new BigDecimal("3.72"), over.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void continuationChargesAFullStepWhenTheExcessIsUnderOneKilogram()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("CTT 48H");
|
||||
product.setCurrency("EUR");
|
||||
PayWeightBand first = band("0", "1", "2.40", "Medium");
|
||||
first.setSectionName("派送费");
|
||||
first.setChargeName("派送费");
|
||||
first.setPriceUnit("EUR/ITEM");
|
||||
product.setWeightBands(new ArrayList<>(List.of(first)));
|
||||
PaySurcharge extra = fee(11L, "每公斤续重", "0.34", "EUR", "EXTRA_KG", "1");
|
||||
extra.setSectionName("派送费");
|
||||
extra.setZoneName("Medium");
|
||||
extra.setPriceUnit("EUR/KG");
|
||||
extra.setChargeText("每增加 1Kg 0.34 EUR/KG");
|
||||
product.setSurcharges(List.of(extra));
|
||||
|
||||
PayOrderCostResult partial = PayCostCalculator.calculate(product, new BigDecimal("1.2"),
|
||||
null, null, null, null, "Medium", null, 1);
|
||||
assertTrue(hasFee(partial, "基础运费", "2.74"));
|
||||
assertTrue(partial.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertEquals(new BigDecimal("2.74"), partial.getPayTotal());
|
||||
|
||||
PayOrderCostResult twoSteps = PayCostCalculator.calculate(product, new BigDecimal("2.2"),
|
||||
null, null, null, null, "Medium", null, 1);
|
||||
assertTrue(hasFee(twoSteps, "基础运费", "3.08"));
|
||||
assertTrue(twoSteps.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void boundSurchargesKeepTheCardContinuation()
|
||||
{
|
||||
@@ -111,8 +81,8 @@ class PayCostCalculatorTest
|
||||
|
||||
PayOrderCostResult over = PayCostCalculator.calculate(product, new BigDecimal("3"),
|
||||
null, null, null, "KY4 0DN", "UK Mainland", null, 1);
|
||||
assertTrue(hasFee(over, "基础运费", "14"));
|
||||
assertTrue(over.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertTrue(hasFee(over, "基础运费", "10"));
|
||||
assertTrue(hasFee(over, "每公斤续重", "4"));
|
||||
assertTrue(hasFee(over, "燃油", "1"));
|
||||
assertFalse(over.getFees().stream().anyMatch(fee -> fee.getFeeName().contains("偏远")));
|
||||
assertFalse(over.getFees().stream().anyMatch(fee -> "超重续收".equals(fee.getFeeName())));
|
||||
@@ -169,20 +139,6 @@ class PayCostCalculatorTest
|
||||
new BigDecimal("70"), new BigDecimal("50"), new BigDecimal("40"), "07008", "马德里", null, 9,
|
||||
List.of(), true, true, "FR", "法国");
|
||||
assertTrue(france.getFees().stream().noneMatch(row -> "偏远附加费".equals(row.getFeeName())));
|
||||
|
||||
PaySurcharge volume = fee(17L, "体积附加费", "6", "EUR", "SIZE", null);
|
||||
volume.setSectionName("附加费配置");
|
||||
volume.setSizeType("VOLUME");
|
||||
volume.setVolumeM3(new BigDecimal("0.01"));
|
||||
product.setSurcharges(List.of(fuel, volume));
|
||||
PayOrderCostResult underVolume = PayCostCalculator.calculate(product, new BigDecimal("1"),
|
||||
new BigDecimal("20"), new BigDecimal("20"), new BigDecimal("5"), "28001", "马德里", null, 1);
|
||||
assertTrue(underVolume.getFees().stream().noneMatch(row -> "体积附加费".equals(row.getFeeName())));
|
||||
PayOrderCostResult overVolume = PayCostCalculator.calculate(product, new BigDecimal("1"),
|
||||
new BigDecimal("50"), new BigDecimal("40"), new BigDecimal("20"), "28001", "马德里", null, 1);
|
||||
assertTrue(hasFee(overVolume, "体积附加费", "6"));
|
||||
assertTrue(overVolume.getFees().stream().anyMatch(row -> "体积附加费".equals(row.getFeeName())
|
||||
&& row.getRemark() != null && row.getRemark().contains("体积超过")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -210,8 +166,9 @@ class PayCostCalculatorTest
|
||||
|
||||
PayOrderCostResult over = PayCostCalculator.calculate(product, new BigDecimal("2"),
|
||||
null, null, null, null, "Canary Islands / Minor Islands", null, 1);
|
||||
assertTrue(hasFee(over, "基础运费", "14.98"));
|
||||
assertTrue(over.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertTrue(hasFee(over, "基础运费", "13.12"));
|
||||
assertTrue(hasFee(over, "每公斤续重", "1.86"));
|
||||
assertEquals(1, over.getFees().stream().filter(fee -> "每公斤续重".equals(fee.getFeeName())).count());
|
||||
assertEquals(new BigDecimal("14.98"), over.getPayTotal());
|
||||
}
|
||||
|
||||
@@ -225,15 +182,13 @@ class PayCostCalculatorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void oversizeAddsEveryMatchingTierOfTheSameName()
|
||||
void oversizeUsesTheHigherPercentWhenBothTiersMatch()
|
||||
{
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(spainOneZone(), new BigDecimal("1"),
|
||||
new BigDecimal("130"), new BigDecimal("50"), new BigDecimal("40"), "28001", null, 1);
|
||||
assertTrue(hasFee(result, "基础运费", "2.27"));
|
||||
assertTrue(hasFee(result, "特大包裹收费", "0.79"));
|
||||
assertTrue(hasFee(result, "特大包裹收费", "1.59"));
|
||||
assertEquals(2, result.getFees().stream().filter(fee -> "特大包裹收费".equals(fee.getFeeName())).count());
|
||||
assertEquals(new BigDecimal("4.65"), result.getPayTotal());
|
||||
assertEquals(1, result.getFees().stream().filter(fee -> "特大包裹收费".equals(fee.getFeeName())).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,43 +233,6 @@ class PayCostCalculatorTest
|
||||
assertTrue(mainland.getFees().stream().noneMatch(fee -> "偏远附加费".equals(fee.getFeeName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void evriRemoteWeightBandAddsTheSameWeightRow()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("Evri 48H");
|
||||
product.setCurrency("GBP");
|
||||
PayWeightBand mainlandLight = band("0", "1", "1.51", "UK Mainland\n英国大陆");
|
||||
mainlandLight.setChargeName("派送费");
|
||||
mainlandLight.setSectionName("派送费");
|
||||
PayWeightBand mainlandNext = band("1", "2", "1.53", "UK Mainland\n英国大陆");
|
||||
mainlandNext.setChargeName("派送费");
|
||||
mainlandNext.setSectionName("派送费");
|
||||
PayWeightBand highlandsLight = band("0", "1", "5.95", "Highlands& Islands\n高地和岛屿");
|
||||
highlandsLight.setChargeName("偏远附加费");
|
||||
highlandsLight.setSectionName("偏远附加费");
|
||||
PayWeightBand highlandsNext = band("1", "2", "5.95", "Highlands& Islands\n高地和岛屿");
|
||||
highlandsNext.setChargeName("偏远附加费");
|
||||
highlandsNext.setSectionName("偏远附加费");
|
||||
PayWeightBand heavyRemote = band("15", "20", "8.2", "Highlands& Islands\n高地和岛屿");
|
||||
heavyRemote.setChargeName("偏远附加费");
|
||||
heavyRemote.setSectionName("偏远附加费");
|
||||
product.setWeightBands(new ArrayList<>(List.of(mainlandLight, mainlandNext, highlandsLight, highlandsNext, heavyRemote)));
|
||||
|
||||
PayOrderCostResult mainland = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "LL22 8PJ", "UK Mainland\n英国大陆", null, 1);
|
||||
assertTrue(hasFee(mainland, "基础运费", "1.51"));
|
||||
assertTrue(mainland.getFees().stream().noneMatch(fee -> "偏远附加费".equals(fee.getFeeName())));
|
||||
assertEquals(new BigDecimal("1.51"), mainland.getPayTotal());
|
||||
|
||||
PayOrderCostResult remote = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "IV1 1AA", "Highlands& Islands\n高地和岛屿", null, 1);
|
||||
assertTrue(hasFee(remote, "基础运费", "1.51"));
|
||||
assertTrue(hasFee(remote, "偏远附加费", "5.95"));
|
||||
assertEquals(1, remote.getFees().stream().filter(fee -> "偏远附加费".equals(fee.getFeeName())).count());
|
||||
assertEquals(new BigDecimal("7.46"), remote.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void spanishPrefixChargesFirstWeightThenExtraKg()
|
||||
{
|
||||
@@ -366,11 +284,9 @@ class PayCostCalculatorTest
|
||||
PayWeightBand lineHaul = band("0", "1", "0.09", "Mad High Density 马德里高密度地区");
|
||||
lineHaul.setSectionName("额外线路运输费");
|
||||
lineHaul.setChargeName("额外线路运输费");
|
||||
PayWeightBand remote = band("0", "1", "7.1", "Balearic Islands");
|
||||
PayWeightBand remote = band("0", "1", "7.1", "Balearic Islands 07邮编开头");
|
||||
remote.setSectionName("偏远附加费");
|
||||
remote.setChargeName("偏远附加费");
|
||||
remote.setCalcRule("POSTCODE");
|
||||
remote.setCalcParam("07");
|
||||
product.setWeightBands(new ArrayList<>(List.of(delivery, lineHaul, remote)));
|
||||
PaySurcharge deliveryExtra = fee(11L, "每公斤续重", "0.29", "EUR", "EXTRA_KG", "1");
|
||||
deliveryExtra.setSectionName("派送费");
|
||||
@@ -380,19 +296,21 @@ class PayCostCalculatorTest
|
||||
lineExtra.setZoneName("Mad High Density 马德里高密度地区");
|
||||
PaySurcharge remoteExtra = fee(13L, "每公斤续重", "4", "EUR", "EXTRA_KG", "1");
|
||||
remoteExtra.setSectionName("偏远附加费");
|
||||
remoteExtra.setZoneName("Balearic Islands");
|
||||
remoteExtra.setZoneName("Balearic Islands 07邮编开头");
|
||||
product.setSurcharges(List.of(deliveryExtra, lineExtra, remoteExtra));
|
||||
|
||||
PayOrderCostResult island = PayCostCalculator.calculate(product, new BigDecimal("3"),
|
||||
null, null, null, "07008", "Mad High Density 马德里高密度地区", null, 1, List.of(), true, true, "ES", "西班牙");
|
||||
assertTrue(hasFee(island, "基础运费", "15.1"));
|
||||
assertTrue(island.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())
|
||||
|| fee.getAmount().compareTo(new BigDecimal("2.05")) == 0
|
||||
|| fee.getFeeName().contains("额外线路") || "偏远附加费".equals(fee.getFeeName())));
|
||||
null, null, null, "07008", "Mad High Density 马德里高密度地区", null, 1);
|
||||
assertTrue(hasFee(island, "基础运费", "2.05"));
|
||||
assertTrue(hasFee(island, "每公斤续重", "0.58"));
|
||||
assertTrue(hasFee(island, "额外线路运输费", "0.09"));
|
||||
assertTrue(hasFee(island, "额外线路运输费", "0.10"));
|
||||
assertTrue(hasFee(island, "偏远附加费", "7.1"));
|
||||
assertTrue(hasFee(island, "偏远附加费", "8"));
|
||||
|
||||
PayOrderCostResult mainland = PayCostCalculator.calculate(product, new BigDecimal("3"),
|
||||
null, null, null, "28001", "Mad High Density 马德里高密度地区", null, 1);
|
||||
assertTrue(hasFee(mainland, "基础运费", "2.63"));
|
||||
assertTrue(hasFee(mainland, "基础运费", "2.05"));
|
||||
assertTrue(hasFee(mainland, "额外线路运输费", "0.09"));
|
||||
assertTrue(mainland.getFees().stream().noneMatch(fee -> "偏远附加费".equals(fee.getFeeName())));
|
||||
assertEquals("07", PaySurchargeRules.remotePrefixes("Balearic Islands 07邮编开头"));
|
||||
@@ -401,40 +319,6 @@ class PayCostCalculatorTest
|
||||
assertEquals("", PaySurchargeRules.remotePrefixes("岛屿邮编地区"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void weightBandConditionSelectsSizeOrWeightTier()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("尺寸重量");
|
||||
product.setCurrency("EUR");
|
||||
PayWeightBand normal = band("0", "30", "2.00", "普通");
|
||||
normal.setSectionName("派送费");
|
||||
normal.setChargeName("派送费");
|
||||
PayWeightBand heavy = band("0", "30", "8.00", "超重");
|
||||
heavy.setSectionName("派送费");
|
||||
heavy.setChargeName("派送费");
|
||||
heavy.setCalcRule("WEIGHT");
|
||||
heavy.setCalcParam("5");
|
||||
PayWeightBand bulky = band("0", "30", "12.00", "超尺寸");
|
||||
bulky.setSectionName("派送费");
|
||||
bulky.setChargeName("派送费");
|
||||
bulky.setCalcRule("SIZE");
|
||||
bulky.setCalcParam("side:100");
|
||||
product.setWeightBands(new ArrayList<>(List.of(normal, heavy, bulky)));
|
||||
|
||||
PayOrderCostResult plain = PayCostCalculator.calculate(product, new BigDecimal("2"),
|
||||
new BigDecimal("40"), new BigDecimal("30"), new BigDecimal("20"), "28001", "普通", null, 1);
|
||||
assertTrue(hasFee(plain, "基础运费", "2"));
|
||||
|
||||
PayOrderCostResult overWeight = PayCostCalculator.calculate(product, new BigDecimal("6"),
|
||||
new BigDecimal("40"), new BigDecimal("30"), new BigDecimal("20"), "28001", "普通", null, 1);
|
||||
assertTrue(hasFee(overWeight, "基础运费", "8"));
|
||||
|
||||
PayOrderCostResult overSize = PayCostCalculator.calculate(product, new BigDecimal("6"),
|
||||
new BigDecimal("120"), new BigDecimal("30"), new BigDecimal("20"), "28001", "普通", null, 1);
|
||||
assertTrue(hasFee(overSize, "基础运费", "12"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void productPostcodeBookChoosesTheMatchingRemoteFee()
|
||||
{
|
||||
@@ -526,59 +410,6 @@ class PayCostCalculatorTest
|
||||
assertTrue(PayRemoteBook.hits(List.of(delivery), List.of(line(42L, "28001")), "28001", "ES", "西班牙") == null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void evriFeePostcodeAddsTheMatchingSurcharge()
|
||||
{
|
||||
assertTrue(PaySurchargeRules.matchesFeePostcode("BS1 1BT", "BS1 1BT"));
|
||||
assertTrue(PaySurchargeRules.matchesFeePostcode("BS1 1BT", "bs11bt"));
|
||||
assertTrue(PaySurchargeRules.matchesFeePostcode("BS1", "BS1 1BT"));
|
||||
assertTrue(PaySurchargeRules.matchesFeePostcode("BS1 1BT", "BS1"));
|
||||
assertFalse(PaySurchargeRules.matchesFeePostcode("BS1 1BT", "SW1A 1AA"));
|
||||
assertFalse(PaySurchargeRules.matchesFeePostcode("B", "BS1 1BT"));
|
||||
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("Evri 48H");
|
||||
product.setCurrency("GBP");
|
||||
product.setWeightBands(new ArrayList<>(List.of(band("0", "1", "1.51", "UK Mainland"))));
|
||||
PaySurcharge air = fee(9L, "空气减排附加费", "0.45", "GBP", "FEE_POSTCODE", null);
|
||||
air.setSectionName("附加费配置");
|
||||
air.setScId(9L);
|
||||
product.setSurcharges(List.of(air));
|
||||
List<PayRemoteBook.Hit> hits = List.of(new PayRemoteBook.Hit("空气减排附加费", null, "Bristol", "Bristol"));
|
||||
PayOrderCostResult hit = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "BS1 1BT", "UK Mainland", null, 1, null, true, true, "GB", "英国", hits);
|
||||
assertTrue(hasFee(hit, "基础运费", "1.51"));
|
||||
assertTrue(hasFee(hit, "空气减排附加费", "0.45"));
|
||||
assertEquals(new BigDecimal("1.96"), hit.getPayTotal());
|
||||
|
||||
PayOrderCostResult miss = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "SW1A 1AA", "UK Mainland", null, 1, null, true, true, "GB", "英国", List.of());
|
||||
assertTrue(miss.getFees().stream().noneMatch(row -> "空气减排附加费".equals(row.getFeeName())));
|
||||
|
||||
List<PayRemoteBook.Hit> other = List.of(new PayRemoteBook.Hit("燃油附加费", null, "", ""));
|
||||
PayOrderCostResult named = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "BS1 1BT", "UK Mainland", null, 1, null, true, true, "GB", "英国", other);
|
||||
assertTrue(named.getFees().stream().noneMatch(row -> "空气减排附加费".equals(row.getFeeName())));
|
||||
|
||||
PayPostcodeLine stored = new PayPostcodeLine();
|
||||
stored.setChannelName("Evri 48H");
|
||||
stored.setFeeName("空气减排附加费");
|
||||
stored.setPostcode("BS1 3LT");
|
||||
List<PayRemoteBook.Hit> channelHits = PayRemoteBook.surchargeHits(List.of(stored), "BS1 3LT", "UBI英国EVRi普", "UBI_GBPEVRI", "Evri 48H");
|
||||
assertEquals(1, channelHits.size());
|
||||
assertEquals("空气减排附加费", channelHits.get(0).getFeeName());
|
||||
|
||||
PaySurcharge configured = fee(203L, "空气减排费_Evri_48H", "0.45", "EUR", "POSTCODE", null);
|
||||
configured.setSectionName("附加费配置");
|
||||
configured.setScId(203L);
|
||||
configured.setPostcodeText("BS1");
|
||||
product.setSurcharges(List.of(configured));
|
||||
PayOrderCostResult order = PayCostCalculator.calculate(product, new BigDecimal("0.5"),
|
||||
null, null, null, "BS1 3LT", "UK Mainland", null, 1, null, true, true, "GB", "英国", channelHits);
|
||||
assertTrue(order.getFees().stream().anyMatch(row -> "空气减排费_Evri_48H".equals(row.getFeeName())
|
||||
&& row.getAmount().compareTo(new BigDecimal("0.45")) == 0 && "EUR".equals(row.getCurrency())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void severalZonesCannotBePricedFromTheOrder()
|
||||
{
|
||||
|
||||
@@ -2,13 +2,11 @@ package com.bms.price.pay;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.bms.price.domain.PayPostcodeGroup;
|
||||
@@ -34,7 +32,7 @@ class PayPostcodeImporterTest
|
||||
assertEquals("Royal Mail", remote195.getChannelName());
|
||||
assertEquals("Royal Mail", remote115.getChannelName());
|
||||
assertEquals("EVRI", evri.getChannelName());
|
||||
assertEquals("Evri 48H", air.getChannelName());
|
||||
assertEquals("EVRI", air.getChannelName());
|
||||
assertEquals(15, remote195.getLineCount());
|
||||
assertTrue(remote195.getLines().stream().anyMatch(line -> "PA60-78".equals(line.getPostcode())));
|
||||
assertTrue(remote195.getLines().stream().anyMatch(line -> "PA80".equals(line.getPostcode())));
|
||||
@@ -49,8 +47,7 @@ class PayPostcodeImporterTest
|
||||
assertEquals("REMOTE", remote195.getCoverage());
|
||||
assertEquals("REMOTE", remote115.getCoverage());
|
||||
assertEquals("REMOTE", evri.getCoverage());
|
||||
assertEquals("SURCHARGE", air.getCoverage());
|
||||
assertTrue(air.getLines().stream().anyMatch(line -> "BS1 1BT".equals(line.getPostcode()) && "Bristol".equals(line.getZoneName())));
|
||||
assertEquals("", air.getCoverage());
|
||||
assertTrue(groups.stream().noneMatch(item -> "Evri 48H".equals(item.getSheetName())));
|
||||
|
||||
PayPostcodeGroup italy = groups.stream().filter(item -> "iMile邮编分区".equals(item.getSheetName()) && "IT".equals(item.getCountryCode())).findFirst().orElseThrow();
|
||||
@@ -83,7 +80,7 @@ class PayPostcodeImporterTest
|
||||
assertEquals("REACH", PayPostcodeImporter.coverageOf("法国GOFO可达邮编", "", ""));
|
||||
assertEquals("UNREACH", PayPostcodeImporter.coverageOf("德国DPD挂号(DEDPD)不可达邮编", "", ""));
|
||||
assertEquals("REMOTE", PayPostcodeImporter.coverageOf("evri 偏远", "", ""));
|
||||
assertEquals("SURCHARGE", PayPostcodeImporter.coverageOf("英国附加费", "EVRI偏远&空气减排地区附加费", "空气减排附加费"));
|
||||
assertEquals("", PayPostcodeImporter.coverageOf("英国附加费", "EVRI偏远&空气减排地区附加费", "空气减排附加费"));
|
||||
List<PayPostcodeImporter.PostcodeToken> kept = PayPostcodeImporter.expandPostcode("KA27-28");
|
||||
assertEquals("KA27-28", kept.get(0).postcode);
|
||||
assertEquals("", kept.get(0).end);
|
||||
@@ -92,75 +89,6 @@ class PayPostcodeImporterTest
|
||||
assertEquals("57039", range.get(0).end);
|
||||
}
|
||||
|
||||
@Test
|
||||
void evriAirReductionReadsAsSurchargeOnEvri48h() throws Exception
|
||||
{
|
||||
List<PayPostcodeGroup> groups = importer.parse(ukFeeBook(), "英国附加费.xlsx");
|
||||
PayPostcodeGroup royal = one(groups.stream().filter(item -> "FEE".equals(item.getConfigKind())).toList(), "偏远附加费", "1.95GBP/票");
|
||||
assertEquals("Royal Mail", royal.getChannelName());
|
||||
assertEquals("REMOTE", royal.getCoverage());
|
||||
assertTrue(royal.getLines().stream().anyMatch(line -> "IV".equals(line.getPostcode())));
|
||||
assertTrue(royal.getLines().stream().anyMatch(line -> "HS".equals(line.getPostcode())));
|
||||
|
||||
PayPostcodeGroup evri = one(groups.stream().filter(item -> "FEE".equals(item.getConfigKind())).toList(), "偏远附加费", "5.95GBP/票");
|
||||
assertEquals("EVRI", evri.getChannelName());
|
||||
assertEquals("REMOTE", evri.getCoverage());
|
||||
assertTrue(evri.getLines().stream().anyMatch(line -> "GY".equals(line.getPostcode()) && "GY*".equals(line.getPostcodeRaw())));
|
||||
assertTrue(evri.getLines().stream().noneMatch(line -> "BS1 1BT".equals(line.getPostcode())));
|
||||
|
||||
PayPostcodeGroup air = one(groups.stream().filter(item -> "FEE".equals(item.getConfigKind())).toList(), "空气减排附加费", "0.45GBP/票");
|
||||
assertEquals("Evri 48H", air.getChannelName());
|
||||
assertEquals("SURCHARGE", air.getCoverage());
|
||||
assertEquals("英国", air.getCountryName());
|
||||
assertEquals(2, air.getLineCount());
|
||||
assertTrue(air.getLines().stream().anyMatch(line -> "BS1 1BT".equals(line.getPostcode()) && "Bristol".equals(line.getZoneName()) && "Bristol".equals(line.getRegionName())));
|
||||
assertTrue(air.getLines().stream().anyMatch(line -> "BS1 1BU".equals(line.getPostcode()) && "Bristol".equals(line.getZoneName())));
|
||||
}
|
||||
|
||||
private static byte[] ukFeeBook() throws Exception
|
||||
{
|
||||
try (XSSFWorkbook book = new XSSFWorkbook(); ByteArrayOutputStream out = new ByteArrayOutputStream())
|
||||
{
|
||||
var sheet = book.createSheet("英国附加费");
|
||||
var title = sheet.createRow(0);
|
||||
title.createCell(0).setCellValue("Royal Mail偏远地区附加费");
|
||||
title.createCell(4).setCellValue("EVRI偏远&空气减排地区附加费");
|
||||
var head = sheet.createRow(1);
|
||||
String[] headers = {
|
||||
"偏远地区(英文)", "邮编开头", "偏远附加费", "",
|
||||
"偏远地区(英文)", "偏远地区(中文)", "邮编开头", "偏远附加费",
|
||||
"空气减排地区", "空气减排地区邮编", "空气减排附加费"
|
||||
};
|
||||
for (int i = 0; i < headers.length; i++)
|
||||
{
|
||||
if (!headers[i].isEmpty())
|
||||
{
|
||||
head.createCell(i).setCellValue(headers[i]);
|
||||
}
|
||||
}
|
||||
var first = sheet.createRow(2);
|
||||
first.createCell(0).setCellValue("The Highlands");
|
||||
first.createCell(1).setCellValue("IV");
|
||||
first.createCell(2).setCellValue("1.95GBP/票");
|
||||
first.createCell(4).setCellValue("Channel Islands");
|
||||
first.createCell(5).setCellValue("海峡群岛(含锡利岛)");
|
||||
first.createCell(6).setCellValue("GY*");
|
||||
first.createCell(7).setCellValue("5.95GBP/票");
|
||||
first.createCell(8).setCellValue("Bristol");
|
||||
first.createCell(9).setCellValue("BS1 1BT");
|
||||
first.createCell(10).setCellValue("0.45GBP/票");
|
||||
var second = sheet.createRow(3);
|
||||
second.createCell(1).setCellValue("HS");
|
||||
second.createCell(2).setCellValue("1.95GBP/票");
|
||||
second.createCell(6).setCellValue("JE*");
|
||||
second.createCell(7).setCellValue("5.95GBP/票");
|
||||
second.createCell(9).setCellValue("BS1 1BU");
|
||||
second.createCell(10).setCellValue("0.45GBP/票");
|
||||
book.write(out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("依赖开发机 D:/应付供应商 下的价卡文件,未随项目提供")
|
||||
void reachableUnreachableAndRemoteKeepTheirOwnCountry() throws Exception
|
||||
|
||||
@@ -37,24 +37,8 @@ class PayWorkbookParserTest
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getWeightLabel() != null && band.getWeightLabel().contains("首重") && decimal(band, "2.05")));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> band.getWeightLabel() != null && band.getWeightLabel().contains("每增加")));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> "每公斤续重".equals(fee.getFeeName()) && fee.getAmount() != null && fee.getAmount().compareTo(new BigDecimal("0.29")) == 0));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "西班牙(ES)".equals(band.getCountryName()) && "ES".equals(band.getCountryCode())
|
||||
&& band.getZoneName() != null && band.getZoneName().contains("马德里") && decimal(band, "2.05")));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "葡萄牙(PT)".equals(band.getCountryName()) && "PT".equals(band.getCountryCode())
|
||||
&& band.getZoneName() != null && band.getZoneName().contains("Mainland") && decimal(band, "2.63")));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> band.getCountryName() != null && band.getCountryName().contains("西班牙") && band.getCountryName().contains("葡萄牙")));
|
||||
assertEquals(1, ctt.getWeightBands().stream().filter(band -> "葡萄牙(PT)".equals(band.getCountryName()) && "派送费".equals(band.getChargeName())).count());
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getChargeName() != null && band.getChargeName().contains("偏远")
|
||||
&& "西班牙(ES)".equals(band.getCountryName()) && "Balearic Islands".equals(band.getZoneName())
|
||||
&& "POSTCODE".equals(band.getCalcRule()) && "07".equals(band.getCalcParam()) && decimal(band, "7.1")));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getChargeName() != null && band.getChargeName().contains("偏远")
|
||||
&& "葡萄牙(PT)".equals(band.getCountryName()) && "Portuguese Island".equals(band.getZoneName())
|
||||
&& "POSTCODE".equals(band.getCalcRule()) && "9".equals(band.getCalcParam())));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> band.getZoneName() != null && band.getZoneName().contains("邮编")));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> "每公斤续重".equals(fee.getFeeName()) && fee.getSectionName() != null && fee.getSectionName().contains("偏远")
|
||||
&& fee.getZoneName() != null && "Balearic Islands".equals(fee.getZoneName())
|
||||
&& fee.getAmount() != null && fee.getAmount().compareTo(new BigDecimal("4")) == 0));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> band.getChargeName() != null && (band.getChargeName().contains("额外") || band.getChargeName().toLowerCase().contains("line-haul"))));
|
||||
assertTrue(ctt.getSurcharges().stream().noneMatch(fee -> fee.getFeeName() != null && (fee.getFeeName().contains("额外线路") || fee.getFeeName().toLowerCase().contains("line-haul") || fee.getSectionName() != null && fee.getSectionName().toLowerCase().contains("line-haul"))));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getChargeName() != null && band.getChargeName().contains("偏远") && decimal(band, "7.1")));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getChargeName() != null && (band.getChargeName().contains("额外") || band.getChargeName().toLowerCase().contains("line-haul")) && decimal(band, "0.09")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -241,24 +225,14 @@ class PayWorkbookParserTest
|
||||
assertEquals("Evri 48H", evri.getDictValue());
|
||||
assertEquals("Evri 48H", evri.getSheetName());
|
||||
assertFalse(evri.getWeightBands().isEmpty());
|
||||
assertTrue(evri.getWeightBands().stream().filter(band -> "派送费".equals(band.getChargeName()))
|
||||
.allMatch(band -> band.getZoneName() != null && band.getZoneName().contains("Mainland")));
|
||||
assertTrue(evri.getWeightBands().stream().anyMatch(band -> decimal(band, "1.51") && band.getZoneName().contains("Mainland")
|
||||
&& "派送费".equals(band.getChargeName())));
|
||||
PayWeightBand highlands = evri.getWeightBands().stream()
|
||||
.filter(band -> "偏远附加费".equals(band.getChargeName()) && band.getZoneName().contains("Highlands") && decimal(band, "5.95"))
|
||||
assertTrue(evri.getWeightBands().stream().allMatch(band -> "派送费".equals(band.getChargeName())));
|
||||
assertTrue(evri.getWeightBands().stream().noneMatch(band -> bandText(band).contains("偏远") || bandText(band).contains("Highlands")));
|
||||
assertTrue(evri.getWeightBands().stream().anyMatch(band -> decimal(band, "1.51") && band.getZoneName().contains("Mainland")));
|
||||
PaySurcharge highlands = evri.getSurcharges().stream()
|
||||
.filter(fee -> "偏远附加费".equals(fee.getFeeName()) && fee.getZoneName().contains("Highlands") && decimalFee(fee, "5.95"))
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals("ZONE", highlands.getCalcRule());
|
||||
assertTrue(highlands.getWeightMax() != null && highlands.getWeightMax().compareTo(java.math.BigDecimal.ONE) == 0);
|
||||
assertTrue(highlands.getWeightMin() != null && highlands.getWeightMin().compareTo(java.math.BigDecimal.ZERO) == 0);
|
||||
assertEquals(5, evri.getWeightBands().stream()
|
||||
.filter(band -> "偏远附加费".equals(band.getChargeName()) && band.getWeightMax() != null
|
||||
&& band.getWeightMax().compareTo(java.math.BigDecimal.ONE) == 0)
|
||||
.count());
|
||||
assertTrue(evri.getWeightBands().stream().anyMatch(band -> "偏远附加费".equals(band.getChargeName())
|
||||
&& band.getZoneName().contains("Isle of Man") && decimal(band, "8.2")
|
||||
&& band.getWeightMin() != null && band.getWeightMin().compareTo(new java.math.BigDecimal("15")) == 0));
|
||||
assertTrue(evri.getSurcharges().stream().noneMatch(fee -> "偏远附加费".equals(fee.getFeeName()) && decimalFee(fee, "5.95")));
|
||||
assertTrue(evri.getSurcharges().stream().anyMatch(fee -> "战争附加费".equals(fee.getFeeName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -484,18 +458,29 @@ class PayWorkbookParserTest
|
||||
PayPreview preview = parser.parseMatched(Files.readAllBytes(file), file.getFileName().toString(), "CTT 48H",
|
||||
List.of("CTT 48H"));
|
||||
PayProduct ctt = preview.getProducts().get(0);
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "派送费".equals(band.getChargeName()) && "西班牙(ES)".equals(band.getCountryName())
|
||||
&& decimal(band, "2.05") && band.getZoneName().contains("马德里")));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "派送费".equals(band.getChargeName()) && "葡萄牙(PT)".equals(band.getCountryName())
|
||||
&& band.getZoneName() != null && band.getZoneName().contains("Mainland")));
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> band.getChargeName() != null && band.getChargeName().contains("偏远")
|
||||
&& "西班牙(ES)".equals(band.getCountryName()) && band.getZoneName() != null && band.getZoneName().contains("Balearic") && decimal(band, "7.1")));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> "每公斤续重".equals(fee.getFeeName()) && fee.getSectionName() != null
|
||||
&& fee.getSectionName().contains("偏远") && fee.getZoneName() != null && fee.getZoneName().contains("Canary") && decimalFee(fee, "4.5")));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> band.getChargeName() != null
|
||||
&& (band.getChargeName().contains("额外") || band.getChargeName().toLowerCase().contains("line-haul"))));
|
||||
assertTrue(ctt.getSurcharges().stream().noneMatch(fee -> (fee.getFeeName() != null && (fee.getFeeName().contains("额外线路") || fee.getFeeName().toLowerCase().contains("line-haul")))
|
||||
|| (fee.getSectionName() != null && (fee.getSectionName().contains("额外线路") || fee.getSectionName().toLowerCase().contains("line-haul")))));
|
||||
assertTrue(ctt.getWeightBands().stream().allMatch(band -> "派送费".equals(band.getChargeName())),
|
||||
ctt.getWeightBands().stream().map(band -> band.getChargeName() + "/" + band.getZoneName() + "/" + band.getPrice()).toList().toString());
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> decimal(band, "2.05") && band.getZoneName().contains("马德里")));
|
||||
assertTrue(ctt.getWeightBands().stream().noneMatch(band -> bandText(band).contains("偏远") || bandText(band).contains("额外")
|
||||
|| bandText(band).toLowerCase().contains("line-haul")));
|
||||
PaySurcharge balearic = ctt.getSurcharges().stream()
|
||||
.filter(fee -> "偏远附加费".equals(fee.getFeeName()) && fee.getZoneName().contains("Balearic") && decimalFee(fee, "7.1"))
|
||||
.findFirst().orElseThrow();
|
||||
assertTrue(balearic.getFeeDesc().contains("首重"));
|
||||
assertEquals("POSTCODE", balearic.getCalcRule());
|
||||
assertTrue(balearic.getCalcParam() != null && balearic.getCalcParam().contains("07"));
|
||||
assertTrue(balearic.getWeightMax() != null && balearic.getWeightMax().compareTo(new java.math.BigDecimal("1")) == 0);
|
||||
PaySurcharge canary = ctt.getSurcharges().stream()
|
||||
.filter(fee -> "偏远附加费".equals(fee.getFeeName()) && fee.getZoneName().contains("Canary") && decimalFee(fee, "4.5")
|
||||
&& fee.getChargeText().contains("KG"))
|
||||
.findFirst().orElseThrow();
|
||||
assertEquals("EXTRA_KG", canary.getCalcRule());
|
||||
assertEquals("1", canary.getCalcParam());
|
||||
assertTrue(canary.getPostcodeParam() != null && canary.getPostcodeParam().contains("35") && canary.getPostcodeParam().contains("38"));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> fee.getFeeName().contains("额外线路运输费") && "MANUAL".equals(fee.getCalcRule())));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> fee.getFeeName().contains("额外线路运输费") && decimalFee(fee, "0.09")));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> fee.getFeeName().contains("额外线路运输费")
|
||||
&& fee.getFeeDesc().contains("800公里")));
|
||||
assertTrue(ctt.getSurcharges().stream().anyMatch(fee -> "超重附加费".equals(fee.getFeeName()) && decimalFee(fee, "5.98")));
|
||||
}
|
||||
|
||||
@@ -603,13 +588,13 @@ class PayWorkbookParserTest
|
||||
PayOrderCostResult twoKg = PayCostCalculator.calculate(ctt, new java.math.BigDecimal("2"), null, null, null, null,
|
||||
"Balearic Islands Economy 48H / Majorca", null, 1);
|
||||
assertEquals(new java.math.BigDecimal("4.24"), twoKg.getPayTotal());
|
||||
assertTrue(twoKg.getFees().stream().anyMatch(fee -> "基础运费".equals(fee.getFeeName())
|
||||
&& fee.getAmount().compareTo(new java.math.BigDecimal("4.24")) == 0));
|
||||
assertTrue(twoKg.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertEquals(1, twoKg.getFees().stream().filter(fee -> "每公斤续重".equals(fee.getFeeName())
|
||||
&& fee.getAmount().compareTo(new java.math.BigDecimal("0.85")) == 0).count());
|
||||
PayOrderCostResult island = PayCostCalculator.calculate(ctt, new java.math.BigDecimal("2"), null, null, null, null,
|
||||
"Portuguese Island / Island", null, 1);
|
||||
assertEquals(new java.math.BigDecimal("12.41"), island.getPayTotal());
|
||||
assertTrue(island.getFees().stream().noneMatch(fee -> "每公斤续重".equals(fee.getFeeName())));
|
||||
assertEquals(1, island.getFees().stream().filter(fee -> "每公斤续重".equals(fee.getFeeName())
|
||||
&& fee.getAmount().compareTo(new java.math.BigDecimal("3.34")) == 0).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.bms.receivable;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.bms.common.core.domain.model.LoginUser;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.customer.customerinfo.domain.BmsCustomerOption;
|
||||
import com.bms.customer.customerinfo.mapper.BmsCustomerMapper;
|
||||
import com.bms.receivable.domain.ArBankAccount;
|
||||
import com.bms.receivable.domain.ArBill;
|
||||
import com.bms.receivable.domain.vo.ArBillGenerateRequest;
|
||||
import com.bms.receivable.mapper.ArBankAccountMapper;
|
||||
import com.bms.receivable.mapper.ArBillGenerateTaskMapper;
|
||||
import com.bms.receivable.mapper.ArBillMapper;
|
||||
import com.bms.receivable.security.ArBillScopeResolver;
|
||||
import com.bms.receivable.service.IArBillLogService;
|
||||
import com.bms.receivable.service.impl.ArBillServiceImpl;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
class ArBillGenerateBankAccountTest {
|
||||
private final ArBillServiceImpl service = new ArBillServiceImpl();
|
||||
private final ArBillMapper bills = mock(ArBillMapper.class);
|
||||
private final ArBankAccountMapper accounts = mock(ArBankAccountMapper.class);
|
||||
private final ArBillGenerateTaskMapper tasks = mock(ArBillGenerateTaskMapper.class);
|
||||
private final ArBillScopeResolver scope = mock(ArBillScopeResolver.class);
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
LoginUser login = new LoginUser();
|
||||
login.setUserId(1L);
|
||||
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(login, null, List.of()));
|
||||
ReflectionTestUtils.setField(service, "billMapper", bills);
|
||||
ReflectionTestUtils.setField(service, "bankAccountMapper", accounts);
|
||||
ReflectionTestUtils.setField(service, "generateTaskMapper", tasks);
|
||||
ReflectionTestUtils.setField(service, "billScope", scope);
|
||||
ReflectionTestUtils.setField(service, "customerMapper", mock(BmsCustomerMapper.class));
|
||||
ReflectionTestUtils.setField(service, "eventPublisher", mock(ApplicationEventPublisher.class));
|
||||
ReflectionTestUtils.setField(service, "logService", mock(IArBillLogService.class));
|
||||
BmsCustomerOption customer = new BmsCustomerOption();
|
||||
customer.setCustomerCode("C1");
|
||||
customer.setCustomerName("客户");
|
||||
when(scope.requireCustomerAccessible(1L)).thenReturn(customer);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void clearLogin() { SecurityContextHolder.clearContext(); }
|
||||
|
||||
@Test
|
||||
void selectedAccountIsValidatedAndSavedAsBillSnapshot() {
|
||||
ArBankAccount account = account("CNY");
|
||||
when(accounts.selectEnabledById(9L)).thenReturn(account);
|
||||
ArBillGenerateRequest request = request();
|
||||
request.setBankAccountId(9L);
|
||||
request.setBankAccountNo("前端伪造的账号");
|
||||
service.generateBill(request, "admin", "request-1");
|
||||
|
||||
ArgumentCaptor<ArBill> saved = ArgumentCaptor.forClass(ArBill.class);
|
||||
verify(bills).insertArBill(saved.capture());
|
||||
assertEquals(account.getAccountName(), saved.getValue().getBankAccountName());
|
||||
assertEquals(account.getAccountNo(), saved.getValue().getBankAccountNo());
|
||||
assertEquals(account.getBankName(), saved.getValue().getBankName());
|
||||
verify(accounts, never()).selectDefaultByCurrency(anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
void missingOrWrongCurrencyAccountCannotCreateBillAndOldRequestsUseDefault() {
|
||||
ArBillGenerateRequest request = request();
|
||||
request.setBankAccountId(9L);
|
||||
assertThrows(ServiceException.class, () -> service.generateBill(request, "admin", "missing"));
|
||||
when(accounts.selectEnabledById(9L)).thenReturn(account("USD"));
|
||||
assertThrows(ServiceException.class, () -> service.generateBill(request, "admin", "wrong-currency"));
|
||||
verify(bills, never()).insertArBill(any());
|
||||
|
||||
request.setBankAccountId(null);
|
||||
when(accounts.selectDefaultByCurrency("CNY")).thenReturn(account("CNY"));
|
||||
assertDoesNotThrow(() -> service.generateBill(request, "admin", "legacy"));
|
||||
verify(accounts).selectDefaultByCurrency("CNY");
|
||||
}
|
||||
|
||||
@Test
|
||||
void bankAccountOptionsMaskNumbersWithoutSpaces() {
|
||||
ArBankAccount account = account("CNY");
|
||||
when(accounts.selectEnabledList("CNY")).thenReturn(List.of(account));
|
||||
assertEquals("****2050", service.selectMaskedBankAccounts("CNY").get(0).getAccountNo());
|
||||
}
|
||||
|
||||
private static ArBankAccount account(String currency) {
|
||||
ArBankAccount account = new ArBankAccount();
|
||||
account.setAccountName("收款单位");
|
||||
account.setAccountNo("8602 1110 0008 9205 0");
|
||||
account.setBankName("开户行");
|
||||
account.setCurrency(currency);
|
||||
return account;
|
||||
}
|
||||
|
||||
private static ArBillGenerateRequest request() {
|
||||
ArBillGenerateRequest request = new ArBillGenerateRequest();
|
||||
request.setCustomerId(1L);
|
||||
request.setBillName("测试账单");
|
||||
request.setBillPeriodEnd(Date.valueOf("2026-10-31"));
|
||||
request.setSourceBillIds(List.of(1L));
|
||||
return request;
|
||||
}
|
||||
}
|
||||
+17
@@ -111,6 +111,23 @@ class ArBillTemplateSelectionTest {
|
||||
assertEquals("应收账单汇总模板", options.get(0).getTemplateName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void fixedPayeeTemplatesAllowDifferentBillAccountSnapshots() {
|
||||
bill.setBankAccountName("其他收款单位");
|
||||
bill.setBankAccountNo("1234567890");
|
||||
bill.setBankName("其他银行");
|
||||
ArExportTemplate guangzhou = template(3L, ArBillWorkbookWriters.GUANGZHOU_TEMPLATE_CODE);
|
||||
guangzhou.setStorageKey("templates/receivable/ar_bill_template_gz.xlsx");
|
||||
ArExportTemplate jiyun = template(4L, ArBillWorkbookWriters.JIYUN_TEMPLATE_CODE);
|
||||
jiyun.setStorageKey("templates/receivable/ar_bill_template_jy.xlsx");
|
||||
when(templates.selectEnabledById(3L, "AR_BILL", bill.getBillDate())).thenReturn(guangzhou);
|
||||
when(templates.selectEnabledById(4L, "AR_BILL", bill.getBillDate())).thenReturn(jiyun);
|
||||
|
||||
assertEquals(3L, service.exportBill(7L, 3L, "admin", "gz-export").getTemplateId());
|
||||
assertEquals(4L, service.exportBill(7L, 4L, "admin", "jy-export").getTemplateId());
|
||||
verify(exports, times(2)).insert(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapperQueriesEnforceBusinessStatusEffectiveDatesAndTaskTemplate() throws Exception {
|
||||
Configuration configuration = new Configuration();
|
||||
|
||||
+86
-3
@@ -11,6 +11,8 @@ import java.math.RoundingMode;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -24,6 +26,8 @@ import com.bms.receivable.domain.ArExportTemplate;
|
||||
import com.bms.receivable.mapper.ArBillDetailFeeMapper;
|
||||
import com.bms.receivable.mapper.ArBillDetailMapper;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
@@ -35,12 +39,42 @@ class ArBillWorkbookWriterTest {
|
||||
@TempDir
|
||||
Path temporary;
|
||||
|
||||
@Test
|
||||
void summaryDetailsKeepReceiptDateTimeAsExcelDateForNormalAndHighlightedRows() throws Exception {
|
||||
ArBillDetail normal = detail(1, "P1", "1.00");
|
||||
normal.setReceiveTime(Timestamp.valueOf("2026-10-01 21:32:51"));
|
||||
ArBillDetail failed = detail(2, "P1", "1.00");
|
||||
failed.setReceiveTime(Timestamp.valueOf("2026-10-02 00:01:02"));
|
||||
failed.setBillingFailStatus(2);
|
||||
ArBillDetail missing = detail(3, "P1", "1.00");
|
||||
missing.setReceiveTime(null);
|
||||
Path target = temporary.resolve("summary-receipt-times.xlsx");
|
||||
summaryWriter(List.of(normal, failed, missing)).write(bill(3, "3.00", "CNY"), summaryTemplate(), target);
|
||||
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook(target.toFile())) {
|
||||
XSSFSheet sheet = workbook.getSheetAt(1);
|
||||
var normalCell = sheet.getRow(4).getCell(1);
|
||||
var failedCell = sheet.getRow(5).getCell(1);
|
||||
assertEquals(CellType.NUMERIC, normalCell.getCellType());
|
||||
assertEquals(CellType.NUMERIC, failedCell.getCellType());
|
||||
assertTrue(DateUtil.isCellDateFormatted(normalCell));
|
||||
assertTrue(DateUtil.isCellDateFormatted(failedCell));
|
||||
assertEquals("yyyy/mm/dd", normalCell.getCellStyle().getDataFormatString());
|
||||
assertEquals("2026/10/01", new DataFormatter().formatCellValue(normalCell));
|
||||
assertEquals(LocalDateTime.of(2026, 10, 1, 21, 32, 51), normalCell.getLocalDateTimeCellValue());
|
||||
assertEquals("2026/10/02", new DataFormatter().formatCellValue(failedCell));
|
||||
assertEquals(LocalDateTime.of(2026, 10, 2, 0, 1, 2), failedCell.getLocalDateTimeCellValue());
|
||||
assertEquals(IndexedColors.YELLOW.getIndex(), failedCell.getCellStyle().getFillForegroundColor());
|
||||
assertEquals("", sheet.getRow(6).getCell(1).getStringCellValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void summaryAndDetailsReconcileSnapshotAmountsAndKeepFreightFormulaAndBlankFields() throws Exception {
|
||||
ArBill bill = bill(3, "13.20", "CNY");
|
||||
List<ArBillDetail> details = List.of(detail(1, "P1", "10.12"), detail(2, "P1", "-2.22"),
|
||||
detail(3, "P2", "5.30"));
|
||||
// 相同名称的不同产品仍需分组;收货日期也不能替代账单所属期。
|
||||
// 相同名称的不同产品仍需分组;日期范围统一按本账单明细的收货日期展示。
|
||||
details.forEach(row -> row.setProductName("相同产品名"));
|
||||
Path target = temporary.resolve("summary.xlsx");
|
||||
SummaryArBillWorkbookWriter writer = summaryWriter(details);
|
||||
@@ -54,7 +88,7 @@ class ArBillWorkbookWriterTest {
|
||||
assertEquals("客户 & <测试>", summary.getRow(3).getCell(1).getStringCellValue());
|
||||
assertEquals("相同产品名", summary.getRow(3).getCell(2).getStringCellValue());
|
||||
assertEquals("相同产品名", summary.getRow(4).getCell(2).getStringCellValue());
|
||||
assertEquals("20261001-20261031", summary.getRow(3).getCell(3).getStringCellValue());
|
||||
assertEquals("20261105-20261105", summary.getRow(3).getCell(3).getStringCellValue());
|
||||
assertEquals("国际货物运输代理服务费", summary.getRow(4).getCell(6).getStringCellValue());
|
||||
assertEquals(7.90, summary.getRow(3).getCell(4).getNumericCellValue(), 0.00001);
|
||||
assertEquals(5.30, summary.getRow(4).getCell(4).getNumericCellValue(), 0.00001);
|
||||
@@ -65,7 +99,7 @@ class ArBillWorkbookWriterTest {
|
||||
assertTrue(summary.getMergedRegions().stream().anyMatch(region -> "A11:B11".equals(region.formatAsString())));
|
||||
|
||||
assertEquals("客户 & <测试>", freight.getRow(2).getCell(1).getStringCellValue());
|
||||
assertEquals("20261001-20261031", freight.getRow(2).getCell(18).getStringCellValue());
|
||||
assertEquals("20261105-20261105", freight.getRow(2).getCell(18).getStringCellValue());
|
||||
assertEquals("0000123", freight.getRow(4).getCell(0).getStringCellValue());
|
||||
assertEquals("00000001", freight.getRow(4).getCell(2).getStringCellValue());
|
||||
assertEquals("001234567890123456789", freight.getRow(4).getCell(3).getStringCellValue());
|
||||
@@ -206,6 +240,53 @@ class ArBillWorkbookWriterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void summaryDatesUseTheWholeBillsReceiveRangeInsteadOfItsStoredPeriod() throws Exception {
|
||||
ArBill bill = bill(3, "3.00", "CNY");
|
||||
bill.setBillPeriodStart(Date.valueOf("2026-09-29"));
|
||||
bill.setBillPeriodEnd(Date.valueOf("2026-10-31"));
|
||||
ArBillDetail middle = detail(1, "P1", "1.00");
|
||||
middle.setReceiveTime(Date.valueOf("2026-10-20"));
|
||||
ArBillDetail earliest = detail(2, "P2", "1.00");
|
||||
earliest.setReceiveTime(Date.valueOf("2026-10-01"));
|
||||
ArBillDetail latest = detail(3, "P1", "1.00");
|
||||
latest.setReceiveTime(Date.valueOf("2026-10-30"));
|
||||
SummaryArBillWorkbookWriter writer = summaryWriter(List.of(middle, earliest, latest));
|
||||
when(writer.detailMapper.selectReceiveTimeRangeByBillId(7L)).thenReturn(Map.of(
|
||||
"minReceiveTime", LocalDateTime.of(2026, 10, 1, 8, 30),
|
||||
"maxReceiveTime", Timestamp.valueOf("2026-10-30 23:50:00")));
|
||||
Path target = temporary.resolve("receive-dates.xlsx");
|
||||
writer.write(bill, summaryTemplate(), target);
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook(target.toFile())) {
|
||||
XSSFSheet summary = workbook.getSheetAt(0);
|
||||
XSSFSheet freight = workbook.getSheetAt(1);
|
||||
assertEquals("20261001-20261030", summary.getRow(3).getCell(3).getStringCellValue());
|
||||
assertEquals("20261001-20261030", summary.getRow(4).getCell(3).getStringCellValue());
|
||||
assertEquals("20261001-20261030", freight.getRow(2).getCell(18).getStringCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 20, 0, 0), freight.getRow(4).getCell(1).getLocalDateTimeCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 1, 0, 0), freight.getRow(5).getCell(1).getLocalDateTimeCellValue());
|
||||
assertEquals(LocalDateTime.of(2026, 10, 30, 0, 0), freight.getRow(6).getCell(1).getLocalDateTimeCellValue());
|
||||
}
|
||||
verify(writer.detailMapper, times(1)).selectReceiveTimeRangeByBillId(7L);
|
||||
assertEquals(Date.valueOf("2026-09-29"), bill.getBillPeriodStart());
|
||||
assertEquals(Date.valueOf("2026-10-31"), bill.getBillPeriodEnd());
|
||||
}
|
||||
|
||||
@Test
|
||||
void summaryDatesStayBlankWhenReceiveTimesAreMissing() throws Exception {
|
||||
ArBillDetail detail = detail(1, "P1", "1.00");
|
||||
detail.setReceiveTime(null);
|
||||
SummaryArBillWorkbookWriter writer = summaryWriter(List.of(detail));
|
||||
when(writer.detailMapper.selectReceiveTimeRangeByBillId(7L)).thenReturn(Map.of());
|
||||
Path target = temporary.resolve("missing-receive-dates.xlsx");
|
||||
writer.write(bill(1, "1.00", "CNY"), summaryTemplate(), target);
|
||||
try (XSSFWorkbook workbook = new XSSFWorkbook(target.toFile())) {
|
||||
assertEquals("", workbook.getSheetAt(0).getRow(3).getCell(3).getStringCellValue());
|
||||
assertEquals("", workbook.getSheetAt(1).getRow(2).getCell(18).getStringCellValue());
|
||||
assertEquals("", workbook.getSheetAt(1).getRow(4).getCell(1).getStringCellValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void fixedPayeeTemplatesKeepTheirOwnBankDetailsAndSecondSheetWhileFillingOrders() throws Exception {
|
||||
for (String code : List.of(ArBillWorkbookWriters.GUANGZHOU_TEMPLATE_CODE,
|
||||
@@ -277,6 +358,8 @@ class ArBillWorkbookWriterTest {
|
||||
private SummaryArBillWorkbookWriter summaryWriter(List<ArBillDetail> details) {
|
||||
SummaryArBillWorkbookWriter writer = new SummaryArBillWorkbookWriter();
|
||||
writer.detailMapper = mapper(details);
|
||||
when(writer.detailMapper.selectReceiveTimeRangeByBillId(7L)).thenReturn(Map.of(
|
||||
"minReceiveTime", Date.valueOf("2026-11-05"), "maxReceiveTime", Date.valueOf("2026-11-05")));
|
||||
writer.detailFeeMapper = mock(ArBillDetailFeeMapper.class);
|
||||
when(writer.detailFeeMapper.selectByDetailIds(anyList())).thenReturn(List.of());
|
||||
return writer;
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表勾选订单后,批量写入同一组手工费用。 */
|
||||
@Data
|
||||
public class PayOrderFeeBatch
|
||||
{
|
||||
/** 勾选的计费订单 ID */
|
||||
private List<String> billIds;
|
||||
|
||||
/** 要加到每一票订单上的费用 */
|
||||
private List<PayOrderFeeLine> fees;
|
||||
}
|
||||
@@ -17,9 +17,6 @@ public class PayOrderRow
|
||||
|
||||
private String trackingNo;
|
||||
|
||||
/** 客户编码,列表展示用 */
|
||||
private String customerCode;
|
||||
|
||||
private String customerName;
|
||||
|
||||
private String productName;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PayPostcodeGroup extends BaseEntity
|
||||
/** ZONE 邮编分区,FEE 附加费 */
|
||||
private String configKind;
|
||||
|
||||
/** REACH 可达,UNREACH 不可达,REMOTE 偏远,SURCHARGE 附加费。普通分区为空 */
|
||||
/** REACH 可达,UNREACH 不可达,REMOTE 偏远。普通分区为空 */
|
||||
private String coverage;
|
||||
|
||||
/** 渠道名称,从表头识别,可在页面修改 */
|
||||
|
||||
@@ -22,9 +22,6 @@ public class PayPostcodeLine implements Serializable
|
||||
/** 查询条件:只看这个渠道下的邮编 */
|
||||
private String channelName;
|
||||
|
||||
/** 附加费邮编查询时带出这一组的费用名 */
|
||||
private String feeName;
|
||||
|
||||
private String regionName;
|
||||
|
||||
private String regionNameCn;
|
||||
|
||||
@@ -75,12 +75,6 @@ public class PaySurcharge
|
||||
/** 来自附加费配置的高,厘米。本表不保存 */
|
||||
private BigDecimal heightCm;
|
||||
|
||||
/** 来自附加费配置的超尺寸类型:SIDE 任一边,VOLUME 体积。本表不保存 */
|
||||
private String sizeType;
|
||||
|
||||
/** 来自附加费配置的体积阈值,立方米。本表不保存 */
|
||||
private BigDecimal volumeM3;
|
||||
|
||||
/** 来自附加费配置的超重阈值,公斤。本表不保存 */
|
||||
private BigDecimal overWeightKg;
|
||||
|
||||
|
||||
@@ -29,12 +29,6 @@ public class PayWeightBand
|
||||
/** 价格列名称,例如英国大陆、马德里高密度 */
|
||||
private String zoneName;
|
||||
|
||||
/** 计费条件类型。POSTCODE 邮编,SIZE 尺寸,WEIGHT 重量。空表示这一档只按分区 */
|
||||
private String calcRule;
|
||||
|
||||
/** 条件参数。邮编如 07 或 35,38;尺寸如 side:80;sum:180 或 box:60*40*30;重量如 30 表示超过 30kg */
|
||||
private String calcParam;
|
||||
|
||||
/** 重量段原文 */
|
||||
private String weightLabel;
|
||||
|
||||
|
||||
@@ -24,21 +24,9 @@ public class PrcPayBill implements Serializable
|
||||
private BigDecimal redlineAmount;
|
||||
/** 成本价合计(当前计费结果) */
|
||||
private BigDecimal costAmount;
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细折人民币重算) */
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细重算) */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** A段合计,人民币 */
|
||||
private BigDecimal amountA;
|
||||
|
||||
/** B段合计,人民币 */
|
||||
private BigDecimal amountB;
|
||||
|
||||
/** C段合计,人民币 */
|
||||
private BigDecimal amountC;
|
||||
|
||||
/** D段合计,人民币 */
|
||||
private BigDecimal amountD;
|
||||
|
||||
/** 应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败 */
|
||||
private Integer payCalcStatus;
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ public class PrcSurcharge extends BaseEntity
|
||||
private BigDecimal widthCm;
|
||||
/** 超尺寸高,厘米 */
|
||||
private BigDecimal heightCm;
|
||||
/** 超尺寸类型,字典 bms_size_type:SIDE 任一边,VOLUME 体积 */
|
||||
private String sizeType;
|
||||
/** 超尺寸体积阈值,立方米。类型为体积时,订单体积超过该值才收取 */
|
||||
private BigDecimal volumeM3;
|
||||
/** 超重阈值,公斤 */
|
||||
private BigDecimal overWeightKg;
|
||||
/** 超重续收起始重量,公斤 */
|
||||
|
||||
@@ -62,12 +62,6 @@ public class PrcSurchargeBind
|
||||
|
||||
private BigDecimal heightCm;
|
||||
|
||||
/** 超尺寸类型:SIDE 任一边,VOLUME 体积 */
|
||||
private String sizeType;
|
||||
|
||||
/** 超尺寸体积阈值,立方米 */
|
||||
private BigDecimal volumeM3;
|
||||
|
||||
private BigDecimal overWeightKg;
|
||||
|
||||
private BigDecimal extraWeightKg;
|
||||
|
||||
@@ -53,12 +53,6 @@ public class PrcSurchargeRel extends BaseEntity
|
||||
private String scNote;
|
||||
/** 命中邮编(来自 prc_surcharge.postcode_text) */
|
||||
private String postcodeText;
|
||||
/** 超尺寸类型:SIDE 任一边,VOLUME 体积 */
|
||||
private String sizeType;
|
||||
|
||||
/** 超尺寸体积阈值,立方米 */
|
||||
private BigDecimal volumeM3;
|
||||
|
||||
/** 超尺寸长/宽/高(厘米) */
|
||||
private BigDecimal lengthCm;
|
||||
private BigDecimal widthCm;
|
||||
|
||||
@@ -72,18 +72,6 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private BigDecimal incomeTotal;
|
||||
/** 应付合计(订单账单);也是报价应付 */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** 应付 A 段合计,来自 prc_pay_bill.amount_a */
|
||||
private BigDecimal amountA;
|
||||
|
||||
/** 应付 B 段合计,来自 prc_pay_bill.amount_b */
|
||||
private BigDecimal amountB;
|
||||
|
||||
/** 应付 C 段合计,来自 prc_pay_bill.amount_c */
|
||||
private BigDecimal amountC;
|
||||
|
||||
/** 应付 D 段合计,来自 prc_pay_bill.amount_d */
|
||||
private BigDecimal amountD;
|
||||
/** 报价 / 历史字段;账单同步时与 incomeTotal 相同 */
|
||||
private BigDecimal payableTotal;
|
||||
private String currency = "CNY";
|
||||
|
||||
@@ -2,21 +2,13 @@ package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.common.core.domain.entity.SysUser;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRow;
|
||||
|
||||
/** 应付列表。 */
|
||||
public interface PayOrderListMapper
|
||||
{
|
||||
/** 当前页的计费订单 ID,顺序就是列表顺序。 */
|
||||
List<Long> selectPageIds(PayOrderQuery query);
|
||||
|
||||
/** 按主键取出这一页的列表字段。 */
|
||||
List<PayOrderRow> selectByBillIds(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 这一页更新人对应的账号和昵称。 */
|
||||
List<SysUser> selectUsers(@Param("userIds") List<Long> userIds, @Param("userNames") List<String> userNames);
|
||||
List<PayOrderRow> selectList(PayOrderQuery query);
|
||||
|
||||
PayOrderRow selectRow(@Param("billId") String billId);
|
||||
|
||||
|
||||
@@ -67,10 +67,6 @@ public interface PayPostcodeMapper
|
||||
List<PayPostcodeGroup> selectRemoteGroupsByCountry(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName);
|
||||
|
||||
/** 附加费邮编。compact 是去掉空格和符号后的订单邮编,用来按前几位缩小范围。 */
|
||||
List<PayPostcodeLine> selectSurchargeLines(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName, @Param("compact") String compact);
|
||||
|
||||
List<PayPostcodeLine> selectRegionKeys(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
List<PayPostcodeLine> selectLinesByGroups(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
@@ -63,8 +64,8 @@ public interface PrcPayBillMapper
|
||||
*/
|
||||
int refreshPayTotal(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 把折成人民币后的应付总额和 ABCD 段合计写到主表,明细金额和币种不动。 */
|
||||
int updateCnyPayTotal(PrcPayBill row);
|
||||
/** 把折成人民币后的应付汇总写到主表,明细金额和币种不动。 */
|
||||
int updateCnyPayTotal(@Param("billId") Long billId, @Param("payTotal") BigDecimal payTotal);
|
||||
|
||||
/** 订单还没有应付主表时补一行,总额随后按明细重算。单次不超过 1000 个订单。 */
|
||||
int insertMissingPayBills(@Param("billIds") List<Long> billIds, @Param("operator") String operator);
|
||||
|
||||
@@ -423,7 +423,34 @@ public final class LabelArCostCalculator
|
||||
result.getSkipped().add(name + ":价卡没有可计算的条件,暂不计费");
|
||||
}
|
||||
}
|
||||
result.getFees().addAll(sized);
|
||||
result.getFees().addAll(keepHighestByName(sized));
|
||||
}
|
||||
|
||||
/** 同一费用名的尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。 */
|
||||
private static List<PayCostLine> keepHighestByName(List<PayCostLine> lines)
|
||||
{
|
||||
List<PayCostLine> kept = new ArrayList<>();
|
||||
for (PayCostLine line : lines)
|
||||
{
|
||||
PayCostLine same = null;
|
||||
for (PayCostLine exists : kept)
|
||||
{
|
||||
if (exists.getFeeName().equals(line.getFeeName()))
|
||||
{
|
||||
same = exists;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (same == null)
|
||||
{
|
||||
kept.add(line);
|
||||
}
|
||||
else if (line.getAmount().compareTo(same.getAmount()) > 0)
|
||||
{
|
||||
kept.set(kept.indexOf(same), line);
|
||||
}
|
||||
}
|
||||
return kept;
|
||||
}
|
||||
|
||||
private static void addExtraKg(List<PayCostLine> fees, PaySurcharge fee, BigDecimal weight, String currency)
|
||||
@@ -446,43 +473,13 @@ public final class LabelArCostCalculator
|
||||
{
|
||||
return;
|
||||
}
|
||||
BigDecimal steps = PaySurchargeRules.extraSteps(fee, weight);
|
||||
if (steps.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BigDecimal over = weight.subtract(threshold);
|
||||
BigDecimal amount = fee.getAmount().multiply(steps).setScale(2, RoundingMode.HALF_UP);
|
||||
String billed = plain(steps.multiply(PaySurchargeRules.extraStepKg(fee)));
|
||||
PayCostLine freightLine = freightLine(fees);
|
||||
if (freightLine != null && "每公斤续重".equals(blank(fee.getFeeName())))
|
||||
{
|
||||
freightLine.setAmount(freightLine.getAmount().add(amount).setScale(2, RoundingMode.HALF_UP));
|
||||
String remark = blank(freightLine.getRemark());
|
||||
freightLine.setRemark((remark.isEmpty() ? "" : remark + ";") + "续重 " + billed + "kg × " + plain(fee.getAmount()));
|
||||
return;
|
||||
}
|
||||
BigDecimal amount = fee.getAmount().multiply(over).setScale(2, RoundingMode.HALF_UP);
|
||||
long scId = fee.getSurchargeId() == null ? 0L : fee.getSurchargeId();
|
||||
String remark = "超出 " + plain(over) + "kg,按 " + billed + "kg × " + plain(fee.getAmount()) + " " + blank(fee.getPriceUnit());
|
||||
String remark = "超出 " + plain(over) + "kg × " + plain(fee.getAmount()) + " " + blank(fee.getPriceUnit());
|
||||
fees.add(line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark));
|
||||
}
|
||||
|
||||
private static PayCostLine freightLine(List<PayCostLine> fees)
|
||||
{
|
||||
if (fees == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (PayCostLine row : fees)
|
||||
{
|
||||
if (row != null && "BASIC_FREIGHT".equals(row.getFeeType()))
|
||||
{
|
||||
return row;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 同一地区有多张服务表时,续重只跟本次首重所在的那一张表。 */
|
||||
private static boolean sameSection(String feeSection, String freightSection)
|
||||
{
|
||||
|
||||
@@ -103,7 +103,7 @@ public final class PayCostCalculator
|
||||
boolean postcodeOn, boolean zoneOn)
|
||||
{
|
||||
return calculate(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, remoteHits,
|
||||
postcodeOn, zoneOn, null, null, null);
|
||||
postcodeOn, zoneOn, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,17 +112,6 @@ public final class PayCostCalculator
|
||||
public static PayOrderCostResult calculate(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, List<PayRemoteBook.Hit> remoteHits,
|
||||
boolean postcodeOn, boolean zoneOn, String countryCode, String countryName)
|
||||
{
|
||||
return calculate(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, remoteHits,
|
||||
postcodeOn, zoneOn, countryCode, countryName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* surchargeHits 是应付邮编配置里属性为附加费、并且前几位对上订单邮编的结果。
|
||||
*/
|
||||
public static PayOrderCostResult calculate(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, List<PayRemoteBook.Hit> remoteHits,
|
||||
boolean postcodeOn, boolean zoneOn, String countryCode, String countryName, List<PayRemoteBook.Hit> surchargeHits)
|
||||
{
|
||||
PayOrderCostResult result = new PayOrderCostResult();
|
||||
result.setFees(new ArrayList<>());
|
||||
@@ -139,64 +128,49 @@ public final class PayCostCalculator
|
||||
result.setMessage(PaymentMesEnum.BMS_PAY_NO_WEIGHT.getCnMes());
|
||||
return result;
|
||||
}
|
||||
PayWeightBand remoteHit = conditionBand(product, postcode, countryCode, weight, length, width, height);
|
||||
PayWeightBand band;
|
||||
String pricedZone = zoneName;
|
||||
if (remoteHit != null)
|
||||
List<PayWeightBand> usable = usableBands(product.getWeightBands());
|
||||
List<PayWeightBand> bands = forZone(usable, zoneName);
|
||||
if (zoneName != null && !zoneName.isBlank() && bands.isEmpty() && hasZoneFee(product, zoneName))
|
||||
{
|
||||
band = remoteHit;
|
||||
if (!blank(remoteHit.getZoneName()).isEmpty())
|
||||
{
|
||||
pricedZone = remoteHit.getZoneName();
|
||||
}
|
||||
bands = deliveryBands(usable, product);
|
||||
}
|
||||
else
|
||||
if (zoneName != null && !zoneName.isBlank() && bands.isEmpty())
|
||||
{
|
||||
List<PayWeightBand> usable = usableBands(product.getWeightBands());
|
||||
List<PayWeightBand> bands = forZone(usable, zoneName);
|
||||
if (zoneName != null && !zoneName.isBlank() && bands.isEmpty()
|
||||
&& (hasZoneFee(product, zoneName) || hasRemoteWeightBand(product, zoneName)))
|
||||
result.setMessage("邮编对应的地区「" + zoneName + "」不在价卡重量段里");
|
||||
return result;
|
||||
}
|
||||
Set<String> zones = zones(bands);
|
||||
if (zones.size() > 1)
|
||||
{
|
||||
result.setMessage("产品「" + product.getProductName() + "」有多个地区(" + String.join("、", zones)
|
||||
+ "),邮编没有对上其中的地区,无法确定运费");
|
||||
return result;
|
||||
}
|
||||
PayWeightBand band = matchBand(bands, weight);
|
||||
if (band == null)
|
||||
{
|
||||
PayWeightBand top = highestBand(bands);
|
||||
if (top == null || weight.compareTo(top.getWeightMax()) <= 0
|
||||
|| !hasExtraKg(product, zoneName, top.getWeightMax(), top.getSectionName()))
|
||||
{
|
||||
bands = deliveryBands(usable, product);
|
||||
}
|
||||
if (zoneName != null && !zoneName.isBlank() && bands.isEmpty())
|
||||
{
|
||||
result.setMessage("邮编对应的地区「" + zoneName + "」不在价卡重量段里");
|
||||
result.setMessage(outOfRange(product, bands, weight));
|
||||
return result;
|
||||
}
|
||||
Set<String> zones = zones(bands);
|
||||
if (zones.size() > 1)
|
||||
{
|
||||
result.setMessage("产品「" + product.getProductName() + "」有多个地区(" + String.join("、", zones)
|
||||
+ "),邮编没有对上其中的地区,无法确定运费");
|
||||
return result;
|
||||
}
|
||||
band = matchBand(bands, weight);
|
||||
if (band == null)
|
||||
{
|
||||
PayWeightBand top = highestBand(bands);
|
||||
if (top == null || weight.compareTo(top.getWeightMax()) <= 0
|
||||
|| !hasExtraKg(product, zoneName, top.getWeightMax(), top.getSectionName()))
|
||||
{
|
||||
result.setMessage(outOfRange(product, bands, weight));
|
||||
return result;
|
||||
}
|
||||
band = top;
|
||||
}
|
||||
band = top;
|
||||
}
|
||||
String currency = currencyOf(product, band);
|
||||
BigDecimal freight = bandAmount(band, weight);
|
||||
String freightRemark = band.getWeightLabel() + " " + plain(band.getPrice()) + " " + blank(band.getPriceUnit());
|
||||
if (pricedZone != null && !pricedZone.isBlank())
|
||||
if (zoneName != null && !zoneName.isBlank())
|
||||
{
|
||||
freightRemark = freightRemark + ",地区 " + pricedZone.replace('\n', ' ');
|
||||
freightRemark = freightRemark + ",地区 " + zoneName.replace('\n', ' ');
|
||||
}
|
||||
PayCostLine freightLine = line("BASIC_FREIGHT", "基础运费", 0L, freight, currency, freightRemark);
|
||||
result.getFees().add(freightLine);
|
||||
result.setCurrency(currency);
|
||||
addZoneFeeBands(result, product, band, weight, postcode, currency, zoneName);
|
||||
addSurcharges(product, weight, length, width, height, postcode, pricedZone, bizDate, orderStatus, freight, currency,
|
||||
band.getSectionName(), remoteHits, surchargeHits, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
addZoneFeeBands(result, product, band, weight, postcode, currency);
|
||||
addSurcharges(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, freight, currency,
|
||||
band.getSectionName(), remoteHits, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
@@ -207,24 +181,6 @@ public final class PayCostCalculator
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 偏远费写在重量段里,和派送费按同一重量行对齐。分区对上时,运费仍用派送档。 */
|
||||
private static boolean hasRemoteWeightBand(PayProduct product, String zoneName)
|
||||
{
|
||||
if (product.getWeightBands() == null || zoneName == null || zoneName.isBlank())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (PayWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band != null && zoneFeeBand(band) && blank(band.getCalcRule()).isEmpty()
|
||||
&& PayZoneMatcher.sameZone(band.getZoneName(), zoneName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 邮编落到偏远分区,而价卡重量段只有大陆派送费时,运费用大陆档。 */
|
||||
private static boolean hasZoneFee(PayProduct product, String zoneName)
|
||||
{
|
||||
@@ -334,7 +290,7 @@ public final class PayCostCalculator
|
||||
*/
|
||||
private static void addSurcharges(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, BigDecimal freight, String currency,
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, List<PayRemoteBook.Hit> surchargeHits, boolean postcodeOn, boolean zoneOn,
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, boolean postcodeOn, boolean zoneOn,
|
||||
String countryCode, String countryName, PayOrderCostResult result)
|
||||
{
|
||||
if (product.getSurcharges() == null)
|
||||
@@ -355,19 +311,6 @@ public final class PayCostCalculator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (PaySurchargeRules.FEE_POSTCODE.equals(rule))
|
||||
{
|
||||
String feePostName = blank(fee.getFeeName());
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(feePostName + ":订单没有邮编");
|
||||
}
|
||||
else if (surchargeBookApplies(surchargeHits, fee))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + postcode.trim());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!countryAllows(fee, countryCode))
|
||||
{
|
||||
continue;
|
||||
@@ -424,11 +367,7 @@ public final class PayCostCalculator
|
||||
String name = blank(fee.getFeeName());
|
||||
if (PaySurchargeRules.POSTCODE.equals(rule))
|
||||
{
|
||||
if (configFee && surchargeBookApplies(surchargeHits, fee))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + (postcode == null ? "" : postcode.trim()));
|
||||
}
|
||||
else if (!postcodeRules.isEmpty())
|
||||
if (!postcodeRules.isEmpty())
|
||||
{
|
||||
addConfiguredZoneFee(result, fee, weight, currency, postcode, countryCode, countryName, postcodeRules, "邮编 ");
|
||||
}
|
||||
@@ -543,10 +482,37 @@ public final class PayCostCalculator
|
||||
result.getSkipped().add(name + ":价卡没有可计算的条件,暂不计费");
|
||||
}
|
||||
}
|
||||
result.getFees().addAll(sized);
|
||||
result.getFees().addAll(keepHighestByName(sized));
|
||||
result.getFees().addAll(stepped);
|
||||
}
|
||||
|
||||
/** 同一费用名的按票尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。按超出单位计的不并进这一档。 */
|
||||
private static List<PayCostLine> keepHighestByName(List<PayCostLine> lines)
|
||||
{
|
||||
List<PayCostLine> kept = new ArrayList<>();
|
||||
for (PayCostLine line : lines)
|
||||
{
|
||||
PayCostLine same = null;
|
||||
for (PayCostLine exists : kept)
|
||||
{
|
||||
if (exists.getFeeName().equals(line.getFeeName()))
|
||||
{
|
||||
same = exists;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (same == null)
|
||||
{
|
||||
kept.add(line);
|
||||
}
|
||||
else if (line.getAmount().compareTo(same.getAmount()) > 0)
|
||||
{
|
||||
kept.set(kept.indexOf(same), line);
|
||||
}
|
||||
}
|
||||
return kept;
|
||||
}
|
||||
|
||||
private static void addExtraKg(List<PayCostLine> fees, PaySurcharge fee, BigDecimal weight, String currency)
|
||||
{
|
||||
if (fee.getAmount() == null || weight == null)
|
||||
@@ -567,43 +533,13 @@ public final class PayCostCalculator
|
||||
{
|
||||
return;
|
||||
}
|
||||
BigDecimal steps = PaySurchargeRules.extraSteps(fee, weight);
|
||||
if (steps.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BigDecimal over = weight.subtract(threshold);
|
||||
BigDecimal amount = fee.getAmount().multiply(steps).setScale(2, RoundingMode.HALF_UP);
|
||||
String billed = plain(steps.multiply(PaySurchargeRules.extraStepKg(fee)));
|
||||
PayCostLine freightLine = freightLine(fees);
|
||||
if (freightLine != null && "每公斤续重".equals(blank(fee.getFeeName())))
|
||||
{
|
||||
freightLine.setAmount(freightLine.getAmount().add(amount).setScale(2, RoundingMode.HALF_UP));
|
||||
String remark = blank(freightLine.getRemark());
|
||||
freightLine.setRemark((remark.isEmpty() ? "" : remark + ";") + "续重 " + billed + "kg × " + plain(fee.getAmount()));
|
||||
return;
|
||||
}
|
||||
BigDecimal amount = fee.getAmount().multiply(over).setScale(2, RoundingMode.HALF_UP);
|
||||
long scId = feeRef(fee);
|
||||
String remark = "超出 " + plain(over) + "kg,按 " + billed + "kg × " + plain(fee.getAmount()) + " " + blank(fee.getPriceUnit());
|
||||
String remark = "超出 " + plain(over) + "kg × " + plain(fee.getAmount()) + " " + blank(fee.getPriceUnit());
|
||||
fees.add(line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark));
|
||||
}
|
||||
|
||||
private static PayCostLine freightLine(List<PayCostLine> fees)
|
||||
{
|
||||
if (fees == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (PayCostLine row : fees)
|
||||
{
|
||||
if (row != null && "BASIC_FREIGHT".equals(row.getFeeType()))
|
||||
{
|
||||
return row;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 同一地区有多张服务表时,续重只跟本次首重所在的那一张表。 */
|
||||
private static boolean sameSection(String feeSection, String freightSection)
|
||||
{
|
||||
@@ -663,11 +599,6 @@ public final class PayCostCalculator
|
||||
private static boolean sizeHit(PayProduct product, PaySurcharge fee, BigDecimal length, BigDecimal width, BigDecimal height,
|
||||
BigDecimal weight)
|
||||
{
|
||||
if (fee != null && (("VOLUME".equalsIgnoreCase(fee.getSizeType()) && fee.getVolumeM3() != null)
|
||||
|| (fee.getLengthCm() != null && fee.getWidthCm() != null && fee.getHeightCm() != null)))
|
||||
{
|
||||
return PaySurchargeRules.matchesFeeSize(fee, length, width, height);
|
||||
}
|
||||
List<Map<String, Object>> details = ruleDetails(product, PaySurchargeRules.SIZE);
|
||||
if (details.isEmpty())
|
||||
{
|
||||
@@ -760,29 +691,6 @@ public final class PayCostCalculator
|
||||
return name.contains("偏远") || name.contains("岛屿") || name.contains("remote") || name.contains("island");
|
||||
}
|
||||
|
||||
/** 附加费配置的费用名和邮编组上的费用名对得上,才收这一笔。邮编组没写费用名时,这一条附加费邮编都收。 */
|
||||
private static boolean surchargeBookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee)
|
||||
{
|
||||
if (hits == null || hits.isEmpty() || fee == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String name = blank(fee.getFeeName());
|
||||
for (PayRemoteBook.Hit hit : hits)
|
||||
{
|
||||
if (hit == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String book = blank(hit.getFeeName());
|
||||
if (book.isEmpty() || name.isEmpty() || sameFeeName(book, name) || sameFeeCore(book, name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 邮编配置命中后,金额相同的那一档才收。命中写了地区时要对上分区;没写地区时用价卡上的邮编前缀选档。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
@@ -844,22 +752,6 @@ public final class PayCostCalculator
|
||||
return fee.contains(book) || book.contains(fee);
|
||||
}
|
||||
|
||||
/** 去掉渠道和「附加费」这几个字后再比,空气减排费_Evri_48H 和空气减排附加费算同一笔。 */
|
||||
private static boolean sameFeeCore(String bookName, String feeName)
|
||||
{
|
||||
String book = feeCore(bookName);
|
||||
String fee = feeCore(feeName);
|
||||
return !book.isEmpty() && !fee.isEmpty() && (book.contains(fee) || fee.contains(book));
|
||||
}
|
||||
|
||||
private static String feeCore(String name)
|
||||
{
|
||||
String text = blank(name).toLowerCase(Locale.ROOT);
|
||||
text = text.replace("附加费", "").replace("附加", "").replace("费", "");
|
||||
text = text.replace("evri48h", "").replace("evri", "").replace("48h", "");
|
||||
return text.replaceAll("[^a-z0-9\\u4e00-\\u9fa5]", "");
|
||||
}
|
||||
|
||||
private static String feeKey(String name)
|
||||
{
|
||||
return blank(name).toLowerCase(Locale.ROOT).replace("地区", "").replace(" ", "");
|
||||
@@ -920,20 +812,7 @@ public final class PayCostCalculator
|
||||
return stepped;
|
||||
}
|
||||
}
|
||||
return matchedFee(fee, freight, currency, sizeRemark(fee));
|
||||
}
|
||||
|
||||
private static String sizeRemark(PaySurcharge fee)
|
||||
{
|
||||
if (fee != null && "VOLUME".equalsIgnoreCase(blank(fee.getSizeType())) && fee.getVolumeM3() != null)
|
||||
{
|
||||
return "体积超过 " + plain(fee.getVolumeM3()) + "m³";
|
||||
}
|
||||
if (fee == null || fee.getLengthCm() == null || fee.getWidthCm() == null || fee.getHeightCm() == null)
|
||||
{
|
||||
return "尺寸命中";
|
||||
}
|
||||
return "任一边超过 " + plain(fee.getLengthCm()) + "×" + plain(fee.getWidthCm()) + "×" + plain(fee.getHeightCm()) + "cm";
|
||||
return matchedFee(fee, freight, currency, "尺寸命中");
|
||||
}
|
||||
|
||||
/** 价卡写成每增加、每超出时,金额是一个步长的单价。 */
|
||||
@@ -1034,18 +913,17 @@ public final class PayCostCalculator
|
||||
}
|
||||
amount = freight.multiply(fee.getAmount()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
String lineCurrency = currency;
|
||||
if (!percent(fee))
|
||||
else
|
||||
{
|
||||
amount = amount.setScale(2, RoundingMode.HALF_UP);
|
||||
String feeCurrency = normalize(fee.getCurrency());
|
||||
if (!feeCurrency.isEmpty())
|
||||
if (!feeCurrency.isEmpty() && !feeCurrency.equals(currency))
|
||||
{
|
||||
lineCurrency = feeCurrency;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
long scId = feeRef(fee);
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, lineCurrency, remark);
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark);
|
||||
}
|
||||
|
||||
private static boolean percent(PaySurcharge fee)
|
||||
@@ -1079,137 +957,9 @@ public final class PayCostCalculator
|
||||
return name.contains("偏远") || name.contains("额外") || name.contains("line-haul") || name.contains("linehaul") || name.contains("运输费");
|
||||
}
|
||||
|
||||
/**
|
||||
* 重量段写了计费条件时,按条件选用这一档的金额和续重。没写条件的价卡仍按分区计费。
|
||||
* 邮编取更长前缀,重量取更高门槛,尺寸取排序靠后的一条。不同类型同时命中时,邮编优先于尺寸,尺寸优先于重量。
|
||||
*/
|
||||
private static PayWeightBand conditionBand(PayProduct product, String postcode, String countryCode, BigDecimal weight,
|
||||
BigDecimal length, BigDecimal width, BigDecimal height)
|
||||
{
|
||||
if (product.getWeightBands() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PayWeightBand best = null;
|
||||
int bestRank = 0;
|
||||
int bestPrefix = 0;
|
||||
BigDecimal bestWeight = null;
|
||||
int bestIndex = -1;
|
||||
int index = 0;
|
||||
for (PayWeightBand band : product.getWeightBands())
|
||||
{
|
||||
int rank = conditionRank(band, postcode, countryCode, weight, length, width, height);
|
||||
if (rank > bestRank)
|
||||
{
|
||||
best = band;
|
||||
bestRank = rank;
|
||||
bestPrefix = prefixScore(band, postcode);
|
||||
bestWeight = weightGate(band);
|
||||
bestIndex = index;
|
||||
}
|
||||
else if (rank > 0 && rank == bestRank)
|
||||
{
|
||||
if (rank == 3 && prefixScore(band, postcode) > bestPrefix)
|
||||
{
|
||||
best = band;
|
||||
bestPrefix = prefixScore(band, postcode);
|
||||
bestIndex = index;
|
||||
}
|
||||
else if (rank == 1)
|
||||
{
|
||||
BigDecimal gate = weightGate(band);
|
||||
if (gate != null && (bestWeight == null || gate.compareTo(bestWeight) > 0))
|
||||
{
|
||||
best = band;
|
||||
bestWeight = gate;
|
||||
bestIndex = index;
|
||||
}
|
||||
}
|
||||
else if (rank == 2 && index > bestIndex)
|
||||
{
|
||||
best = band;
|
||||
bestIndex = index;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/** 邮编 3,尺寸 2,重量 1。没有命中返回 0。 */
|
||||
private static int conditionRank(PayWeightBand band, String postcode, String countryCode, BigDecimal weight,
|
||||
BigDecimal length, BigDecimal width, BigDecimal height)
|
||||
{
|
||||
if (band == null || band.getPrice() == null || !countryFits(band.getCountryCode(), countryCode))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
String rule = blank(band.getCalcRule()).toUpperCase(Locale.ROOT);
|
||||
String param = blank(band.getCalcParam());
|
||||
if (rule.isEmpty() || param.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (PaySurchargeRules.POSTCODE.equals(rule) && PaySurchargeRules.matchesPostcode(param, postcode))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (PaySurchargeRules.SIZE.equals(rule) && PaySurchargeRules.matchesSize(param, length, width, height))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (PaySurchargeRules.WEIGHT.equals(rule) && PaySurchargeRules.matchesWeight(param, weight))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int prefixScore(PayWeightBand band, String postcode)
|
||||
{
|
||||
int length = prefixLength(blank(band.getCalcParam()), postcode);
|
||||
return length == 0 ? 1 : length;
|
||||
}
|
||||
|
||||
private static BigDecimal weightGate(PayWeightBand band)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new BigDecimal(blank(band.getCalcParam()).trim());
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean countryFits(String bandCountry, String orderCountry)
|
||||
{
|
||||
if (bandCountry == null || bandCountry.isBlank() || orderCountry == null || orderCountry.isBlank())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return bandCountry.trim().equalsIgnoreCase(orderCountry.trim());
|
||||
}
|
||||
|
||||
private static int prefixLength(String prefixes, String postcode)
|
||||
{
|
||||
String digits = postcode.replaceAll("\\D", "");
|
||||
int best = 0;
|
||||
for (String token : prefixes.split(","))
|
||||
{
|
||||
String value = token.trim();
|
||||
if (value.matches("\\d{1,5}") && !digits.isEmpty() && digits.startsWith(value) && value.length() > best)
|
||||
{
|
||||
best = value.length();
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/** 没有邮编条件的分区费用仍按地区加在已选运费上。写了邮编条件的档已经当作运费本身。 */
|
||||
/** 和首重同一地区的线路费直接加;带邮编前缀的偏远费按邮编加。超出首重再加该费用自己的续重价。 */
|
||||
private static void addZoneFeeBands(PayOrderCostResult result, PayProduct product, PayWeightBand freight, BigDecimal weight,
|
||||
String postcode, String currency, String orderZone)
|
||||
String postcode, String currency)
|
||||
{
|
||||
if (product.getWeightBands() == null || freight == null)
|
||||
{
|
||||
@@ -1217,8 +967,7 @@ public final class PayCostCalculator
|
||||
}
|
||||
for (PayWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band == null || band.getPrice() == null || !zoneFeeBand(band) || !blank(band.getCalcRule()).isEmpty()
|
||||
|| !sameWeightRow(band, freight) || !zoneFeeHits(band, freight, postcode, orderZone))
|
||||
if (band == null || band.getPrice() == null || !zoneFeeBand(band) || !zoneFeeHits(band, freight, postcode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1230,29 +979,13 @@ public final class PayCostCalculator
|
||||
}
|
||||
}
|
||||
|
||||
/** 偏远行和本次派送费是同一重量段,才按这一行加价。 */
|
||||
private static boolean sameWeightRow(PayWeightBand band, PayWeightBand freight)
|
||||
{
|
||||
if (band.getWeightMin() == null || band.getWeightMax() == null || freight.getWeightMin() == null || freight.getWeightMax() == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return band.getWeightMin().compareTo(freight.getWeightMin()) == 0
|
||||
&& band.getWeightMax().compareTo(freight.getWeightMax()) == 0;
|
||||
}
|
||||
|
||||
private static boolean zoneFeeHits(PayWeightBand band, PayWeightBand freight, String postcode, String orderZone)
|
||||
private static boolean zoneFeeHits(PayWeightBand band, PayWeightBand freight, String postcode)
|
||||
{
|
||||
String prefixes = PaySurchargeRules.remotePrefixes(band.getZoneName());
|
||||
if (!prefixes.isEmpty())
|
||||
{
|
||||
return PaySurchargeRules.matchesPostcode(prefixes, postcode);
|
||||
}
|
||||
String label = blank(band.getChargeName()) + " " + blank(band.getSectionName());
|
||||
if (label.contains("偏远"))
|
||||
{
|
||||
return orderZone != null && !orderZone.isBlank() && PayZoneMatcher.sameZone(band.getZoneName(), orderZone);
|
||||
}
|
||||
return PayZoneMatcher.sameZone(band.getZoneName(), freight.getZoneName());
|
||||
}
|
||||
|
||||
@@ -1277,17 +1010,11 @@ public final class PayCostCalculator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal steps = PaySurchargeRules.extraSteps(fee, weight);
|
||||
if (steps.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
BigDecimal over = weight.subtract(band.getWeightMax());
|
||||
BigDecimal amount = fee.getAmount().multiply(steps).setScale(2, RoundingMode.HALF_UP);
|
||||
BigDecimal amount = fee.getAmount().multiply(over).setScale(2, RoundingMode.HALF_UP);
|
||||
long scId = feeRef(fee);
|
||||
result.getFees().add(line("SURCHARGE", name, scId, amount, currency,
|
||||
"超出 " + plain(over) + "kg,按 " + plain(steps.multiply(PaySurchargeRules.extraStepKg(fee))) + "kg × "
|
||||
+ plain(fee.getAmount()) + " " + blank(fee.getPriceUnit())));
|
||||
"超出 " + plain(over) + "kg × " + plain(fee.getAmount()) + " " + blank(fee.getPriceUnit())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1301,8 +1028,7 @@ public final class PayCostCalculator
|
||||
}
|
||||
for (PayWeightBand band : bands)
|
||||
{
|
||||
if (band != null && band.getPrice() != null && band.getWeightMin() != null && band.getWeightMax() != null
|
||||
&& !zoneFeeBand(band) && blank(band.getCalcRule()).isEmpty())
|
||||
if (band != null && band.getPrice() != null && band.getWeightMin() != null && band.getWeightMax() != null && !zoneFeeBand(band))
|
||||
{
|
||||
usable.add(band);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -70,10 +69,9 @@ public class PayOrderFeeCalculator
|
||||
String zoneName = resolveZone(channel, product, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), linked);
|
||||
applyCurrentSurcharge(channel.getId(), product);
|
||||
List<PayRemoteBook.Hit> remoteHits = remoteHits(linked, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), channel);
|
||||
List<PayRemoteBook.Hit> surchargeHits = surchargeHits(bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), channel, product);
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, weight, bill.getPkgLength(), bill.getPkgWidth(),
|
||||
bill.getPkgHeight(), bill.getDestPostcode(), zoneName, priceDate, orderStatus, remoteHits, true, true,
|
||||
bill.getCountryCode(), bill.getCountryName(), surchargeHits);
|
||||
bill.getCountryCode(), bill.getCountryName());
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
@@ -287,32 +285,6 @@ public class PayOrderFeeCalculator
|
||||
return hits == null || hits.isEmpty() ? null : hits;
|
||||
}
|
||||
|
||||
/** EVRI 渠道按应付邮编配置里的附加费邮编判断。前几位对上时,返回对应的费用名。 */
|
||||
private List<PayRemoteBook.Hit> surchargeHits(String postcode, String countryCode, String countryName, ServiceChannel channel,
|
||||
PayProduct product)
|
||||
{
|
||||
String productName = product == null ? "" : product.getProductName();
|
||||
if (channel == null || postcode == null || postcode.isBlank() || !evriChannel(channel, productName))
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String compact = postcode.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
if (compact.length() < 2)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<PayPostcodeLine> lines = payPostcodeMapper.selectSurchargeLines(countryCode, countryName, compact);
|
||||
return PayRemoteBook.surchargeHits(lines, postcode, channel.getChannelName(), channel.getChannelCode(), productName);
|
||||
}
|
||||
|
||||
private static boolean evriChannel(ServiceChannel channel, String productName)
|
||||
{
|
||||
String blob = ((channel.getChannelName() == null ? "" : channel.getChannelName()) + " "
|
||||
+ (channel.getChannelCode() == null ? "" : channel.getChannelCode()) + " "
|
||||
+ (productName == null ? "" : productName)).toLowerCase(Locale.ROOT);
|
||||
return blob.contains("evri");
|
||||
}
|
||||
|
||||
/**
|
||||
* 在给定邮编组里做偏远匹配。没有偏远组时返回 null,有组但邮编没命中时返回空列表。
|
||||
*
|
||||
@@ -496,8 +468,7 @@ public class PayOrderFeeCalculator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String coverage = group.getCoverage() == null ? "" : group.getCoverage().trim();
|
||||
if ("UNREACH".equalsIgnoreCase(coverage) || "SURCHARGE".equalsIgnoreCase(coverage))
|
||||
if ("UNREACH".equalsIgnoreCase(group.getCoverage() == null ? "" : group.getCoverage().trim()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -415,12 +415,6 @@ public class PayPostcodeImporter
|
||||
series.startCol = bound(owner, i, start, end, true);
|
||||
series.endBound = bound(owner, i, start, end, false);
|
||||
series.channel = channelOf(channelSources(grid, header, owner, i, start, end, title, sheetName));
|
||||
if (airReduction(grid, header, series))
|
||||
{
|
||||
series.air = true;
|
||||
series.channel = "Evri 48H";
|
||||
series.coverage = "SURCHARGE";
|
||||
}
|
||||
list.add(series);
|
||||
}
|
||||
return list;
|
||||
@@ -626,10 +620,6 @@ public class PayPostcodeImporter
|
||||
String feeName = series.fee ? cut(series.feeName, 200) : "";
|
||||
String feeValue = series.fee ? cut(feeText, 200) : "";
|
||||
String channel = cut(series.channel, 100);
|
||||
if (series.air && (zone == null || zone.isBlank()))
|
||||
{
|
||||
zone = region;
|
||||
}
|
||||
String key = kind + "|" + sheetName + "|" + country.code + "|" + channel + "|" + feeName + "|" + feeValue + "|" + (series.fee ? "" : series.startCol);
|
||||
PayPostcodeGroup group = groups.get(key);
|
||||
if (group == null)
|
||||
@@ -640,7 +630,7 @@ public class PayPostcodeImporter
|
||||
group.setSheetName(sheetName);
|
||||
group.setBlockTitle(cut(series.title.isEmpty() ? sheetName : series.title, 200));
|
||||
group.setConfigKind(kind);
|
||||
group.setCoverage(series.coverage.isEmpty() ? coverageOf(sheetName, series.title, feeName) : series.coverage);
|
||||
group.setCoverage(coverageOf(sheetName, series.title, feeName));
|
||||
group.setChannelName(channel);
|
||||
group.setCountryName(country.name);
|
||||
group.setCountryCode(country.code);
|
||||
@@ -704,10 +694,6 @@ public class PayPostcodeImporter
|
||||
{
|
||||
return "REACH";
|
||||
}
|
||||
if (source.contains("空气减排"))
|
||||
{
|
||||
return "SURCHARGE";
|
||||
}
|
||||
if (source.contains("偏远") || source.contains("岛屿"))
|
||||
{
|
||||
return "REMOTE";
|
||||
@@ -715,15 +701,6 @@ public class PayPostcodeImporter
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 空气减排地区、空气减排地区邮编这一组,属性记为附加费,渠道记为 Evri 48H。 */
|
||||
private static boolean airReduction(ExcelGrid grid, int header, Series series)
|
||||
{
|
||||
String feeHead = series.feeCol >= 0 ? flat(grid.text(header, series.feeCol)) : "";
|
||||
String postHead = flat(grid.text(header, series.postcodeCol));
|
||||
String regionHead = series.regionCol >= 0 ? flat(grid.text(header, series.regionCol)) : "";
|
||||
return feeHead.contains("空气减排") || postHead.contains("空气减排") || regionHead.contains("空气减排");
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个格子里用逗号写了多条邮编时拆开。两端都是完整邮编的区间写成起止,KA27-28 这种短区间保持原文。
|
||||
*/
|
||||
@@ -1205,8 +1182,6 @@ public class PayPostcodeImporter
|
||||
private String title = "";
|
||||
private String feeName = "";
|
||||
private String channel = "";
|
||||
private String coverage = "";
|
||||
private boolean air;
|
||||
private String zoneAbove = "";
|
||||
private String countryHint = "";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.bms.price.domain.PayPostcodeGroup;
|
||||
@@ -134,63 +133,6 @@ public final class PayRemoteBook
|
||||
return hits;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渠道对得上、邮编前几位命中的附加费邮编。同一费用名只留一条。
|
||||
*/
|
||||
public static List<Hit> surchargeHits(List<PayPostcodeLine> lines, String postcode, String channelName, String channelCode,
|
||||
String productName)
|
||||
{
|
||||
List<Hit> hits = new ArrayList<>();
|
||||
if (lines == null || lines.isEmpty() || postcode == null || postcode.isBlank())
|
||||
{
|
||||
return hits;
|
||||
}
|
||||
Set<String> seen = new java.util.LinkedHashSet<>();
|
||||
for (PayPostcodeLine line : lines)
|
||||
{
|
||||
if (line == null || !channelOwns(line.getChannelName(), channelName, channelCode, productName)
|
||||
|| !PaySurchargeRules.matchesFeePostcode(line.getPostcode(), postcode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String feeName = line.getFeeName() == null ? "" : line.getFeeName().trim();
|
||||
if (!seen.add(feeName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String region = first(line.getRegionName(), line.getRegionNameCn());
|
||||
hits.add(new Hit(feeName, null, line.getZoneName(), region));
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
/** 服务渠道或价卡产品名对上邮编组上的渠道即可。Evri 48H 价卡挂在「UBI英国EVRi普」这类渠道上时仍能用。 */
|
||||
private static boolean channelOwns(String bookChannel, String channelName, String channelCode, String productName)
|
||||
{
|
||||
if (owns(bookChannel, channelName, channelCode))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return owns(bookChannel, productName, "");
|
||||
}
|
||||
|
||||
private static boolean owns(String bookChannel, String channelName, String channelCode)
|
||||
{
|
||||
PayPostcodeGroup probe = new PayPostcodeGroup();
|
||||
probe.setChannelName(bookChannel);
|
||||
List<PayPostcodeGroup> kept = PayPostcodeBooks.ownChannel(List.of(probe), channelName, channelCode);
|
||||
String book = bookChannel == null ? "" : bookChannel.trim();
|
||||
for (PayPostcodeGroup group : kept)
|
||||
{
|
||||
String name = group.getChannelName() == null ? "" : group.getChannelName().trim();
|
||||
if (book.equals(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static BigDecimal amountOf(String feeText)
|
||||
{
|
||||
if (feeText == null || feeText.isBlank())
|
||||
|
||||
@@ -32,9 +32,6 @@ public final class PaySurchargeRules
|
||||
/** 邮编已经落到这个分区,再按重量区间收取,例如英国高地 */
|
||||
public static final String ZONE = "ZONE";
|
||||
|
||||
/** 邮编落在应付邮编配置的附加费邮编里才收取,前几位按正则前缀匹配。 */
|
||||
public static final String FEE_POSTCODE = "FEE_POSTCODE";
|
||||
|
||||
private static final Pattern REMOTE_PREFIX = Pattern.compile("(\\d{1,5}(?:\\s*[、,,]\\s*\\d{1,5})*)\\s*邮编");
|
||||
|
||||
private static final Pattern RANGE = Pattern.compile("([A-Z]{1,2})(\\d{1,2})\\s*-\\s*(\\d{1,2})");
|
||||
@@ -57,8 +54,6 @@ public final class PaySurchargeRules
|
||||
|
||||
private static final Pattern KG = Pattern.compile("(?i)(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤|千克)");
|
||||
|
||||
private static final Pattern EXTRA_STEP = Pattern.compile("(?i)(?:每增加|每超过|每超出)\\s*(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤|千克)");
|
||||
|
||||
private PaySurchargeRules()
|
||||
{
|
||||
}
|
||||
@@ -154,39 +149,6 @@ public final class PaySurchargeRules
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应付邮编配置里的附加费邮编。去掉空格后,配置邮编是订单邮编的前几位,或订单前几位对上配置邮编,都算命中。
|
||||
*/
|
||||
public static boolean matchesFeePostcode(String configured, String postcode)
|
||||
{
|
||||
String book = compactPostcode(configured);
|
||||
String order = compactPostcode(postcode);
|
||||
if (book.length() < 2 || order.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (leading(book, order))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return order.length() >= 3 && leading(order, book);
|
||||
}
|
||||
|
||||
/** 前缀正则。quote 掉邮编里的符号,只认开头连续的几位。 */
|
||||
private static boolean leading(String prefix, String text)
|
||||
{
|
||||
return Pattern.compile("^" + Pattern.quote(prefix)).matcher(text).find();
|
||||
}
|
||||
|
||||
private static String compactPostcode(String value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 应收订单附加费邮编命中:去掉全部空白后按连续串计费。
|
||||
* 如 PA2 8HA → PA28HA,并尝试 PA2/PA28 等外向码前缀,便于命中 PA20-49。
|
||||
@@ -595,14 +557,6 @@ public final class PaySurchargeRules
|
||||
/** 配置了长宽高时按三边箱规判断,否则仍认导入价卡里的尺寸表达式。 */
|
||||
public static boolean matchesFeeSize(PaySurcharge fee, BigDecimal length, BigDecimal width, BigDecimal height)
|
||||
{
|
||||
if (fee != null && "VOLUME".equalsIgnoreCase(fee.getSizeType()) && fee.getVolumeM3() != null)
|
||||
{
|
||||
if (length == null || width == null || height == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return cubicMetres(length, width, height).compareTo(fee.getVolumeM3()) > 0;
|
||||
}
|
||||
if (fee != null && fee.getLengthCm() != null && fee.getWidthCm() != null && fee.getHeightCm() != null)
|
||||
{
|
||||
if (length == null || width == null || height == null)
|
||||
@@ -706,45 +660,6 @@ public final class PaySurchargeRules
|
||||
}
|
||||
}
|
||||
|
||||
/** 续重计费步长。价卡写了每增加若干公斤时用该步长,否则按 1kg。 */
|
||||
public static BigDecimal extraStepKg(PaySurcharge fee)
|
||||
{
|
||||
if (fee != null)
|
||||
{
|
||||
String blob = (fee.getChargeText() == null ? "" : fee.getChargeText()) + " "
|
||||
+ (fee.getFeeDesc() == null ? "" : fee.getFeeDesc());
|
||||
Matcher matcher = EXTRA_STEP.matcher(blob);
|
||||
if (matcher.find())
|
||||
{
|
||||
try
|
||||
{
|
||||
BigDecimal step = new BigDecimal(matcher.group(1));
|
||||
if (step.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
return step;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return BigDecimal.ONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return BigDecimal.ONE;
|
||||
}
|
||||
|
||||
/** 超出起重后的续重档数。不足一个计重单位也按一整档收取。 */
|
||||
public static BigDecimal extraSteps(PaySurcharge fee, BigDecimal weight)
|
||||
{
|
||||
BigDecimal threshold = extraStartKg(fee);
|
||||
if (threshold == null || weight == null || weight.compareTo(threshold) <= 0)
|
||||
{
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal step = extraStepKg(fee);
|
||||
return weight.subtract(threshold).divide(step, 0, RoundingMode.CEILING);
|
||||
}
|
||||
|
||||
/** 命中邮编。独立字段优先,其次是原来的邮编列和导入文本。 */
|
||||
public static String feePostcodes(PaySurcharge fee)
|
||||
{
|
||||
@@ -998,11 +913,6 @@ public final class PaySurchargeRules
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BigDecimal cubicMetres(BigDecimal length, BigDecimal width, BigDecimal height)
|
||||
{
|
||||
return length.multiply(width).multiply(height).divide(new BigDecimal("1000000"), 6, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
private static boolean exceedsBox(BigDecimal[] parcel, BigDecimal a, BigDecimal b, BigDecimal c)
|
||||
{
|
||||
BigDecimal[] limit = desc(a, b, c);
|
||||
|
||||
@@ -428,8 +428,6 @@ public class PayWorkbookParser
|
||||
copy.setCountryName(band.getCountryName());
|
||||
copy.setCountryCode(band.getCountryCode());
|
||||
copy.setZoneName(band.getZoneName());
|
||||
copy.setCalcRule(band.getCalcRule());
|
||||
copy.setCalcParam(band.getCalcParam());
|
||||
copy.setWeightLabel(band.getWeightLabel());
|
||||
copy.setWeightMin(band.getWeightMin());
|
||||
copy.setWeightMax(band.getWeightMax());
|
||||
@@ -1153,7 +1151,7 @@ public class PayWorkbookParser
|
||||
}
|
||||
if (isFeeRateHeader(grid, row))
|
||||
{
|
||||
row = isLineHaulHeader(grid, row) ? skipRateTable(grid, row) : readFeeRateTable(grid, row, product);
|
||||
row = readFeeRateTable(grid, row, product);
|
||||
pending = "";
|
||||
continue;
|
||||
}
|
||||
@@ -1241,7 +1239,7 @@ public class PayWorkbookParser
|
||||
private int readFeeRateTable(ExcelGrid grid, int header, PayProduct product)
|
||||
{
|
||||
int data = header + 1;
|
||||
List<Integer> labelRows = new ArrayList<>();
|
||||
int subHeader = -1;
|
||||
while (data < grid.rows() && !grid.blankRow(data) && !isHardHeader(grid, data))
|
||||
{
|
||||
if (countNumbers(grid, data) > 0 || rowHasWeight(grid, data))
|
||||
@@ -1250,20 +1248,17 @@ public class PayWorkbookParser
|
||||
}
|
||||
if (countText(grid, data) >= 2)
|
||||
{
|
||||
labelRows.add(data);
|
||||
subHeader = data;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
int[] heads = countryAndZoneRows(grid, labelRows);
|
||||
int countryRow = heads[0];
|
||||
int zoneRow = heads[1];
|
||||
int[] kind = new int[grid.cols()];
|
||||
String[] parent = new String[grid.cols()];
|
||||
String[] sub = new String[grid.cols()];
|
||||
String carry = "";
|
||||
for (int col = 0; col < grid.cols(); col++)
|
||||
{
|
||||
if (strayColumn(grid, header, col, zoneRow))
|
||||
if (strayColumn(grid, header, col, subHeader))
|
||||
{
|
||||
parent[col] = "";
|
||||
sub[col] = "";
|
||||
@@ -1280,7 +1275,7 @@ public class PayWorkbookParser
|
||||
head = carry;
|
||||
}
|
||||
parent[col] = head;
|
||||
sub[col] = zoneRow < 0 ? "" : spanned(grid, zoneRow, col);
|
||||
sub[col] = subHeader < 0 ? "" : grid.text(subHeader, col);
|
||||
kind[col] = columnKind(head, numericBelow(grid, col, data));
|
||||
}
|
||||
int added = product.getSurcharges().size();
|
||||
@@ -1329,16 +1324,13 @@ public class PayWorkbookParser
|
||||
String zone = zoneOf(sub[col], parent[col]).replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
if (zoneFeeName(feeName))
|
||||
{
|
||||
String grouped = countryRow < 0 ? "" : countryAt(grid, countryRow, col);
|
||||
String prefixes = PaySurchargeRules.remotePrefixes(zone);
|
||||
String place = prefixes.isEmpty() ? zone : zoneWithoutPostcode(zone);
|
||||
if (stepWeight(weight))
|
||||
{
|
||||
addExtraKg(product, feeName, place, weight, price, firstLimit(product, feeName, place));
|
||||
addExtraKg(product, feeName, zone, weight, price, firstLimit(product, feeName, zone));
|
||||
}
|
||||
else
|
||||
{
|
||||
addZoneFeeBand(product, feeName, place, weight, price, parent[col], countryLabel(grouped), countryCodeOf(grouped), prefixes);
|
||||
addZoneFeeBand(product, feeName, zone, weight, price, parent[col]);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1386,8 +1378,8 @@ public class PayWorkbookParser
|
||||
private int readPriceTable(ExcelGrid grid, int header, String pending, PayProduct product, StringBuilder note)
|
||||
{
|
||||
int data = header + 1;
|
||||
int subHeader = -1;
|
||||
String section = cleanTitle(pending);
|
||||
List<Integer> labelRows = new ArrayList<>();
|
||||
while (data < grid.rows() && !grid.blankRow(data) && !isHardHeader(grid, data))
|
||||
{
|
||||
if (countNumbers(grid, data) > 0 || rowHasWeight(grid, data))
|
||||
@@ -1396,7 +1388,7 @@ public class PayWorkbookParser
|
||||
}
|
||||
if (countText(grid, data) >= 2)
|
||||
{
|
||||
labelRows.add(data);
|
||||
subHeader = data;
|
||||
}
|
||||
else if (section.isEmpty())
|
||||
{
|
||||
@@ -1404,16 +1396,13 @@ public class PayWorkbookParser
|
||||
}
|
||||
data++;
|
||||
}
|
||||
int[] heads = countryAndZoneRows(grid, labelRows);
|
||||
int countryRow = heads[0];
|
||||
int zoneRow = heads[1];
|
||||
int[] kind = new int[grid.cols()];
|
||||
String[] parent = new String[grid.cols()];
|
||||
String[] sub = new String[grid.cols()];
|
||||
String carry = "";
|
||||
for (int col = 0; col < grid.cols(); col++)
|
||||
{
|
||||
if (strayColumn(grid, header, col, zoneRow))
|
||||
if (strayColumn(grid, header, col, subHeader))
|
||||
{
|
||||
parent[col] = "";
|
||||
sub[col] = "";
|
||||
@@ -1430,7 +1419,7 @@ public class PayWorkbookParser
|
||||
head = carry;
|
||||
}
|
||||
parent[col] = head;
|
||||
sub[col] = zoneRow < 0 ? "" : spanned(grid, zoneRow, col);
|
||||
sub[col] = subHeader < 0 ? "" : grid.text(subHeader, col);
|
||||
kind[col] = columnKind(head, numericBelow(grid, col, data));
|
||||
}
|
||||
if (section.isEmpty())
|
||||
@@ -1518,27 +1507,7 @@ public class PayWorkbookParser
|
||||
priced = true;
|
||||
if (isSurchargePriceHead(parent[col]))
|
||||
{
|
||||
String feeName = chargeTitle(parent[col]);
|
||||
if (zoneFeeName(feeName))
|
||||
{
|
||||
String remoteCountry = country;
|
||||
String remoteCode = countryCode;
|
||||
if (countryRow >= 0)
|
||||
{
|
||||
String grouped = countryAt(grid, countryRow, col);
|
||||
if (!grouped.isBlank())
|
||||
{
|
||||
remoteCountry = countryLabel(grouped);
|
||||
remoteCode = countryCodeOf(grouped);
|
||||
}
|
||||
}
|
||||
addZoneFeeBand(product, feeName, zoneOf(sub[col], parent[col]), weight, price, parent[col],
|
||||
remoteCountry, remoteCode, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
addPricedSurcharge(product, blankTo(section, "价格"), parent[col], zoneOf(sub[col], parent[col]), weight, price);
|
||||
}
|
||||
addPricedSurcharge(product, blankTo(section, "价格"), parent[col], zoneOf(sub[col], parent[col]), weight, price);
|
||||
continue;
|
||||
}
|
||||
boolean feeHead = isPriceHead(parent[col]);
|
||||
@@ -1549,21 +1518,10 @@ public class PayWorkbookParser
|
||||
addExtraKg(product, sectionName, zone, weight, price, firstLimit(product, sectionName, zone));
|
||||
continue;
|
||||
}
|
||||
String bandCountry = country;
|
||||
String bandCode = countryCode;
|
||||
if (countryRow >= 0)
|
||||
{
|
||||
String grouped = countryAt(grid, countryRow, col);
|
||||
if (!grouped.isBlank())
|
||||
{
|
||||
bandCountry = countryLabel(grouped);
|
||||
bandCode = countryCodeOf(grouped);
|
||||
}
|
||||
}
|
||||
PayWeightBand band = new PayWeightBand();
|
||||
band.setSectionName(blankTo(section, "价格"));
|
||||
band.setCountryName(bandCountry);
|
||||
band.setCountryCode(bandCode);
|
||||
band.setCountryName(country);
|
||||
band.setCountryCode(countryCode);
|
||||
band.setWeightLabel(weight);
|
||||
BigDecimal[] bounds = PayTexts.weightBounds(weight);
|
||||
band.setWeightMin(bounds[0]);
|
||||
@@ -2201,32 +2159,12 @@ public class PayWorkbookParser
|
||||
product.getSurcharges().add(fee);
|
||||
}
|
||||
|
||||
/** 分区里的“07邮编开头”“35、38邮编开头”拆出去,地区名单独留下。 */
|
||||
private static String zoneWithoutPostcode(String zone)
|
||||
{
|
||||
if (zone == null || zone.isBlank())
|
||||
{
|
||||
return zone;
|
||||
}
|
||||
String cleaned = zone.replaceAll("\\d+(?:[、,,\\s]+\\d+)*\\s*邮编开头", "");
|
||||
cleaned = cleaned.replaceAll("\\s+", " ").trim();
|
||||
return cleaned.isEmpty() ? zone : cleaned;
|
||||
}
|
||||
|
||||
/** 偏远附加费的首重记进重量段。邮编写成计费条件,分区只留地区名。 */
|
||||
private static void addZoneFeeBand(PayProduct product, String feeName, String zone, String weight, BigDecimal price, String head,
|
||||
String country, String countryCode, String postcodeParam)
|
||||
/** 偏远附加费、额外线路运输费的首重,作为重量段里的费用项。 */
|
||||
private static void addZoneFeeBand(PayProduct product, String feeName, String zone, String weight, BigDecimal price, String head)
|
||||
{
|
||||
PayWeightBand band = new PayWeightBand();
|
||||
band.setSectionName(feeName);
|
||||
band.setCountryName(country == null || country.isBlank() ? null : country);
|
||||
band.setCountryCode(countryCode == null || countryCode.isBlank() ? null : countryCode);
|
||||
band.setZoneName(zone);
|
||||
if (postcodeParam != null && !postcodeParam.isBlank())
|
||||
{
|
||||
band.setCalcRule(PaySurchargeRules.POSTCODE);
|
||||
band.setCalcParam(postcodeParam);
|
||||
}
|
||||
band.setWeightLabel(weight);
|
||||
BigDecimal[] bounds = PayTexts.weightBounds(weight);
|
||||
band.setWeightMin(bounds[0]);
|
||||
@@ -2266,184 +2204,15 @@ public class PayWorkbookParser
|
||||
return compact.contains("每增加") || compact.contains("additionalkg") || compact.contains("kg.ad");
|
||||
}
|
||||
|
||||
/** 偏远附加费进重量段。额外线路运输费先不解析。超重、超尺寸仍走附加费。 */
|
||||
/** 偏远、额外线路这类和首重同表的费用,要进重量段。超重、超尺寸仍走附加费。 */
|
||||
private static boolean zoneFeeName(String name)
|
||||
{
|
||||
return name != null && name.contains("偏远");
|
||||
}
|
||||
|
||||
/** 表头下先是国家、再是分区时两行都认。只有一行时当作分区。 */
|
||||
private static int[] countryAndZoneRows(ExcelGrid grid, List<Integer> labelRows)
|
||||
{
|
||||
int country = -1;
|
||||
int zone = labelRows == null || labelRows.isEmpty() ? -1 : labelRows.get(labelRows.size() - 1);
|
||||
if (labelRows != null && labelRows.size() >= 2 && countryGroupRow(grid, labelRows.get(0)))
|
||||
if (name == null)
|
||||
{
|
||||
country = labelRows.get(0);
|
||||
return false;
|
||||
}
|
||||
return new int[] { country, zone };
|
||||
}
|
||||
|
||||
private static boolean countryGroupRow(ExcelGrid grid, int row)
|
||||
{
|
||||
int countries = 0;
|
||||
for (int col = 0; col < grid.cols(); col++)
|
||||
{
|
||||
String text = spanned(grid, row, col);
|
||||
if (text.isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (zoneMarker(text))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (countryWord(text))
|
||||
{
|
||||
countries++;
|
||||
}
|
||||
}
|
||||
return countries >= 1;
|
||||
}
|
||||
|
||||
private static boolean countryWord(String text)
|
||||
{
|
||||
String lower = text.toLowerCase(Locale.ROOT);
|
||||
return text.contains("西班牙") || text.contains("葡萄牙") || text.contains("英国") || text.contains("法国")
|
||||
|| text.contains("德国") || text.contains("意大利") || text.contains("荷兰")
|
||||
|| lower.contains("spain") || lower.contains("portugal");
|
||||
}
|
||||
|
||||
private static boolean zoneMarker(String text)
|
||||
{
|
||||
String lower = text.toLowerCase(Locale.ROOT);
|
||||
return text.contains("地区") || text.contains("邮编") || text.contains("密度")
|
||||
|| lower.contains("density") || lower.contains("island") || lower.contains("mainland");
|
||||
}
|
||||
|
||||
private static String countryLabel(String country)
|
||||
{
|
||||
if (country == null || country.isBlank())
|
||||
{
|
||||
return country;
|
||||
}
|
||||
String code = countryCodeOf(country);
|
||||
if (code.isEmpty() || country.contains("("))
|
||||
{
|
||||
return country;
|
||||
}
|
||||
return country + "(" + code + ")";
|
||||
}
|
||||
|
||||
private static String countryCodeOf(String country)
|
||||
{
|
||||
if (country == null || country.isBlank())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (country.contains("西班牙") || country.toLowerCase(Locale.ROOT).contains("spain"))
|
||||
{
|
||||
return "ES";
|
||||
}
|
||||
if (country.contains("葡萄牙") || country.toLowerCase(Locale.ROOT).contains("portugal"))
|
||||
{
|
||||
return "PT";
|
||||
}
|
||||
if (country.contains("英国"))
|
||||
{
|
||||
return "GB";
|
||||
}
|
||||
if (country.contains("法国"))
|
||||
{
|
||||
return "FR";
|
||||
}
|
||||
if (country.contains("德国"))
|
||||
{
|
||||
return "DE";
|
||||
}
|
||||
if (country.contains("意大利"))
|
||||
{
|
||||
return "IT";
|
||||
}
|
||||
if (country.contains("荷兰"))
|
||||
{
|
||||
return "NL";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 国家表头按列向左找到这一列所属国家。合并格和只写在左上角的国家都能认到。 */
|
||||
private static String countryAt(ExcelGrid grid, int row, int col)
|
||||
{
|
||||
if (row < 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String own = spanned(grid, row, col);
|
||||
if (!own.isBlank())
|
||||
{
|
||||
return own;
|
||||
}
|
||||
for (int left = col - 1; left >= 0; left--)
|
||||
{
|
||||
String text = spanned(grid, row, left);
|
||||
if (text.isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return countryWord(text) ? text : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** 合并单元格只在左上角有字,右侧列沿用这一格。 */
|
||||
private static String spanned(ExcelGrid grid, int row, int col)
|
||||
{
|
||||
String text = grid.text(row, col).replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
if (!text.isBlank())
|
||||
{
|
||||
return text;
|
||||
}
|
||||
for (int left = col - 1; left >= 0; left--)
|
||||
{
|
||||
if (grid.colSpan(row, left) > 1 && left + grid.colSpan(row, left) - 1 >= col)
|
||||
{
|
||||
return grid.text(row, left).replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static boolean isLineHaulHeader(ExcelGrid grid, int row)
|
||||
{
|
||||
for (int col = 0; col < grid.cols(); col++)
|
||||
{
|
||||
String text = grid.text(row, col).toLowerCase(Locale.ROOT);
|
||||
if (text.contains("line-haul") || text.contains("linehaul") || text.contains("额外线路") || text.contains("额外路线"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 额外线路运输费整表跳过,留到下一块表头。 */
|
||||
private int skipRateTable(ExcelGrid grid, int header)
|
||||
{
|
||||
int data = header + 1;
|
||||
while (data < grid.rows() && !grid.blankRow(data) && !isHardHeader(grid, data))
|
||||
{
|
||||
if (countNumbers(grid, data) > 0 || rowHasWeight(grid, data))
|
||||
{
|
||||
break;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
while (data < grid.rows() && !grid.blankRow(data) && !isHardHeader(grid, data))
|
||||
{
|
||||
data++;
|
||||
}
|
||||
return data;
|
||||
String text = name.toLowerCase(Locale.ROOT);
|
||||
return text.contains("偏远") || text.contains("额外") || text.contains("line-haul") || text.contains("linehaul") || text.contains("运输费");
|
||||
}
|
||||
|
||||
private static boolean sameSectionText(String left, String right)
|
||||
@@ -4615,7 +4384,7 @@ public class PayWorkbookParser
|
||||
}
|
||||
}
|
||||
|
||||
/** 价格表里和派送费并排、又不是偏远的费用列,按分区和重量区间记附加费。偏远列记进重量段。 */
|
||||
/** 价格表里和派送费并排的偏远列,按分区和重量区间记附加费,不进重量段。 */
|
||||
private void addPricedSurcharge(PayProduct product, String section, String head, String zone, String weight, BigDecimal price)
|
||||
{
|
||||
String feeName = shortCharge(head);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.bms.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
@@ -27,14 +26,6 @@ public interface IPayOrderListService
|
||||
*/
|
||||
PayOrderFeeLine addManualFee(String billId, PayOrderFeeLine line);
|
||||
|
||||
/**
|
||||
* 给勾选的订单批量增加同一组手工费用。来源记 MANUAL,创建人是当前登录用户,并记新增日志。
|
||||
*
|
||||
* @param batch 订单和费用行
|
||||
* @return 写入的费用条数
|
||||
*/
|
||||
int addManualFees(PayOrderFeeBatch batch);
|
||||
|
||||
/**
|
||||
* 逻辑删除一条应付费用。已经进入应付账单的费用不能删。
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IPrcPayBillFeeService
|
||||
{
|
||||
/**
|
||||
* 分批写入应付明细,并回写这些订单的应付总额。
|
||||
* 明细每批最多 1000 条,金额和币种按原样写入 prc_pay_bill_fee。汇总时外币按汇率折成人民币,ABCD 段分别四舍五入到两位后写入 prc_pay_bill,应付总额取这四段之和。
|
||||
* 明细每批最多 1000 条,金额和币种按原样写入 prc_pay_bill_fee。汇总时外币按汇率折成人民币,只回写 prc_pay_bill.pay_total。
|
||||
*
|
||||
* @param fees 本次新增的应付明细
|
||||
*/
|
||||
|
||||
+2
-33
@@ -138,10 +138,9 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
String zoneName = resolveZone(channel, product, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), linked);
|
||||
applyCurrentSurcharge(channel.getId(), product);
|
||||
List<PayRemoteBook.Hit> remoteHits = remoteHits(linked, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), channel);
|
||||
List<PayRemoteBook.Hit> surchargeHits = surchargeHits(bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), channel, product);
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, weight, bill.getPkgLength(), bill.getPkgWidth(),
|
||||
bill.getPkgHeight(), bill.getDestPostcode(), zoneName, bizDate, orderStatus, remoteHits, true, true,
|
||||
bill.getCountryCode(), bill.getCountryName(), surchargeHits);
|
||||
bill.getCountryCode(), bill.getCountryName());
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
@@ -313,34 +312,6 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
return hits == null || hits.isEmpty() ? null : hits;
|
||||
}
|
||||
|
||||
/**
|
||||
* EVRI 渠道按应付邮编配置里的附加费邮编判断。前几位对上时,返回对应的费用名。
|
||||
*/
|
||||
private List<PayRemoteBook.Hit> surchargeHits(String postcode, String countryCode, String countryName, ServiceChannel channel,
|
||||
PayProduct product)
|
||||
{
|
||||
String productName = product == null ? "" : product.getProductName();
|
||||
if (channel == null || postcode == null || postcode.isBlank() || !evriChannel(channel, productName))
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String compact = postcode.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
if (compact.length() < 2)
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<PayPostcodeLine> lines = payPostcodeMapper.selectSurchargeLines(countryCode, countryName, compact);
|
||||
return PayRemoteBook.surchargeHits(lines, postcode, channel.getChannelName(), channel.getChannelCode(), productName);
|
||||
}
|
||||
|
||||
private static boolean evriChannel(ServiceChannel channel, String productName)
|
||||
{
|
||||
String blob = ((channel.getChannelName() == null ? "" : channel.getChannelName()) + " "
|
||||
+ (channel.getChannelCode() == null ? "" : channel.getChannelCode()) + " "
|
||||
+ (productName == null ? "" : productName)).toLowerCase(Locale.ROOT);
|
||||
return blob.contains("evri");
|
||||
}
|
||||
|
||||
/** 在给定邮编组里做偏远匹配。没有偏远组时返回 null,有组但邮编没命中时返回空列表。 */
|
||||
private List<PayRemoteBook.Hit> hitsOf(List<PayPostcodeGroup> groups, String postcode, String countryCode, String countryName)
|
||||
{
|
||||
@@ -516,8 +487,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String coverage = group.getCoverage() == null ? "" : group.getCoverage().trim();
|
||||
if ("UNREACH".equalsIgnoreCase(coverage) || "SURCHARGE".equalsIgnoreCase(coverage))
|
||||
if ("UNREACH".equalsIgnoreCase(group.getCoverage() == null ? "" : group.getCoverage().trim()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -698,7 +668,6 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
scId = fallback++;
|
||||
}
|
||||
row.setScId(scId);
|
||||
row.setFeeLevel("4");
|
||||
String userId = PayFeeMoney.userId();
|
||||
row.setAmount(fee.getAmount());
|
||||
row.setCurrency(fee.getCurrency());
|
||||
|
||||
+60
-304
@@ -3,28 +3,21 @@ package com.bms.price.service.impl;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.bms.common.core.domain.entity.SysUser;
|
||||
import com.bms.common.enums.PaymentMesEnum;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
@@ -53,10 +46,6 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
|
||||
private static final int MAX_LADING_NOS = 10;
|
||||
|
||||
private static final int MAX_BATCH_LINES = 20;
|
||||
|
||||
private static final AtomicLong MANUAL_SC_SEQ = new AtomicLong();
|
||||
|
||||
private static final Map<String, String> TITLES = new LinkedHashMap<>();
|
||||
|
||||
static
|
||||
@@ -108,133 +97,7 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
safe.setOrderNos(null);
|
||||
safe.setOrderNo(orderNos.isEmpty() ? null : orderNos.get(0));
|
||||
}
|
||||
List<Long> billIds = payOrderListMapper.selectPageIds(safe);
|
||||
PageHelper.clearPage();
|
||||
Page<PayOrderRow> page = new Page<>();
|
||||
if (billIds instanceof Page<?> source)
|
||||
{
|
||||
page.setTotal(source.getTotal());
|
||||
page.setPageNum(source.getPageNum());
|
||||
page.setPageSize(source.getPageSize());
|
||||
}
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
return page;
|
||||
}
|
||||
Map<String, PayOrderRow> byId = new HashMap<>();
|
||||
for (PayOrderRow row : payOrderListMapper.selectByBillIds(billIds))
|
||||
{
|
||||
if (row != null && row.getBillId() != null)
|
||||
{
|
||||
byId.put(row.getBillId().trim(), row);
|
||||
}
|
||||
}
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
PayOrderRow row = byId.get(String.valueOf(billId));
|
||||
if (row != null)
|
||||
{
|
||||
page.add(row);
|
||||
}
|
||||
}
|
||||
fillOperators(page);
|
||||
return page;
|
||||
}
|
||||
|
||||
/** 只给当前页解析更新人。system 显示系统自动,数字主键取昵称,其余按账号取昵称。 */
|
||||
private void fillOperators(List<PayOrderRow> rows)
|
||||
{
|
||||
List<Long> userIds = new ArrayList<>();
|
||||
List<String> userNames = new ArrayList<>();
|
||||
for (PayOrderRow row : rows)
|
||||
{
|
||||
String raw = row.getUpdateBy();
|
||||
if (raw == null || raw.isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ("system".equalsIgnoreCase(raw.trim()))
|
||||
{
|
||||
row.setUpdateBy("系统自动");
|
||||
continue;
|
||||
}
|
||||
if (raw.matches("^[0-9]+$"))
|
||||
{
|
||||
try
|
||||
{
|
||||
userIds.add(Long.parseLong(raw));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
userNames.add(raw);
|
||||
}
|
||||
}
|
||||
if (userIds.isEmpty() && userNames.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Long, String> byUserId = new HashMap<>();
|
||||
Map<String, String> byUserName = new HashMap<>();
|
||||
for (SysUser user : payOrderListMapper.selectUsers(userIds, userNames))
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String label = operatorLabel(user);
|
||||
if (user.getUserId() != null && !byUserId.containsKey(user.getUserId()))
|
||||
{
|
||||
byUserId.put(user.getUserId(), label);
|
||||
}
|
||||
if (user.getUserName() != null && !user.getUserName().isBlank())
|
||||
{
|
||||
byUserName.putIfAbsent(user.getUserName().toLowerCase(Locale.ROOT), label);
|
||||
}
|
||||
}
|
||||
for (PayOrderRow row : rows)
|
||||
{
|
||||
String raw = row.getUpdateBy();
|
||||
if (raw == null || raw.isBlank() || "系统自动".equals(raw))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String label = null;
|
||||
if (raw.matches("^[0-9]+$"))
|
||||
{
|
||||
try
|
||||
{
|
||||
label = byUserId.get(Long.parseLong(raw));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
label = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label = byUserName.get(raw.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
if (label != null && !label.isBlank())
|
||||
{
|
||||
row.setUpdateBy(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 有昵称用昵称,没有就用账号。和原来列表里的更新人显示一致。 */
|
||||
private static String operatorLabel(SysUser user)
|
||||
{
|
||||
String nick = user.getNickName() == null ? "" : user.getNickName().trim();
|
||||
if (!nick.isEmpty())
|
||||
{
|
||||
return user.getNickName();
|
||||
}
|
||||
return user.getUserName();
|
||||
return payOrderListMapper.selectList(safe);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,12 +303,67 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
public PayOrderFeeLine addManualFee(String billId, PayOrderFeeLine line)
|
||||
{
|
||||
PayOrderRow order = requireOrder(billId);
|
||||
PayOrderFeeLine ready = checkedLine(line);
|
||||
if (line == null)
|
||||
{
|
||||
throw new ServiceException("请填写费用");
|
||||
}
|
||||
String level = line.getLevel() == null ? "" : line.getLevel().trim();
|
||||
if (!TITLES.containsKey(level))
|
||||
{
|
||||
throw new ServiceException("请选择费用阶段");
|
||||
}
|
||||
String feeName = firstText(line.getFeeName(), line.getFeeType());
|
||||
if (feeName.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写费用项");
|
||||
}
|
||||
if (feeName.length() > 100)
|
||||
{
|
||||
feeName = feeName.substring(0, 100);
|
||||
}
|
||||
String feeType = firstText(line.getFeeType(), "MANUAL");
|
||||
if (feeType.length() > 30)
|
||||
{
|
||||
feeType = "MANUAL";
|
||||
}
|
||||
if (line.getAmount() == null)
|
||||
{
|
||||
throw new ServiceException("请填写金额");
|
||||
}
|
||||
String currency = firstText(line.getCurrency(), "CNY").toUpperCase();
|
||||
if (currency.length() > 10)
|
||||
{
|
||||
throw new ServiceException("币种过长");
|
||||
}
|
||||
BigDecimal amount = line.getAmount().setScale(2, RoundingMode.HALF_UP);
|
||||
if (amount.abs().compareTo(new BigDecimal("9999999999.99")) > 0)
|
||||
{
|
||||
throw new ServiceException("金额超出范围");
|
||||
}
|
||||
String remark = line.getRemark() == null ? null : line.getRemark().trim();
|
||||
if (remark != null && remark.length() > 200)
|
||||
{
|
||||
throw new ServiceException("说明不能超过200字");
|
||||
}
|
||||
Long orderBillId = Long.valueOf(order.getBillId().trim());
|
||||
String operator = operator();
|
||||
String userId = PayFeeMoney.userId();
|
||||
payBillMapper.insertMissingPayBills(List.of(orderBillId), operator());
|
||||
payBillMapper.insertMissingPayBills(List.of(orderBillId), operator);
|
||||
PrcPayBill payBill = payBillMapper.selectByBillId(orderBillId);
|
||||
PrcPayBillFee fee = newManualFee(orderBillId, payBill == null ? null : payBill.getPayBillId(), ready, userId);
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(orderBillId);
|
||||
fee.setPayBillId(payBill == null ? null : payBill.getPayBillId());
|
||||
fee.setFeeType(feeType);
|
||||
fee.setFeeName(feeName);
|
||||
fee.setScId(manualScId());
|
||||
fee.setFeeLevel(level);
|
||||
fee.setAmount(amount);
|
||||
fee.setCurrency(currency);
|
||||
fee.setRemark(remark == null || remark.isEmpty() ? null : remark);
|
||||
fee.setFeeSource("MANUAL");
|
||||
fee.setCreateBy(userId);
|
||||
fee.setUpdateBy(userId);
|
||||
payBillFeeMapper.insertManual(fee);
|
||||
payBillFeeService.refreshTotals(List.of(orderBillId));
|
||||
payBillFeeLogService.record(fee, PayBillFeeLogService.ADD);
|
||||
@@ -453,34 +371,6 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
return toLine(saved == null ? fee : saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一组费用写到每一票勾选订单上。应付总额和 ABCD 段在写入后一起重算。
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int addManualFees(PayOrderFeeBatch batch)
|
||||
{
|
||||
List<Long> billIds = batchBillIds(batch);
|
||||
List<PayOrderFeeLine> lines = batchLines(batch);
|
||||
List<PayOrderRow> orders = payOrderListMapper.selectByBillIds(billIds);
|
||||
if (orders == null || orders.size() != billIds.size())
|
||||
{
|
||||
throw new ServiceException("有订单不在应付列表中,请重新勾选");
|
||||
}
|
||||
String userId = PayFeeMoney.userId();
|
||||
List<PrcPayBillFee> fees = new ArrayList<>(billIds.size() * lines.size());
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
for (PayOrderFeeLine line : lines)
|
||||
{
|
||||
fees.add(newManualFee(billId, null, line, userId));
|
||||
}
|
||||
}
|
||||
payBillFeeService.insertBatchAndRefreshTotals(fees);
|
||||
payBillFeeLogService.record(fees, PayBillFeeLogService.ADD);
|
||||
return fees.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除一条费用,并按剩余未删除明细重算应付总额。
|
||||
*
|
||||
@@ -558,144 +448,10 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
return fallback == null ? "" : fallback.trim();
|
||||
}
|
||||
|
||||
/** 校验并收成可落库的一行。金额保留三位,和费用明细的小数位一致。 */
|
||||
private PayOrderFeeLine checkedLine(PayOrderFeeLine line)
|
||||
{
|
||||
if (line == null)
|
||||
{
|
||||
throw new ServiceException("请填写费用");
|
||||
}
|
||||
String level = line.getLevel() == null ? "" : line.getLevel().trim();
|
||||
if (!TITLES.containsKey(level))
|
||||
{
|
||||
throw new ServiceException("请选择费用阶段");
|
||||
}
|
||||
String feeName = firstText(line.getFeeName(), line.getFeeType());
|
||||
if (feeName.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写费用项");
|
||||
}
|
||||
if (feeName.length() > 100)
|
||||
{
|
||||
feeName = feeName.substring(0, 100);
|
||||
}
|
||||
String feeType = firstText(line.getFeeType(), "MANUAL");
|
||||
if (feeType.length() > 30)
|
||||
{
|
||||
feeType = "MANUAL";
|
||||
}
|
||||
if (line.getAmount() == null)
|
||||
{
|
||||
throw new ServiceException("请填写金额");
|
||||
}
|
||||
String currency = firstText(line.getCurrency(), "CNY").toUpperCase(Locale.ROOT);
|
||||
if (currency.length() > 10)
|
||||
{
|
||||
throw new ServiceException("币种过长");
|
||||
}
|
||||
BigDecimal amount = line.getAmount().setScale(3, RoundingMode.HALF_UP);
|
||||
if (amount.abs().compareTo(new BigDecimal("9999999999.999")) > 0)
|
||||
{
|
||||
throw new ServiceException("金额超出范围");
|
||||
}
|
||||
String remark = line.getRemark() == null ? null : line.getRemark().trim();
|
||||
if (remark != null && remark.length() > 200)
|
||||
{
|
||||
throw new ServiceException("说明不能超过200字");
|
||||
}
|
||||
PayOrderFeeLine ready = new PayOrderFeeLine();
|
||||
ready.setLevel(level);
|
||||
ready.setFeeName(feeName);
|
||||
ready.setFeeType(feeType);
|
||||
ready.setAmount(amount);
|
||||
ready.setCurrency(currency);
|
||||
ready.setRemark(remark == null || remark.isEmpty() ? null : remark);
|
||||
return ready;
|
||||
}
|
||||
|
||||
private List<Long> batchBillIds(PayOrderFeeBatch batch)
|
||||
{
|
||||
if (batch == null || batch.getBillIds() == null || batch.getBillIds().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请勾选订单");
|
||||
}
|
||||
LinkedHashSet<Long> ids = new LinkedHashSet<>();
|
||||
for (String raw : batch.getBillIds())
|
||||
{
|
||||
if (raw == null || raw.isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
ids.add(Long.valueOf(raw.trim()));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
throw new ServiceException("订单编号不正确");
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请勾选订单");
|
||||
}
|
||||
if (ids.size() > MAX_ORDER_NOS)
|
||||
{
|
||||
throw new ServiceException("一次最多选择" + MAX_ORDER_NOS + "个订单");
|
||||
}
|
||||
return new ArrayList<>(ids);
|
||||
}
|
||||
|
||||
private List<PayOrderFeeLine> batchLines(PayOrderFeeBatch batch)
|
||||
{
|
||||
if (batch.getFees() == null || batch.getFees().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写费用");
|
||||
}
|
||||
if (batch.getFees().size() > MAX_BATCH_LINES)
|
||||
{
|
||||
throw new ServiceException("一次最多增加" + MAX_BATCH_LINES + "条费用");
|
||||
}
|
||||
List<PayOrderFeeLine> lines = new ArrayList<>(batch.getFees().size());
|
||||
for (PayOrderFeeLine line : batch.getFees())
|
||||
{
|
||||
if (line != null && (line.getLevel() == null || line.getLevel().isBlank()))
|
||||
{
|
||||
line.setLevel("4");
|
||||
}
|
||||
lines.add(checkedLine(line));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** 手工费用。创建人和更新人记当前登录用户主键,来源固定为手工。 */
|
||||
private static PrcPayBillFee newManualFee(Long billId, String payBillId, PayOrderFeeLine line, String userId)
|
||||
{
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setPayBillId(payBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
fee.setFeeName(line.getFeeName());
|
||||
fee.setScId(manualScId());
|
||||
fee.setFeeLevel(line.getLevel());
|
||||
fee.setAmount(line.getAmount());
|
||||
fee.setCurrency(line.getCurrency());
|
||||
fee.setRemark(line.getRemark());
|
||||
fee.setFeeSource("MANUAL");
|
||||
fee.setIsDeleted("0");
|
||||
fee.setCreateBy(userId);
|
||||
fee.setUpdateBy(userId);
|
||||
return fee;
|
||||
}
|
||||
|
||||
/** 手工费用用负数序号,避免和同一费用项的计算费用撞上唯一键。 */
|
||||
private static long manualScId()
|
||||
{
|
||||
long tick = MANUAL_SC_SEQ.updateAndGet(current -> {
|
||||
long next = System.nanoTime();
|
||||
return next > current ? next : current + 1L;
|
||||
});
|
||||
long tick = System.nanoTime();
|
||||
if (tick == Long.MIN_VALUE)
|
||||
{
|
||||
return -1L;
|
||||
|
||||
+1
-1
@@ -399,7 +399,7 @@ public class PayPostcodeServiceImpl implements IPayPostcodeService
|
||||
private static String normalizeCoverage(String value)
|
||||
{
|
||||
String coverage = trimToEmpty(value).toUpperCase(java.util.Locale.ROOT);
|
||||
if (coverage.isEmpty() || "REACH".equals(coverage) || "UNREACH".equals(coverage) || "REMOTE".equals(coverage) || "SURCHARGE".equals(coverage))
|
||||
if (coverage.isEmpty() || "REACH".equals(coverage) || "UNREACH".equals(coverage) || "REMOTE".equals(coverage))
|
||||
{
|
||||
return coverage;
|
||||
}
|
||||
|
||||
+5
-27
@@ -51,7 +51,6 @@ import com.bms.price.mapper.PrcPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeBindMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.pay.PayParseProgressListener;
|
||||
import com.bms.price.pay.PaySurchargeRules;
|
||||
import com.bms.price.pay.PayChargeMode;
|
||||
import com.bms.price.pay.PayTemplateWorkbook;
|
||||
import com.bms.price.pay.PayWorkbookParser;
|
||||
@@ -1134,18 +1133,10 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
String currency = isBlank(fee.getCurrency()) ? DEFAULT_CURRENCY : fee.getCurrency();
|
||||
if ("SIZE".equals(rule))
|
||||
{
|
||||
if ("VOLUME".equalsIgnoreCase(config.getSizeType()))
|
||||
{
|
||||
BigDecimal volume = positive(config.getVolumeM3(), fee.getFeeName() + "的体积");
|
||||
fee.setChargeText("体积超过 " + plain(volume) + "m³");
|
||||
}
|
||||
else
|
||||
{
|
||||
BigDecimal length = positive(config.getLengthCm(), fee.getFeeName() + "的长");
|
||||
BigDecimal width = positive(config.getWidthCm(), fee.getFeeName() + "的宽");
|
||||
BigDecimal height = positive(config.getHeightCm(), fee.getFeeName() + "的高");
|
||||
fee.setChargeText("任一边超过 " + plain(length) + "×" + plain(width) + "×" + plain(height) + "cm");
|
||||
}
|
||||
BigDecimal length = positive(config.getLengthCm(), fee.getFeeName() + "的长");
|
||||
BigDecimal width = positive(config.getWidthCm(), fee.getFeeName() + "的宽");
|
||||
BigDecimal height = positive(config.getHeightCm(), fee.getFeeName() + "的高");
|
||||
fee.setChargeText("超过 " + plain(length) + "×" + plain(width) + "×" + plain(height) + "cm");
|
||||
fee.setPriceUnit(currency + "/ITEM");
|
||||
return;
|
||||
}
|
||||
@@ -1174,12 +1165,6 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
fee.setPriceUnit(currency + "/ITEM");
|
||||
return;
|
||||
}
|
||||
if (PaySurchargeRules.FEE_POSTCODE.equals(rule))
|
||||
{
|
||||
fee.setChargeText("邮编命中应付邮编配置中的附加费");
|
||||
fee.setPriceUnit(currency + "/ITEM");
|
||||
return;
|
||||
}
|
||||
fee.setPriceUnit(currency + "/ITEM");
|
||||
fee.setChargeText(isBlank(fee.getFeeDesc()) ? "" : cut(fee.getFeeDesc(), 500));
|
||||
}
|
||||
@@ -1224,8 +1209,6 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
fee.setLengthCm(bind.getLengthCm());
|
||||
fee.setWidthCm(bind.getWidthCm());
|
||||
fee.setHeightCm(bind.getHeightCm());
|
||||
fee.setSizeType(bind.getSizeType());
|
||||
fee.setVolumeM3(bind.getVolumeM3());
|
||||
fee.setOverWeightKg(bind.getOverWeightKg());
|
||||
fee.setExtraWeightKg(bind.getExtraWeightKg());
|
||||
fee.setPostcodeText(bind.getPostcodeText());
|
||||
@@ -1235,8 +1218,6 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
config.setLengthCm(bind.getLengthCm());
|
||||
config.setWidthCm(bind.getWidthCm());
|
||||
config.setHeightCm(bind.getHeightCm());
|
||||
config.setSizeType(bind.getSizeType());
|
||||
config.setVolumeM3(bind.getVolumeM3());
|
||||
config.setOverWeightKg(bind.getOverWeightKg());
|
||||
config.setExtraWeightKg(bind.getExtraWeightKg());
|
||||
config.setPostcodeText(bind.getPostcodeText());
|
||||
@@ -1284,8 +1265,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return "MANUAL";
|
||||
}
|
||||
if ("ALWAYS".equals(code) || "POSTCODE".equals(code) || "ZONE".equals(code) || "EXTRA_KG".equals(code)
|
||||
|| "WEIGHT".equals(code) || "SIZE".equals(code) || "RETURN".equals(code) || "MANUAL".equals(code)
|
||||
|| PaySurchargeRules.FEE_POSTCODE.equals(code))
|
||||
|| "WEIGHT".equals(code) || "SIZE".equals(code) || "RETURN".equals(code) || "MANUAL".equals(code))
|
||||
{
|
||||
return code;
|
||||
}
|
||||
@@ -2208,8 +2188,6 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
band.setCountryName(cut(band.getCountryName(), 200));
|
||||
band.setCountryCode(cut(band.getCountryCode(), 32));
|
||||
band.setZoneName(cut(band.getZoneName(), 200));
|
||||
band.setCalcRule(cut(band.getCalcRule(), 32));
|
||||
band.setCalcParam(cut(band.getCalcParam(), 1000));
|
||||
band.setWeightLabel(cut(band.getWeightLabel(), 100));
|
||||
band.setVolumeText(cut(band.getVolumeText(), 40));
|
||||
band.setChargeName(cut(band.getChargeName(), 200));
|
||||
|
||||
+1
-14
@@ -490,21 +490,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
TmsPriceQuoteResult result = toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
PrcPayBill payBill = payBillMapper.selectByBillId(bill.getBillId());
|
||||
if (payBill != null)
|
||||
{
|
||||
if (payBill.getPayTotal() != null)
|
||||
{
|
||||
result.setPayTotal(payBill.getPayTotal());
|
||||
}
|
||||
result.setAmountA(payBill.getAmountA());
|
||||
result.setAmountB(payBill.getAmountB());
|
||||
result.setAmountC(payBill.getAmountC());
|
||||
result.setAmountD(payBill.getAmountD());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-39
@@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
import com.bms.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcPayBillMapper;
|
||||
@@ -84,13 +83,13 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
}
|
||||
}
|
||||
|
||||
/** 不改 prc_pay_bill_fee。按计费日汇率把明细折成人民币后,ABCD 段分别四舍五入到两位,应付总额取这四段之和,写入 prc_pay_bill。 */
|
||||
/** 不改 prc_pay_bill_fee。按计费日汇率把明细折成人民币后相加,四舍五入到两位,只写入 prc_pay_bill.pay_total。 */
|
||||
private void writeCnyTotals(List<Long> billIds)
|
||||
{
|
||||
Map<Long, BigDecimal[]> sums = new LinkedHashMap<>();
|
||||
Map<Long, BigDecimal> sums = new LinkedHashMap<>();
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
sums.put(billId, new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO });
|
||||
sums.put(billId, BigDecimal.ZERO);
|
||||
}
|
||||
List<PrcPayBillFee> fees = payBillFeeMapper.selectOpenFees(billIds);
|
||||
if (fees != null)
|
||||
@@ -101,52 +100,20 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal[] bucket = sums.get(fee.getBillId());
|
||||
if (bucket == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal cny = payFeeMoney.toCny(fee.getAmount(), fee.getCurrency(), fee.getBizDate());
|
||||
if (cny == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int segment = segmentIndex(fee.getFeeLevel());
|
||||
bucket[segment] = bucket[segment].add(cny);
|
||||
sums.merge(fee.getBillId(), cny, BigDecimal::add);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Long, BigDecimal[]> entry : sums.entrySet())
|
||||
for (Map.Entry<Long, BigDecimal> entry : sums.entrySet())
|
||||
{
|
||||
BigDecimal[] bucket = entry.getValue();
|
||||
PrcPayBill row = new PrcPayBill();
|
||||
row.setBillId(entry.getKey());
|
||||
row.setAmountA(PayFeeMoney.total(bucket[0]));
|
||||
row.setAmountB(PayFeeMoney.total(bucket[1]));
|
||||
row.setAmountC(PayFeeMoney.total(bucket[2]));
|
||||
row.setAmountD(PayFeeMoney.total(bucket[3]));
|
||||
row.setPayTotal(row.getAmountA().add(row.getAmountB()).add(row.getAmountC()).add(row.getAmountD()));
|
||||
payBillMapper.updateCnyPayTotal(row);
|
||||
payBillMapper.updateCnyPayTotal(entry.getKey(), PayFeeMoney.total(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
/** 0A 1B 2C,其余含未标阶段的尾程计算费用归到 D。 */
|
||||
private static int segmentIndex(String feeLevel)
|
||||
{
|
||||
if ("1".equals(feeLevel))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ("2".equals(feeLevel))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ("3".equals(feeLevel))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
private static String currentOperator()
|
||||
{
|
||||
try
|
||||
|
||||
+4
-44
@@ -10,7 +10,6 @@ import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.MessageUtils;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
import com.bms.price.domain.PrcSurcharge;
|
||||
import com.bms.price.pay.PaySurchargeRules;
|
||||
import com.bms.price.mapper.PrcSurchargeBindMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeRelMapper;
|
||||
@@ -97,8 +96,6 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
fresh.setLengthCm(surcharge.getLengthCm());
|
||||
fresh.setWidthCm(surcharge.getWidthCm());
|
||||
fresh.setHeightCm(surcharge.getHeightCm());
|
||||
fresh.setSizeType(surcharge.getSizeType());
|
||||
fresh.setVolumeM3(surcharge.getVolumeM3());
|
||||
fresh.setOverWeightKg(surcharge.getOverWeightKg());
|
||||
fresh.setExtraWeightKg(surcharge.getExtraWeightKg());
|
||||
fresh.setPostcodeText(surcharge.getPostcodeText());
|
||||
@@ -128,8 +125,6 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
&& eqDecimal(old.getLengthCm(), updated.getLengthCm())
|
||||
&& eqDecimal(old.getWidthCm(), updated.getWidthCm())
|
||||
&& eqDecimal(old.getHeightCm(), updated.getHeightCm())
|
||||
&& eq(old.getSizeType(), updated.getSizeType())
|
||||
&& eqDecimal(old.getVolumeM3(), updated.getVolumeM3())
|
||||
&& eqDecimal(old.getOverWeightKg(), updated.getOverWeightKg())
|
||||
&& eqDecimal(old.getExtraWeightKg(), updated.getExtraWeightKg())
|
||||
&& eq(old.getPostcodeText(), updated.getPostcodeText())
|
||||
@@ -231,21 +226,11 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
BigDecimal overWeight = null;
|
||||
BigDecimal extraWeight = null;
|
||||
String postcodes = null;
|
||||
String sizeType = null;
|
||||
BigDecimal volume = null;
|
||||
if ("SIZE".equals(type))
|
||||
{
|
||||
sizeType = requiredSizeType(row.getSizeType());
|
||||
if ("VOLUME".equals(sizeType))
|
||||
{
|
||||
volume = requiredSize(row.getVolumeM3(), "体积");
|
||||
}
|
||||
else
|
||||
{
|
||||
length = requiredSize(row.getLengthCm(), "长");
|
||||
width = requiredSize(row.getWidthCm(), "宽");
|
||||
height = requiredSize(row.getHeightCm(), "高");
|
||||
}
|
||||
length = requiredSize(row.getLengthCm(), "长");
|
||||
width = requiredSize(row.getWidthCm(), "宽");
|
||||
height = requiredSize(row.getHeightCm(), "高");
|
||||
row.setBlockTitle(null);
|
||||
}
|
||||
else if ("WEIGHT".equals(type))
|
||||
@@ -274,32 +259,11 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
row.setLengthCm(length);
|
||||
row.setWidthCm(width);
|
||||
row.setHeightCm(height);
|
||||
row.setSizeType(sizeType);
|
||||
row.setVolumeM3(volume);
|
||||
row.setOverWeightKg(overWeight);
|
||||
row.setExtraWeightKg(extraWeight);
|
||||
row.setPostcodeText(postcodes);
|
||||
}
|
||||
|
||||
private static String requiredSizeType(String raw)
|
||||
{
|
||||
String code = raw == null ? "" : raw.trim().toUpperCase();
|
||||
if (!"SIDE".equals(code) && !"VOLUME".equals(code))
|
||||
{
|
||||
throw new ServiceException("请选择超尺寸类型");
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
private static String sizeChargeText(String sizeType, BigDecimal length, BigDecimal width, BigDecimal height, BigDecimal volume)
|
||||
{
|
||||
if ("VOLUME".equals(sizeType))
|
||||
{
|
||||
return "体积超过 " + plain(volume) + "m³";
|
||||
}
|
||||
return "任一边超过 " + plain(length) + "×" + plain(width) + "×" + plain(height) + "cm";
|
||||
}
|
||||
|
||||
private static BigDecimal requiredSize(BigDecimal value, String label)
|
||||
{
|
||||
if (value == null || value.compareTo(BigDecimal.ZERO) <= 0)
|
||||
@@ -357,7 +321,7 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
String text;
|
||||
if ("SIZE".equals(rule))
|
||||
{
|
||||
text = sizeChargeText(row.getSizeType(), row.getLengthCm(), row.getWidthCm(), row.getHeightCm(), row.getVolumeM3());
|
||||
text = "超过 " + plain(row.getLengthCm()) + "×" + plain(row.getWidthCm()) + "×" + plain(row.getHeightCm()) + "cm";
|
||||
}
|
||||
else if ("WEIGHT".equals(rule))
|
||||
{
|
||||
@@ -371,10 +335,6 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
{
|
||||
text = "邮编 " + (row.getPostcodeText() == null ? "" : row.getPostcodeText());
|
||||
}
|
||||
else if (PaySurchargeRules.FEE_POSTCODE.equals(rule))
|
||||
{
|
||||
text = "邮编命中应付邮编配置中的附加费";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = row.getScNote() == null ? "" : row.getScNote();
|
||||
|
||||
+2
@@ -40,6 +40,8 @@ public class ArBillGenerateRequest
|
||||
@JsonDeserialize(using = StrictDateDeserializer.class)
|
||||
private Date billDate;
|
||||
private String currency = "CNY";
|
||||
/** 收款账户配置 ID;旧调用方未传时沿用币种默认账户。 */
|
||||
private Long bankAccountId;
|
||||
/** 订单号、运单号或转单号原始输入,生成时会拆分并再次校验筛选条件。 */
|
||||
private String orderOrTrackingNo;
|
||||
private String bankAccountName;
|
||||
|
||||
+39
@@ -7,7 +7,12 @@ import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -351,6 +356,40 @@ public abstract class ArBillWorkbookSupport implements ArBillWorkbookWriter {
|
||||
return detail == null ? null : detail.getRegistrationFee();
|
||||
}
|
||||
|
||||
protected String exportReceiveTimeRange(Map<String, Object> receiveTimeRange) {
|
||||
return exportReceiveTimeRange(receiveTimeRange, "yyyy-MM-dd", " 至 ");
|
||||
}
|
||||
|
||||
/** 所有账单模板使用当前账单明细的收货日期范围,缺失时留空。 */
|
||||
protected String exportReceiveTimeRange(Map<String, Object> receiveTimeRange, String pattern, String separator) {
|
||||
if (receiveTimeRange == null) {
|
||||
return "";
|
||||
}
|
||||
String start = formatReceiveDate(receiveTimeRange.get("minReceiveTime"), pattern);
|
||||
String end = formatReceiveDate(receiveTimeRange.get("maxReceiveTime"), pattern);
|
||||
return StringUtils.isEmpty(start) || StringUtils.isEmpty(end) ? "" : start + separator + end;
|
||||
}
|
||||
|
||||
private String formatReceiveDate(Object value, String pattern) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
if (value instanceof LocalDateTime) {
|
||||
return ((LocalDateTime) value).toLocalDate().format(formatter);
|
||||
}
|
||||
if (value instanceof LocalDate) {
|
||||
return ((LocalDate) value).format(formatter);
|
||||
}
|
||||
if (value instanceof java.sql.Date) {
|
||||
return ((java.sql.Date) value).toLocalDate().format(formatter);
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return new SimpleDateFormat(pattern).format((Date) value);
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
throw new IllegalArgumentException("不支持的收货时间类型: " + value.getClass().getName());
|
||||
}
|
||||
|
||||
protected String exportBankAccountNo(String value) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return "";
|
||||
|
||||
@@ -24,4 +24,5 @@ public class ArBillWorkbookWriters {
|
||||
public boolean isSummary(ArExportTemplate template) {
|
||||
return SUMMARY_TEMPLATE_CODE.equals(template.getTemplateCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-31
@@ -8,9 +8,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -534,34 +531,6 @@ public class DefaultArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String exportReceiveTimeRange(Map<String, Object> receiveTimeRange) {
|
||||
if (receiveTimeRange == null) {
|
||||
return "";
|
||||
}
|
||||
String start = formatReceiveDate(receiveTimeRange.get("minReceiveTime"));
|
||||
String end = formatReceiveDate(receiveTimeRange.get("maxReceiveTime"));
|
||||
return StringUtils.isEmpty(start) || StringUtils.isEmpty(end) ? "" : start + " 至 " + end;
|
||||
}
|
||||
|
||||
private String formatReceiveDate(Object value) {
|
||||
if (value instanceof LocalDateTime) {
|
||||
return ((LocalDateTime) value).toLocalDate().toString();
|
||||
}
|
||||
if (value instanceof LocalDate) {
|
||||
return value.toString();
|
||||
}
|
||||
if (value instanceof java.sql.Date) {
|
||||
return ((java.sql.Date) value).toLocalDate().toString();
|
||||
}
|
||||
if (value instanceof Date) {
|
||||
return new SimpleDateFormat("yyyy-MM-dd").format((Date) value);
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
throw new IllegalArgumentException("不支持的收货时间类型: " + value.getClass().getName());
|
||||
}
|
||||
|
||||
private String exportFormula(ArBillDetail detail) {
|
||||
String formula = joinFeeText(detail.getFees(), true);
|
||||
if (!StringUtils.isEmpty(formula)) {
|
||||
|
||||
+48
-20
@@ -9,7 +9,6 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -26,6 +25,8 @@ import com.bms.receivable.domain.ArBillDetail;
|
||||
import com.bms.receivable.domain.ArBillDetailFee;
|
||||
import com.bms.receivable.domain.ArExportTemplate;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
@@ -55,7 +56,10 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
Path detailXml = Files.createTempFile("ar-bill-summary-details-", ".xml");
|
||||
try (InputStream input = openTemplateStream(template); XSSFWorkbook workbook = new XSSFWorkbook(input)) {
|
||||
validateTemplate(workbook);
|
||||
prepareTemplate(workbook, bill);
|
||||
String receiveTimePeriod = exportReceiveTimeRange(
|
||||
detailMapper.selectReceiveTimeRangeByBillId(bill.getArBillId()), "yyyyMMdd", "-");
|
||||
prepareTemplate(workbook, bill, receiveTimePeriod);
|
||||
SummaryStyles summaryStyles = createSummaryStyles(workbook);
|
||||
DetailStyles detailStyles = createDetailStyles(workbook);
|
||||
byte[] skeleton = serialize(workbook);
|
||||
String summaryPath = partPath(workbook.getSheetAt(0));
|
||||
@@ -92,7 +96,7 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
for (ZipEntry entry; (entry = zip.getNextEntry()) != null; ) {
|
||||
output.putNextEntry(new ZipEntry(entry.getName()));
|
||||
if (summaryPath.equals(entry.getName())) {
|
||||
writeSummary(summary, bill, groups, result.amount(), output);
|
||||
writeSummary(summary, bill, groups, result.amount(), receiveTimePeriod, summaryStyles, output);
|
||||
} else if (detailPath.equals(entry.getName())) {
|
||||
Files.copy(detailXml, output);
|
||||
} else {
|
||||
@@ -133,7 +137,7 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
return row;
|
||||
}
|
||||
|
||||
private void prepareTemplate(XSSFWorkbook workbook, ArBill bill) throws IOException {
|
||||
private void prepareTemplate(XSSFWorkbook workbook, ArBill bill, String receiveTimePeriod) throws IOException {
|
||||
String currency = StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency();
|
||||
String company = StringUtils.isEmpty(bill.getBankAccountName())
|
||||
? "威狮国际供应链(深圳)有限公司" : bill.getBankAccountName();
|
||||
@@ -146,7 +150,7 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
textCell(summary, 11, 1, exportBankAccountNo(bill.getBankAccountNo()));
|
||||
textCell(summary, 12, 1, bill.getBankName());
|
||||
textCell(detail, 2, 1, bill.getCustomerName());
|
||||
textCell(detail, 2, 18, billPeriod(bill));
|
||||
textCell(detail, 2, 18, receiveTimePeriod);
|
||||
for (int column : new int[]{11, 12, 13, 15, 16}) {
|
||||
XSSFCell header = detail.getRow(3).getCell(column);
|
||||
header.setCellValue(header.getStringCellValue().replace("CNY", currency));
|
||||
@@ -155,10 +159,11 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
XSSFCell cell = detail.getRow(4).getCell(column, XSSFRow.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||
boolean identifier = column == 0 || column == 2 || column == 3 || column == 6;
|
||||
boolean money = column == 10 || column == 13 || column == 14 || column == 15 || column == 16;
|
||||
if (!identifier && !money) continue;
|
||||
boolean receiveDate = column == 1;
|
||||
if (!identifier && !money && !receiveDate) continue;
|
||||
XSSFCellStyle style = workbook.createCellStyle();
|
||||
style.cloneStyleFrom(cell.getCellStyle());
|
||||
String format = identifier ? "@" : "0.00";
|
||||
String format = receiveDate ? "yyyy/mm/dd" : identifier ? "@" : "0.00";
|
||||
style.setDataFormat(workbook.createDataFormat().getFormat(format));
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
@@ -190,7 +195,28 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
failed[column] = Short.toUnsignedInt(style.getIndex());
|
||||
}
|
||||
return new DetailStyles(normal, failed, workbook.getSheetAt(1).getRow(4).getHeightInPoints());
|
||||
return new DetailStyles(normal, failed, workbook.getSheetAt(1).getRow(4).getHeightInPoints(), workbook.isDate1904());
|
||||
}
|
||||
|
||||
/** 产品行之间不画网格线;最后一行沿用模板底边,组成完整外框。 */
|
||||
private SummaryStyles createSummaryStyles(XSSFWorkbook workbook) throws IOException {
|
||||
XSSFRow source = requireRow(workbook.getSheetAt(0), SUMMARY_START_ROW - 1);
|
||||
int[] normal = new int[7];
|
||||
int[] last = new int[7];
|
||||
for (int column = 0; column < normal.length; column++) {
|
||||
XSSFCellStyle original = source.getCell(column, XSSFRow.MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellStyle();
|
||||
XSSFCellStyle lastStyle = workbook.createCellStyle();
|
||||
lastStyle.cloneStyleFrom(original);
|
||||
lastStyle.setBorderTop(BorderStyle.NONE);
|
||||
if (column > 0) lastStyle.setBorderLeft(BorderStyle.NONE);
|
||||
if (column < normal.length - 1) lastStyle.setBorderRight(BorderStyle.NONE);
|
||||
last[column] = Short.toUnsignedInt(lastStyle.getIndex());
|
||||
XSSFCellStyle normalStyle = workbook.createCellStyle();
|
||||
normalStyle.cloneStyleFrom(lastStyle);
|
||||
normalStyle.setBorderBottom(BorderStyle.NONE);
|
||||
normal[column] = Short.toUnsignedInt(normalStyle.getIndex());
|
||||
}
|
||||
return new SummaryStyles(normal, last);
|
||||
}
|
||||
|
||||
private DetailResult writeDetails(SheetXml sheet, ArBill bill, OutputStream output,
|
||||
@@ -235,11 +261,16 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
}
|
||||
|
||||
private String detailRow(int rowNumber, ArBill bill, ArBillDetail detail,
|
||||
DetailAmounts amounts, DetailStyles styles) {
|
||||
DetailAmounts amounts, DetailStyles styles) throws IOException {
|
||||
String failure = exportBillingFailDescription(detail.getBillingFailStatus());
|
||||
Double receiveTime = detail.getReceiveTime() == null ? null
|
||||
: DateUtil.getExcelDate(detail.getReceiveTime(), styles.use1904());
|
||||
if (receiveTime != null && !DateUtil.isValidExcelDate(receiveTime)) {
|
||||
throw new IOException("账单明细收货时间超出 Excel 日期范围,请检查账单");
|
||||
}
|
||||
Object[] values = {
|
||||
bill.getCustomerCode(),
|
||||
detail.getReceiveTime() == null ? "" : new SimpleDateFormat("yyyy-MM-dd").format(detail.getReceiveTime()),
|
||||
receiveTime,
|
||||
detail.getTransferNo(), detail.getTrackingNo(),
|
||||
StringUtils.isEmpty(detail.getProductName()) ? detail.getProductCode() : detail.getProductName(),
|
||||
StringUtils.isEmpty(detail.getCountryName()) ? detail.getCountryCode() : detail.getCountryName(),
|
||||
@@ -305,17 +336,19 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
}
|
||||
|
||||
private void writeSummary(SheetXml sheet, ArBill bill, Map<String, ProductSummary> groups,
|
||||
BigDecimal total, OutputStream output) throws IOException {
|
||||
BigDecimal total, String receiveTimePeriod, SummaryStyles styles,
|
||||
OutputStream output) throws IOException {
|
||||
writeUtf8(output, sheet.prefix());
|
||||
for (int row = 1; row <= 3; row++) writeUtf8(output, sheet.rows().get(row));
|
||||
int rowNumber = SUMMARY_START_ROW;
|
||||
for (ProductSummary product : groups.values()) {
|
||||
String row = shiftRowXml(sheet.rows().get(4), rowNumber);
|
||||
Object[] values = {rowNumber - 3, bill.getCustomerName(), product.name, billPeriod(bill),
|
||||
int[] rowStyles = rowNumber == SUMMARY_START_ROW + groups.size() - 1 ? styles.last() : styles.normal();
|
||||
Object[] values = {rowNumber - 3, bill.getCustomerName(), product.name, receiveTimePeriod,
|
||||
product.amount, bill.getCurrency(), SUMMARY_REMARK};
|
||||
for (int index = 0; index < values.length; index++) {
|
||||
row = replaceCellXml(row, (char) ('A' + index) + String.valueOf(rowNumber),
|
||||
values[index], values[index] instanceof Number);
|
||||
values[index], values[index] instanceof Number, rowStyles[index]);
|
||||
}
|
||||
writeUtf8(output, row);
|
||||
rowNumber++;
|
||||
@@ -356,12 +389,6 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
return FILTER.matcher(suffix).replaceAll("$1" + range + "$2");
|
||||
}
|
||||
|
||||
private String billPeriod(ArBill bill) {
|
||||
if (bill.getBillPeriodStart() == null || bill.getBillPeriodEnd() == null) return "";
|
||||
SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd");
|
||||
return date.format(bill.getBillPeriodStart()) + "-" + date.format(bill.getBillPeriodEnd());
|
||||
}
|
||||
|
||||
private String partPath(XSSFSheet sheet) {
|
||||
return sheet.getPackagePart().getPartName().getName().substring(1);
|
||||
}
|
||||
@@ -390,7 +417,8 @@ public class SummaryArBillWorkbookWriter extends ArBillWorkbookSupport {
|
||||
|
||||
private record SheetXml(String prefix, Map<Integer, String> rows, String suffix) { }
|
||||
private record DetailResult(int count, int lastRow, BigDecimal amount) { }
|
||||
private record DetailStyles(int[] normal, int[] failed, float rowHeight) { }
|
||||
private record SummaryStyles(int[] normal, int[] last) { }
|
||||
private record DetailStyles(int[] normal, int[] failed, float rowHeight, boolean use1904) { }
|
||||
private record DetailAmounts(BigDecimal freight, BigDecimal processing, BigDecimal remote,
|
||||
BigDecimal surcharge, BigDecimal romania, BigDecimal total) { }
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface IArBillService
|
||||
|
||||
List<ArBankAccount> selectEnabledBankAccounts(String currency);
|
||||
|
||||
List<ArBankAccount> selectMaskedBankAccounts(String currency);
|
||||
|
||||
List<PrcOrderBill> previewBill(ArBillGenerateQuery query);
|
||||
|
||||
List<PrcOrderBill> previewBill(ArBillGenerateQuery query, ArBillRowScope scope);
|
||||
|
||||
+17
-3
@@ -261,6 +261,13 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
return accounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArBankAccount> selectMaskedBankAccounts(String currency) {
|
||||
List<ArBankAccount> accounts = selectEnabledBankAccounts(currency);
|
||||
accounts.forEach(account -> account.setAccountNo(maskAccount(account.getAccountNo())));
|
||||
return accounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页预览可生成订单;多个订单号、运单号或转单号按 OR 条件精确匹配。
|
||||
*/
|
||||
@@ -383,10 +390,16 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
if (generatingBill != null) {
|
||||
throw new ServiceException("该客户当前账期已有账单正在生成,请稍后再试");
|
||||
}
|
||||
ArBankAccount bankAccount = bankAccountMapper.selectDefaultByCurrency(currency);
|
||||
ArBankAccount bankAccount = request.getBankAccountId() == null
|
||||
? bankAccountMapper.selectDefaultByCurrency(currency)
|
||||
: bankAccountMapper.selectEnabledById(request.getBankAccountId());
|
||||
if (bankAccount == null) {
|
||||
throw failure(null, ArLogObjectType.BILL, "", ArLogOperationType.GENERATE, null,
|
||||
"未配置 " + currency + " 币种的公司默认收款账户,请先完成收款账户配置", operator, requestId);
|
||||
request.getBankAccountId() == null ? "未配置 " + currency + " 币种的公司默认收款账户,请先完成收款账户配置"
|
||||
: "所选收款账户不存在或已停用,请重新选择", operator, requestId);
|
||||
}
|
||||
if (!currency.equalsIgnoreCase(bankAccount.getCurrency())) {
|
||||
throw new ServiceException("所选收款账户币种与账单币种不一致,请重新选择");
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
@@ -1359,7 +1372,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
|
||||
private String maskAccount(String value) {
|
||||
if (StringUtils.isEmpty(value)) return "";
|
||||
return value.length() <= 4 ? "****" : "****" + value.substring(value.length() - 4);
|
||||
String normalized = value.replaceAll("[\\s\\p{Z}]+", "");
|
||||
return normalized.length() <= 4 ? "****" : "****" + normalized.substring(normalized.length() - 4);
|
||||
}
|
||||
|
||||
private String sha256(Path file) throws IOException, NoSuchAlgorithmException {
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where f.bill_id = o.bill_id and f.is_deleted = '0') as feeText,
|
||||
(select count(*) from prc_pay_bill_fee f
|
||||
where f.bill_id = o.bill_id and ifnull(f.is_deleted, '0') = '0') as feeCount,
|
||||
@@ -130,7 +130,7 @@
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where f.is_deleted = '0'
|
||||
and f.bill_id in
|
||||
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
@@ -262,7 +262,7 @@
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where ifnull(f.is_deleted, '0') = '0'
|
||||
and f.statement_line_id is null
|
||||
and f.bill_id in
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo,
|
||||
p.tracking_no as trackingNo,
|
||||
p.customer_code as customerCode,
|
||||
p.customer_name as customerName,
|
||||
p.product_name as productName,
|
||||
p.country_name as countryName,
|
||||
@@ -18,7 +17,22 @@
|
||||
ifnull(nullif(trim(b.currency), ''), 'CNY') as currency,
|
||||
b.pay_calc_status as payCalcStatus,
|
||||
b.pay_calc_msg as payCalcMsg,
|
||||
b.update_by as updateBy,
|
||||
case
|
||||
when lower(trim(b.update_by)) = 'system' then '系统自动'
|
||||
else ifnull((
|
||||
select case
|
||||
when nullif(trim(u.nick_name), '') is not null then u.nick_name
|
||||
else u.user_name
|
||||
end
|
||||
from sys_user u
|
||||
where u.del_flag = '0'
|
||||
and (
|
||||
(b.update_by regexp '^[0-9]+$' and u.user_id = cast(b.update_by as unsigned))
|
||||
or (ifnull(b.update_by, '') not regexp '^[0-9]+$' and u.user_name = b.update_by COLLATE utf8mb4_general_ci)
|
||||
)
|
||||
limit 1
|
||||
), b.update_by)
|
||||
end as updateBy,
|
||||
b.update_time as updateTime,
|
||||
p.biz_date as bizDate
|
||||
from prc_order_bill p
|
||||
@@ -26,69 +40,25 @@
|
||||
left join prc_pay_bill b on b.bill_id = p.bill_id
|
||||
</sql>
|
||||
|
||||
<sql id="pageFilters">
|
||||
<if test="orderNos != null and orderNos.size() > 0">
|
||||
and p.order_no in
|
||||
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</if>
|
||||
<if test="(orderNos == null or orderNos.size() == 0) and orderNo != null and orderNo != ''">
|
||||
and p.order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
and (p.customer_name like concat('%', #{customerName}, '%')
|
||||
or p.customer_code like concat('%', #{customerName}, '%'))
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 先只取这一页的订单主键。计数和排序都不带应付表,也不逐行查用户。 -->
|
||||
<select id="selectPageIds" resultType="java.lang.Long">
|
||||
<choose>
|
||||
<when test="ladingNo != null and ladingNo != ''">
|
||||
select p.bill_id
|
||||
from prc_order_bill p
|
||||
inner join (
|
||||
select e.bill_id
|
||||
from prc_order_bill_ext e
|
||||
where e.air_no_old like concat('%', #{ladingNo}, '%')
|
||||
) hit on hit.bill_id = p.bill_id
|
||||
<where>
|
||||
<include refid="pageFilters"/>
|
||||
</where>
|
||||
order by p.create_time desc, p.bill_id desc
|
||||
</when>
|
||||
<otherwise>
|
||||
select p.bill_id
|
||||
from prc_order_bill p
|
||||
<where>
|
||||
<include refid="pageFilters"/>
|
||||
</where>
|
||||
order by p.create_time desc, p.bill_id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectByBillIds" resultType="com.bms.price.domain.PayOrderRow">
|
||||
<select id="selectList" resultType="com.bms.price.domain.PayOrderRow">
|
||||
<include refid="orderColumns"/>
|
||||
where p.bill_id in
|
||||
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectUsers" resultType="com.bms.common.core.domain.entity.SysUser">
|
||||
select u.user_id as userId, u.user_name as userName, u.nick_name as nickName
|
||||
from sys_user u
|
||||
where u.del_flag = '0'
|
||||
and (
|
||||
<trim prefixOverrides="or">
|
||||
<if test="userIds != null and userIds.size() > 0">
|
||||
u.user_id in
|
||||
<foreach collection="userIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</if>
|
||||
<if test="userNames != null and userNames.size() > 0">
|
||||
or u.user_name in
|
||||
<foreach collection="userNames" item="name" open="(" separator="," close=")">#{name} collate utf8mb4_general_ci</foreach>
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
<where>
|
||||
<if test="orderNos != null and orderNos.size() > 0">
|
||||
and p.order_no in
|
||||
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</if>
|
||||
<if test="(orderNos == null or orderNos.size() == 0) and orderNo != null and orderNo != ''">
|
||||
and p.order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="ladingNo != null and ladingNo != ''">
|
||||
and trim(e.air_no_old) like concat('%', #{ladingNo}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
and (p.customer_name like concat('%', #{customerName}, '%')
|
||||
or p.customer_code like concat('%', #{customerName}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by p.create_time desc, p.bill_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectRow" resultType="com.bms.price.domain.PayOrderRow">
|
||||
@@ -110,9 +80,9 @@
|
||||
select p.bill_id as billId,
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo
|
||||
from prc_order_bill_ext e
|
||||
inner join prc_order_bill p on p.bill_id = e.bill_id
|
||||
where e.air_no_old in
|
||||
from prc_order_bill p
|
||||
left join prc_order_bill_ext e on e.bill_id = p.bill_id
|
||||
where trim(e.air_no_old) in
|
||||
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -476,29 +476,6 @@
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectSurchargeLines" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select l.line_id as lineId, l.group_id as groupId, g.channel_name as channelName, g.fee_name as feeName,
|
||||
g.country_name as countryName, g.country_code as countryCode,
|
||||
l.region_name as regionName, l.zone_name as zoneName, l.postcode
|
||||
from pay_postcode_group g
|
||||
inner join pay_postcode_line l on l.group_id = g.group_id
|
||||
where upper(trim(ifnull(g.coverage, ''))) = 'SURCHARGE'
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
and upper(trim(g.country_code)) = upper(trim(#{countryCode}))
|
||||
</if>
|
||||
<if test="(countryCode == null or countryCode == '') and countryName != null and countryName != ''">
|
||||
and trim(g.country_name) = trim(#{countryName})
|
||||
</if>
|
||||
and (
|
||||
replace(replace(replace(upper(ifnull(l.postcode, '')), ' ', ''), '-', ''), '*', '') = #{compact}
|
||||
or #{compact} like concat(replace(replace(replace(upper(ifnull(l.postcode, '')), ' ', ''), '-', ''), '*', ''), '%')
|
||||
or (
|
||||
char_length(#{compact}) >= 3
|
||||
and replace(replace(replace(upper(ifnull(l.postcode, '')), ' ', ''), '-', ''), '*', '') like concat(#{compact}, '%')
|
||||
)
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectGroupsByTokens" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, block_title as blockTitle, channel_name as channelName,
|
||||
product_name as productName, quote_sheet as quoteSheet, sheet_name as sheetName,
|
||||
|
||||
@@ -109,7 +109,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and (b.weight_label like concat('%', #{weightKeyword}, '%')
|
||||
or b.charge_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.zone_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.calc_param like concat('%', #{weightKeyword}, '%')
|
||||
or b.country_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.section_name like concat('%', #{weightKeyword}, '%')
|
||||
or b.volume_text like concat('%', #{weightKeyword}, '%'))
|
||||
@@ -321,12 +320,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertWeightBands">
|
||||
insert into pay_weight_band (
|
||||
product_id, term_id, version_no, section_name, country_name, country_code, zone_name, calc_rule, calc_param, weight_label, weight_min, weight_max,
|
||||
product_id, term_id, version_no, section_name, country_name, country_code, zone_name, weight_label, weight_min, weight_max,
|
||||
volume_text, charge_name, price, price_unit, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.countryName}, #{row.countryCode}, #{row.zoneName},
|
||||
#{row.calcRule}, #{row.calcParam}, #{row.weightLabel}, #{row.weightMin}, #{row.weightMax}, #{row.volumeText}, #{row.chargeName}, #{row.price},
|
||||
#{row.weightLabel}, #{row.weightMin}, #{row.weightMax}, #{row.volumeText}, #{row.chargeName}, #{row.price},
|
||||
#{row.priceUnit}, #{row.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -353,7 +352,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectWeightBands" resultType="com.bms.price.domain.PayWeightBand">
|
||||
select band_id as bandId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
country_code as countryCode, zone_name as zoneName, calc_rule as calcRule, calc_param as calcParam, weight_label as weightLabel, weight_min as weightMin,
|
||||
country_code as countryCode, zone_name as zoneName, weight_label as weightLabel, weight_min as weightMin,
|
||||
weight_max as weightMax, volume_text as volumeText, charge_name as chargeName, price, price_unit as priceUnit, sort_no as sortNo
|
||||
from pay_weight_band
|
||||
where product_id in
|
||||
@@ -363,7 +362,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectWeightBandsByTerm" resultType="com.bms.price.domain.PayWeightBand">
|
||||
select band_id as bandId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
country_code as countryCode, zone_name as zoneName, calc_rule as calcRule, calc_param as calcParam, weight_label as weightLabel, weight_min as weightMin,
|
||||
country_code as countryCode, zone_name as zoneName, weight_label as weightLabel, weight_min as weightMin,
|
||||
weight_max as weightMax, volume_text as volumeText, charge_name as chargeName, price, price_unit as priceUnit, sort_no as sortNo
|
||||
from pay_weight_band
|
||||
where term_id in
|
||||
|
||||
@@ -39,29 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</insert>
|
||||
|
||||
<select id="selectByBillId" resultMap="PrcPayBillFeeLogResult">
|
||||
select l.log_id, l.fee_id, l.bill_id, l.fee_name, l.amount, l.currency,
|
||||
l.before_fee_name, l.before_amount, l.before_currency,
|
||||
l.after_fee_name, l.after_amount, l.after_currency,
|
||||
l.operation_type, l.remark,
|
||||
case
|
||||
when lower(trim(l.create_by)) = 'system' then '系统自动'
|
||||
else ifnull((
|
||||
select case
|
||||
when nullif(trim(u.nick_name), '') is not null then u.nick_name
|
||||
else u.user_name
|
||||
end
|
||||
from sys_user u
|
||||
where u.del_flag = '0'
|
||||
and (
|
||||
(l.create_by regexp '^[0-9]+$' and u.user_id = cast(l.create_by as unsigned))
|
||||
or (ifnull(l.create_by, '') not regexp '^[0-9]+$' and u.user_name = l.create_by COLLATE utf8mb4_general_ci)
|
||||
)
|
||||
limit 1
|
||||
), l.create_by)
|
||||
end as create_by,
|
||||
l.create_time
|
||||
from prc_pay_bill_fee_log l
|
||||
where l.bill_id = #{billId}
|
||||
order by l.log_id desc
|
||||
select log_id, fee_id, bill_id, fee_name, amount, currency,
|
||||
before_fee_name, before_amount, before_currency,
|
||||
after_fee_name, after_amount, after_currency,
|
||||
operation_type, remark,
|
||||
case when lower(trim(create_by)) = 'system' then '系统自动' else create_by end as create_by,
|
||||
create_time
|
||||
from prc_pay_bill_fee_log
|
||||
where bill_id = #{billId}
|
||||
order by log_id desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join pay_surcharge pay_sc on f.fee_type = 'SURCHARGE' and ifnull(f.fee_source, '') <> 'LADING' and pay_sc.surcharge_id = f.sc_id
|
||||
left join prc_surcharge item_sc on f.fee_type = 'SURCHARGE' and ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
</sql>
|
||||
|
||||
<sql id="feeActorName">
|
||||
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where u.del_flag = '0'
|
||||
and (
|
||||
(${column} regexp '^[0-9]+$' and u.user_id = cast(${column} as unsigned))
|
||||
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name COLLATE utf8mb4_general_ci = ${column} COLLATE utf8mb4_general_ci)
|
||||
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name = ${column} COLLATE utf8mb4_general_ci)
|
||||
)
|
||||
limit 1
|
||||
), ${column})
|
||||
@@ -197,7 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectOpenFees" resultMap="PrcPayBillFeeResult">
|
||||
select f.fee_id, f.bill_id, f.fee_level, f.amount, f.currency, b.biz_date
|
||||
select f.fee_id, f.bill_id, f.amount, f.currency, b.biz_date
|
||||
from prc_pay_bill_fee f
|
||||
left join prc_order_bill b on b.bill_id = f.bill_id
|
||||
where ifnull(f.is_deleted, '0') = '0'
|
||||
|
||||
@@ -12,10 +12,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="redlineAmount" column="redline_amount" />
|
||||
<result property="costAmount" column="cost_amount" />
|
||||
<result property="payTotal" column="pay_total" />
|
||||
<result property="amountA" column="amount_a" />
|
||||
<result property="amountB" column="amount_b" />
|
||||
<result property="amountC" column="amount_c" />
|
||||
<result property="amountD" column="amount_d" />
|
||||
<result property="belongSaler" column="belong_saler" />
|
||||
<result property="belongSalerCode" column="belong_saler_code" />
|
||||
<result property="settlementMan" column="settlement_man" />
|
||||
@@ -28,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcPayBillVo">
|
||||
select pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
cost_amount, pay_total, amount_a, amount_b, amount_c, amount_d,
|
||||
cost_amount, pay_total,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time, update_by, update_time
|
||||
from prc_pay_bill
|
||||
@@ -142,13 +138,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateCnyPayTotal" parameterType="PrcPayBill">
|
||||
<update id="updateCnyPayTotal">
|
||||
update prc_pay_bill
|
||||
set pay_total = #{payTotal},
|
||||
amount_a = #{amountA},
|
||||
amount_b = #{amountB},
|
||||
amount_c = #{amountC},
|
||||
amount_d = #{amountD},
|
||||
currency = 'CNY',
|
||||
update_time = sysdate()
|
||||
where bill_id = #{billId}
|
||||
|
||||
@@ -9,7 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
b.created_by as createdBy, b.create_time as createTime, b.updated_by as updatedBy, b.update_time as updateTime,
|
||||
c.sc_name as scName, c.charge_type as chargeType, c.charge_value as chargeValue, c.currency, c.ss_code as ssCode,
|
||||
c.block_title as blockTitle, c.sc_note as scNote, c.country_code as countryCode, c.fee_type as feeType,
|
||||
c.length_cm as lengthCm, c.width_cm as widthCm, c.height_cm as heightCm, c.size_type as sizeType, c.volume_m3 as volumeM3,
|
||||
c.length_cm as lengthCm, c.width_cm as widthCm, c.height_cm as heightCm,
|
||||
c.over_weight_kg as overWeightKg, c.extra_weight_kg as extraWeightKg, c.postcode_text as postcodeText
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="lengthCm" column="length_cm" />
|
||||
<result property="widthCm" column="width_cm" />
|
||||
<result property="heightCm" column="height_cm" />
|
||||
<result property="sizeType" column="size_type" />
|
||||
<result property="volumeM3" column="volume_m3" />
|
||||
<result property="overWeightKg" column="over_weight_kg" />
|
||||
<result property="extraWeightKg" column="extra_weight_kg" />
|
||||
<result property="postcodeText" column="postcode_text" />
|
||||
@@ -35,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcSurchargeVo">
|
||||
select sc_id, sc_name, fee_type, charge_type, dict_value, charge_value,
|
||||
length_cm, width_cm, height_cm, size_type, volume_m3, over_weight_kg, extra_weight_kg, postcode_text, currency, round_mode,
|
||||
length_cm, width_cm, height_cm, over_weight_kg, extra_weight_kg, postcode_text, currency, round_mode,
|
||||
ss_code, is_del, country_code, block_title, sc_note, tms_id, created_by, create_time, updated_by, update_time
|
||||
from prc_surcharge
|
||||
</sql>
|
||||
@@ -104,8 +102,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="lengthCm != null">length_cm,</if>
|
||||
<if test="widthCm != null">width_cm,</if>
|
||||
<if test="heightCm != null">height_cm,</if>
|
||||
<if test="sizeType != null and sizeType != ''">size_type,</if>
|
||||
<if test="volumeM3 != null">volume_m3,</if>
|
||||
<if test="overWeightKg != null">over_weight_kg,</if>
|
||||
<if test="extraWeightKg != null">extra_weight_kg,</if>
|
||||
<if test="postcodeText != null">postcode_text,</if>
|
||||
@@ -128,8 +124,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="lengthCm != null">#{lengthCm},</if>
|
||||
<if test="widthCm != null">#{widthCm},</if>
|
||||
<if test="heightCm != null">#{heightCm},</if>
|
||||
<if test="sizeType != null and sizeType != ''">#{sizeType},</if>
|
||||
<if test="volumeM3 != null">#{volumeM3},</if>
|
||||
<if test="overWeightKg != null">#{overWeightKg},</if>
|
||||
<if test="extraWeightKg != null">#{extraWeightKg},</if>
|
||||
<if test="postcodeText != null">#{postcodeText},</if>
|
||||
|
||||
@@ -25,8 +25,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="lengthCm" column="length_cm" />
|
||||
<result property="widthCm" column="width_cm" />
|
||||
<result property="heightCm" column="height_cm" />
|
||||
<result property="sizeType" column="size_type" />
|
||||
<result property="volumeM3" column="volume_m3" />
|
||||
<result property="overWeightKg" column="over_weight_kg" />
|
||||
<result property="extraWeightKg" column="extra_weight_kg" />
|
||||
<result property="blockTitle" column="block_title" />
|
||||
@@ -45,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time,
|
||||
s.sc_name, s.fee_type, s.charge_type, s.charge_value, s.currency,
|
||||
s.round_mode, s.ss_code, s.sc_note,
|
||||
s.postcode_text, s.length_cm, s.width_cm, s.height_cm, s.size_type, s.volume_m3,
|
||||
s.postcode_text, s.length_cm, s.width_cm, s.height_cm,
|
||||
s.over_weight_kg, s.extra_weight_kg, s.block_title,
|
||||
ifnull(c.country_name, rc.country_name) as country_name, ifnull(c.weight_min, rc.weight_min) as weight_min, ifnull(c.weight_max, rc.weight_max) as weight_max
|
||||
from prc_surcharge_rel r
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
-- 应付列表增加批量新增费用按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT (SELECT IFNULL(MAX(`t`.`menu_id`), 0) + 1 FROM (SELECT `menu_id` FROM `bms`.`sys_menu`) `t`), '批量新增费用', `p`.`menu_id`, (SELECT IFNULL(MAX(`c`.`order_num`), 0) + 1 FROM (SELECT `parent_id`, `order_num` FROM `bms`.`sys_menu`) `c` WHERE `c`.`parent_id` = `p`.`menu_id`), '', '', 1, 0, 'F', '0', '0', 'price:payOrder:feeBatch', '#', 'admin', sysdate()
|
||||
FROM `bms`.`sys_menu` `p`
|
||||
WHERE `p`.`perms` = 'price:payOrder:list' AND `p`.`menu_type` = 'C'
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` `e` WHERE `e`.`perms` = 'price:payOrder:feeBatch')
|
||||
ORDER BY `p`.`menu_id`
|
||||
LIMIT 1;
|
||||
|
||||
-- 管理员拥有批量新增费用按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, `m`.`menu_id`
|
||||
FROM `bms`.`sys_menu` `m`
|
||||
WHERE `m`.`perms` = 'price:payOrder:feeBatch'
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` `rm` WHERE `rm`.`role_id` = 1 AND `rm`.`menu_id` = `m`.`menu_id`);
|
||||
|
||||
-- 能看应付列表的角色同时拥有批量新增费用按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT `rm`.`role_id`, `btn`.`menu_id`
|
||||
FROM `bms`.`sys_role_menu` `rm`
|
||||
INNER JOIN `bms`.`sys_menu` `parent` ON `parent`.`menu_id` = `rm`.`menu_id` AND `parent`.`perms` = 'price:payOrder:list' AND `parent`.`menu_type` = 'C'
|
||||
INNER JOIN `bms`.`sys_menu` `btn` ON `btn`.`perms` = 'price:payOrder:feeBatch'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` `x` WHERE `x`.`role_id` = `rm`.`role_id` AND `x`.`menu_id` = `btn`.`menu_id`);
|
||||
@@ -1,5 +0,0 @@
|
||||
-- `prc_order_bill` 增加创建时间和主键索引,应付列表按创建时间倒序翻页
|
||||
ALTER TABLE `bms`.`prc_order_bill` ADD INDEX `idx_order_bill_create_bill` (`create_time`, `bill_id`);
|
||||
|
||||
-- `prc_order_bill_ext` 增加提单号索引,按空运单号筛选和重算时不再扫整张扩展表
|
||||
ALTER TABLE `bms`.`prc_order_bill_ext` ADD INDEX `idx_ext_air_no` (`air_no_old`, `bill_id`);
|
||||
@@ -1,8 +0,0 @@
|
||||
-- `pay_weight_band` 表中添加`calc_rule` 属性
|
||||
ALTER TABLE `bms`.`pay_weight_band` ADD COLUMN `calc_rule` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '计费条件类型:POSTCODE邮编、SIZE尺寸、WEIGHT重量。空表示按分区计费' AFTER `zone_name`;
|
||||
-- `pay_weight_band` 表中添加`calc_param` 属性
|
||||
ALTER TABLE `bms`.`pay_weight_band` ADD COLUMN `calc_param` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '计费条件参数。邮编如07或35,38;尺寸如side:80;sum:180或box:60*40*30;重量如30表示超过30kg' AFTER `calc_rule`;
|
||||
-- 原邮编条件改为通用计费条件
|
||||
UPDATE `bms`.`pay_weight_band` SET `calc_rule` = 'POSTCODE', `calc_param` = `postcode_param` WHERE `postcode_param` IS NOT NULL AND TRIM(`postcode_param`) <> '';
|
||||
-- `pay_weight_band` 去掉只表示邮编的字段
|
||||
ALTER TABLE `bms`.`pay_weight_band` DROP COLUMN `postcode_param`;
|
||||
@@ -1,18 +0,0 @@
|
||||
-- `pay_weight_band` 表中添加`postcode_param` 属性
|
||||
ALTER TABLE `bms`.`pay_weight_band` ADD COLUMN `postcode_param` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '邮编条件,如07或35,38。有值时按邮编选用这一档金额和续重' AFTER `zone_name`;
|
||||
-- 巴利阿里偏远档的邮编条件从分区拆出
|
||||
UPDATE `bms`.`pay_weight_band` SET `postcode_param` = '07', `zone_name` = TRIM(REPLACE(`zone_name`, '07邮编开头', '')) WHERE `zone_name` LIKE '%07邮编开头%';
|
||||
-- 加那利偏远档的邮编条件从分区拆出
|
||||
UPDATE `bms`.`pay_weight_band` SET `postcode_param` = '35,38', `zone_name` = TRIM(REPLACE(`zone_name`, '35、38邮编开头', '')) WHERE `zone_name` LIKE '%35、38邮编开头%';
|
||||
-- 休达和梅利利亚偏远档的邮编条件从分区拆出
|
||||
UPDATE `bms`.`pay_weight_band` SET `postcode_param` = '51,52', `zone_name` = TRIM(REPLACE(`zone_name`, '51、52邮编开头', '')) WHERE `zone_name` LIKE '%51、52邮编开头%';
|
||||
-- 葡萄牙岛屿偏远档的邮编条件从分区拆出
|
||||
UPDATE `bms`.`pay_weight_band` SET `postcode_param` = '9', `zone_name` = TRIM(REPLACE(`zone_name`, '9邮编开头', '')) WHERE `zone_name` LIKE '%9邮编开头%';
|
||||
-- 巴利阿里续重分区去掉邮编字样
|
||||
UPDATE `bms`.`pay_surcharge` SET `zone_name` = TRIM(REPLACE(`zone_name`, '07邮编开头', '')) WHERE `zone_name` LIKE '%07邮编开头%';
|
||||
-- 加那利续重分区去掉邮编字样
|
||||
UPDATE `bms`.`pay_surcharge` SET `zone_name` = TRIM(REPLACE(`zone_name`, '35、38邮编开头', '')) WHERE `zone_name` LIKE '%35、38邮编开头%';
|
||||
-- 休达和梅利利亚续重分区去掉邮编字样
|
||||
UPDATE `bms`.`pay_surcharge` SET `zone_name` = TRIM(REPLACE(`zone_name`, '51、52邮编开头', '')) WHERE `zone_name` LIKE '%51、52邮编开头%';
|
||||
-- 葡萄牙岛屿续重分区去掉邮编字样
|
||||
UPDATE `bms`.`pay_surcharge` SET `zone_name` = TRIM(REPLACE(`zone_name`, '9邮编开头', '')) WHERE `zone_name` LIKE '%9邮编开头%';
|
||||
@@ -1,20 +0,0 @@
|
||||
-- `prc_surcharge` 表中添加`size_type` 属性
|
||||
ALTER TABLE `bms`.`prc_surcharge` ADD COLUMN `size_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '超尺寸类型,字典 bms_size_type:SIDE任一边、VOLUME体积' AFTER `height_cm`;
|
||||
|
||||
-- 增加超尺寸类型字典
|
||||
INSERT INTO `bms`.`sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT '超尺寸类型', 'bms_size_type', '0', 'admin', sysdate(), '附加费超尺寸的比对方式'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_type` WHERE `dict_type` = 'bms_size_type');
|
||||
|
||||
-- 超尺寸类型增加任一边
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 1, '任一边', 'SIDE', 'bms_size_type', '', 'default', 'N', '0', 'admin', sysdate(), '长宽高按从大到小比对,任一边超过即命中'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_data` WHERE `dict_type` = 'bms_size_type' AND `dict_value` = 'SIDE');
|
||||
|
||||
-- 超尺寸类型增加体积
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 2, '体积(m³)', 'VOLUME', 'bms_size_type', '', 'default', 'N', '0', 'admin', sysdate(), '长宽高相乘换算立方米后比较'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_data` WHERE `dict_type` = 'bms_size_type' AND `dict_value` = 'VOLUME');
|
||||
@@ -1,2 +0,0 @@
|
||||
-- `prc_surcharge` 表中添加`volume_m3` 属性
|
||||
ALTER TABLE `bms`.`prc_surcharge` ADD COLUMN `volume_m3` decimal(12,6) NULL COMMENT '超尺寸体积阈值,立方米。类型为体积时,订单体积超过该值才收取' AFTER `size_type`;
|
||||
@@ -29,6 +29,10 @@ export function getDefaultArBankAccount(currency = 'CNY') {
|
||||
return request({ url: '/ar/bill/default-bank-account', method: 'get', params: { currency } })
|
||||
}
|
||||
|
||||
export function listArBillBankAccountOptions(currency = 'CNY') {
|
||||
return request({ url: '/ar/bill/bank-account-options', method: 'get', params: { currency } })
|
||||
}
|
||||
|
||||
export function generateArBill(data) {
|
||||
return request({ url: '/ar/bill/generate', method: 'post', data, timeout: 30000 })
|
||||
}
|
||||
|
||||
@@ -38,14 +38,6 @@ export function addPayOrderFee(billId, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function addPayOrderFees(data) {
|
||||
return request({
|
||||
url: '/price/payOrder/fees/batch',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function removePayOrderFee(feeId) {
|
||||
return request({
|
||||
url: '/price/payOrder/fees/' + feeId,
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
<el-table-column prop="totalAmount" label="订单金额" width="120" align="right"><template #default="{ row }">{{ money(row.totalAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="productAmount" label="整单产品价" width="130" align="right"><template #default="{ row }">{{ amount4(row.productAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="redlineAmount" label="整单红线价" width="130" align="right"><template #default="{ row }">{{ amount4(row.redlineAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="receiveTime" label="收货时间" width="170"><template #default="{ row }">{{ row.receiveTime || '-' }}</template></el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="detailTotal > 0 || appliedDetailQuery.orderKeyword || appliedDetailQuery.productKeyword"
|
||||
|
||||
@@ -32,13 +32,16 @@
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div class="payee-card" v-loading="bankAccountLoading">
|
||||
<div class="payee-title">收款方信息(按币种自动匹配)</div>
|
||||
<div class="payee-title">收款方信息</div>
|
||||
<el-select v-model="selectedBankAccountId" class="payee-select" placeholder="请选择收款账户" :disabled="bankAccountLoading || generateLoading" @change="handleBankAccountChange">
|
||||
<el-option v-for="account in bankAccounts" :key="account.bankAccountId" :value="String(account.bankAccountId)" :label="`${account.accountName}(${account.accountNo})`" />
|
||||
</el-select>
|
||||
<template v-if="bankAccount">
|
||||
<span><b>开户名:</b>{{ bankAccount.accountName }}</span>
|
||||
<span><b>开户行:</b>{{ bankAccount.bankName }}</span>
|
||||
<span><b>账号:</b>{{ bankAccount.accountNo }}</span>
|
||||
</template>
|
||||
<span v-else class="payee-empty">当前币种尚未配置公司默认收款账户</span>
|
||||
<span v-else-if="!bankAccountLoading" class="payee-empty">当前币种尚未配置启用的收款账户</span>
|
||||
</div>
|
||||
<div class="preview-toolbar">
|
||||
<span v-if="previewSearched" class="preview-summary">
|
||||
@@ -177,7 +180,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="GenerateBillDialog">
|
||||
import { listArBillGenerateCustomerOptions, getDefaultArBankAccount, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
|
||||
import { listArBillGenerateCustomerOptions, listArBillBankAccountOptions, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
|
||||
import { Download, Refresh, Search, Select } from '@element-plus/icons-vue'
|
||||
import { AR_BILL_SELECTION_MODE } from '@/constants/ar/enums'
|
||||
import { exportAsync } from '@/utils/excelExport'
|
||||
@@ -255,7 +258,10 @@ let excludeRequestSeq = 0
|
||||
const previewQuery = ref(null)
|
||||
let syncingPageSelection = false
|
||||
const bankAccountLoading = ref(false)
|
||||
const bankAccount = ref(null)
|
||||
const bankAccounts = ref([])
|
||||
const selectedBankAccountId = ref('')
|
||||
const bankAccount = computed(() => bankAccounts.value.find(account => String(account.bankAccountId) === selectedBankAccountId.value) || null)
|
||||
let bankAccountRequestSeq = 0
|
||||
const generateRequestId = ref('')
|
||||
const generateFormRef = ref()
|
||||
const billNameFormRef = ref()
|
||||
@@ -288,8 +294,7 @@ function openGenerate() {
|
||||
Object.assign(billNameForm, { billName: '' })
|
||||
billNameOpen.value = false
|
||||
resetPreview()
|
||||
bankAccount.value = null
|
||||
loadDefaultBankAccount()
|
||||
loadBankAccounts()
|
||||
nextTick(() => generateFormRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
@@ -301,7 +306,7 @@ function handleCustomerChange(_, item) {
|
||||
|
||||
function handleCurrencyChange() {
|
||||
resetPreview()
|
||||
loadDefaultBankAccount()
|
||||
loadBankAccounts()
|
||||
}
|
||||
|
||||
// 只清空输入内容,不自动刷新预览;用户点击“查询”后再按新条件查询。
|
||||
@@ -315,16 +320,25 @@ function clearExcludeIdentifiers() {
|
||||
invalidateExcludeSearch()
|
||||
}
|
||||
|
||||
function loadDefaultBankAccount() {
|
||||
function loadBankAccounts() {
|
||||
const requestSeq = ++bankAccountRequestSeq
|
||||
bankAccountLoading.value = true
|
||||
bankAccount.value = null
|
||||
getDefaultArBankAccount(generateForm.currency).then(res => {
|
||||
bankAccount.value = res.data || null
|
||||
bankAccounts.value = []
|
||||
selectedBankAccountId.value = ''
|
||||
listArBillBankAccountOptions(generateForm.currency).then(res => {
|
||||
if (requestSeq !== bankAccountRequestSeq) return
|
||||
bankAccounts.value = res.data || []
|
||||
const defaultAccount = bankAccounts.value.find(account => String(account.isDefault) === '1') || bankAccounts.value[0]
|
||||
selectedBankAccountId.value = defaultAccount ? String(defaultAccount.bankAccountId) : ''
|
||||
}).finally(() => {
|
||||
bankAccountLoading.value = false
|
||||
if (requestSeq === bankAccountRequestSeq) bankAccountLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleBankAccountChange() {
|
||||
if (!generateLoading.value) generateRequestId.value = ''
|
||||
}
|
||||
|
||||
// 条件变化后清理预览和跨页选中状态;用户点击查询时重新加载第一页。
|
||||
function resetPreview() {
|
||||
previewRows.value = []
|
||||
@@ -363,6 +377,7 @@ function buildGenerateRequest(requestId) {
|
||||
return {
|
||||
...(previewQuery.value || buildGenerateQuery()),
|
||||
billName: billNameForm.billName.trim(),
|
||||
bankAccountId: selectedBankAccountId.value,
|
||||
selectionMode: selectionMode.value,
|
||||
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => String(row.billId)),
|
||||
excludedSourceBillIds: [],
|
||||
@@ -673,6 +688,7 @@ function createRequestId() { return globalThis.crypto?.randomUUID?.() || `ar-${D
|
||||
.order-identifier-clear { position: absolute; top: 4px; right: 6px; z-index: 1; padding: 2px 4px; }
|
||||
.payee-card { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 42px; margin: 4px 0 12px; padding: 9px 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 4px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); font-size: 13px; }
|
||||
.payee-title { color: var(--el-text-color-primary); font-weight: 600; }
|
||||
.payee-select { width: 340px; max-width: 100%; }
|
||||
.payee-empty { color: var(--el-color-danger); }
|
||||
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 10px; padding: 10px 14px; border-radius: 6px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); }
|
||||
.preview-summary { flex: 1; font-size: 14px; }
|
||||
|
||||
@@ -67,8 +67,7 @@ const lineRef = ref()
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
]
|
||||
|
||||
function firstPart(value) {
|
||||
@@ -82,7 +81,6 @@ function coverageLabel(value) {
|
||||
function coverageType(value) {
|
||||
if (value === 'UNREACH') return 'danger'
|
||||
if (value === 'REMOTE') return 'warning'
|
||||
if (value === 'SURCHARGE') return 'primary'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@ const rules = {
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
]
|
||||
|
||||
function open(row) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</basic-table>
|
||||
|
||||
<el-dialog v-model="open" title="导入应付邮编" width="480px" append-to-body destroy-on-close>
|
||||
<!-- <p class="import-tip">导入后按国家归成一行。表头里带邮编或附加费的工作表会被导入。可达、可派记为可达,不可达记为不可达,偏远和岛屿记为偏远。英国附加费里的空气减排地区和空气减排地区邮编记为附加费,渠道为 Evri 48H。</p>-->
|
||||
<p class="import-tip">导入后按国家归成一行。表头里带邮编或附加费的工作表会被导入。可达、可派记为可达,不可达记为不可达,偏远和岛屿记为偏远。</p>
|
||||
<el-upload :auto-upload="false" :limit="1" accept=".xlsx" :on-change="onFile" :on-remove="() => file = null">
|
||||
<el-button type="primary" plain>选择 xlsx</el-button>
|
||||
</el-upload>
|
||||
@@ -87,8 +87,7 @@ const form = ref({})
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
]
|
||||
|
||||
function coverageParts(value) {
|
||||
@@ -102,7 +101,6 @@ function coverageLabel(value) {
|
||||
function coverageType(value) {
|
||||
if (value === 'UNREACH') return 'danger'
|
||||
if (value === 'REMOTE') return 'warning'
|
||||
if (value === 'SURCHARGE') return 'primary'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<el-option v-for="item in available" :key="item.scId" :label="optionLabel(item)" :value="item.scId" />
|
||||
</el-select>
|
||||
<el-button type="primary" plain class="add" @click="addPicked">添加</el-button>
|
||||
<p class="hint">从附加费配置里选择。长宽高、体积、重量和邮编在配置里维护,这里只选用。</p>
|
||||
<p class="hint">从附加费配置里选择。长宽高、重量和邮编在配置里维护,这里只选用。</p>
|
||||
</section>
|
||||
<section class="chosen">
|
||||
<div class="pane-title">已选附加费</div>
|
||||
@@ -84,19 +84,6 @@ function valueText(row) {
|
||||
return `${row.amount} ${row.currency || ''}`.trim()
|
||||
}
|
||||
|
||||
function configMeasure(item) {
|
||||
return {
|
||||
lengthCm: item.lengthCm,
|
||||
widthCm: item.widthCm,
|
||||
heightCm: item.heightCm,
|
||||
sizeType: item.sizeType,
|
||||
volumeM3: item.volumeM3,
|
||||
overWeightKg: item.overWeightKg,
|
||||
extraWeightKg: item.extraWeightKg,
|
||||
postcodeText: item.postcodeText || ''
|
||||
}
|
||||
}
|
||||
|
||||
function rowFromConfig(item) {
|
||||
return {
|
||||
scId: item.scId,
|
||||
@@ -105,7 +92,12 @@ function rowFromConfig(item) {
|
||||
amount: item.chargeValue,
|
||||
currency: item.currency,
|
||||
zoneName: item.blockTitle || '',
|
||||
...configMeasure(item)
|
||||
lengthCm: item.lengthCm,
|
||||
widthCm: item.widthCm,
|
||||
heightCm: item.heightCm,
|
||||
overWeightKg: item.overWeightKg,
|
||||
extraWeightKg: item.extraWeightKg,
|
||||
postcodeText: item.postcodeText || ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +117,6 @@ function removeRow(row) {
|
||||
|
||||
function conditionText(row) {
|
||||
if (row.calcRule === 'SIZE') {
|
||||
if (String(row.sizeType || '').trim().toUpperCase() === 'VOLUME') {
|
||||
if (Number(row.volumeM3) > 0) {
|
||||
return `体积超过 ${row.volumeM3} m³`
|
||||
}
|
||||
return '体积还没在附加费配置里填写'
|
||||
}
|
||||
if (Number(row.lengthCm) > 0 && Number(row.widthCm) > 0 && Number(row.heightCm) > 0) {
|
||||
return `长 ${row.lengthCm} cm,宽 ${row.widthCm} cm,高 ${row.heightCm} cm`
|
||||
}
|
||||
@@ -178,7 +164,12 @@ async function open(row) {
|
||||
amount: item.amount,
|
||||
currency: item.currency,
|
||||
zoneName: item.zoneName || '',
|
||||
...configMeasure(item)
|
||||
lengthCm: item.lengthCm,
|
||||
widthCm: item.widthCm,
|
||||
heightCm: item.heightCm,
|
||||
overWeightKg: item.overWeightKg,
|
||||
extraWeightKg: item.extraWeightKg,
|
||||
postcodeText: item.postcodeText || ''
|
||||
}))
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
@@ -36,19 +36,6 @@
|
||||
<el-table-column prop="zoneName" label="分区" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }"><cell-text v-model="row.zoneName" :edit="isRowEditing(row)" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="calcRule" label="计费条件" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-if="isRowEditing(row)" v-model="row.calcRule" clearable size="small" placeholder="不限">
|
||||
<el-option label="邮编" value="POSTCODE" />
|
||||
<el-option label="尺寸" value="SIZE" />
|
||||
<el-option label="重量" value="WEIGHT" />
|
||||
</el-select>
|
||||
<span v-else>{{ bandRuleLabel(row.calcRule) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="calcParam" label="条件参数" min-width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }"><cell-text v-model="row.calcParam" :edit="isRowEditing(row)" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="weightLabel" label="重量段" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }"><cell-text v-model="row.weightLabel" :edit="isRowEditing(row)" /></template>
|
||||
</el-table-column>
|
||||
@@ -552,7 +539,7 @@ watch(source, (list) => {
|
||||
}, { immediate: true })
|
||||
|
||||
function filteredBands(pane) {
|
||||
return filterRows(pane.item.weightBands || [], pane.bandKeyword, ['sectionName', 'countryName', 'countryCode', 'zoneName', 'calcRule', 'calcParam', 'weightLabel', 'chargeName', 'priceUnit'])
|
||||
return filterRows(pane.item.weightBands || [], pane.bandKeyword, ['sectionName', 'countryName', 'countryCode', 'zoneName', 'weightLabel', 'chargeName', 'priceUnit'])
|
||||
}
|
||||
|
||||
function filteredFees(pane) {
|
||||
@@ -731,14 +718,6 @@ function filterRows(rows, keyword, fields) {
|
||||
return rows.filter(row => fields.some(field => String(row?.[field] ?? '').toLowerCase().includes(text)))
|
||||
}
|
||||
|
||||
function bandRuleLabel(rule) {
|
||||
const value = String(rule || '').toUpperCase()
|
||||
if (value === 'POSTCODE') return '邮编'
|
||||
if (value === 'SIZE') return '尺寸'
|
||||
if (value === 'WEIGHT') return '重量'
|
||||
return ''
|
||||
}
|
||||
|
||||
function pageOf(rows, pageNo) {
|
||||
const start = (pageNo - 1) * pageSize
|
||||
return rows.slice(start, start + pageSize)
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="价卡名称" required>
|
||||
<el-input v-model="form.productName" maxlength="80" placeholder="价卡名称" />
|
||||
<el-form-item label="产品名称" required>
|
||||
<el-input v-model="form.productName" maxlength="80" placeholder="渠道或产品名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
@@ -66,18 +66,6 @@
|
||||
<el-table-column label="分区" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.zoneName" size="small" placeholder="不分区可空" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="计费条件" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.calcRule" clearable size="small" placeholder="不限">
|
||||
<el-option label="邮编" value="POSTCODE" />
|
||||
<el-option label="尺寸" value="SIZE" />
|
||||
<el-option label="重量" value="WEIGHT" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条件参数" min-width="160">
|
||||
<template #default="{ row }"><el-input v-model="row.calcParam" size="small" placeholder="07 / side:80 / 30" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType !== 'EXTRA'" label="重量下限KG" width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.weightMin" size="small" /></template>
|
||||
</el-table-column>
|
||||
@@ -198,7 +186,7 @@ function onMode() {
|
||||
}
|
||||
|
||||
function blankRow() {
|
||||
return { countryName: '', countryCode: '', zoneName: '', calcRule: '', calcParam: '', weightMin: '0', weightMax: '', price: '', extraPrice: '' }
|
||||
return { countryName: '', countryCode: '', zoneName: '', weightMin: '0', weightMax: '', price: '', extraPrice: '' }
|
||||
}
|
||||
|
||||
function addRow() {
|
||||
@@ -247,8 +235,6 @@ async function submit() {
|
||||
countryName: row.countryName,
|
||||
countryCode: row.countryCode,
|
||||
zoneName: row.zoneName,
|
||||
calcRule: row.calcRule,
|
||||
calcParam: row.calcParam,
|
||||
weightMin: 0,
|
||||
weightMax: firstKg,
|
||||
price
|
||||
@@ -267,8 +253,6 @@ async function submit() {
|
||||
countryName: row.countryName,
|
||||
countryCode: row.countryCode,
|
||||
zoneName: row.zoneName,
|
||||
calcRule: row.calcRule,
|
||||
calcParam: row.calcParam,
|
||||
weightMin: min,
|
||||
weightMax: max,
|
||||
price
|
||||
|
||||
@@ -29,7 +29,6 @@ const calcModeOptions = [
|
||||
{ value: 'MANUAL', label: '暂不计费' },
|
||||
{ value: 'ALWAYS', label: '每票都收' },
|
||||
{ value: 'POSTCODE', label: '命中邮编' },
|
||||
{ value: 'FEE_POSTCODE', label: '附加费邮编' },
|
||||
{ value: 'ZONE', label: '命中分区' },
|
||||
{ value: 'EXTRA_KG', label: '超重续收' },
|
||||
{ value: 'WEIGHT', label: '超重' },
|
||||
@@ -51,8 +50,6 @@ const blockSelectOptions = computed(() =>
|
||||
|
||||
const chargeType = computed(() => String(form.value.chargeType || '').toUpperCase())
|
||||
|
||||
const sizeKind = computed(() => String(form.value.sizeType || '').toUpperCase())
|
||||
|
||||
const schemas = computed(() => [
|
||||
{
|
||||
label: '附加费名称',
|
||||
@@ -84,26 +81,15 @@ const schemas = computed(() => [
|
||||
width: '100%',
|
||||
rules: [{ required: true, message: '请选择计费方式', trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: '超尺寸类型',
|
||||
prop: 'sizeType',
|
||||
component: 'select',
|
||||
placeholder: '请选择',
|
||||
dict: 'bms_size_type',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE',
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请选择超尺寸类型', trigger: 'change' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '长(cm)',
|
||||
prop: 'lengthCm',
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '宽(cm)',
|
||||
@@ -111,9 +97,9 @@ const schemas = computed(() => [
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '高(cm)',
|
||||
@@ -121,20 +107,9 @@ const schemas = computed(() => [
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
show: chargeType.value === 'SIZE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE' ? [{ required: true, message: '请填写高', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '体积值/m³',
|
||||
prop: 'volumeM3',
|
||||
component: 'inputNumber',
|
||||
placeholder: '超过这个体积才收取',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'VOLUME',
|
||||
props: { min: 0, precision: 6, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'VOLUME' ? [{ required: true, message: '请填写体积', trigger: 'blur' }] : undefined
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写高', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '超过重量(kg)',
|
||||
@@ -242,8 +217,6 @@ function emptyForm() {
|
||||
countryCode: undefined,
|
||||
blockTitle: undefined,
|
||||
scNote: undefined,
|
||||
sizeType: undefined,
|
||||
volumeM3: undefined,
|
||||
lengthCm: undefined,
|
||||
widthCm: undefined,
|
||||
heightCm: undefined,
|
||||
@@ -354,8 +327,6 @@ watch(() => form.value.countryCode, (code, prev) => {
|
||||
|
||||
watch(() => form.value.chargeType, (type, prev) => {
|
||||
if (suppressCountryWatch.value || !prev || type === prev) return
|
||||
form.value.sizeType = undefined
|
||||
form.value.volumeM3 = undefined
|
||||
form.value.lengthCm = undefined
|
||||
form.value.widthCm = undefined
|
||||
form.value.heightCm = undefined
|
||||
@@ -366,19 +337,6 @@ watch(() => form.value.chargeType, (type, prev) => {
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
})
|
||||
|
||||
watch(() => form.value.sizeType, (type, prev) => {
|
||||
if (suppressCountryWatch.value || !prev || type === prev) return
|
||||
const code = String(type || '').toUpperCase()
|
||||
if (code === 'VOLUME') {
|
||||
form.value.lengthCm = undefined
|
||||
form.value.widthCm = undefined
|
||||
form.value.heightCm = undefined
|
||||
} else if (code === 'SIDE') {
|
||||
form.value.volumeM3 = undefined
|
||||
}
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
})
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
|
||||
@@ -109,7 +109,6 @@ const chargeTypeLabelMap = {
|
||||
MANUAL: '暂不计费',
|
||||
ALWAYS: '每票都收',
|
||||
POSTCODE: '命中邮编',
|
||||
FEE_POSTCODE: '附加费邮编',
|
||||
ZONE: '命中分区',
|
||||
EXTRA_KG: '超重续收',
|
||||
WEIGHT: '超重',
|
||||
|
||||
@@ -87,7 +87,6 @@ const calcModeLabelMap = {
|
||||
MANUAL: '暂不计费',
|
||||
ALWAYS: '每票都收',
|
||||
POSTCODE: '命中邮编',
|
||||
FEE_POSTCODE: '附加费邮编',
|
||||
ZONE: '命中分区',
|
||||
EXTRA_KG: '超重续收',
|
||||
WEIGHT: '超重',
|
||||
@@ -99,8 +98,6 @@ const columns = [
|
||||
{ label: '附加费名称', prop: 'scName', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'feeType', align: 'center', width: 110, dict: 'bms_fee_type' },
|
||||
{ label: '计费方式', prop: 'chargeType', align: 'center', width: 110 },
|
||||
{ label: '超尺寸类型', prop: 'sizeType', align: 'center', width: 120, dict: 'bms_size_type' },
|
||||
{ label: '体积(m³)', prop: 'volumeM3', align: 'center', width: 110 },
|
||||
{ label: '计费数值', prop: 'chargeValue', align: 'center', width: 140 },
|
||||
{ label: '取值方式', prop: 'roundMode', align: 'center', width: 110, dict: 'bms_round_mode' },
|
||||
{ label: '适用国家', prop: 'countryCode', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
|
||||
@@ -1,375 +0,0 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
:title="title"
|
||||
size="840px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="bill-detail-drawer"
|
||||
@update:model-value="$emit('update:modelValue', $event)"
|
||||
>
|
||||
<div v-loading="loading" class="bill-detail-wrap">
|
||||
<el-empty v-if="!detail" description="暂无详情" />
|
||||
<div v-else class="bill-detail">
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">订单信息</div>
|
||||
<el-descriptions class="detail-desc" :column="2" border size="small">
|
||||
<el-descriptions-item label="订单号">{{ detail.orderNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运单号">{{ detail.trackingNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="转单号">{{ detail.transferNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="销售员">{{ detail.belongSaler || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结算员">{{ detail.settlementMan || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客服员">{{ detail.serviceMan || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户">{{ displayCustomer(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户状态">{{ customerActiveLabel(detail.customerActiveStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="额度欠费">{{ creditArrearsLabel(detail.creditArrearsStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="退费状态">{{ refundLabel(detail.refundStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库">{{ detail.warehouseCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="发件人">{{ detail.shipperName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收件人">{{ detail.consigneeName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="目的国/地区">{{ countryLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="目的邮编">{{ detail.destPostcode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="件数">{{ detail.pieces != null ? detail.pieces : '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="尺寸(cm)">{{ dimLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="实重(kg)">{{ formatWeight(detail.actualWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收货重(kg)">{{ formatWeight(detail.receiveWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="材积重(kg)">{{ formatWeight(detail.volumeWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="体积(m³)">{{ formatMoney(detail.volume) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="下单时间">{{ formatDateTime(detail.orderTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单备注" :span="2">{{ detail.orderRemark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">计费信息</div>
|
||||
<div class="amount-summary">
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">A段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountA) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">B段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountB) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">C段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountC) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">D段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountD) }}</div>
|
||||
</div>
|
||||
<div class="amount-card is-total">
|
||||
<div class="amount-label">应付总额</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.payTotal) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-descriptions class="detail-desc" :column="2" border size="small">
|
||||
<el-descriptions-item label="产品">{{ productLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户确认重(kg)">{{ formatWeight(detail.chargeWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费重量(kg)">{{ formatWeight(detail.chargeWeight ?? detail.weight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="重量段">{{ detail.weightLabel || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费时间">{{ detail.bizDate || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道编码">{{ detail.productFloorCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道名称">{{ detail.productFloor || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费状态">
|
||||
<el-tag size="small" :type="billingFailTagType(detail.billingFailStatus)">{{ billingFailLabel(detail.billingFailStatus) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐">{{ priceSetLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(detail.currency)" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="取值方式">{{ roundModeLabel(detail.roundMode) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运费单价">{{ formatRate(detail.freightRate) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="挂号费">{{ formatMoney(detail.registrationFee) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">费用明细</div>
|
||||
<div v-if="!readonly" class="pay-generate">
|
||||
<el-button type="primary" plain size="small" v-hasPermi="['price:billing:bill']" @click="handlePayBill">生成应付</el-button>
|
||||
</div>
|
||||
<el-table v-if="payFees.length" :data="payFees" border size="small" class="fee-table">
|
||||
<el-table-column label="费用名称" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ displayFeeName(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="费用类型" min-width="140" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="feeTypeTag(row.feeType)" effect="plain">
|
||||
{{ payFeeTypeLabel(row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="fee-amount">{{ formatFeeAmount(row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(row.currency)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-else description="暂无应付明细" :image-size="64" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { generatePayBill } from '@/api/price/pay'
|
||||
import { getPayOrder } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
title: { type: String, default: '订单详情' },
|
||||
loading: { type: Boolean, default: false },
|
||||
detail: { type: Object, default: null },
|
||||
readonly: { type: Boolean, default: false }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'updated'])
|
||||
|
||||
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
|
||||
|
||||
const payFees = computed(() => {
|
||||
const d = props.detail
|
||||
if (!d) return []
|
||||
return d.payFeeDetails || []
|
||||
})
|
||||
|
||||
function handlePayBill() {
|
||||
const billId = props.detail?.billId
|
||||
if (!billId) return
|
||||
ElMessageBox.confirm('确认生成应付?', '生成应付', { type: 'warning' })
|
||||
.then(() => generatePayBill(billId))
|
||||
.then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
return getPayOrder(billId)
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) emit('updated', res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
if (err === 'cancel' || err === 'close') return
|
||||
})
|
||||
}
|
||||
|
||||
function customerActiveLabel(status) {
|
||||
const map = { ACTIVE: '正常', MISSING: '不存在', DISABLED: '停用' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
function creditArrearsLabel(status) {
|
||||
const map = { NORMAL: '正常', ARREARS: '欠费' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
function displayCustomer(row) {
|
||||
if (row.customerName && row.customerCode) return row.customerName + ' (' + row.customerCode + ')'
|
||||
return row.customerName || row.customerCode || row.customerId || '-'
|
||||
}
|
||||
|
||||
function countryLabel(row) {
|
||||
return (row.countryName || '-') + ' (' + (row.countryCode || '-') + ')'
|
||||
}
|
||||
|
||||
function productLabel(row) {
|
||||
return (row.productName || '-') + ' (' + (row.productCode || '-') + ')'
|
||||
}
|
||||
|
||||
function priceSetLabel(row) {
|
||||
const name = row.priceSetName || '-'
|
||||
return row.priceSetCode ? name + ' (' + row.priceSetCode + ')' : name
|
||||
}
|
||||
|
||||
function dimLabel(row) {
|
||||
if (row.pkgLength == null && row.pkgWidth == null && row.pkgHeight == null) return '-'
|
||||
return [row.pkgLength, row.pkgWidth, row.pkgHeight].map(v => v == null ? '-' : v).join(' × ')
|
||||
}
|
||||
|
||||
function formatMoney(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
function formatFeeAmount(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(3)
|
||||
}
|
||||
|
||||
function formatWeight(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(3)
|
||||
}
|
||||
|
||||
function formatRate(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
function formatDateTime(val) {
|
||||
if (!val) return '-'
|
||||
const d = new Date(val)
|
||||
if (Number.isNaN(d.getTime())) return val
|
||||
const pad = n => String(n).padStart(2, '0')
|
||||
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
|
||||
}
|
||||
|
||||
const billingFailStatusOptions = [
|
||||
{ label: '计费成功', value: 0 },
|
||||
{ label: '销售价未匹配产品', value: 1 },
|
||||
{ label: '销售价未匹配国家', value: 2 },
|
||||
{ label: '销售价未匹配重量段', value: 3 },
|
||||
{ label: '产品价未匹配产品', value: 23 },
|
||||
{ label: '产品价未匹配国家', value: 24 },
|
||||
{ label: '产品价未匹配重量段', value: 25 },
|
||||
{ label: '未绑定套餐', value: 4 },
|
||||
{ label: '套餐未启用/无生效版本', value: 5 },
|
||||
{ label: '已生成应收账单', value: 6 },
|
||||
{ label: '产品档案缺失', value: 7 },
|
||||
{ label: '未命中价格', value: 8 },
|
||||
{ label: '分区无价格', value: 9 },
|
||||
{ label: '邮编必填', value: 10 },
|
||||
{ label: '邮编未匹配分区', value: 11 },
|
||||
{ label: '上游订单不存在', value: 12 },
|
||||
{ label: '上游订单号为空', value: 13 },
|
||||
{ label: '上游客户为空', value: 14 },
|
||||
{ label: '上游产品为空', value: 15 },
|
||||
{ label: '上游重量无效', value: 16 },
|
||||
{ label: '计费时间为空', value: 17 },
|
||||
{ label: '退费订单无法解析', value: 18 },
|
||||
{ label: '客户代码为空', value: 19 },
|
||||
{ label: '客户已停用', value: 20 },
|
||||
{ label: '运费为空', value: 21 },
|
||||
{ label: '未知失败', value: 22 },
|
||||
{ label: '未计费', value: 26 }
|
||||
]
|
||||
|
||||
function billingFailLabel(status) {
|
||||
const code = status == null ? 0 : Number(status)
|
||||
const hit = billingFailStatusOptions.find(item => item.value === code)
|
||||
return hit ? hit.label : '未知失败'
|
||||
}
|
||||
|
||||
function billingFailTagType(status) {
|
||||
const code = status == null ? 0 : Number(status)
|
||||
if (code === 26) return 'info'
|
||||
if (code > 0) return 'danger'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
const map = { UP: '向上取值', DOWN: '向下取整', HALF_UP: '四舍五入' }
|
||||
return map[mode] || mode || '四舍五入'
|
||||
}
|
||||
|
||||
function payFeeTypeLabel(row) {
|
||||
const name = String(row?.feeName || row?.fee_name || '').trim()
|
||||
if (row?.feeType === 'LADING' || row?.feeSource === 'LADING') return name || '提单费用'
|
||||
return feeTypeLabel(row?.feeType) || row?.feeType || '-'
|
||||
}
|
||||
|
||||
function feeTypeLabel(type) {
|
||||
const found = (bms_fee_type.value || []).find(d => d.value === type)
|
||||
return found ? found.label : ''
|
||||
}
|
||||
|
||||
function feeTypeTag(type) {
|
||||
if (type === 'FREIGHT') return ''
|
||||
if (type === 'REGISTRATION') return 'warning'
|
||||
if (type === 'SURCHARGE') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function displayCurrency(v) {
|
||||
if (!v || v === 'RMB' || v === 'rmb') return 'CNY'
|
||||
return v
|
||||
}
|
||||
|
||||
function displayFeeName(row) {
|
||||
const typeLabel = feeTypeLabel(row.feeType)
|
||||
const name = String(row.feeName || row.fee_name || '').trim()
|
||||
const isSurcharge = row.feeType === 'SURCHARGE' || row.feeType === '附加费'
|
||||
if (isSurcharge && name && name !== typeLabel && name !== 'SURCHARGE' && name !== '附加费') {
|
||||
return name
|
||||
}
|
||||
return name || typeLabel || row.feeType || '-'
|
||||
}
|
||||
|
||||
function refundLabel(status) {
|
||||
const map = { NONE: '未退费', REFUNDED: '已退费' }
|
||||
return map[status] || status || '未退费'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bill-detail-wrap { min-height: 240px; }
|
||||
.pay-generate { margin-bottom: 8px; }
|
||||
.bill-detail { padding-bottom: 8px; }
|
||||
.detail-block { margin-bottom: 20px; }
|
||||
.detail-block:last-child { margin-bottom: 0; }
|
||||
.sec-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1;
|
||||
}
|
||||
.sec-title::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: var(--el-color-primary);
|
||||
}
|
||||
.amount-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.amount-card {
|
||||
padding: 12px 14px;
|
||||
background: #f7f8fa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.amount-card.is-total { background: #fff1f0; }
|
||||
.amount-label { font-size: 12px; color: #909399; line-height: 1.2; }
|
||||
.amount-value {
|
||||
margin-top: 6px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.amount-card.is-total .amount-value { color: #f56c6c; }
|
||||
.detail-desc :deep(.el-descriptions__label) {
|
||||
width: 108px;
|
||||
color: #909399;
|
||||
font-weight: 400;
|
||||
background: #fafbfc;
|
||||
}
|
||||
.detail-desc :deep(.el-descriptions__content) { color: #303133; }
|
||||
.detail-desc :deep(.el-descriptions__cell) { padding: 9px 12px; }
|
||||
.fee-amount { font-variant-numeric: tabular-nums; font-weight: 500; }
|
||||
</style>
|
||||
@@ -29,22 +29,18 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row class="mb8" align="middle">
|
||||
<el-row class="mb8">
|
||||
<el-button type="primary" plain icon="RefreshRight" :loading="recalcRunning" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
|
||||
<el-button type="primary" plain icon="Plus" v-hasPermi="['price:payOrder:feeBatch']" @click="openBatch">新增费用</el-button>
|
||||
<span v-if="selectedOrders.length" class="picked-count">已选 {{ selectedOrders.length }} 个订单</span>
|
||||
</el-row>
|
||||
|
||||
<el-table ref="orderTableRef" v-loading="loading" :data="rows" row-key="billId" border @selection-change="onSelectionChange">
|
||||
<el-table-column type="selection" width="48" reserve-selection fixed="left" />
|
||||
<el-table v-loading="loading" :data="rows" border>
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="160" fixed="left" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="150" fixed="left" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.ladingNo || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="trackingNo" label="运单号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="customerCode" label="客户编码" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.customerCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="destPostcode" label="邮编" width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.destPostcode || '-' }}</template>
|
||||
@@ -81,7 +77,7 @@
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="query.pageNum" v-model:limit="query.pageSize" @pagination="loadList" />
|
||||
|
||||
<pay-order-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" @updated="onDetailUpdated" />
|
||||
<bill-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" :show-income="false" />
|
||||
|
||||
<el-dialog v-model="feeOpen" :title="feeTitle" width="1280px" append-to-body destroy-on-close>
|
||||
<div v-loading="feeLoading" class="fee-board">
|
||||
@@ -176,63 +172,6 @@
|
||||
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="batchOpen" title="批量新增费用" width="1080px" append-to-body destroy-on-close :close-on-click-modal="false">
|
||||
<div class="batch-block batch-orders">
|
||||
<div class="fee-head">已选订单({{ batchOrders.length }})</div>
|
||||
<div class="batch-order-list">
|
||||
<el-tag
|
||||
v-for="row in batchOrders"
|
||||
:key="row.billId"
|
||||
closable
|
||||
effect="plain"
|
||||
@close="removeBatchOrder(row)"
|
||||
>{{ row.orderNo || '-' }}</el-tag>
|
||||
<span v-if="!batchOrders.length" class="batch-order-empty">没有订单</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="batch-block">
|
||||
<div class="fee-head">新增费用</div>
|
||||
<div class="fee-tools">
|
||||
<el-button type="primary" plain size="small" @click="addBatchFee">增加一行</el-button>
|
||||
</div>
|
||||
<el-table class="fee-table" :data="batchFees" border empty-text="请增加费用">
|
||||
<el-table-column label="费用项" min-width="160" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.feeType" filterable placeholder="选择费用项">
|
||||
<el-option v-for="item in (bms_fee_type || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.amount" :precision="3" :controls="false" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" min-width="120" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.currency" filterable placeholder="选择币种">
|
||||
<el-option v-for="item in (bms_currency || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" maxlength="200" placeholder="选填" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center" class-name="fee-op">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" @click="removeBatchFee(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="batchOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="batchSaving" @click="submitBatch">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body :close-on-click-modal="false">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="重算方式">
|
||||
@@ -313,9 +252,9 @@
|
||||
</template>
|
||||
|
||||
<script setup name="PayOrderList">
|
||||
import { addPayOrderFee, addPayOrderFees, cancelPayOrderRecalc, getPayOrder, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { addPayOrderFee, cancelPayOrderRecalc, getPayOrder, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import PayOrderDetail from './PayOrderDetail.vue'
|
||||
import BillDetail from '../components/BillDetail.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_pay_calc_status, bms_fee_type, bms_currency, bms_pay_fee_log_type } = useDict('bms_pay_calc_status', 'bms_fee_type', 'bms_currency', 'bms_pay_fee_log_type')
|
||||
@@ -324,14 +263,6 @@ const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const query = reactive({ orderNo: '', ladingNo: '', customerName: '', pageNum: 1, pageSize: 20 })
|
||||
const orderTableRef = ref()
|
||||
const selectedMap = ref(new Map())
|
||||
const selectedOrders = computed(() => Array.from(selectedMap.value.values()))
|
||||
const batchOpen = ref(false)
|
||||
const batchSaving = ref(false)
|
||||
const batchOrders = ref([])
|
||||
const batchFees = ref([])
|
||||
let batchFeeSeed = 1
|
||||
|
||||
const detailOpen = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
@@ -466,30 +397,6 @@ function reset() {
|
||||
search()
|
||||
}
|
||||
|
||||
function snapshotOrder(row) {
|
||||
return {
|
||||
billId: row.billId,
|
||||
orderNo: row.orderNo,
|
||||
ladingNo: row.ladingNo,
|
||||
customerName: row.customerName,
|
||||
productName: row.productName
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectionChange(selection) {
|
||||
if (loading.value) return
|
||||
const pageIds = new Set((rows.value || []).map(row => String(row.billId)))
|
||||
const next = new Map(selectedMap.value)
|
||||
for (const id of pageIds) next.delete(id)
|
||||
for (const row of selection || []) next.set(String(row.billId), snapshotOrder(row))
|
||||
selectedMap.value = next
|
||||
}
|
||||
|
||||
function syncSelection() {
|
||||
const selection = orderTableRef.value?.getSelectionRows?.() || []
|
||||
onSelectionChange(selection)
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
listPayOrder(query).then(res => {
|
||||
@@ -497,98 +404,6 @@ function loadList() {
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
nextTick(syncSelection)
|
||||
})
|
||||
}
|
||||
|
||||
function emptyBatchFee() {
|
||||
batchFeeSeed += 1
|
||||
return { key: batchFeeSeed, level: '4', feeType: '', amount: null, currency: 'CNY', remark: '' }
|
||||
}
|
||||
|
||||
function openBatch() {
|
||||
if (!selectedOrders.value.length) {
|
||||
proxy.$modal.msgWarning('请先勾选订单')
|
||||
return
|
||||
}
|
||||
batchOrders.value = selectedOrders.value.map(row => ({ ...row }))
|
||||
batchFees.value = [emptyBatchFee()]
|
||||
batchOpen.value = true
|
||||
}
|
||||
|
||||
function removeBatchOrder(row) {
|
||||
const id = String(row.billId)
|
||||
batchOrders.value = batchOrders.value.filter(item => String(item.billId) !== id)
|
||||
const stored = selectedMap.value.get(id)
|
||||
const current = (rows.value || []).find(item => String(item.billId) === id)
|
||||
orderTableRef.value?.toggleRowSelection(current || stored || row, false)
|
||||
const next = new Map(selectedMap.value)
|
||||
next.delete(id)
|
||||
selectedMap.value = next
|
||||
}
|
||||
|
||||
function addBatchFee() {
|
||||
if (batchFees.value.length >= 20) {
|
||||
proxy.$modal.msgWarning('一次最多增加20条费用')
|
||||
return
|
||||
}
|
||||
batchFees.value.push(emptyBatchFee())
|
||||
}
|
||||
|
||||
function removeBatchFee(row) {
|
||||
batchFees.value = batchFees.value.filter(item => item !== row)
|
||||
}
|
||||
|
||||
function submitBatch() {
|
||||
if (!batchOrders.value.length) {
|
||||
proxy.$modal.msgWarning('请勾选订单')
|
||||
return
|
||||
}
|
||||
if (!batchFees.value.length) {
|
||||
proxy.$modal.msgWarning('请增加费用')
|
||||
return
|
||||
}
|
||||
const fees = []
|
||||
for (const row of batchFees.value) {
|
||||
if (!row.feeType) {
|
||||
proxy.$modal.msgWarning('请选择费用项')
|
||||
return
|
||||
}
|
||||
if (row.amount === null || row.amount === undefined || row.amount === '') {
|
||||
proxy.$modal.msgWarning('请填写金额')
|
||||
return
|
||||
}
|
||||
if (!row.currency) {
|
||||
proxy.$modal.msgWarning('请选择币种')
|
||||
return
|
||||
}
|
||||
const dict = (bms_fee_type.value || []).find(item => item.value === row.feeType)
|
||||
fees.push({
|
||||
feeType: row.feeType,
|
||||
feeName: dict ? dict.label : row.feeType,
|
||||
level: '4',
|
||||
amount: row.amount,
|
||||
currency: row.currency,
|
||||
remark: row.remark
|
||||
})
|
||||
}
|
||||
const orderCount = batchOrders.value.length
|
||||
proxy.$modal.confirm('确认为 ' + orderCount + ' 个订单各增加 ' + fees.length + ' 条手工费用?').then(() => {
|
||||
batchSaving.value = true
|
||||
return addPayOrderFees({
|
||||
billIds: batchOrders.value.map(row => String(row.billId)),
|
||||
fees
|
||||
})
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已为 ' + orderCount + ' 个订单增加费用')
|
||||
batchOpen.value = false
|
||||
selectedMap.value = new Map()
|
||||
orderTableRef.value?.clearSelection()
|
||||
loadList()
|
||||
}).catch(() => {
|
||||
/* 取消或接口失败时保留弹框 */
|
||||
}).finally(() => {
|
||||
batchSaving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -603,12 +418,6 @@ function openDetail(row) {
|
||||
})
|
||||
}
|
||||
|
||||
function onDetailUpdated(data) {
|
||||
if (data) {
|
||||
detail.value = data
|
||||
}
|
||||
}
|
||||
|
||||
function openFees(row) {
|
||||
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
|
||||
feeBillId.value = row.billId
|
||||
@@ -1022,20 +831,6 @@ loadList()
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
.fee-tools { margin-bottom: 8px; text-align: right; }
|
||||
.picked-count { margin-left: 12px; color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
.batch-block { margin-bottom: 16px; }
|
||||
.batch-order-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
max-height: 132px;
|
||||
overflow: auto;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-top: none;
|
||||
}
|
||||
.batch-orders .fee-head { margin-bottom: 0; }
|
||||
.batch-order-empty { color: var(--el-text-color-secondary); font-size: 13px; line-height: 24px; }
|
||||
.log-change { line-height: 1.6; }
|
||||
.log-empty { color: var(--el-text-color-secondary); }
|
||||
.rebill-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
|
||||
|
||||
Reference in New Issue
Block a user