evri渠道附加费计算调整,应付列表查询性能优化
This commit is contained in:
@@ -169,6 +169,20 @@ 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
|
||||
@@ -211,13 +225,15 @@ class PayCostCalculatorTest
|
||||
}
|
||||
|
||||
@Test
|
||||
void oversizeUsesTheHigherPercentWhenBothTiersMatch()
|
||||
void oversizeAddsEveryMatchingTierOfTheSameName()
|
||||
{
|
||||
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(1, result.getFees().stream().filter(fee -> "特大包裹收费".equals(fee.getFeeName())).count());
|
||||
assertEquals(2, result.getFees().stream().filter(fee -> "特大包裹收费".equals(fee.getFeeName())).count());
|
||||
assertEquals(new BigDecimal("4.65"), result.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -510,6 +526,59 @@ 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,11 +2,13 @@ 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;
|
||||
@@ -32,7 +34,7 @@ class PayPostcodeImporterTest
|
||||
assertEquals("Royal Mail", remote195.getChannelName());
|
||||
assertEquals("Royal Mail", remote115.getChannelName());
|
||||
assertEquals("EVRI", evri.getChannelName());
|
||||
assertEquals("EVRI", air.getChannelName());
|
||||
assertEquals("Evri 48H", 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())));
|
||||
@@ -47,7 +49,8 @@ class PayPostcodeImporterTest
|
||||
assertEquals("REMOTE", remote195.getCoverage());
|
||||
assertEquals("REMOTE", remote115.getCoverage());
|
||||
assertEquals("REMOTE", evri.getCoverage());
|
||||
assertEquals("", air.getCoverage());
|
||||
assertEquals("SURCHARGE", air.getCoverage());
|
||||
assertTrue(air.getLines().stream().anyMatch(line -> "BS1 1BT".equals(line.getPostcode()) && "Bristol".equals(line.getZoneName())));
|
||||
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();
|
||||
@@ -80,7 +83,7 @@ class PayPostcodeImporterTest
|
||||
assertEquals("REACH", PayPostcodeImporter.coverageOf("法国GOFO可达邮编", "", ""));
|
||||
assertEquals("UNREACH", PayPostcodeImporter.coverageOf("德国DPD挂号(DEDPD)不可达邮编", "", ""));
|
||||
assertEquals("REMOTE", PayPostcodeImporter.coverageOf("evri 偏远", "", ""));
|
||||
assertEquals("", PayPostcodeImporter.coverageOf("英国附加费", "EVRI偏远&空气减排地区附加费", "空气减排附加费"));
|
||||
assertEquals("SURCHARGE", PayPostcodeImporter.coverageOf("英国附加费", "EVRI偏远&空气减排地区附加费", "空气减排附加费"));
|
||||
List<PayPostcodeImporter.PostcodeToken> kept = PayPostcodeImporter.expandPostcode("KA27-28");
|
||||
assertEquals("KA27-28", kept.get(0).postcode);
|
||||
assertEquals("", kept.get(0).end);
|
||||
@@ -89,6 +92,75 @@ 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
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PayPostcodeGroup extends BaseEntity
|
||||
/** ZONE 邮编分区,FEE 附加费 */
|
||||
private String configKind;
|
||||
|
||||
/** REACH 可达,UNREACH 不可达,REMOTE 偏远。普通分区为空 */
|
||||
/** REACH 可达,UNREACH 不可达,REMOTE 偏远,SURCHARGE 附加费。普通分区为空 */
|
||||
private String coverage;
|
||||
|
||||
/** 渠道名称,从表头识别,可在页面修改 */
|
||||
|
||||
@@ -22,6 +22,9 @@ public class PayPostcodeLine implements Serializable
|
||||
/** 查询条件:只看这个渠道下的邮编 */
|
||||
private String channelName;
|
||||
|
||||
/** 附加费邮编查询时带出这一组的费用名 */
|
||||
private String feeName;
|
||||
|
||||
private String regionName;
|
||||
|
||||
private String regionNameCn;
|
||||
|
||||
@@ -75,6 +75,12 @@ public class PaySurcharge
|
||||
/** 来自附加费配置的高,厘米。本表不保存 */
|
||||
private BigDecimal heightCm;
|
||||
|
||||
/** 来自附加费配置的超尺寸类型:SIDE 任一边,VOLUME 体积。本表不保存 */
|
||||
private String sizeType;
|
||||
|
||||
/** 来自附加费配置的体积阈值,立方米。本表不保存 */
|
||||
private BigDecimal volumeM3;
|
||||
|
||||
/** 来自附加费配置的超重阈值,公斤。本表不保存 */
|
||||
private BigDecimal overWeightKg;
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ 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,6 +62,12 @@ public class PrcSurchargeBind
|
||||
|
||||
private BigDecimal heightCm;
|
||||
|
||||
/** 超尺寸类型:SIDE 任一边,VOLUME 体积 */
|
||||
private String sizeType;
|
||||
|
||||
/** 超尺寸体积阈值,立方米 */
|
||||
private BigDecimal volumeM3;
|
||||
|
||||
private BigDecimal overWeightKg;
|
||||
|
||||
private BigDecimal extraWeightKg;
|
||||
|
||||
@@ -53,6 +53,12 @@ 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;
|
||||
|
||||
@@ -2,13 +2,21 @@ 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
|
||||
{
|
||||
List<PayOrderRow> selectList(PayOrderQuery query);
|
||||
/** 当前页的计费订单 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);
|
||||
|
||||
PayOrderRow selectRow(@Param("billId") String billId);
|
||||
|
||||
|
||||
@@ -67,6 +67,10 @@ 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);
|
||||
|
||||
@@ -423,34 +423,7 @@ public final class LabelArCostCalculator
|
||||
result.getSkipped().add(name + ":价卡没有可计算的条件,暂不计费");
|
||||
}
|
||||
}
|
||||
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;
|
||||
result.getFees().addAll(sized);
|
||||
}
|
||||
|
||||
private static void addExtraKg(List<PayCostLine> fees, PaySurcharge fee, BigDecimal weight, String currency)
|
||||
|
||||
@@ -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);
|
||||
postcodeOn, zoneOn, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,6 +112,17 @@ 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<>());
|
||||
@@ -185,7 +196,7 @@ public final class PayCostCalculator
|
||||
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, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
band.getSectionName(), remoteHits, surchargeHits, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
@@ -323,7 +334,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, boolean postcodeOn, boolean zoneOn,
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, List<PayRemoteBook.Hit> surchargeHits, boolean postcodeOn, boolean zoneOn,
|
||||
String countryCode, String countryName, PayOrderCostResult result)
|
||||
{
|
||||
if (product.getSurcharges() == null)
|
||||
@@ -344,6 +355,19 @@ 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;
|
||||
@@ -400,7 +424,11 @@ public final class PayCostCalculator
|
||||
String name = blank(fee.getFeeName());
|
||||
if (PaySurchargeRules.POSTCODE.equals(rule))
|
||||
{
|
||||
if (!postcodeRules.isEmpty())
|
||||
if (configFee && surchargeBookApplies(surchargeHits, fee))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + (postcode == null ? "" : postcode.trim()));
|
||||
}
|
||||
else if (!postcodeRules.isEmpty())
|
||||
{
|
||||
addConfiguredZoneFee(result, fee, weight, currency, postcode, countryCode, countryName, postcodeRules, "邮编 ");
|
||||
}
|
||||
@@ -515,37 +543,10 @@ public final class PayCostCalculator
|
||||
result.getSkipped().add(name + ":价卡没有可计算的条件,暂不计费");
|
||||
}
|
||||
}
|
||||
result.getFees().addAll(keepHighestByName(sized));
|
||||
result.getFees().addAll(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)
|
||||
@@ -662,6 +663,11 @@ 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())
|
||||
{
|
||||
@@ -754,6 +760,29 @@ 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)
|
||||
{
|
||||
@@ -815,6 +844,22 @@ 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(" ", "");
|
||||
@@ -875,7 +920,20 @@ public final class PayCostCalculator
|
||||
return stepped;
|
||||
}
|
||||
}
|
||||
return matchedFee(fee, freight, currency, "尺寸命中");
|
||||
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";
|
||||
}
|
||||
|
||||
/** 价卡写成每增加、每超出时,金额是一个步长的单价。 */
|
||||
@@ -976,17 +1034,18 @@ public final class PayCostCalculator
|
||||
}
|
||||
amount = freight.multiply(fee.getAmount()).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
else
|
||||
String lineCurrency = currency;
|
||||
if (!percent(fee))
|
||||
{
|
||||
amount = amount.setScale(2, RoundingMode.HALF_UP);
|
||||
String feeCurrency = normalize(fee.getCurrency());
|
||||
if (!feeCurrency.isEmpty() && !feeCurrency.equals(currency))
|
||||
if (!feeCurrency.isEmpty())
|
||||
{
|
||||
return null;
|
||||
lineCurrency = feeCurrency;
|
||||
}
|
||||
}
|
||||
long scId = feeRef(fee);
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark);
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, lineCurrency, remark);
|
||||
}
|
||||
|
||||
private static boolean percent(PaySurcharge fee)
|
||||
|
||||
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -69,9 +70,10 @@ 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());
|
||||
bill.getCountryCode(), bill.getCountryName(), surchargeHits);
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
@@ -285,6 +287,32 @@ 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,有组但邮编没命中时返回空列表。
|
||||
*
|
||||
@@ -468,7 +496,8 @@ public class PayOrderFeeCalculator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ("UNREACH".equalsIgnoreCase(group.getCoverage() == null ? "" : group.getCoverage().trim()))
|
||||
String coverage = group.getCoverage() == null ? "" : group.getCoverage().trim();
|
||||
if ("UNREACH".equalsIgnoreCase(coverage) || "SURCHARGE".equalsIgnoreCase(coverage))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -415,6 +415,12 @@ 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;
|
||||
@@ -620,6 +626,10 @@ 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)
|
||||
@@ -630,7 +640,7 @@ public class PayPostcodeImporter
|
||||
group.setSheetName(sheetName);
|
||||
group.setBlockTitle(cut(series.title.isEmpty() ? sheetName : series.title, 200));
|
||||
group.setConfigKind(kind);
|
||||
group.setCoverage(coverageOf(sheetName, series.title, feeName));
|
||||
group.setCoverage(series.coverage.isEmpty() ? coverageOf(sheetName, series.title, feeName) : series.coverage);
|
||||
group.setChannelName(channel);
|
||||
group.setCountryName(country.name);
|
||||
group.setCountryCode(country.code);
|
||||
@@ -694,6 +704,10 @@ public class PayPostcodeImporter
|
||||
{
|
||||
return "REACH";
|
||||
}
|
||||
if (source.contains("空气减排"))
|
||||
{
|
||||
return "SURCHARGE";
|
||||
}
|
||||
if (source.contains("偏远") || source.contains("岛屿"))
|
||||
{
|
||||
return "REMOTE";
|
||||
@@ -701,6 +715,15 @@ 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 这种短区间保持原文。
|
||||
*/
|
||||
@@ -1182,6 +1205,8 @@ 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,6 +6,7 @@ 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;
|
||||
@@ -133,6 +134,63 @@ 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,6 +32,9 @@ 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})");
|
||||
@@ -151,6 +154,39 @@ 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。
|
||||
@@ -559,6 +595,14 @@ 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)
|
||||
@@ -954,6 +998,11 @@ 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);
|
||||
|
||||
+32
-2
@@ -138,9 +138,10 @@ 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());
|
||||
bill.getCountryCode(), bill.getCountryName(), surchargeHits);
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
@@ -312,6 +313,34 @@ 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)
|
||||
{
|
||||
@@ -487,7 +516,8 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ("UNREACH".equalsIgnoreCase(group.getCoverage() == null ? "" : group.getCoverage().trim()))
|
||||
String coverage = group.getCoverage() == null ? "" : group.getCoverage().trim();
|
||||
if ("UNREACH".equalsIgnoreCase(coverage) || "SURCHARGE".equalsIgnoreCase(coverage))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
+132
-1
@@ -3,9 +3,11 @@ 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 org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,10 +15,13 @@ 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.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
@@ -97,7 +102,133 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
safe.setOrderNos(null);
|
||||
safe.setOrderNo(orderNos.isEmpty() ? null : orderNos.get(0));
|
||||
}
|
||||
return payOrderListMapper.selectList(safe);
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+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))
|
||||
if (coverage.isEmpty() || "REACH".equals(coverage) || "UNREACH".equals(coverage) || "REMOTE".equals(coverage) || "SURCHARGE".equals(coverage))
|
||||
{
|
||||
return coverage;
|
||||
}
|
||||
|
||||
+25
-5
@@ -51,6 +51,7 @@ 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;
|
||||
@@ -1133,10 +1134,18 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
String currency = isBlank(fee.getCurrency()) ? DEFAULT_CURRENCY : fee.getCurrency();
|
||||
if ("SIZE".equals(rule))
|
||||
{
|
||||
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");
|
||||
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");
|
||||
}
|
||||
fee.setPriceUnit(currency + "/ITEM");
|
||||
return;
|
||||
}
|
||||
@@ -1165,6 +1174,12 @@ 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));
|
||||
}
|
||||
@@ -1209,6 +1224,8 @@ 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());
|
||||
@@ -1218,6 +1235,8 @@ 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());
|
||||
@@ -1265,7 +1284,8 @@ 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))
|
||||
|| "WEIGHT".equals(code) || "SIZE".equals(code) || "RETURN".equals(code) || "MANUAL".equals(code)
|
||||
|| PaySurchargeRules.FEE_POSTCODE.equals(code))
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
+44
-4
@@ -10,6 +10,7 @@ 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;
|
||||
@@ -96,6 +97,8 @@ 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());
|
||||
@@ -125,6 +128,8 @@ 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())
|
||||
@@ -226,11 +231,21 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
BigDecimal overWeight = null;
|
||||
BigDecimal extraWeight = null;
|
||||
String postcodes = null;
|
||||
String sizeType = null;
|
||||
BigDecimal volume = null;
|
||||
if ("SIZE".equals(type))
|
||||
{
|
||||
length = requiredSize(row.getLengthCm(), "长");
|
||||
width = requiredSize(row.getWidthCm(), "宽");
|
||||
height = requiredSize(row.getHeightCm(), "高");
|
||||
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(), "高");
|
||||
}
|
||||
row.setBlockTitle(null);
|
||||
}
|
||||
else if ("WEIGHT".equals(type))
|
||||
@@ -259,11 +274,32 @@ 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)
|
||||
@@ -321,7 +357,7 @@ public class PrcSurchargeServiceImpl implements IPrcSurchargeService
|
||||
String text;
|
||||
if ("SIZE".equals(rule))
|
||||
{
|
||||
text = "超过 " + plain(row.getLengthCm()) + "×" + plain(row.getWidthCm()) + "×" + plain(row.getHeightCm()) + "cm";
|
||||
text = sizeChargeText(row.getSizeType(), row.getLengthCm(), row.getWidthCm(), row.getHeightCm(), row.getVolumeM3());
|
||||
}
|
||||
else if ("WEIGHT".equals(rule))
|
||||
{
|
||||
@@ -335,6 +371,10 @@ 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();
|
||||
|
||||
@@ -17,22 +17,7 @@
|
||||
ifnull(nullif(trim(b.currency), ''), 'CNY') as currency,
|
||||
b.pay_calc_status as payCalcStatus,
|
||||
b.pay_calc_msg as payCalcMsg,
|
||||
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_by as updateBy,
|
||||
b.update_time as updateTime,
|
||||
p.biz_date as bizDate
|
||||
from prc_order_bill p
|
||||
@@ -40,25 +25,69 @@
|
||||
left join prc_pay_bill b on b.bill_id = p.bill_id
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultType="com.bms.price.domain.PayOrderRow">
|
||||
<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">
|
||||
<include refid="orderColumns"/>
|
||||
<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
|
||||
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>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectRow" resultType="com.bms.price.domain.PayOrderRow">
|
||||
@@ -80,9 +109,9 @@
|
||||
select p.bill_id as billId,
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo
|
||||
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
|
||||
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
|
||||
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -476,6 +476,29 @@
|
||||
</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,
|
||||
|
||||
@@ -39,14 +39,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</insert>
|
||||
|
||||
<select id="selectByBillId" resultMap="PrcPayBillFeeLogResult">
|
||||
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 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>
|
||||
</mapper>
|
||||
|
||||
@@ -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.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.over_weight_kg as overWeightKg, c.extra_weight_kg as extraWeightKg, c.postcode_text as postcodeText
|
||||
</sql>
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ 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" />
|
||||
@@ -33,7 +35,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, over_weight_kg, extra_weight_kg, postcode_text, currency, round_mode,
|
||||
length_cm, width_cm, height_cm, size_type, volume_m3, 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>
|
||||
@@ -102,6 +104,8 @@ 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>
|
||||
@@ -124,6 +128,8 @@ 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,6 +25,8 @@ 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" />
|
||||
@@ -43,7 +45,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.postcode_text, s.length_cm, s.width_cm, s.height_cm, s.size_type, s.volume_m3,
|
||||
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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- `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`);
|
||||
@@ -0,0 +1,20 @@
|
||||
-- `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');
|
||||
@@ -0,0 +1,2 @@
|
||||
-- `prc_surcharge` 表中添加`volume_m3` 属性
|
||||
ALTER TABLE `bms`.`prc_surcharge` ADD COLUMN `volume_m3` decimal(12,6) NULL COMMENT '超尺寸体积阈值,立方米。类型为体积时,订单体积超过该值才收取' AFTER `size_type`;
|
||||
@@ -67,7 +67,8 @@ const lineRef = ref()
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
]
|
||||
|
||||
function firstPart(value) {
|
||||
@@ -81,6 +82,7 @@ function coverageLabel(value) {
|
||||
function coverageType(value) {
|
||||
if (value === 'UNREACH') return 'danger'
|
||||
if (value === 'REMOTE') return 'warning'
|
||||
if (value === 'SURCHARGE') return 'primary'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ const rules = {
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
]
|
||||
|
||||
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">导入后按国家归成一行。表头里带邮编或附加费的工作表会被导入。可达、可派记为可达,不可达记为不可达,偏远和岛屿记为偏远。</p>
|
||||
<!-- <p class="import-tip">导入后按国家归成一行。表头里带邮编或附加费的工作表会被导入。可达、可派记为可达,不可达记为不可达,偏远和岛屿记为偏远。英国附加费里的空气减排地区和空气减排地区邮编记为附加费,渠道为 Evri 48H。</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,7 +87,8 @@ const form = ref({})
|
||||
const coverageOptions = [
|
||||
{ label: '可达', value: 'REACH' },
|
||||
{ label: '不可达', value: 'UNREACH' },
|
||||
{ label: '偏远', value: 'REMOTE' }
|
||||
{ label: '偏远', value: 'REMOTE' },
|
||||
{ label: '附加费', value: 'SURCHARGE' }
|
||||
]
|
||||
|
||||
function coverageParts(value) {
|
||||
@@ -101,6 +102,7 @@ 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,6 +84,19 @@ 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,
|
||||
@@ -92,12 +105,7 @@ function rowFromConfig(item) {
|
||||
amount: item.chargeValue,
|
||||
currency: item.currency,
|
||||
zoneName: item.blockTitle || '',
|
||||
lengthCm: item.lengthCm,
|
||||
widthCm: item.widthCm,
|
||||
heightCm: item.heightCm,
|
||||
overWeightKg: item.overWeightKg,
|
||||
extraWeightKg: item.extraWeightKg,
|
||||
postcodeText: item.postcodeText || ''
|
||||
...configMeasure(item)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +125,12 @@ 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`
|
||||
}
|
||||
@@ -164,12 +178,7 @@ async function open(row) {
|
||||
amount: item.amount,
|
||||
currency: item.currency,
|
||||
zoneName: item.zoneName || '',
|
||||
lengthCm: item.lengthCm,
|
||||
widthCm: item.widthCm,
|
||||
heightCm: item.heightCm,
|
||||
overWeightKg: item.overWeightKg,
|
||||
extraWeightKg: item.extraWeightKg,
|
||||
postcodeText: item.postcodeText || ''
|
||||
...configMeasure(item)
|
||||
}))
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
@@ -29,6 +29,7 @@ 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: '超重' },
|
||||
@@ -50,6 +51,8 @@ const blockSelectOptions = computed(() =>
|
||||
|
||||
const chargeType = computed(() => String(form.value.chargeType || '').toUpperCase())
|
||||
|
||||
const sizeKind = computed(() => String(form.value.sizeType || '').toUpperCase())
|
||||
|
||||
const schemas = computed(() => [
|
||||
{
|
||||
label: '附加费名称',
|
||||
@@ -81,15 +84,26 @@ 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',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE' ? [{ required: true, message: '请填写长', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '宽(cm)',
|
||||
@@ -97,9 +111,9 @@ const schemas = computed(() => [
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
|
||||
rules: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE' ? [{ required: true, message: '请填写宽', trigger: 'blur' }] : undefined
|
||||
},
|
||||
{
|
||||
label: '高(cm)',
|
||||
@@ -107,9 +121,20 @@ const schemas = computed(() => [
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
show: chargeType.value === 'SIZE',
|
||||
show: chargeType.value === 'SIZE' && sizeKind.value === 'SIDE',
|
||||
props: { min: 0, precision: 2, controls: false, align: 'left' },
|
||||
rules: chargeType.value === 'SIZE' ? [{ required: true, message: '请填写高', trigger: 'blur' }] : undefined
|
||||
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
|
||||
},
|
||||
{
|
||||
label: '超过重量(kg)',
|
||||
@@ -217,6 +242,8 @@ function emptyForm() {
|
||||
countryCode: undefined,
|
||||
blockTitle: undefined,
|
||||
scNote: undefined,
|
||||
sizeType: undefined,
|
||||
volumeM3: undefined,
|
||||
lengthCm: undefined,
|
||||
widthCm: undefined,
|
||||
heightCm: undefined,
|
||||
@@ -327,6 +354,8 @@ 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
|
||||
@@ -337,6 +366,19 @@ 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,6 +109,7 @@ const chargeTypeLabelMap = {
|
||||
MANUAL: '暂不计费',
|
||||
ALWAYS: '每票都收',
|
||||
POSTCODE: '命中邮编',
|
||||
FEE_POSTCODE: '附加费邮编',
|
||||
ZONE: '命中分区',
|
||||
EXTRA_KG: '超重续收',
|
||||
WEIGHT: '超重',
|
||||
|
||||
@@ -87,6 +87,7 @@ const calcModeLabelMap = {
|
||||
MANUAL: '暂不计费',
|
||||
ALWAYS: '每票都收',
|
||||
POSTCODE: '命中邮编',
|
||||
FEE_POSTCODE: '附加费邮编',
|
||||
ZONE: '命中分区',
|
||||
EXTRA_KG: '超重续收',
|
||||
WEIGHT: '超重',
|
||||
@@ -98,6 +99,8 @@ 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 },
|
||||
|
||||
Reference in New Issue
Block a user