修改分区功能

This commit is contained in:
wuweihua
2026-09-15 16:55:11 +08:00
parent 7679a7d091
commit ccf85ebefc
17 changed files with 394 additions and 18 deletions
@@ -28,6 +28,8 @@ import com.ruoyi.price.domain.PrcPriceSetDetail;
import com.ruoyi.price.domain.PrcQuote;
import com.ruoyi.price.domain.PrcQuoteFee;
import com.ruoyi.price.domain.PrcSurchargeRel;
import com.ruoyi.price.domain.PrcZone;
import com.ruoyi.price.mapper.PrcZoneDetailMapper;
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
import com.ruoyi.price.domain.vo.TmsPriceQuoteRequest;
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
@@ -87,6 +89,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
@Autowired
private PrcQuoteFeeMapper quoteFeeMapper;
@Autowired
private PrcZoneDetailMapper zoneDetailMapper;
@Autowired
private IBillSearchStore billSearchStore;
@@ -178,11 +183,55 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
}
BigDecimal weight = request.getWeight();
String destPostcode = emptyToNull(request.getDestPostcode());
String zoneCode = null;
PrcZone resolvedZone = null;
int zonedCount = productCountryMapper.countZonedByProductCountry(
productCode, countryCode, countryName, bizDate);
if (zonedCount > 0)
{
if (StringUtils.isEmpty(destPostcode))
{
throw new ServiceException(MessageUtils.message("price.quote.postcodeRequired"));
}
String iso2 = resolveCountryIso2(productCode, countryCode, countryName);
if (StringUtils.isEmpty(iso2))
{
throw new ServiceException(MessageUtils.message("price.quote.countryRequired"));
}
resolvedZone = zoneDetailMapper.selectZoneByCountryPostcode(iso2, normalizePostcode(destPostcode));
if (resolvedZone == null || StringUtils.isEmpty(resolvedZone.getZoneCode()))
{
throw new ServiceException(MessageUtils.message("price.quote.postcodeZoneNotFound"));
}
zoneCode = resolvedZone.getZoneCode();
if (countryCode == null)
{
countryCode = iso2;
}
}
BmsProductCountry base = productCountryMapper.selectMatchByProductCountryWeight(
productCode, countryCode, countryName, weight, bizDate);
productCode, countryCode, countryName, zoneCode, weight, bizDate);
if (base == null)
{
throw new ServiceException(MessageUtils.message("price.quote.priceNotHit"));
throw new ServiceException(MessageUtils.message(
zonedCount > 0 ? "price.quote.zonePriceNotHit" : "price.quote.priceNotHit"));
}
if (resolvedZone != null)
{
if (base.getZoneId() == null)
{
base.setZoneId(resolvedZone.getZoneId());
}
if (StringUtils.isEmpty(base.getZoneCode()))
{
base.setZoneCode(resolvedZone.getZoneCode());
}
if (StringUtils.isEmpty(base.getZoneName()))
{
base.setZoneName(resolvedZone.getZoneName());
}
}
String productName = resolveProductName(productCode, bizDate);
@@ -213,6 +262,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
TmsPriceQuoteResult hit = tryFixed(bind, set, base, productCode, productName, weight);
if (hit != null)
{
stampRequestMeta(request, hit);
return hit;
}
}
@@ -221,14 +271,67 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
TmsPriceQuoteResult hit = tryDiscount(bind, set, base, productCode, productName, weight);
if (hit != null)
{
stampRequestMeta(request, hit);
return hit;
}
}
}
}
return buildDefault(request.getCustomerId(), base, productCode, productName, weight,
TmsPriceQuoteResult fallback = buildDefault(request.getCustomerId(), base, productCode, productName, weight,
MessageUtils.message("price.quote.noCustomerPackageOverride"));
stampRequestMeta(request, fallback);
return fallback;
}
private void stampRequestMeta(TmsPriceQuoteRequest request, TmsPriceQuoteResult result)
{
if (result == null || request == null)
{
return;
}
if (StringUtils.isEmpty(result.getDestPostcode()))
{
result.setDestPostcode(emptyToNull(request.getDestPostcode()));
}
}
private String resolveCountryIso2(String productCode, String countryCode, String countryName)
{
if (StringUtils.isNotEmpty(countryCode))
{
return countryCode.toUpperCase();
}
BmsProductCountry query = new BmsProductCountry();
query.setProductCode(productCode);
query.setCountryName(countryName);
List<BmsProductCountry> rows = productCountryMapper.selectBmsProductCountryList(query);
if (rows == null)
{
return null;
}
for (BmsProductCountry row : rows)
{
if (StringUtils.isNotEmpty(row.getCountryCode()))
{
return row.getCountryCode().toUpperCase();
}
}
return null;
}
private static String normalizePostcode(String postcode)
{
if (StringUtils.isEmpty(postcode))
{
return postcode;
}
String n = postcode.trim().replace(" ", "");
if (n.endsWith(".0") && n.matches("\\d+\\.0"))
{
return n.substring(0, n.length() - 2);
}
return n;
}
private TmsPriceQuoteResult tryFixed(PrcCustomerPriceSet bind, PrcPriceSet set,
@@ -359,6 +462,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
r.setProductName(productName);
r.setCountryCode(base.getCountryCode());
r.setCountryName(base.getCountryName());
r.setZoneId(base.getZoneId());
r.setZoneCode(base.getZoneCode());
r.setZoneName(base.getZoneName());
r.setProductCountryId(base.getDetailId());
r.setWeightMin(base.getWeightMin());
r.setWeightMax(base.getWeightMax());
@@ -506,6 +612,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
quote.setProductName(result.getProductName());
quote.setCountryCode(result.getCountryCode());
quote.setCountryName(result.getCountryName());
quote.setDestPostcode(result.getDestPostcode());
quote.setWeight(weight);
quote.setBizDate(bizDate);
quote.setTmsId(request.getTmsId() == null ? null : Long.valueOf(request.getTmsId()));
@@ -637,6 +744,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
r.setProductName(quote.getProductName());
r.setCountryCode(quote.getCountryCode());
r.setCountryName(quote.getCountryName());
r.setDestPostcode(quote.getDestPostcode());
r.setProductCountryId(quote.getProductCountryId());
r.setWeightMin(quote.getWeightMin());
r.setWeightMax(quote.getWeightMax());
@@ -683,6 +791,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
to.setProductName(from.getProductName());
to.setCountryCode(from.getCountryCode());
to.setCountryName(from.getCountryName());
to.setDestPostcode(from.getDestPostcode());
to.setZoneId(from.getZoneId());
to.setZoneCode(from.getZoneCode());
to.setZoneName(from.getZoneName());
to.setProductCountryId(from.getProductCountryId());
to.setWeightMin(from.getWeightMin());
to.setWeightMax(from.getWeightMax());
@@ -716,6 +828,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
+ request.getProductCode().trim() + "|"
+ nvlStr(countryCode) + "|"
+ nvlStr(countryName) + "|"
+ nvlStr(emptyToNull(request.getDestPostcode())) + "|"
+ weight.toPlainString() + "|"
+ biz + "|"
+ (request.getTmsId() == null ? "" : request.getTmsId());