Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 359c3c18e4 | |||
| 4f2f2db20f | |||
| 0094e4aaff | |||
| 8b7c346ec4 | |||
| bde1d7d86e | |||
| 87eab12d51 | |||
| 880b4751c5 | |||
| 3a104d2d8c |
+72
-1
@@ -40,10 +40,81 @@ public class PayPostcodeController extends BaseController
|
||||
public TableDataInfo list(PayPostcodeGroup query)
|
||||
{
|
||||
startPage();
|
||||
List<PayPostcodeGroup> list = payPostcodeService.selectGroupList(query);
|
||||
List<PayPostcodeGroup> list = payPostcodeService.selectCountryList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:query')")
|
||||
@GetMapping("/zones")
|
||||
public AjaxResult zones(PayPostcodeGroup query)
|
||||
{
|
||||
return success(payPostcodeService.selectZoneList(query));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/zones")
|
||||
public AjaxResult addZone(@RequestBody PayPostcodeGroup zone)
|
||||
{
|
||||
return toAjax(payPostcodeService.addZone(zone, getUsername()));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/zones")
|
||||
public AjaxResult editZone(@RequestBody PayPostcodeGroup zone)
|
||||
{
|
||||
return toAjax(payPostcodeService.updateZone(zone));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:remove')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/zones")
|
||||
public AjaxResult removeZone(PayPostcodeGroup zone)
|
||||
{
|
||||
return toAjax(payPostcodeService.deleteZone(zone));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/country")
|
||||
public AjaxResult editCountry(@RequestBody PayPostcodeGroup country)
|
||||
{
|
||||
return toAjax(payPostcodeService.updateCountry(country));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:remove')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/country")
|
||||
public AjaxResult removeCountry(PayPostcodeGroup country)
|
||||
{
|
||||
return toAjax(payPostcodeService.deleteCountry(country));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/lines")
|
||||
public AjaxResult addLine(@RequestBody PayPostcodeLine line)
|
||||
{
|
||||
return toAjax(payPostcodeService.addLine(line));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/lines")
|
||||
public AjaxResult editLine(@RequestBody PayPostcodeLine line)
|
||||
{
|
||||
return toAjax(payPostcodeService.updateLine(line));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:remove')")
|
||||
@Log(title = "应付邮编配置", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/lines/{lineIds}")
|
||||
public AjaxResult removeLines(@PathVariable Long[] lineIds)
|
||||
{
|
||||
return toAjax(payPostcodeService.deleteLines(lineIds));
|
||||
}
|
||||
|
||||
/** 按国家去重区块,供附加费编辑分区下拉 */
|
||||
@PreAuthorize("@ss.hasPermi('data:payPostcode:list')")
|
||||
@GetMapping("/blockOptions")
|
||||
|
||||
+11
-11
@@ -253,7 +253,7 @@ public class BillingController extends BaseController
|
||||
/** 订单列表弹窗:按 billId 查询计费失败原因(受数据权限控制)。 */
|
||||
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
|
||||
@GetMapping("/orderBill/{billId}/failReason")
|
||||
public AjaxResult orderBillFailReason(@PathVariable("billId") String billId)
|
||||
public AjaxResult orderBillFailReason(@PathVariable("billId") Long billId)
|
||||
{
|
||||
return success(prcOrderBillService.getBillingFailReason(billId));
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public class BillingController extends BaseController
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@GetMapping("/bill/{billId}")
|
||||
public AjaxResult getBill(@PathVariable String billId)
|
||||
public AjaxResult getBill(@PathVariable Long billId)
|
||||
{
|
||||
return success(prcOrderBillService.getBill(billId));
|
||||
}
|
||||
@@ -391,13 +391,13 @@ public class BillingController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@GetMapping("/bill/{billId}/history")
|
||||
public TableDataInfo billHistory(@PathVariable("billId") String billId)
|
||||
public TableDataInfo billHistory(@PathVariable("billId") Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
return getDataTable(new ArrayList<BillSyncSnapshot>());
|
||||
}
|
||||
TmsPriceQuoteResult bill = prcOrderBillService.getBill(billId.trim());
|
||||
TmsPriceQuoteResult bill = prcOrderBillService.getBill(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
TableDataInfo empty = new TableDataInfo();
|
||||
@@ -482,13 +482,13 @@ public class BillingController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:refund')")
|
||||
@Log(title = "Billing refund", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/bill/{billId}/refund")
|
||||
public AjaxResult refundBill(@PathVariable("billId") String billId)
|
||||
public AjaxResult refundBill(@PathVariable("billId") Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
return error("billId required");
|
||||
}
|
||||
TmsPriceQuoteResult bill = prcOrderBillService.getBill(billId.trim());
|
||||
TmsPriceQuoteResult bill = prcOrderBillService.getBill(billId);
|
||||
if (bill == null || StringUtils.isEmpty(bill.getOrderNo()))
|
||||
{
|
||||
return error("bill not found");
|
||||
@@ -519,7 +519,7 @@ public class BillingController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:arrearsUpdate')")
|
||||
@Log(title = "Billing credit arrears", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/bill/creditArrears")
|
||||
public AjaxResult updateCreditArrears(@RequestBody java.util.List<String> billIds)
|
||||
public AjaxResult updateCreditArrears(@RequestBody java.util.List<Long> billIds)
|
||||
{
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
@@ -527,7 +527,7 @@ public class BillingController extends BaseController
|
||||
}
|
||||
int success = 0;
|
||||
java.util.List<String> fails = new java.util.ArrayList<String>();
|
||||
for (String billId : billIds)
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -664,7 +664,7 @@ public class BillingController extends BaseController
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:feeRemove')")
|
||||
@Log(title = "Billing income fee", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/bill/fee/{feeId}")
|
||||
public AjaxResult deleteIncomeFee(@PathVariable String feeId)
|
||||
public AjaxResult deleteIncomeFee(@PathVariable Long feeId)
|
||||
{
|
||||
return success(prcOrderBillService.deleteIncomeFee(feeId));
|
||||
}
|
||||
|
||||
+7
-7
@@ -89,7 +89,7 @@ public class PayProductController extends BaseController
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:billing:bill,price:pay:edit')")
|
||||
@Log(title = "应付账单", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/order/{billId}")
|
||||
public AjaxResult generateOrderCost(@PathVariable String billId)
|
||||
public AjaxResult generateOrderCost(@PathVariable Long billId)
|
||||
{
|
||||
payOrderCostService.generate(billId);
|
||||
return success("操作成功");
|
||||
@@ -107,20 +107,20 @@ public class PayProductController extends BaseController
|
||||
payProductService.writeSource(productId, response.getOutputStream());
|
||||
}
|
||||
|
||||
/** 当前版本的附加费计费条件。同一版本只有一份。 */
|
||||
/** 产品上的附加费计费条件。不按价格版本拆开。 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:query,price:pay:edit')")
|
||||
@GetMapping("/surchargeRule")
|
||||
public AjaxResult surchargeRule(@RequestParam Long productId, @RequestParam Long termId)
|
||||
public AjaxResult surchargeRule(@RequestParam Long productId, @RequestParam(required = false) Long termId)
|
||||
{
|
||||
return success(paySurchargeRuleService.list(productId, termId));
|
||||
}
|
||||
|
||||
/** 上一版条件,复制到当前页后再保存。 */
|
||||
/** 这个产品上的附加费配置操作记录。 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:query,price:pay:edit')")
|
||||
@GetMapping("/surchargeRule/previous")
|
||||
public AjaxResult previousSurchargeRule(@RequestParam Long productId)
|
||||
@GetMapping("/surchargeRule/log")
|
||||
public AjaxResult surchargeRuleLog(@RequestParam Long productId, @RequestParam(required = false) Long termId)
|
||||
{
|
||||
return success(paySurchargeRuleService.previous(productId));
|
||||
return success(paySurchargeRuleService.logs(productId, termId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:edit')")
|
||||
|
||||
@@ -228,6 +228,44 @@ class PayCostCalculatorTest
|
||||
assertTrue(hasFee(result, "偏远附加费", "0.70"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void countryRemoteHitWithoutAZoneUsesTheFeePostcodeTier()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("CTT 48H");
|
||||
product.setCurrency("EUR");
|
||||
product.setWeightBands(new ArrayList<>(List.of(band("0", "5", "2.05", "马德里"))));
|
||||
PaySurcharge balearic = fee(1L, "偏远附加费", "7.1", "EUR", "POSTCODE", "07");
|
||||
balearic.setZoneName("Balearic Islands 07邮编开头");
|
||||
balearic.setPostcodeParam("07");
|
||||
PaySurcharge canary = fee(2L, "偏远附加费", "8.9", "EUR", "POSTCODE", "35,38");
|
||||
canary.setZoneName("Canary Islands 35、38邮编开头");
|
||||
canary.setPostcodeParam("35,38");
|
||||
PaySurcharge extra = fee(3L, "偏远附加费", "4", "EUR", "EXTRA_KG", "1");
|
||||
extra.setZoneName("Balearic Islands 07邮编开头");
|
||||
extra.setPostcodeParam("07");
|
||||
extra.setPriceUnit("EUR/KG");
|
||||
product.setSurcharges(List.of(balearic, canary, extra));
|
||||
List<PayRemoteBook.Hit> hits = List.of(new PayRemoteBook.Hit("", null, "", ""));
|
||||
|
||||
PayOrderCostResult light = PayCostCalculator.calculate(product, new BigDecimal("0.8"),
|
||||
null, null, null, "07008", "马德里", null, 1, hits, false, false, "ES", "西班牙");
|
||||
assertTrue(hasFee(light, "偏远附加费", "7.1"));
|
||||
assertTrue(light.getFees().stream().noneMatch(fee -> fee.getFeeName().equals("偏远附加费")
|
||||
&& fee.getAmount().compareTo(new BigDecimal("8.9")) == 0));
|
||||
assertTrue(light.getFees().stream().noneMatch(fee -> fee.getAmount().compareTo(new BigDecimal("4")) == 0));
|
||||
|
||||
PayOrderCostResult heavy = PayCostCalculator.calculate(product, new BigDecimal("3"),
|
||||
null, null, null, "07008", "马德里", null, 1, hits, false, false, "ES", "西班牙");
|
||||
assertTrue(hasFee(heavy, "偏远附加费", "7.1"));
|
||||
assertTrue(hasFee(heavy, "偏远附加费", "8"));
|
||||
|
||||
List<PayRemoteBook.Hit> named = List.of(new PayRemoteBook.Hit("", null, "", "Aland Islands"));
|
||||
PayOrderCostResult skipped = PayCostCalculator.calculate(product, new BigDecimal("0.8"),
|
||||
null, null, null, "07008", "马德里", null, 1, named, false, false, "ES", "西班牙");
|
||||
assertTrue(skipped.getFees().stream().noneMatch(fee -> "偏远附加费".equals(fee.getFeeName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void remoteHitsFollowTheProductGroupAndCountry()
|
||||
{
|
||||
|
||||
@@ -68,6 +68,24 @@ class PaySurchargeConfigCalcTest
|
||||
assertTrue(peak.getFees().stream().noneMatch(fee -> fee.getFeeName().contains("超尺寸")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sumOverThreeHundredChargesEachExtraTenCentimetres()
|
||||
{
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(sumStep(), new BigDecimal("0.039"),
|
||||
new BigDecimal("300"), new BigDecimal("300"), new BigDecimal("300"),
|
||||
null, null, null, 8);
|
||||
assertTrue(hasFee(result, "基础运费", "2.40"));
|
||||
assertTrue(hasFee(result, "超尺寸附加费", "2.43"));
|
||||
assertTrue(hasFee(result, "超尺寸附加费", "378.00"));
|
||||
assertEquals(new BigDecimal("382.83"), result.getPayTotal());
|
||||
|
||||
PayOrderCostResult oneStep = PayCostCalculator.calculate(sumStep(), new BigDecimal("0.039"),
|
||||
new BigDecimal("100"), new BigDecimal("100"), new BigDecimal("101"),
|
||||
null, null, null, 8);
|
||||
assertTrue(hasFee(oneStep, "超尺寸附加费", "2.43"));
|
||||
assertTrue(hasFee(oneStep, "超尺寸附加费", "6.30"));
|
||||
}
|
||||
|
||||
private static boolean hasFee(PayOrderCostResult result, String name, String amount)
|
||||
{
|
||||
return result.getFees().stream().anyMatch(fee -> name.equals(fee.getFeeName())
|
||||
@@ -79,6 +97,28 @@ class PaySurchargeConfigCalcTest
|
||||
return Date.from(LocalDate.of(year, month, day).atStartOfDay(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
private static PayProduct sumStep()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("CTT 48H");
|
||||
product.setCurrency("EUR");
|
||||
product.setWeightBands(List.of(band("0", "1", "2.40")));
|
||||
PaySurcharge flat = fee("超尺寸附加费", "2.43", "SIZE");
|
||||
PaySurcharge step = fee("超尺寸附加费", "6.30", "SIZE");
|
||||
step.setChargeText("6.3EUR/增加10cm");
|
||||
product.setSurcharges(List.of(flat, step));
|
||||
PaySurchargeRule rule = new PaySurchargeRule();
|
||||
rule.setCalcRule("SIZE");
|
||||
rule.setEnabled("1");
|
||||
Map<String, Object> detail = new LinkedHashMap<>();
|
||||
detail.put("matchMode", "ANY");
|
||||
detail.put("sumMin", new BigDecimal("300"));
|
||||
detail.put("exceedStepCm", new BigDecimal("10"));
|
||||
rule.setDetail(detail);
|
||||
product.setBillingRules(List.of(rule));
|
||||
return product;
|
||||
}
|
||||
|
||||
private static PayProduct imile()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class SrvBillAirAllocFee
|
||||
|
||||
private String billCode;
|
||||
|
||||
/** 提单主键 srv_bill_air.guid,写入订单费用的 source_id */
|
||||
/** 提单主键 srv_bill_air.guid */
|
||||
private String ladingId;
|
||||
|
||||
/** 费用阶段,字典 bms_fee_level */
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class SrvBillAirAllocOrder
|
||||
private String orderNo;
|
||||
|
||||
/** 计费订单 ID,对应 prc_order_bill.bill_id */
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
/** 计费重,没有计费重时依次取实际重量、收货重量 */
|
||||
private BigDecimal chargeWeight;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PayBillDiff
|
||||
|
||||
private Long lineId;
|
||||
|
||||
private String feeId;
|
||||
private Long feeId;
|
||||
|
||||
private BigDecimal ourAmount;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PayBillDiff
|
||||
/** OPEN ACCEPT_OURS ACCEPT_THEIRS */
|
||||
private String handleType;
|
||||
|
||||
private String adjustFeeId;
|
||||
private Long adjustFeeId;
|
||||
|
||||
private String createBy;
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ public class PayBillLine
|
||||
|
||||
private Long billId;
|
||||
|
||||
private String feeId;
|
||||
private Long feeId;
|
||||
|
||||
private String orderBillId;
|
||||
private Long orderBillId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class PayBillLog
|
||||
|
||||
private Long lineId;
|
||||
|
||||
private String feeId;
|
||||
private Long feeId;
|
||||
|
||||
private String operationType;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class PayBillOrder
|
||||
{
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class PayOrderCostResult
|
||||
{
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
private String channelId;
|
||||
|
||||
|
||||
@@ -59,6 +59,15 @@ public class PayPostcodeGroup extends BaseEntity
|
||||
/** 查询条件:邮编 */
|
||||
private String postcode;
|
||||
|
||||
/** 国家下的分区名,例如 mainland。列表按国家归拢后,分区在抽屉里维护 */
|
||||
private String zoneName;
|
||||
|
||||
/** 修改分区时的原名称 */
|
||||
private String oldZoneName;
|
||||
|
||||
/** 这个国家下的分区个数 */
|
||||
private Integer zoneCount;
|
||||
|
||||
/** 导入时挂上的明细,列表查询不填充 */
|
||||
private List<PayPostcodeLine> lines = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/** 应付附加费配置在某一产品版本上的操作记录。 */
|
||||
public class PaySurchargeRuleLog
|
||||
{
|
||||
private Long logId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private Long termId;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
/** 1新增 2修改 3删除 */
|
||||
private String operationType;
|
||||
|
||||
private String ruleKey;
|
||||
|
||||
private String changeContent;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
public Long getLogId()
|
||||
{
|
||||
return logId;
|
||||
}
|
||||
|
||||
public void setLogId(Long logId)
|
||||
{
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public Long getProductId()
|
||||
{
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId)
|
||||
{
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getTermId()
|
||||
{
|
||||
return termId;
|
||||
}
|
||||
|
||||
public void setTermId(Long termId)
|
||||
{
|
||||
this.termId = termId;
|
||||
}
|
||||
|
||||
public Integer getVersionNo()
|
||||
{
|
||||
return versionNo;
|
||||
}
|
||||
|
||||
public void setVersionNo(Integer versionNo)
|
||||
{
|
||||
this.versionNo = versionNo;
|
||||
}
|
||||
|
||||
public String getOperationType()
|
||||
{
|
||||
return operationType;
|
||||
}
|
||||
|
||||
public void setOperationType(String operationType)
|
||||
{
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public String getRuleKey()
|
||||
{
|
||||
return ruleKey;
|
||||
}
|
||||
|
||||
public void setRuleKey(String ruleKey)
|
||||
{
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
|
||||
public String getChangeContent()
|
||||
{
|
||||
return changeContent;
|
||||
}
|
||||
|
||||
public void setChangeContent(String changeContent)
|
||||
{
|
||||
this.changeContent = changeContent;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class PrcBillingTask extends BaseEntity
|
||||
/** 移动端传入的计费时间(非 Oracle 订单时间;回写时不会被覆盖) */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date billTime;
|
||||
private String billId;
|
||||
private Long billId;
|
||||
/** 用于查询的稳定失败码,例如 NO_CUSTOMER_PACKAGE */
|
||||
private String failCode;
|
||||
private String errorMessage;
|
||||
|
||||
@@ -13,9 +13,9 @@ public class PrcIncomeBill implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 应收主表ID */
|
||||
private String incomeBillId;
|
||||
private Long incomeBillId;
|
||||
/** 计费订单ID */
|
||||
private String billId;
|
||||
private Long billId;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 产品价合计 */
|
||||
|
||||
@@ -12,10 +12,10 @@ public class PrcIncomeBillFee implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String feeId;
|
||||
private String billId;
|
||||
private Long feeId;
|
||||
private Long billId;
|
||||
/** 应收主表ID */
|
||||
private String incomeBillId;
|
||||
private Long incomeBillId;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
private Long scId;
|
||||
|
||||
@@ -15,9 +15,9 @@ public class PrcOrderBill extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String billId;
|
||||
private Long billId;
|
||||
/** 批量查询:多个账单ID精确匹配(仅查询用,非表字段) */
|
||||
private List<String> billIds;
|
||||
private List<Long> billIds;
|
||||
private String billKey;
|
||||
private String orderNo;
|
||||
/** 批量查询:多个订单号精确匹配(仅查询用,非表字段) */
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PrcOrderBillExt implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String billId;
|
||||
private Long billId;
|
||||
private String orderNo;
|
||||
private String upstreamId;
|
||||
private String lineNo;
|
||||
|
||||
@@ -13,9 +13,9 @@ public class PrcPayBill implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
private Long payBillId;
|
||||
/** 计费订单ID */
|
||||
private String billId;
|
||||
private Long billId;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 产品价合计 */
|
||||
|
||||
@@ -12,10 +12,10 @@ public class PrcPayBillFee implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String feeId;
|
||||
private String billId;
|
||||
private Long feeId;
|
||||
private Long billId;
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
private Long payBillId;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
private Long scId;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class AddIncomeBillFeeRequest implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "billId required")
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
/** 附加费配置ID(prc_surcharge.sc_id)。 */
|
||||
@NotNull(message = "scId required")
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class BatchAddIncomeBillFeeRequest implements Serializable
|
||||
private String scopeMode;
|
||||
|
||||
/** scopeMode=SELECTED 时选中的账单ID。 */
|
||||
private List<String> billIds;
|
||||
private List<Long> billIds;
|
||||
|
||||
/** 与计费列表搜索相同的筛选条件。 */
|
||||
private List<String> orderNos;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class LocalRebillRequest implements Serializable
|
||||
|
||||
/** ALL | SELECTED */
|
||||
private String scopeMode;
|
||||
private List<String> billIds;
|
||||
private List<Long> billIds;
|
||||
private List<String> orderNos;
|
||||
private List<String> trackingNos;
|
||||
private List<String> transferNos;
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class OrderBillFailReasonVo implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String billId;
|
||||
private Long billId;
|
||||
private String orderNo;
|
||||
private String transferNo;
|
||||
private String trackingNo;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class RecalcBillPriceRequest implements Serializable
|
||||
|
||||
/** ALL = 筛选条件;SELECTED = billIds。 */
|
||||
private String scopeMode;
|
||||
private List<String> billIds;
|
||||
private List<Long> billIds;
|
||||
private List<String> orderNos;
|
||||
private List<String> trackingNos;
|
||||
private List<String> transferNos;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class TmsOrderBillStatusResult {
|
||||
/**
|
||||
* 计费订单标识,仅在唯一命中时返回。
|
||||
*/
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
/** 应付费用明细 */
|
||||
private List<TmsPriceQuoteFeeLine> payFeeDetails;
|
||||
private String quoteId;
|
||||
private String billId;
|
||||
private Long billId;
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
/** 转单号 */
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class UpdateChargeWeightRequest implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "billId is required")
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
@NotNull(message = "chargeWeight is required")
|
||||
@DecimalMin(value = "0.001", message = "chargeWeight must be > 0")
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class UpdateIncomeBillFeeRequest implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "feeId required")
|
||||
private String feeId;
|
||||
private Long feeId;
|
||||
|
||||
/** 可选:更换附加费配置。 */
|
||||
private Long scId;
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class LblSurchargeRules
|
||||
}
|
||||
if (name.contains("签名") || name.contains("重复") || name.contains("未预报") || name.contains("重新贴"))
|
||||
{
|
||||
fee.setCalcRule(MANUAL);
|
||||
fee.setCalcRule("ITEM");
|
||||
return;
|
||||
}
|
||||
String postcodes = postcodeParam(desc);
|
||||
@@ -104,10 +104,10 @@ public final class LblSurchargeRules
|
||||
}
|
||||
if (blob.contains("固定收取") || "固定收取".equals(fee.getChargeTiming()))
|
||||
{
|
||||
fee.setCalcRule(ALWAYS);
|
||||
fee.setCalcRule("ITEM");
|
||||
return;
|
||||
}
|
||||
fee.setCalcRule(MANUAL);
|
||||
fee.setCalcRule("ITEM");
|
||||
}
|
||||
|
||||
public static boolean matchesPostcode(String param, String postcode)
|
||||
|
||||
@@ -3443,7 +3443,7 @@ public class LblWorkbookParser
|
||||
product.getSurcharges().add(fee);
|
||||
}
|
||||
|
||||
/** 附加费币种为空时取价卡币种,价卡也没有则默认 EUR。 */
|
||||
/** 附加费补齐币种;计费条件默认按票(ITEM),单位不默认。 */
|
||||
private static void fillSurchargeCurrency(LblProduct product, String cardCurrency)
|
||||
{
|
||||
if (product == null || product.getSurcharges() == null || product.getSurcharges().isEmpty())
|
||||
@@ -3461,6 +3461,23 @@ public class LblWorkbookParser
|
||||
{
|
||||
fee.setCurrency(fallback);
|
||||
}
|
||||
ensureSurchargeDefaults(fee);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ensureSurchargeDefaults(LblSurcharge fee)
|
||||
{
|
||||
String name = fee.getFeeName() == null ? "" : fee.getFeeName();
|
||||
boolean quoteNote = name.contains("报价说明");
|
||||
if (quoteNote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String rule = fee.getCalcRule() == null ? "" : fee.getCalcRule().trim();
|
||||
if (rule.isEmpty() || LblSurchargeRules.MANUAL.equalsIgnoreCase(rule)
|
||||
|| LblSurchargeRules.ALWAYS.equalsIgnoreCase(rule))
|
||||
{
|
||||
fee.setCalcRule("ITEM");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4819,7 +4836,7 @@ public class LblWorkbookParser
|
||||
return currency.isEmpty() ? "每票" : currency + "/票";
|
||||
}
|
||||
|
||||
/** 附加费的货币单位跟重量段一样,价格数字单独放 amount,这里只放 EUR/ITEM、RMB/KG、%。 */
|
||||
/** 附加费的货币单位跟重量段一样,价格数字单独放 amount,这里只放 EUR/ITEM、RMB/KG、%;无单位不默认。 */
|
||||
private static String surchargeUnit(LblTexts.Money money, String standard)
|
||||
{
|
||||
if (money == null || money.amount == null)
|
||||
|
||||
@@ -65,7 +65,7 @@ public interface PayBillMapper
|
||||
* @param billIds 计费订单ID
|
||||
* @return 订单应付费用
|
||||
*/
|
||||
List<PrcPayBillFee> selectOrderFees(@Param("billIds") List<String> billIds);
|
||||
List<PrcPayBillFee> selectOrderFees(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 读取还没被未作废账单占用的费用。旧账单没有费用行号时,整票视为已占用。
|
||||
@@ -73,7 +73,7 @@ public interface PayBillMapper
|
||||
* @param billIds 计费订单ID
|
||||
* @return 可抄进本次账单的费用
|
||||
*/
|
||||
List<PrcPayBillFee> selectFreeFees(@Param("billIds") List<String> billIds);
|
||||
List<PrcPayBillFee> selectFreeFees(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 这票订单还有没有未删除的计算费用。
|
||||
@@ -81,7 +81,7 @@ public interface PayBillMapper
|
||||
* @param billId 计费订单ID
|
||||
* @return 计算费用条数
|
||||
*/
|
||||
int countCalcFees(@Param("billId") String billId);
|
||||
int countCalcFees(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 插入一张草稿应付账单。
|
||||
@@ -122,7 +122,7 @@ public interface PayBillMapper
|
||||
* @param lineId 账单行ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int bindFeeLine(@Param("feeId") String feeId, @Param("lineId") Long lineId);
|
||||
int bindFeeLine(@Param("feeId") Long feeId, @Param("lineId") Long lineId);
|
||||
|
||||
/**
|
||||
* 释放一张账单占用的费用明细。
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface PayFinanceMapper
|
||||
|
||||
Long selectLadingSupplier(@Param("ladingNo") String ladingNo);
|
||||
|
||||
int stampFee(@Param("feeId") String feeId, @Param("supplierId") Long supplierId, @Param("supplierName") String supplierName);
|
||||
int stampFee(@Param("feeId") Long feeId, @Param("supplierId") Long supplierId, @Param("supplierName") String supplierName);
|
||||
|
||||
int stampCalc(@Param("billId") String billId, @Param("supplierId") Long supplierId, @Param("supplierName") String supplierName);
|
||||
int stampCalc(@Param("billId") Long billId, @Param("supplierId") Long supplierId, @Param("supplierName") String supplierName);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,38 @@ public interface PayPostcodeMapper
|
||||
{
|
||||
List<PayPostcodeGroup> selectGroupList(PayPostcodeGroup query);
|
||||
|
||||
List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query);
|
||||
|
||||
List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query);
|
||||
|
||||
PayPostcodeGroup selectSampleGroup(PayPostcodeGroup query);
|
||||
|
||||
int countZoneName(PayPostcodeGroup query);
|
||||
|
||||
int updateCountryProfile(PayPostcodeGroup country);
|
||||
|
||||
List<Long> selectGroupIdsByCountry(PayPostcodeGroup query);
|
||||
|
||||
int renameZoneLines(PayPostcodeGroup zone);
|
||||
|
||||
int updateExclusiveZone(PayPostcodeGroup zone);
|
||||
|
||||
int insertLine(PayPostcodeLine line);
|
||||
|
||||
int updateLine(PayPostcodeLine line);
|
||||
|
||||
PayPostcodeLine selectLineById(Long lineId);
|
||||
|
||||
List<Long> selectGroupIdsByLineIds(@Param("lineIds") List<Long> lineIds);
|
||||
|
||||
int deleteLineByIds(@Param("lineIds") List<Long> lineIds);
|
||||
|
||||
int deleteLinesByZone(PayPostcodeGroup zone);
|
||||
|
||||
int refreshLineCount(Long groupId);
|
||||
|
||||
Long selectZoneGroupId(PayPostcodeGroup query);
|
||||
|
||||
/** 按国家去重区块标题 */
|
||||
List<String> selectBlockTitlesByCountry(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName);
|
||||
@@ -31,6 +63,10 @@ public interface PayPostcodeMapper
|
||||
/** 报价表、销售产品或工作表与产品名称完全一致的邮编配置 */
|
||||
List<PayPostcodeGroup> selectGroupsForProduct(@Param("names") List<String> names);
|
||||
|
||||
/** 目的国家下标记为偏远的邮编组。产品自己没有偏远名单时,用这一份做偏远附加费。 */
|
||||
List<PayPostcodeGroup> selectRemoteGroupsByCountry(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName);
|
||||
|
||||
List<PayPostcodeLine> selectRegionKeys(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
List<PayPostcodeLine> selectLinesByGroups(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PaySurchargeRuleLog;
|
||||
|
||||
public interface PaySurchargeRuleLogMapper
|
||||
{
|
||||
List<PaySurchargeRuleLog> selectByTerm(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
List<PaySurchargeRuleLog> selectByProductIds(@Param("productIds") List<Long> productIds);
|
||||
|
||||
int insertBatch(@Param("list") List<PaySurchargeRuleLog> list);
|
||||
}
|
||||
@@ -4,15 +4,16 @@ import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
|
||||
/** 应付附加费计费条件。一个产品版本一份。 */
|
||||
/** 应付附加费计费条件。一份跟产品走。 */
|
||||
public interface PaySurchargeRuleMapper
|
||||
{
|
||||
List<PaySurchargeRule> selectByProduct(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
List<PaySurchargeRule> selectByProductId(@Param("productId") Long productId);
|
||||
|
||||
int deleteByTerm(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
int insertBatch(@Param("list") List<PaySurchargeRule> rules);
|
||||
int deleteByProductIds(@Param("productIds") List<Long> productIds);
|
||||
|
||||
/** 同一产品字典下,比当前版本号小的最近一版 */
|
||||
PaySurchargeRule selectPreviousVersion(@Param("productId") Long productId);
|
||||
int insertBatch(@Param("list") List<PaySurchargeRule> rules);
|
||||
}
|
||||
|
||||
+12
-12
@@ -7,22 +7,22 @@ import com.bms.price.domain.PrcIncomeBillFee;
|
||||
/** 应收账单费用 mapper */
|
||||
public interface PrcIncomeBillFeeMapper
|
||||
{
|
||||
public List<PrcIncomeBillFee> selectByBillId(String billId);
|
||||
public List<PrcIncomeBillFee> selectByBillId(Long billId);
|
||||
|
||||
public List<PrcIncomeBillFee> selectByBillIds(@Param("billIds") List<String> billIds);
|
||||
public List<PrcIncomeBillFee> selectByBillIds(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 查询指定计费订单中尚未生成应收账单的费用。 */
|
||||
public List<PrcIncomeBillFee> selectUnbilledByBillIds(@Param("billIds") List<String> billIds,
|
||||
public List<PrcIncomeBillFee> selectUnbilledByBillIds(@Param("billIds") List<Long> billIds,
|
||||
@Param("arBillStatus") String arBillStatus);
|
||||
|
||||
public PrcIncomeBillFee selectByFeeId(String feeId);
|
||||
public PrcIncomeBillFee selectByFeeId(Long feeId);
|
||||
|
||||
/** 按唯一键 uk_bill_fee_item(bill_id、fee_type、sc_id)查询。 */
|
||||
public PrcIncomeBillFee selectByBillIdAndFeeTypeAndScId(@Param("billId") String billId,
|
||||
public PrcIncomeBillFee selectByBillIdAndFeeTypeAndScId(@Param("billId") Long billId,
|
||||
@Param("feeType") String feeType, @Param("scId") Long scId);
|
||||
|
||||
/** 统计某账单在指定 ar_bill_status 和 fee_type 下的费用数(例如 BILLED + BASIC_FREIGHT)。 */
|
||||
public int countByBillIdAndArBillStatusAndFeeType(@Param("billId") String billId,
|
||||
public int countByBillIdAndArBillStatusAndFeeType(@Param("billId") Long billId,
|
||||
@Param("arBillStatus") String arBillStatus, @Param("feeType") String feeType);
|
||||
|
||||
public int insertPrcIncomeBillFee(PrcIncomeBillFee fee);
|
||||
@@ -31,23 +31,23 @@ public interface PrcIncomeBillFeeMapper
|
||||
|
||||
public int updatePrcIncomeBillFee(PrcIncomeBillFee fee);
|
||||
|
||||
public int updateArBillStatusByBillIds(@Param("billIds") List<String> billIds,
|
||||
public int updateArBillStatusByBillIds(@Param("billIds") List<Long> billIds,
|
||||
@Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus);
|
||||
|
||||
/** 按费用明细 ID 精确更新状态,避免误更新同一订单的历史费用。 */
|
||||
public int updateArBillStatusByFeeIds(@Param("feeIds") List<String> feeIds,
|
||||
public int updateArBillStatusByFeeIds(@Param("feeIds") List<Long> feeIds,
|
||||
@Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus);
|
||||
|
||||
/** 作废或失败清理后,仅在不存在其他有效账单关联时恢复为未出账。 */
|
||||
public int restoreUnbilledIfNoActiveArBill(@Param("feeIds") List<String> feeIds);
|
||||
public int restoreUnbilledIfNoActiveArBill(@Param("feeIds") List<Long> feeIds);
|
||||
|
||||
/** 按应收账单批量恢复其关联费用,避免大账单组装超大的费用 ID 列表。 */
|
||||
public int restoreUnbilledIfNoActiveArBillByArBillId(@Param("arBillId") Long arBillId);
|
||||
|
||||
public int deleteByFeeId(String feeId);
|
||||
public int deleteByFeeId(Long feeId);
|
||||
|
||||
public int deleteByBillId(String billId);
|
||||
public int deleteByBillId(Long billId);
|
||||
|
||||
/** 重新出账:只删除自动费用;保留 manual_flag=1 的行。 */
|
||||
public int deleteAutoFeesByBillId(String billId);
|
||||
public int deleteAutoFeesByBillId(Long billId);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import org.apache.ibatis.annotations.Param;
|
||||
/** 应收账单 prc_income_bill 的 mapper */
|
||||
public interface PrcIncomeBillMapper
|
||||
{
|
||||
PrcIncomeBill selectByBillId(String billId);
|
||||
PrcIncomeBill selectByBillId(Long billId);
|
||||
|
||||
List<PrcIncomeBill> selectByBillIds(@Param("billIds") List<String> billIds);
|
||||
List<PrcIncomeBill> selectByBillIds(@Param("billIds") List<Long> billIds);
|
||||
|
||||
PrcIncomeBill selectByIncomeBillId(String incomeBillId);
|
||||
PrcIncomeBill selectByIncomeBillId(Long incomeBillId);
|
||||
|
||||
int insertPrcIncomeBill(PrcIncomeBill row);
|
||||
|
||||
@@ -19,5 +19,5 @@ public interface PrcIncomeBillMapper
|
||||
|
||||
int upsertPrcIncomeBill(PrcIncomeBill row);
|
||||
|
||||
int deleteByBillId(String billId);
|
||||
int deleteByBillId(Long billId);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.bms.price.domain.PrcOrderBillExt;
|
||||
/** 订单账单扩展 prc_order_bill_ext 的 mapper */
|
||||
public interface PrcOrderBillExtMapper
|
||||
{
|
||||
public PrcOrderBillExt selectByBillId(String billId);
|
||||
public PrcOrderBillExt selectByBillId(Long billId);
|
||||
|
||||
public PrcOrderBillExt selectByOrderNo(String orderNo);
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ public interface PrcOrderBillMapper
|
||||
/** TMS 状态查询:按订单号、运单号或转单号精确匹配,最多返回两条用于识别歧义。 */
|
||||
List<PrcOrderBill> selectPrcOrderBillByTmsIdentifier(@Param("identifier") String identifier);
|
||||
|
||||
public PrcOrderBill selectPrcOrderBillById(String billId);
|
||||
public PrcOrderBill selectPrcOrderBillById(Long billId);
|
||||
|
||||
public List<PrcOrderBill> selectPrcOrderBillList(PrcOrderBill bill);
|
||||
|
||||
/** 只取 bill_id(筛选条件/数据权限与列表一致),用于本地大批量重新出账。 */
|
||||
List<String> selectPrcOrderBillIds(PrcOrderBill bill);
|
||||
List<Long> selectPrcOrderBillIds(PrcOrderBill bill);
|
||||
|
||||
/** 统计匹配的账单数(筛选条件/数据权限与列表一致)。 */
|
||||
int countPrcOrderBillIds(PrcOrderBill bill);
|
||||
@@ -65,7 +65,7 @@ public interface PrcOrderBillMapper
|
||||
@Param("excludeOrderIdentifiers") List<String> excludeOrderIdentifiers,
|
||||
@Param("cutoffDate") Date cutoffDate, @Param("dateType") String dateType, @Param("currency") String currency,
|
||||
@Param("arBillStatuses") List<String> arBillStatuses, @Param("feeArBillStatus") String feeArBillStatus,
|
||||
@Param("excludedBillIds") List<String> excludedBillIds);
|
||||
@Param("excludedBillIds") List<Long> excludedBillIds);
|
||||
|
||||
/** 统计应收账单预览结果金额,供全选模式展示。 */
|
||||
BigDecimal sumPrcOrderBillIncomeByCustomerPeriod(@Param("customerId") Long customerId,
|
||||
@@ -80,8 +80,8 @@ public interface PrcOrderBillMapper
|
||||
@Param("cutoffDate") Date cutoffDate, @Param("dateType") String dateType, @Param("currency") String currency,
|
||||
@Param("arBillStatuses") List<String> arBillStatuses, @Param("feeArBillStatus") String feeArBillStatus,
|
||||
@Param("snapshotCreateTime") Date snapshotCreateTime,
|
||||
@Param("lastSourceBillId") String lastSourceBillId, @Param("billIds") List<String> billIds,
|
||||
@Param("excludedBillIds") List<String> excludedBillIds,
|
||||
@Param("lastSourceBillId") Long lastSourceBillId, @Param("billIds") List<Long> billIds,
|
||||
@Param("excludedBillIds") List<Long> excludedBillIds,
|
||||
@Param("excludedOrderIdentifiers") List<String> excludedOrderIdentifiers, @Param("limit") int limit);
|
||||
|
||||
int countPrcOrderBillByCustomerPeriod(@Param("customerId") Long customerId,
|
||||
@@ -89,29 +89,29 @@ public interface PrcOrderBillMapper
|
||||
@Param("cutoffDate") Date cutoffDate, @Param("dateType") String dateType, @Param("currency") String currency,
|
||||
@Param("arBillStatuses") List<String> arBillStatuses, @Param("feeArBillStatus") String feeArBillStatus,
|
||||
@Param("snapshotCreateTime") Date snapshotCreateTime,
|
||||
@Param("billIds") List<String> billIds, @Param("excludedBillIds") List<String> excludedBillIds,
|
||||
@Param("billIds") List<Long> billIds, @Param("excludedBillIds") List<Long> excludedBillIds,
|
||||
@Param("excludedOrderIdentifiers") List<String> excludedOrderIdentifiers);
|
||||
|
||||
/** 按生成账单时用户勾选的订单读取,并再次校验账单筛选条件。 */
|
||||
public List<PrcOrderBill> selectPrcOrderBillByCustomerCutoffAndIds(@Param("customerId") Long customerId,
|
||||
@Param("customerCode") String customerCode, @Param("orderIdentifiers") List<String> orderIdentifiers,
|
||||
@Param("cutoffDate") Date cutoffDate, @Param("dateType") String dateType,
|
||||
@Param("currency") String currency, @Param("billIds") List<String> billIds,
|
||||
@Param("currency") String currency, @Param("billIds") List<Long> billIds,
|
||||
@Param("arBillStatuses") List<String> arBillStatuses, @Param("feeArBillStatus") String feeArBillStatus);
|
||||
|
||||
/** 原子占用订单,防止同一订单被并发生成到多张应收账单。 */
|
||||
public int claimArBillOrders(@Param("billIds") List<String> billIds, @Param("operator") String operator,
|
||||
public int claimArBillOrders(@Param("billIds") List<Long> billIds, @Param("operator") String operator,
|
||||
@Param("arBillStatuses") List<String> arBillStatuses, @Param("toStatus") String toStatus);
|
||||
|
||||
/** 作废账单后释放订单,允许后续重新生成新版本账单。 */
|
||||
public int releaseArBillOrders(@Param("billIds") List<String> billIds, @Param("operator") String operator,
|
||||
public int releaseArBillOrders(@Param("billIds") List<Long> billIds, @Param("operator") String operator,
|
||||
@Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus);
|
||||
|
||||
int releaseArBillOrdersByArBillId(@Param("arBillId") Long arBillId, @Param("operator") String operator,
|
||||
@Param("fromStatus") String fromStatus, @Param("toStatus") String toStatus);
|
||||
|
||||
/** 根据费用明细状态及无费用失败订单的有效账单快照汇总订单出账状态。 */
|
||||
int refreshArBillStatusByBillIds(@Param("billIds") List<String> billIds);
|
||||
int refreshArBillStatusByBillIds(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 清理或作废时批量释放来源订单;无费用失败订单的占用判断排除当前账单。 */
|
||||
int refreshArBillStatusByArBillId(@Param("arBillId") Long arBillId);
|
||||
@@ -126,20 +126,20 @@ public interface PrcOrderBillMapper
|
||||
@Param("creditArrearsStatus") String creditArrearsStatus);
|
||||
|
||||
/** 更新订单额度欠费状态 */
|
||||
int updateCreditArrearsStatus(@Param("billId") String billId,
|
||||
int updateCreditArrearsStatus(@Param("billId") Long billId,
|
||||
@Param("creditArrearsStatus") String creditArrearsStatus,
|
||||
@Param("updateBy") String updateBy);
|
||||
|
||||
public int updateOrderBillAmounts(@Param("billId") String billId,
|
||||
public int updateOrderBillAmounts(@Param("billId") Long billId,
|
||||
@Param("surchargeAmount") BigDecimal surchargeAmount,
|
||||
@Param("incomeTotal") BigDecimal incomeTotal,
|
||||
@Param("payTotal") BigDecimal payTotal);
|
||||
|
||||
/** 只更新应付合计,不改应收。 */
|
||||
int updatePayTotal(@Param("billId") String billId, @Param("payTotal") BigDecimal payTotal);
|
||||
int updatePayTotal(@Param("billId") Long billId, @Param("payTotal") BigDecimal payTotal);
|
||||
|
||||
/** 按未删除应付明细合计回写订单上的应付总额。单次不超过 1000 个订单。 */
|
||||
int refreshPayTotalFromFees(@Param("billIds") List<String> billIds);
|
||||
int refreshPayTotalFromFees(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 统计引用该销售套餐版本的订单账单数。 */
|
||||
int countByPsvId(@Param("psvId") Long psvId);
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface PrcPayBillFeeMapper
|
||||
* @param billId 计费订单ID
|
||||
* @return 费用明细
|
||||
*/
|
||||
public List<PrcPayBillFee> selectByBillId(String billId);
|
||||
public List<PrcPayBillFee> selectByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 插入一条订单应付费用。
|
||||
@@ -31,13 +31,16 @@ public interface PrcPayBillFeeMapper
|
||||
*/
|
||||
public int insertBatch(@Param("list") List<PrcPayBillFee> fees);
|
||||
|
||||
/** 把还没标明来源的费用,关联到本行主键 id。 */
|
||||
public int fillSourceIdByFeeIds(@Param("feeIds") List<Long> feeIds);
|
||||
|
||||
/**
|
||||
* 删除一票订单上来源为计算的费用。提单分摊和人工费用保留。
|
||||
*
|
||||
* @param billId 计费订单ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int deleteByBillId(String billId);
|
||||
public int deleteByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 逻辑删除某一条提单费用分摊到订单上的明细。
|
||||
@@ -48,10 +51,10 @@ public interface PrcPayBillFeeMapper
|
||||
public int markLadingFeeDeleted(@Param("feeId") Long feeId);
|
||||
|
||||
/** 这条提单费用已经分摊到的订单。作废前取出,用来重算应付总额。 */
|
||||
public List<String> selectBillIdsByLadingFee(@Param("feeId") Long feeId);
|
||||
public List<Long> selectBillIdsByLadingFee(@Param("feeId") Long feeId);
|
||||
|
||||
/** 明细还没挂上应付主表时,按订单补上主表 ID。单次不超过 1000 个订单。 */
|
||||
public int bindPayBillId(@Param("billIds") List<String> billIds);
|
||||
public int bindPayBillId(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 这条提单费用分摊到的订单里,取一个已经生成应付账单的订单号。
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface PrcPayBillMapper
|
||||
* @param billId 计费订单ID
|
||||
* @return 订单应付,没有时为 null
|
||||
*/
|
||||
PrcPayBill selectByBillId(String billId);
|
||||
PrcPayBill selectByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 按应付主表ID读取。
|
||||
@@ -21,7 +21,7 @@ public interface PrcPayBillMapper
|
||||
* @param payBillId 订单应付ID
|
||||
* @return 订单应付,没有时为 null
|
||||
*/
|
||||
PrcPayBill selectByPayBillId(String payBillId);
|
||||
PrcPayBill selectByPayBillId(Long payBillId);
|
||||
|
||||
/**
|
||||
* 新增一票订单的应付主表。
|
||||
@@ -53,7 +53,7 @@ public interface PrcPayBillMapper
|
||||
* @param billId 计费订单ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteByBillId(String billId);
|
||||
int deleteByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 按未删除的应付明细合计,回写这些订单的应付总额。
|
||||
@@ -61,8 +61,8 @@ public interface PrcPayBillMapper
|
||||
* @param billIds 计费订单 ID,单次不超过 1000 个
|
||||
* @return 影响行数
|
||||
*/
|
||||
int refreshPayTotal(@Param("billIds") List<String> billIds);
|
||||
int refreshPayTotal(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 订单还没有应付主表时补一行,总额随后按明细重算。单次不超过 1000 个订单。 */
|
||||
int insertMissingPayBills(@Param("billIds") List<String> billIds, @Param("operator") String operator);
|
||||
int insertMissingPayBills(@Param("billIds") List<Long> billIds, @Param("operator") String operator);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface SrvBillAirAllocMapper
|
||||
* @param billIds 计费订单 ID
|
||||
* @return 应付主表编号
|
||||
*/
|
||||
List<PrcPayBill> selectPayBills(@Param("billIds") List<String> billIds);
|
||||
List<PrcPayBill> selectPayBills(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 把仍是未分摊的费用改为已分摊。已经不是未分摊的行不会被改到。
|
||||
|
||||
@@ -311,7 +311,7 @@ public final class LabelArCostCalculator
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (bookApplies(remoteHits, fee, rule))
|
||||
else if (bookApplies(remoteHits, fee, rule, postcode))
|
||||
{
|
||||
String remark = "邮编 " + postcode.trim();
|
||||
if (PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
@@ -406,7 +406,7 @@ public final class LabelArCostCalculator
|
||||
addExtraKg(result.getFees(), fee, weight, currency);
|
||||
}
|
||||
}
|
||||
else if (PaySurchargeRules.ALWAYS.equals(rule))
|
||||
else if (PaySurchargeRules.ALWAYS.equals(rule) || "ITEM".equals(rule))
|
||||
{
|
||||
PayCostLine matched = matchedFee(fee, freight, currency, blank(fee.getChargeText()));
|
||||
if (matched != null)
|
||||
@@ -414,6 +414,10 @@ public final class LabelArCostCalculator
|
||||
result.getFees().add(matched);
|
||||
}
|
||||
}
|
||||
else if ("PER_KG".equals(rule))
|
||||
{
|
||||
addPerKg(result.getFees(), fee, weight, currency, blank(fee.getChargeText()));
|
||||
}
|
||||
else if (!name.isEmpty() && !name.contains("报价说明"))
|
||||
{
|
||||
result.getSkipped().add(name + ":价卡没有可计算的条件,暂不计费");
|
||||
@@ -547,10 +551,11 @@ public final class LabelArCostCalculator
|
||||
return name.contains("偏远") || name.contains("岛屿") || name.contains("remote") || name.contains("island");
|
||||
}
|
||||
|
||||
/** 邮编配置命中后,金额相同的那一档才收;分区写明时还要对上地区。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule)
|
||||
/** 邮编配置命中后,金额相同的那一档才收。命中写了地区时要对上分区;没写地区时用价卡上的邮编前缀选档。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
boolean extra = PaySurchargeRules.EXTRA_KG.equals(rule);
|
||||
boolean tier = extra || PaySurchargeRules.POSTCODE.equals(rule);
|
||||
boolean zoned = !blank(fee.getZoneName()).isEmpty();
|
||||
for (PayRemoteBook.Hit hit : hits)
|
||||
{
|
||||
@@ -568,11 +573,15 @@ public final class LabelArCostCalculator
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && zoned && !sameArea(hit, fee))
|
||||
if ((zoned && !areaKnown || !zoned && tier) && !feePostcodeMatches(fee, rule, postcode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && !sameArea(hit, fee))
|
||||
if (extra && zoned && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -581,6 +590,21 @@ public final class LabelArCostCalculator
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 价卡这一档写了邮编时,订单邮编必须落在里面。续重的重量门槛不算邮编。 */
|
||||
private static boolean feePostcodeMatches(PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
String param = blank(fee.getPostcodeParam());
|
||||
if (param.isEmpty() && !PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
{
|
||||
param = blank(fee.getCalcParam());
|
||||
}
|
||||
if (param.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return PaySurchargeRules.matchesPostcode(param, postcode);
|
||||
}
|
||||
|
||||
private static boolean sameFeeName(String bookName, String feeName)
|
||||
{
|
||||
String book = feeKey(bookName);
|
||||
@@ -599,8 +623,11 @@ public final class LabelArCostCalculator
|
||||
|
||||
private static boolean sameArea(PayRemoteBook.Hit hit, PaySurcharge fee)
|
||||
{
|
||||
return PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName())
|
||||
|| PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
if (!blank(hit.getZoneName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !blank(hit.getRegionName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
}
|
||||
|
||||
private static boolean perKg(PaySurcharge fee)
|
||||
|
||||
@@ -101,6 +101,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)
|
||||
{
|
||||
return calculate(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, remoteHits,
|
||||
postcodeOn, zoneOn, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算一票尾程应付。countryCode、countryName 用来核对配置页上写了国家的命中邮编和命中分区。
|
||||
*/
|
||||
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)
|
||||
{
|
||||
PayOrderCostResult result = new PayOrderCostResult();
|
||||
result.setFees(new ArrayList<>());
|
||||
@@ -158,7 +169,7 @@ public final class PayCostCalculator
|
||||
result.getFees().add(freightLine);
|
||||
result.setCurrency(currency);
|
||||
addSurcharges(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, freight, currency,
|
||||
band.getSectionName(), remoteHits, postcodeOn, zoneOn, result);
|
||||
band.getSectionName(), remoteHits, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
@@ -278,13 +289,15 @@ 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, PayOrderCostResult result)
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, boolean postcodeOn, boolean zoneOn,
|
||||
String countryCode, String countryName, PayOrderCostResult result)
|
||||
{
|
||||
if (product.getSurcharges() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<PayCostLine> sized = new ArrayList<>();
|
||||
List<PayCostLine> stepped = new ArrayList<>();
|
||||
for (PaySurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee == null || !inForce(fee, bizDate))
|
||||
@@ -292,7 +305,9 @@ public final class PayCostCalculator
|
||||
continue;
|
||||
}
|
||||
String rule = fee.getCalcRule() == null || fee.getCalcRule().isBlank() ? PaySurchargeRules.MANUAL : fee.getCalcRule();
|
||||
if (remoteHits != null && remoteFee(fee))
|
||||
List<Map<String, Object>> postcodeRules = prefixRules(product, PaySurchargeRules.POSTCODE);
|
||||
List<Map<String, Object>> zoneRules = prefixRules(product, PaySurchargeRules.ZONE);
|
||||
if (remoteHits != null && remoteFee(fee) && postcodeRules.isEmpty())
|
||||
{
|
||||
String name = blank(fee.getFeeName());
|
||||
boolean added = false;
|
||||
@@ -300,7 +315,7 @@ public final class PayCostCalculator
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (bookApplies(remoteHits, fee, rule))
|
||||
else if (bookApplies(remoteHits, fee, rule, postcode))
|
||||
{
|
||||
String remark = "邮编 " + postcode.trim();
|
||||
if (PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
@@ -332,8 +347,9 @@ public final class PayCostCalculator
|
||||
result.getSkipped().add(blank(fee.getFeeName()) + ":未打开命中分区");
|
||||
continue;
|
||||
}
|
||||
boolean configuredZone = PaySurchargeRules.ZONE.equals(rule) && !zoneRules.isEmpty();
|
||||
boolean postcodeDriven = PaySurchargeRules.POSTCODE.equals(rule) || !blank(fee.getPostcodeParam()).isEmpty();
|
||||
if (!postcodeDriven && zoneName != null && !zoneName.isBlank() && fee.getZoneName() != null && !fee.getZoneName().isBlank()
|
||||
if (!configuredZone && !postcodeDriven && zoneName != null && !zoneName.isBlank() && fee.getZoneName() != null && !fee.getZoneName().isBlank()
|
||||
&& !PayZoneMatcher.sameZone(fee.getZoneName(), zoneName))
|
||||
{
|
||||
continue;
|
||||
@@ -341,22 +357,45 @@ public final class PayCostCalculator
|
||||
String name = blank(fee.getFeeName());
|
||||
if (PaySurchargeRules.POSTCODE.equals(rule))
|
||||
{
|
||||
String param = blank(fee.getPostcodeParam()).isEmpty() ? fee.getCalcParam() : fee.getPostcodeParam();
|
||||
if (postcode == null || postcode.isBlank())
|
||||
if (!postcodeRules.isEmpty())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
addConfiguredZoneFee(result, fee, weight, currency, postcode, countryCode, countryName, postcodeRules, "邮编 ");
|
||||
}
|
||||
else if (PaySurchargeRules.matchesPostcode(param, postcode) && weightAtLeast(fee, weight))
|
||||
else
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + postcode.trim());
|
||||
String param = blank(fee.getPostcodeParam()).isEmpty() ? fee.getCalcParam() : fee.getPostcodeParam();
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (PaySurchargeRules.matchesPostcode(param, postcode) && weightAtLeast(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + postcode.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PaySurchargeRules.ZONE.equals(rule))
|
||||
{
|
||||
boolean already = result.getFees().stream().anyMatch(line -> name.equals(line.getFeeName()));
|
||||
if (!already && zoneName != null && !zoneName.isBlank() && PayZoneMatcher.sameZone(fee.getZoneName(), zoneName) && weightIn(fee, weight))
|
||||
if (!zoneRules.isEmpty())
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "地区 " + zoneName.replace('\n', ' '));
|
||||
String hit = PaySurchargeRules.matchedZone(zoneRules, postcode, countryCode, countryName);
|
||||
boolean already = result.getFees().stream().anyMatch(line -> name.equals(line.getFeeName()));
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (!already && hit != null && PayZoneMatcher.sameZone(fee.getZoneName(), hit) && weightIn(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "地区 " + hit.replace('\n', ' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean already = result.getFees().stream().anyMatch(line -> name.equals(line.getFeeName()));
|
||||
if (!already && zoneName != null && !zoneName.isBlank() && PayZoneMatcher.sameZone(fee.getZoneName(), zoneName) && weightIn(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "地区 " + zoneName.replace('\n', ' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PaySurchargeRules.WEIGHT.equals(rule))
|
||||
@@ -375,10 +414,17 @@ public final class PayCostCalculator
|
||||
}
|
||||
else if (sizeHit(product, fee, length, width, height, weight))
|
||||
{
|
||||
PayCostLine matched = matchedFee(fee, freight, currency, "尺寸命中");
|
||||
PayCostLine matched = sizedFee(product, fee, length, width, height, freight, currency);
|
||||
if (matched != null)
|
||||
{
|
||||
sized.add(matched);
|
||||
if (stepPriced(fee))
|
||||
{
|
||||
stepped.add(matched);
|
||||
}
|
||||
else
|
||||
{
|
||||
sized.add(matched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -427,9 +473,10 @@ public final class PayCostCalculator
|
||||
}
|
||||
}
|
||||
result.getFees().addAll(keepHighestByName(sized));
|
||||
result.getFees().addAll(stepped);
|
||||
}
|
||||
|
||||
/** 同一费用名的尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。 */
|
||||
/** 同一费用名的按票尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。按超出单位计的不并进这一档。 */
|
||||
private static List<PayCostLine> keepHighestByName(List<PayCostLine> lines)
|
||||
{
|
||||
List<PayCostLine> kept = new ArrayList<>();
|
||||
@@ -566,6 +613,38 @@ public final class PayCostCalculator
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 配置页写了邮编前缀的命中邮编或命中分区。命中后只收同一分区的那一档附加费。 */
|
||||
private static void addConfiguredZoneFee(PayOrderCostResult result, PaySurcharge fee, BigDecimal weight, String currency, String postcode,
|
||||
String countryCode, String countryName, List<Map<String, Object>> rules, String remark)
|
||||
{
|
||||
String name = blank(fee.getFeeName());
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
return;
|
||||
}
|
||||
String hit = PaySurchargeRules.matchedZone(rules, postcode, countryCode, countryName);
|
||||
if (hit != null && PayZoneMatcher.sameZone(fee.getZoneName(), hit) && weightAtLeast(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, remark + postcode.trim());
|
||||
}
|
||||
}
|
||||
|
||||
/** 只留下写了邮编前缀的配置。没写前缀的旧开关仍走原来的邮编配置。 */
|
||||
private static List<Map<String, Object>> prefixRules(PayProduct product, String calcRule)
|
||||
{
|
||||
List<Map<String, Object>> rules = new ArrayList<>();
|
||||
for (Map<String, Object> detail : ruleDetails(product, calcRule))
|
||||
{
|
||||
Object postcodes = detail.get("postcodes");
|
||||
if (postcodes != null && !String.valueOf(postcodes).isBlank())
|
||||
{
|
||||
rules.add(detail);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
private static List<Map<String, Object>> ruleDetails(PayProduct product, String calcRule)
|
||||
{
|
||||
List<Map<String, Object>> details = new ArrayList<>();
|
||||
@@ -590,10 +669,11 @@ public final class PayCostCalculator
|
||||
return name.contains("偏远") || name.contains("岛屿") || name.contains("remote") || name.contains("island");
|
||||
}
|
||||
|
||||
/** 邮编配置命中后,金额相同的那一档才收;分区写明时还要对上地区。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule)
|
||||
/** 邮编配置命中后,金额相同的那一档才收。命中写了地区时要对上分区;没写地区时用价卡上的邮编前缀选档。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
boolean extra = PaySurchargeRules.EXTRA_KG.equals(rule);
|
||||
boolean tier = extra || PaySurchargeRules.POSTCODE.equals(rule);
|
||||
boolean zoned = !blank(fee.getZoneName()).isEmpty();
|
||||
for (PayRemoteBook.Hit hit : hits)
|
||||
{
|
||||
@@ -607,15 +687,19 @@ public final class PayCostCalculator
|
||||
continue;
|
||||
}
|
||||
boolean areaKnown = !blank(hit.getZoneName()).isEmpty() || !blank(hit.getRegionName()).isEmpty();
|
||||
if (zoned && (!areaKnown || !sameArea(hit, fee)))
|
||||
if (zoned && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && zoned && !sameArea(hit, fee))
|
||||
if ((zoned && !areaKnown || !zoned && tier) && !feePostcodeMatches(fee, rule, postcode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && !sameArea(hit, fee))
|
||||
if (extra && zoned && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -624,6 +708,21 @@ public final class PayCostCalculator
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 价卡这一档写了邮编时,订单邮编必须落在里面。续重的重量门槛不算邮编。 */
|
||||
private static boolean feePostcodeMatches(PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
String param = blank(fee.getPostcodeParam());
|
||||
if (param.isEmpty() && !PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
{
|
||||
param = blank(fee.getCalcParam());
|
||||
}
|
||||
if (param.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return PaySurchargeRules.matchesPostcode(param, postcode);
|
||||
}
|
||||
|
||||
private static boolean sameFeeName(String bookName, String feeName)
|
||||
{
|
||||
String book = feeKey(bookName);
|
||||
@@ -642,8 +741,11 @@ public final class PayCostCalculator
|
||||
|
||||
private static boolean sameArea(PayRemoteBook.Hit hit, PaySurcharge fee)
|
||||
{
|
||||
return PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName())
|
||||
|| PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
if (!blank(hit.getZoneName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !blank(hit.getRegionName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
}
|
||||
|
||||
private static boolean perKg(PaySurcharge fee)
|
||||
@@ -677,6 +779,107 @@ public final class PayCostCalculator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 收费标准写了每增加若干厘米时,按三边之和超出下限的档数乘单价。
|
||||
* 没有步长配置的尺寸费仍按价卡金额收一次。
|
||||
*/
|
||||
private static PayCostLine sizedFee(PayProduct product, PaySurcharge fee, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, BigDecimal freight, String currency)
|
||||
{
|
||||
if (stepPriced(fee))
|
||||
{
|
||||
PayCostLine stepped = stepBySum(product, fee, length, width, height, currency);
|
||||
if (stepped != null || hasSumStep(product))
|
||||
{
|
||||
return stepped;
|
||||
}
|
||||
}
|
||||
return matchedFee(fee, freight, currency, "尺寸命中");
|
||||
}
|
||||
|
||||
/** 价卡写成每增加、每超出时,金额是一个步长的单价。 */
|
||||
private static boolean stepPriced(PaySurcharge fee)
|
||||
{
|
||||
String charge = fee.getChargeText() == null ? "" : fee.getChargeText();
|
||||
return charge.contains("增加") || charge.contains("每超出");
|
||||
}
|
||||
|
||||
private static boolean hasSumStep(PayProduct product)
|
||||
{
|
||||
for (Map<String, Object> detail : ruleDetails(product, PaySurchargeRules.SIZE))
|
||||
{
|
||||
BigDecimal step = decimal(detail.get("exceedStepCm"));
|
||||
BigDecimal threshold = decimal(detail.get("sumMin"));
|
||||
if (step != null && step.compareTo(BigDecimal.ZERO) > 0 && threshold != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 超出厘米数按步长向上取整。刚超过不足一个步长也收一档。 */
|
||||
private static PayCostLine stepBySum(PayProduct product, PaySurcharge fee, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String currency)
|
||||
{
|
||||
if (fee.getAmount() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal sum = length.add(width).add(height);
|
||||
for (Map<String, Object> detail : ruleDetails(product, PaySurchargeRules.SIZE))
|
||||
{
|
||||
BigDecimal step = decimal(detail.get("exceedStepCm"));
|
||||
BigDecimal threshold = decimal(detail.get("sumMin"));
|
||||
if (step == null || step.compareTo(BigDecimal.ZERO) <= 0 || threshold == null || sum.compareTo(threshold) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String feeCurrency = normalize(fee.getCurrency());
|
||||
if (!feeCurrency.isEmpty() && !feeCurrency.equals(currency))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal excess = sum.subtract(threshold);
|
||||
BigDecimal steps = excess.divide(step, 0, RoundingMode.CEILING);
|
||||
if (steps.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal amount = fee.getAmount().multiply(steps);
|
||||
String remark = "三边之和 " + plain(sum) + "cm,超出 " + plain(excess) + "cm,每 " + plain(step) + "cm "
|
||||
+ plain(fee.getAmount()) + "," + plain(steps) + " 档";
|
||||
long scId = fee.getSurchargeId() == null ? 0L : fee.getSurchargeId();
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BigDecimal decimal(Object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (value instanceof BigDecimal decimal)
|
||||
{
|
||||
return decimal;
|
||||
}
|
||||
String text = String.valueOf(value).trim();
|
||||
if (text.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigDecimal(text);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static PayCostLine matchedFee(PaySurcharge fee, BigDecimal freight, String currency, String remark)
|
||||
{
|
||||
if (fee.getAmount() == null)
|
||||
|
||||
@@ -24,10 +24,10 @@ public class PaySettleSupport
|
||||
* @param billId 计费订单ID
|
||||
* @param cardName 价卡归属名称
|
||||
*/
|
||||
public void stampCalc(String billId, String cardName)
|
||||
public void stampCalc(Long billId, String cardName)
|
||||
{
|
||||
BmsSupplier supplier = match(cardName);
|
||||
if (supplier == null || billId == null || billId.isBlank())
|
||||
if (supplier == null || billId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ public final class PaySurchargeRules
|
||||
|
||||
private static final Pattern RANGE = Pattern.compile("([A-Z]{1,2})(\\d{1,2})\\s*-\\s*(\\d{1,2})");
|
||||
|
||||
private static final Pattern DIGIT_RANGE = Pattern.compile("(\\d{2,10})\\s*-\\s*(\\d{2,10})");
|
||||
|
||||
private static final Pattern DISTRICT = Pattern.compile("([A-Z]{1,2})(\\d{1,2})");
|
||||
|
||||
private static final Pattern AREA = Pattern.compile("^[A-Z]{1,2}$");
|
||||
@@ -147,6 +149,132 @@ public final class PaySurchargeRules
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置页上的邮编。逗号或换行分隔。短码按前缀,长码按完整邮编,数字区间和英国邮编区间都认。
|
||||
* 返回命中的最长一段长度,没有命中时为 -1。
|
||||
*/
|
||||
public static int configuredMatchLength(String param, String postcode)
|
||||
{
|
||||
if (param == null || param.isBlank() || postcode == null || postcode.isBlank())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int best = -1;
|
||||
for (String token : param.split("[,,、;;\\n\\r]+"))
|
||||
{
|
||||
String value = token.trim();
|
||||
if (value.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int length = tokenLength(value, postcode);
|
||||
if (length > best)
|
||||
{
|
||||
best = length;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在命中邮编或命中分区的配置里,选出和订单邮编最贴合的分区。同一长度对上多个分区时返回 null。
|
||||
*/
|
||||
public static String matchedZone(java.util.List<java.util.Map<String, Object>> details, String postcode,
|
||||
String countryCode, String countryName)
|
||||
{
|
||||
if (details == null || details.isEmpty() || postcode == null || postcode.isBlank())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String bestZone = null;
|
||||
int best = -1;
|
||||
boolean tie = false;
|
||||
for (java.util.Map<String, Object> detail : details)
|
||||
{
|
||||
if (detail == null || !countryOk(detail, countryCode, countryName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int length = configuredMatchLength(text(detail.get("postcodes")), postcode);
|
||||
if (length < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String zone = text(detail.get("zoneName"));
|
||||
if (length > best)
|
||||
{
|
||||
best = length;
|
||||
bestZone = zone;
|
||||
tie = false;
|
||||
}
|
||||
else if (length == best && !PayZoneMatcher.sameZone(zone, bestZone))
|
||||
{
|
||||
tie = true;
|
||||
}
|
||||
}
|
||||
return tie ? null : bestZone;
|
||||
}
|
||||
|
||||
private static int tokenLength(String token, String postcode)
|
||||
{
|
||||
Matcher range = DIGIT_RANGE.matcher(token);
|
||||
if (range.matches())
|
||||
{
|
||||
String from = range.group(1);
|
||||
String to = range.group(2);
|
||||
String digits = postcode.replaceAll("\\D", "");
|
||||
if (from.length() != to.length() || digits.length() != from.length())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
long low = Long.parseLong(from);
|
||||
long high = Long.parseLong(to);
|
||||
if (low > high)
|
||||
{
|
||||
long swap = low;
|
||||
low = high;
|
||||
high = swap;
|
||||
}
|
||||
long current = Long.parseLong(digits);
|
||||
return current >= low && current <= high ? from.length() : -1;
|
||||
}
|
||||
if (!matchesPostcode(token, postcode))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
String compact = token.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
return compact.isEmpty() ? -1 : compact.length();
|
||||
}
|
||||
|
||||
/** 配置没写国家时不限制。写了国家时,订单目的国二字码或名称要对上其中一项。 */
|
||||
private static boolean countryOk(java.util.Map<String, Object> detail, String countryCode, String countryName)
|
||||
{
|
||||
String raw = text(detail.get("country"));
|
||||
if (raw == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
boolean listed = false;
|
||||
for (String token : raw.split("[,,、;;\\s]+"))
|
||||
{
|
||||
String value = token.trim();
|
||||
if (value.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
listed = true;
|
||||
if (countryCode != null && countryCode.equalsIgnoreCase(value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (countryName != null && countryName.trim().equals(value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !listed;
|
||||
}
|
||||
|
||||
/** 从“07邮编开头”“35、38邮编开头”取出数字前缀。没有邮编字样时不猜。 */
|
||||
public static String remotePrefixes(String text)
|
||||
{
|
||||
@@ -233,7 +361,7 @@ public final class PaySurchargeRules
|
||||
return checks.contains(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/** 每票都收。写了费用名的规则只约束这一项;带生效月日的规则只在这段日期内收取。 */
|
||||
/** 每票都收。配置了条件之后,只有写明费用项的规则才收取这一项;带生效月日的只在这段日期内收取。 */
|
||||
public static boolean allowsAlways(List<java.util.Map<String, Object>> details, String feeName, java.util.Date bizDate)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
@@ -241,8 +369,12 @@ public final class PaySurchargeRules
|
||||
return true;
|
||||
}
|
||||
String name = feeName == null ? "" : feeName.trim();
|
||||
List<java.util.Map<String, Object>> named = new ArrayList<>();
|
||||
List<java.util.Map<String, Object>> shared = new ArrayList<>();
|
||||
if (name.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
java.time.LocalDate day = bizDate == null ? null : bizDate.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
|
||||
boolean open = false;
|
||||
for (java.util.Map<String, Object> detail : details)
|
||||
{
|
||||
if (detail == null)
|
||||
@@ -252,31 +384,23 @@ public final class PaySurchargeRules
|
||||
String ruleName = detail.get("feeName") == null ? "" : String.valueOf(detail.get("feeName")).trim();
|
||||
if (ruleName.isEmpty())
|
||||
{
|
||||
shared.add(detail);
|
||||
if (!hasPeriod(detail))
|
||||
{
|
||||
open = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (ruleName.equals(name))
|
||||
if (!ruleName.equals(name))
|
||||
{
|
||||
named.add(detail);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
List<java.util.Map<String, Object>> mine = named.isEmpty() ? shared : named;
|
||||
if (mine.isEmpty())
|
||||
{
|
||||
return shared.isEmpty();
|
||||
}
|
||||
java.time.LocalDate day = bizDate == null ? null : bizDate.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
|
||||
for (java.util.Map<String, Object> detail : mine)
|
||||
{
|
||||
if (!hasPeriod(detail))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (day != null && inPeriod(day, detail))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return day != null && inPeriod(day, detail);
|
||||
}
|
||||
return false;
|
||||
return open;
|
||||
}
|
||||
|
||||
private static void addBound(List<Boolean> checks, BigDecimal actual, Object min, Object max)
|
||||
|
||||
@@ -46,6 +46,10 @@ public final class PayTexts
|
||||
private static final Pattern MONEY = Pattern.compile(
|
||||
"(?i)(\\d+(?:\\.\\d+)?)\\s*(EUR|GBP|USD|RMB|CNY|欧元|英镑|人民币)?");
|
||||
|
||||
/** GBP 23.00 这种币种写在数字前面 */
|
||||
private static final Pattern MONEY_BEFORE = Pattern.compile(
|
||||
"(?i)(EUR|GBP|USD|RMB|CNY|欧元|英镑|人民币)\\s*(\\d+(?:\\.\\d+)?)");
|
||||
|
||||
private static final Pattern PERCENT = Pattern.compile("(\\d+(?:\\.\\d+)?)\\s*%");
|
||||
|
||||
private PayTexts()
|
||||
@@ -193,6 +197,11 @@ public final class PayTexts
|
||||
return found;
|
||||
}
|
||||
}
|
||||
Matcher ahead = MONEY_BEFORE.matcher(source);
|
||||
if (ahead.find())
|
||||
{
|
||||
return new Money(decimal(ahead.group(2)), currency(ahead.group(1)), unit(source));
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
@@ -828,6 +828,20 @@ public class PayWorkbookParser
|
||||
|
||||
private static boolean mentionsHighRisk(PayProduct product)
|
||||
{
|
||||
if (product.getServiceNote() != null && product.getServiceNote().contains("高风险"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (product.getExtraLines() != null)
|
||||
{
|
||||
for (PayExtraLine line : product.getExtraLines())
|
||||
{
|
||||
if (line.getLineText() != null && line.getLineText().contains("高风险"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (product.getSurcharges() == null)
|
||||
{
|
||||
return false;
|
||||
@@ -1172,7 +1186,12 @@ public class PayWorkbookParser
|
||||
continue;
|
||||
}
|
||||
String line = joinRow(grid, row);
|
||||
// 备注、说明段落不是表格,不写入附加费,也不收进服务说明
|
||||
// 特别注意、体积重计算方式这类说明不是附加费,也不当作下一张表的标题
|
||||
if (isNarrative(line))
|
||||
{
|
||||
row++;
|
||||
continue;
|
||||
}
|
||||
if (countText(grid, row) <= 2 && line.length() <= 40 && !line.contains("特别申明") && !line.contains("。"))
|
||||
{
|
||||
pending = line;
|
||||
@@ -1305,13 +1324,25 @@ public class PayWorkbookParser
|
||||
String zone = zoneOf(sub[col], parent[col]).replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
String standard = price.stripTrailingZeros().toPlainString() + " " + feeUnit(parent[col], weight);
|
||||
String desc = country.isBlank() ? weight : country + ";" + weight;
|
||||
addSurcharge(product, feeName, feeName, zone, standard.trim(), desc, "");
|
||||
PaySurcharge fee = product.getSurcharges().get(product.getSurcharges().size() - 1);
|
||||
applyFeeRateRule(fee, feeName, zone, weight, includedKg);
|
||||
if (addSurcharge(product, feeName, feeName, zone, standard.trim(), desc, ""))
|
||||
{
|
||||
PaySurcharge fee = product.getSurcharges().get(product.getSurcharges().size() - 1);
|
||||
applyFeeRateRule(fee, feeName, zone, weight, includedKg);
|
||||
}
|
||||
}
|
||||
if (!priced && joinRow(grid, data).length() > 40)
|
||||
if (!priced)
|
||||
{
|
||||
break;
|
||||
String line = joinRow(grid, data);
|
||||
if (line.contains("特别注意") || line.contains("体积重") || line.contains("计算方式"))
|
||||
{
|
||||
addConfig(product, line);
|
||||
data++;
|
||||
break;
|
||||
}
|
||||
if (line.length() > 40)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
data++;
|
||||
}
|
||||
@@ -1492,9 +1523,19 @@ public class PayWorkbookParser
|
||||
band.setSortNo(product.getWeightBands().size() + 1);
|
||||
product.getWeightBands().add(band);
|
||||
}
|
||||
if (!priced && joinRow(grid, data).length() > 40)
|
||||
if (!priced)
|
||||
{
|
||||
break;
|
||||
String line = joinRow(grid, data);
|
||||
if (line.contains("特别注意") || line.contains("体积重") || line.contains("计算方式"))
|
||||
{
|
||||
addConfig(product, line);
|
||||
data++;
|
||||
break;
|
||||
}
|
||||
if (line.length() > 40)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
data++;
|
||||
}
|
||||
@@ -1867,9 +1908,8 @@ public class PayWorkbookParser
|
||||
markManual(product);
|
||||
}
|
||||
}
|
||||
else if (!sentence.isBlank())
|
||||
else if (!sentence.isBlank() && addSurcharge(product, section, name, "", sentence, sentence, ""))
|
||||
{
|
||||
addSurcharge(product, section, name, "", sentence, sentence, "");
|
||||
markManual(product);
|
||||
keepSingleEuro(product.getSurcharges().get(product.getSurcharges().size() - 1), sentence);
|
||||
}
|
||||
@@ -2156,7 +2196,10 @@ public class PayWorkbookParser
|
||||
}
|
||||
desc.append(String.join("、", entry.getValue())).append(" ").append(entry.getKey());
|
||||
}
|
||||
addSurcharge(product, section, "Cubic Capacity", "", String.join("、", factors.keySet()), desc.toString(), "");
|
||||
if (!addSurcharge(product, section, "Cubic Capacity", "", String.join("、", factors.keySet()), desc.toString(), ""))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PaySurcharge fee = product.getSurcharges().get(product.getSurcharges().size() - 1);
|
||||
fee.setChargeText(String.join("、", factors.keySet()));
|
||||
fee.setAmount(null);
|
||||
@@ -3277,11 +3320,21 @@ public class PayWorkbookParser
|
||||
addSurcharge(product, cleanTitle(pending), blankTo(name, "附加费"), "", standard, desc, "");
|
||||
}
|
||||
|
||||
private void addSurcharge(PayProduct product, String section, String name, String zone, String standard, String desc, String remark)
|
||||
/** 没有价格、币种、单位的说明不记成附加费。报价里的「不含燃油」仍然保留。 */
|
||||
private boolean addSurcharge(PayProduct product, String section, String name, String zone, String standard, String desc, String remark)
|
||||
{
|
||||
String combined = (standard + " " + desc + " " + remark).trim();
|
||||
Period period = PayTexts.period(combined, 2026);
|
||||
Money money = PayTexts.money(blankTo(standard, combined), period);
|
||||
// 收费标准自己要能认出价格、币种或单位。说明里的 5000、10KG 不能拿来凑成一条附加费
|
||||
Money money = PayTexts.money(standard, period);
|
||||
if (!hasCharge(money, standard) && fuelMark(standard).isEmpty() && !"Cubic Capacity".equals(name))
|
||||
{
|
||||
if ((name != null && name.contains("高风险")) || (standard != null && standard.contains("高风险")))
|
||||
{
|
||||
addConfig(product, (name + " " + standard).trim());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
PaySurcharge fee = new PaySurcharge();
|
||||
fee.setSectionName(section);
|
||||
fee.setFeeName(cut(new StringBuilder(name), 200));
|
||||
@@ -3309,6 +3362,7 @@ public class PayWorkbookParser
|
||||
fee.setSortNo(product.getSurcharges().size() + 1);
|
||||
PaySurchargeRules.apply(fee);
|
||||
product.getSurcharges().add(fee);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 附加费币种为空时取价卡币种,价卡也没有则默认 EUR。 */
|
||||
@@ -4239,7 +4293,10 @@ public class PayWorkbookParser
|
||||
{
|
||||
String feeName = shortCharge(head);
|
||||
String standard = price.stripTrailingZeros().toPlainString() + " " + feeUnit(head, weight);
|
||||
addSurcharge(product, section, feeName, zone, standard.trim(), weight, "");
|
||||
if (!addSurcharge(product, section, feeName, zone, standard.trim(), weight, ""))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PaySurcharge fee = product.getSurcharges().get(product.getSurcharges().size() - 1);
|
||||
BigDecimal[] bounds = PayTexts.weightBounds(weight);
|
||||
if (bounds[0] != null && bounds[1] != null)
|
||||
@@ -4341,7 +4398,7 @@ public class PayWorkbookParser
|
||||
private static boolean isLooseSurcharge(ExcelGrid grid, int row)
|
||||
{
|
||||
String line = joinRow(grid, row);
|
||||
if (!line.contains("费") || line.length() > 500)
|
||||
if (!line.contains("费") || line.length() > 500 || isNarrative(line))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -4820,7 +4877,56 @@ public class PayWorkbookParser
|
||||
return "";
|
||||
}
|
||||
String value = title.trim();
|
||||
return value.length() > 80 ? "" : value;
|
||||
if (value.length() > 80 || isNarrative(value))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收费标准要带币种或计价单位。纯说明里的 90cm、5000、10KG 不算价格。
|
||||
* 单元格里单独一个数字仍然算价格。
|
||||
*/
|
||||
private static boolean hasCharge(PayTexts.Money money, String standard)
|
||||
{
|
||||
if (money == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (money.currency != null && !money.currency.isBlank())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (money.unit != null && !money.unit.isBlank())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
String text = standard == null ? "" : standard.trim();
|
||||
if (money.amount != null && text.matches("\\d+(?:\\.\\d+)?"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// 按 31.5kg 收费。体积公式里的 kg/m3 不是计价单位
|
||||
String upper = text.toUpperCase(Locale.ROOT);
|
||||
return money.amount != null && text.length() <= 80 && upper.matches("(?s).*\\d(?:\\.\\d+)?\\s*KG(?!/).*")
|
||||
&& !upper.contains("M3") && !text.contains("立方米");
|
||||
}
|
||||
|
||||
/** 价卡里的说明句。提到费用或除数,也不当成附加费。 */
|
||||
private static boolean isNarrative(String line)
|
||||
{
|
||||
if (line == null || line.isBlank())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String text = line.replace('\n', ' ').trim();
|
||||
if (text.contains("特别注意") || text.contains("特别申明") || text.contains("体积重")
|
||||
|| text.contains("计算方式") || text.contains("计费说明") || text.contains("计费重量"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return text.length() >= 20 && (text.contains(";") || text.contains("。")) && !isMoneyText(text);
|
||||
}
|
||||
|
||||
private static String blankTo(String value, String fallback)
|
||||
|
||||
@@ -13,7 +13,7 @@ public interface IPayOrderCostService
|
||||
* @param billId 计费订单ID,对应 prc_order_bill.bill_id
|
||||
* @return 本次算出的产品、版本、币种和费用明细
|
||||
*/
|
||||
PayOrderCostResult generate(String billId);
|
||||
PayOrderCostResult generate(Long billId);
|
||||
|
||||
/**
|
||||
* 单独提交一票尾程。失败时只回滚这一票,不影响外面的对账单事务。
|
||||
@@ -21,7 +21,7 @@ public interface IPayOrderCostService
|
||||
* @param billId 计费订单ID
|
||||
* @return 本次算出的产品、版本、币种和费用明细
|
||||
*/
|
||||
PayOrderCostResult generateIsolated(String billId);
|
||||
PayOrderCostResult generateIsolated(Long billId);
|
||||
|
||||
/**
|
||||
* 这票订单当前尾程价卡上的归属供应商名称。没有价卡时返回空字符串。
|
||||
@@ -29,5 +29,5 @@ public interface IPayOrderCostService
|
||||
* @param billId 计费订单ID
|
||||
* @return 价卡归属名称
|
||||
*/
|
||||
String cardSupplierName(String billId);
|
||||
String cardSupplierName(Long billId);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,29 @@ public interface IPayPostcodeService
|
||||
{
|
||||
List<PayPostcodeGroup> selectGroupList(PayPostcodeGroup query);
|
||||
|
||||
/** 每个国家一行:邮编属性、服务类型、销售产品、渠道、分区数、邮编总数、导入时间 */
|
||||
List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query);
|
||||
|
||||
/** 一个国家下面的分区,同一分区名只出现一行 */
|
||||
List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query);
|
||||
|
||||
int addZone(PayPostcodeGroup zone, String username);
|
||||
|
||||
int updateZone(PayPostcodeGroup zone);
|
||||
|
||||
int deleteZone(PayPostcodeGroup zone);
|
||||
|
||||
/** 保存后写回这个国家下的全部分组,报价表和工作表保持不动,计费仍能对上产品 */
|
||||
int updateCountry(PayPostcodeGroup country);
|
||||
|
||||
int deleteCountry(PayPostcodeGroup country);
|
||||
|
||||
int addLine(PayPostcodeLine line);
|
||||
|
||||
int updateLine(PayPostcodeLine line);
|
||||
|
||||
int deleteLines(Long[] lineIds);
|
||||
|
||||
/** 附加费分区下拉:按国家去重区块标题 */
|
||||
List<String> selectBlockTitlesByCountry(String countryCode, String countryName);
|
||||
|
||||
|
||||
+9
-4
@@ -1,17 +1,22 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
import com.bms.price.domain.PaySurchargeRuleLog;
|
||||
import com.bms.price.domain.PaySurchargeRuleSave;
|
||||
|
||||
/** 应付附加费计费条件。一个产品版本只保留一份。 */
|
||||
/** 应付附加费计费条件。一份跟产品走,计算时用当前生效版本上的附加费。 */
|
||||
public interface IPaySurchargeRuleService
|
||||
{
|
||||
List<PaySurchargeRule> list(Long productId, Long termId);
|
||||
|
||||
/** 上一版的条件,只读出来供当前页编辑,不直接落库 */
|
||||
List<PaySurchargeRule> previous(Long productId);
|
||||
/** 计算时读取的条件。先取产品上的一份,没有再取当前生效版本上的。 */
|
||||
List<PaySurchargeRule> listForCalc(PayProduct product);
|
||||
|
||||
/** 覆盖所选产品当前版本的配置。同一版本不会留下两份。 */
|
||||
/** 覆盖所选产品的配置。不按价格版本各存一份。 */
|
||||
void save(PaySurchargeRuleSave command);
|
||||
|
||||
/** 这个产品上的附加费配置操作记录。 */
|
||||
List<PaySurchargeRuleLog> logs(Long productId, Long termId);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface IPrcOrderBillService
|
||||
* @param upstreamRow Oracle TAB_ORDER 整行数据
|
||||
* @return billId
|
||||
*/
|
||||
String syncUpstreamOverwrite(java.util.Map<String, Object> upstreamRow);
|
||||
Long syncUpstreamOverwrite(java.util.Map<String, Object> upstreamRow);
|
||||
|
||||
/**
|
||||
* 计费无法生成报价时,仍然落库 prc_order_bill 及其扩展表。
|
||||
@@ -59,10 +59,10 @@ public interface IPrcOrderBillService
|
||||
/** 转单号下拉搜索选项(模糊匹配,去重限量,带数据权限) */
|
||||
List<String> listTransferNoOptions(PrcOrderBill query);
|
||||
|
||||
TmsPriceQuoteResult getBill(String billId);
|
||||
TmsPriceQuoteResult getBill(Long billId);
|
||||
|
||||
/** 订单列表弹窗使用的计费失败原因(带数据权限)。 */
|
||||
OrderBillFailReasonVo getBillingFailReason(String billId);
|
||||
OrderBillFailReasonVo getBillingFailReason(Long billId);
|
||||
|
||||
TmsPriceQuoteResult getBillByOrderNo(String orderNo);
|
||||
|
||||
@@ -73,7 +73,7 @@ public interface IPrcOrderBillService
|
||||
TmsPriceQuoteResult updateIncomeFee(UpdateIncomeBillFeeRequest request);
|
||||
|
||||
/** 删除手工录入的 UNBILLED 收入费用;同时刷新应收合计。 */
|
||||
TmsPriceQuoteResult deleteIncomeFee(String feeId);
|
||||
TmsPriceQuoteResult deleteIncomeFee(Long feeId);
|
||||
|
||||
/** 预览批量添加费用命中的账单(带数据权限)。 */
|
||||
BatchAddIncomeBillFeePreview previewBatchAddIncomeFee(BatchAddIncomeBillFeeRequest request);
|
||||
@@ -103,7 +103,7 @@ public interface IPrcOrderBillService
|
||||
* @param billId 订单计费ID
|
||||
* @return 更新后的计费结果
|
||||
*/
|
||||
TmsPriceQuoteResult updateCreditArrearsStatus(String billId);
|
||||
TmsPriceQuoteResult updateCreditArrearsStatus(Long billId);
|
||||
|
||||
/**
|
||||
* 更新 charge_weight(手工覆盖),保留原重量,并重新计费。
|
||||
@@ -112,12 +112,12 @@ public interface IPrcOrderBillService
|
||||
* @param billId 账单 ID
|
||||
* @param chargeWeight 新的计费重量(kg)
|
||||
*/
|
||||
TmsPriceQuoteResult updateChargeWeight(String billId, BigDecimal chargeWeight);
|
||||
TmsPriceQuoteResult updateChargeWeight(Long billId, BigDecimal chargeWeight);
|
||||
|
||||
/**
|
||||
* 更新 charge_weight,不做数据权限校验(供已校验的异步导入使用)。
|
||||
*/
|
||||
TmsPriceQuoteResult updateChargeWeightByBillId(String billId, BigDecimal chargeWeight);
|
||||
TmsPriceQuoteResult updateChargeWeightByBillId(Long billId, BigDecimal chargeWeight);
|
||||
|
||||
/**
|
||||
* 提交 charge_weight 更新的异步导入;返回 taskId。
|
||||
@@ -151,7 +151,7 @@ public interface IPrcOrderBillService
|
||||
* 按模式(PRODUCT/REDLINE)重算并落库 product_amount 或 redline_amount。
|
||||
* 要求 prc_order_bill 已存在;跳过应收可编辑校验。
|
||||
*/
|
||||
void recalcBillPriceByBillId(String billId, String mode);
|
||||
void recalcBillPriceByBillId(Long billId, String mode);
|
||||
|
||||
/**
|
||||
* 仅基于本地 prc_order_bill 做完整重算(不调 Oracle 上游)。
|
||||
@@ -159,7 +159,7 @@ public interface IPrcOrderBillService
|
||||
* 若 prc_income_bill_fee 已有 fee_type=REFUND 则跳过,否则走 {@link #refund}。
|
||||
* 其余情况用账单行重建请求后走 {@link #bill}。
|
||||
*/
|
||||
TmsPriceQuoteResult rebillLocalByBillId(String billId);
|
||||
TmsPriceQuoteResult rebillLocalByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 按选中的 billId 或列表筛选条件做异步本地重算。返回 taskId 用于进度轮询。
|
||||
@@ -174,7 +174,7 @@ public interface IPrcOrderBillService
|
||||
BatchAddIncomeBillFeeTask cancelLocalRebill(String taskId);
|
||||
|
||||
/** 本地重算用的带数据权限的 bill_id 列表(筛选条件与订单账单列表一致)。 */
|
||||
List<String> selectBillIdsForLocalRebill(PrcOrderBill query);
|
||||
List<Long> selectBillIdsForLocalRebill(PrcOrderBill query);
|
||||
|
||||
/** 本地重算的带数据权限的数量统计。 */
|
||||
int countBillIdsForLocalRebill(PrcOrderBill query);
|
||||
|
||||
@@ -21,5 +21,5 @@ public interface IPrcPayBillFeeService
|
||||
*
|
||||
* @param billIds 计费订单 ID
|
||||
*/
|
||||
void refreshTotals(List<String> billIds);
|
||||
void refreshTotals(List<Long> billIds);
|
||||
}
|
||||
|
||||
+14
@@ -23,6 +23,8 @@ import com.bms.common.utils.DateUtils;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.common.utils.file.OssStorage;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
||||
import com.bms.price.domain.ChannelProductMap;
|
||||
import com.bms.price.domain.LabelPackageVersion;
|
||||
import com.bms.price.domain.LblPreview;
|
||||
@@ -82,6 +84,9 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
@Autowired
|
||||
private ChannelProductMapMapper channelProductMapMapper;
|
||||
|
||||
@Autowired
|
||||
private ServiceChannelMapper serviceChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@@ -546,12 +551,21 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
}
|
||||
}
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
for (String channelId : wanted)
|
||||
{
|
||||
ServiceChannel channel = serviceChannelMapper.selectServiceChannelById(channelId);
|
||||
if (channel == null || isBlank(channel.getChannelCode()))
|
||||
{
|
||||
throw new ServiceException("渠道不存在或渠道编码为空: " + channelId);
|
||||
}
|
||||
ChannelProductMap row = new ChannelProductMap();
|
||||
row.setChannelId(channelId);
|
||||
row.setChannelCode(channel.getChannelCode());
|
||||
row.setProductId(productId);
|
||||
row.setPayType(type);
|
||||
row.setCreateBy(operator);
|
||||
row.setUpdateBy(operator);
|
||||
channelProductMapMapper.upsert(row);
|
||||
}
|
||||
return "已绑定" + wanted.size() + "个渠道";
|
||||
|
||||
+15
-13
@@ -15,7 +15,6 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
@@ -152,9 +151,9 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
throw new ServiceException(preview.getMissingNos().isEmpty() ? PaymentMesEnum.BMS_PAY_NO_GEN.getCnMes() : "订单号没有对上:" + String.join("、", preview.getMissingNos()));
|
||||
}
|
||||
String currency = currencyOf(orders);
|
||||
Map<String, Integer> versions = new HashMap<>();
|
||||
Map<Long, Integer> versions = new HashMap<>();
|
||||
List<String> skipped = new ArrayList<>();
|
||||
List<String> billIds = new ArrayList<>();
|
||||
List<Long> billIds = new ArrayList<>();
|
||||
for (PayBillOrder order : orders)
|
||||
{
|
||||
billIds.add(order.getBillId());
|
||||
@@ -228,7 +227,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
bill.setSourceType(mode(command));
|
||||
bill.setPeriodStart(parseDay(command.getBeginDate()));
|
||||
bill.setPeriodEnd(parseDay(command.getEndDate()));
|
||||
Set<String> orderIds = new HashSet<>();
|
||||
Set<Long> orderIds = new HashSet<>();
|
||||
for (PayBillLine line : lines)
|
||||
{
|
||||
if (line.getOrderBillId() != null)
|
||||
@@ -260,7 +259,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
{
|
||||
line.setBillId(bill.getBillId());
|
||||
payBillMapper.insertLine(line);
|
||||
if (line.getFeeId() != null && !line.getFeeId().isBlank() && payBillMapper.bindFeeLine(line.getFeeId(), line.getLineId()) != 1)
|
||||
if (line.getFeeId() != null && payBillMapper.bindFeeLine(line.getFeeId(), line.getLineId()) != 1)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_FEE_TAKEN.exception();
|
||||
}
|
||||
@@ -399,7 +398,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
throw PaymentMesEnum.BMS_PAY_PENDING.exception();
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
if (operator.equals(bill.getCreateBy()) || (bill.getSubmitBy() != null && operator.equals(bill.getSubmitBy())))
|
||||
if (!SecurityUtils.isAdmin() && (operator.equals(bill.getCreateBy()) || (bill.getSubmitBy() != null && operator.equals(bill.getSubmitBy()))))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_SAME_USER.exception();
|
||||
}
|
||||
@@ -574,7 +573,6 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
}
|
||||
}
|
||||
PrcPayBillFee adjust = new PrcPayBillFee();
|
||||
adjust.setFeeId(UUID.randomUUID().toString());
|
||||
adjust.setBillId(line.getOrderBillId());
|
||||
adjust.setPayBillId(source == null ? null : source.getPayBillId());
|
||||
adjust.setFeeType("对账调整");
|
||||
@@ -584,11 +582,15 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
adjust.setAmount(delta);
|
||||
adjust.setCurrency(line.getCurrency());
|
||||
adjust.setFeeSource("MANUAL");
|
||||
adjust.setSourceId(String.valueOf(open.getDiffId()));
|
||||
adjust.setSourceId(source != null && source.getFeeId() != null ? String.valueOf(source.getFeeId()) : null);
|
||||
adjust.setRemark(open.getReason());
|
||||
adjust.setSettleSupplierId(bill.getSupplierId());
|
||||
adjust.setSettleSupplierName(bill.getSupplierName());
|
||||
payBillFeeMapper.insertPrcPayBillFee(adjust);
|
||||
if (adjust.getSourceId() == null || adjust.getSourceId().isBlank())
|
||||
{
|
||||
payBillFeeMapper.fillSourceIdByFeeIds(List.of(adjust.getFeeId()));
|
||||
}
|
||||
payFinanceMapper.stampFee(adjust.getFeeId(), bill.getSupplierId(), bill.getSupplierName());
|
||||
if (line.getOrderBillId() != null)
|
||||
{
|
||||
@@ -943,7 +945,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
* @param billId 计费订单ID
|
||||
* @return 订单;对不上时返回 null
|
||||
*/
|
||||
private PayBillOrder findOrder(List<PayBillOrder> orders, String billId)
|
||||
private PayBillOrder findOrder(List<PayBillOrder> orders, Long billId)
|
||||
{
|
||||
for (PayBillOrder order : orders)
|
||||
{
|
||||
@@ -1107,11 +1109,11 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
{
|
||||
List<PrcPayBillFee> kept = new ArrayList<>();
|
||||
Set<String> notes = new LinkedHashSet<>();
|
||||
Map<String, String> cards = new HashMap<>();
|
||||
Map<Long, String> cards = new HashMap<>();
|
||||
for (PrcPayBillFee fee : fees)
|
||||
{
|
||||
PayBillOrder order = findOrder(orders, fee.getBillId());
|
||||
String orderNo = order == null || order.getOrderNo() == null ? fee.getBillId() : order.getOrderNo();
|
||||
String orderNo = order == null || order.getOrderNo() == null ? String.valueOf(fee.getBillId()) : order.getOrderNo();
|
||||
String why = partyReason(fee, order, supplier, cards);
|
||||
if (why == null)
|
||||
{
|
||||
@@ -1127,7 +1129,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
return kept;
|
||||
}
|
||||
|
||||
private String partyReason(PrcPayBillFee fee, PayBillOrder order, BmsSupplier supplier, Map<String, String> cards)
|
||||
private String partyReason(PrcPayBillFee fee, PayBillOrder order, BmsSupplier supplier, Map<Long, String> cards)
|
||||
{
|
||||
if (fee.getSettleSupplierId() != null)
|
||||
{
|
||||
@@ -1263,7 +1265,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
List<PayBillLine> lines = payBillMapper.selectLines(billId);
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
BigDecimal supplier = BigDecimal.ZERO;
|
||||
Set<String> orders = new HashSet<>();
|
||||
Set<Long> orders = new HashSet<>();
|
||||
for (PayBillLine line : lines)
|
||||
{
|
||||
BigDecimal amount = line.getAmount() == null ? BigDecimal.ZERO : line.getAmount();
|
||||
|
||||
+84
-28
@@ -84,20 +84,20 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public PayOrderCostResult generateIsolated(String billId)
|
||||
public PayOrderCostResult generateIsolated(Long billId)
|
||||
{
|
||||
return generate(billId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PayOrderCostResult generate(String billId)
|
||||
public PayOrderCostResult generate(Long billId)
|
||||
{
|
||||
if (billId == null || billId.isBlank())
|
||||
if (billId == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PICK_ORDER.exception();
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_ORDER_MISS.exception();
|
||||
@@ -110,21 +110,18 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
Integer orderStatus = bill.getOrderStatus() != null ? bill.getOrderStatus() : (ext == null ? null : ext.getOrderStatus());
|
||||
List<PayPostcodeGroup> linked = linkedGroups(product);
|
||||
String zoneName = resolveZone(channel, product, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), linked);
|
||||
List<PaySurchargeRule> billingRules = billingRules(product);
|
||||
product.setBillingRules(billingRules);
|
||||
applyCurrentSurcharge(channel.getId(), product);
|
||||
List<PaySurchargeRule> billingRules = product.getBillingRules();
|
||||
boolean postcodeOn = ruleOn(billingRules, PaySurchargeRules.POSTCODE);
|
||||
boolean zoneOn = ruleOn(billingRules, PaySurchargeRules.ZONE);
|
||||
List<PayRemoteBook.Hit> remoteHits = null;
|
||||
if (postcodeOn)
|
||||
if (!hasPrefixRules(billingRules, PaySurchargeRules.POSTCODE))
|
||||
{
|
||||
remoteHits = remoteHits(linked, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName());
|
||||
if (remoteHits == null)
|
||||
{
|
||||
remoteHits = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, weight, bill.getPkgLength(), bill.getPkgWidth(),
|
||||
bill.getPkgHeight(), bill.getDestPostcode(), zoneName, bizDate, orderStatus, remoteHits, postcodeOn, zoneOn);
|
||||
bill.getPkgHeight(), bill.getDestPostcode(), zoneName, bizDate, orderStatus, remoteHits, postcodeOn, zoneOn,
|
||||
bill.getCountryCode(), bill.getCountryName());
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
@@ -138,22 +135,22 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
saveFees(bill.getBillId(), payBill.getPayBillId(), result.getFees());
|
||||
String channelName = channel.getChannelName() == null ? channel.getChannelCode() : channel.getChannelName();
|
||||
String end = product.getTermEnd() == null ? "不限" : day(product.getTermEnd());
|
||||
result.setMessage("渠道「" + channelName + "」产品编号 " + product.getOriginId() + " 第 " + product.getVersionNo()
|
||||
result.setMessage("渠道「" + channelName + "」" + product.getProductName() + " 第 " + product.getVersionNo()
|
||||
+ " 版(" + day(product.getTermStart()) + " 至 " + end + ")," + result.getMessage());
|
||||
paySettleSupport.stampCalc(bill.getBillId(), product.getSupplierName());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cardSupplierName(String billId)
|
||||
public String cardSupplierName(Long billId)
|
||||
{
|
||||
if (billId == null || billId.isBlank())
|
||||
if (billId == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
return "";
|
||||
@@ -176,14 +173,45 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
* @param product 当前价卡版本
|
||||
* @return 名称能对上的邮编组,没有时为空列表
|
||||
*/
|
||||
private List<PaySurchargeRule> billingRules(PayProduct product)
|
||||
/** 运费仍按订单日期取版本。附加费条件和附加费明细改用产品当前生效版本。 */
|
||||
private void applyCurrentSurcharge(String channelId, PayProduct priced)
|
||||
{
|
||||
if (product == null || product.getProductId() == null || product.getTermId() == null)
|
||||
try
|
||||
{
|
||||
return new ArrayList<>();
|
||||
PayProduct current = payProductService.selectPriceForDate(channelId, new Date());
|
||||
if (current != null && current.getSurcharges() != null)
|
||||
{
|
||||
priced.setSurcharges(current.getSurcharges());
|
||||
}
|
||||
}
|
||||
List<PaySurchargeRule> rules = paySurchargeRuleService.list(product.getProductId(), product.getTermId());
|
||||
return rules == null ? new ArrayList<>() : rules;
|
||||
catch (ServiceException ignored)
|
||||
{
|
||||
// 今天没有生效版本时,附加费明细仍用订单日期命中的那一版
|
||||
}
|
||||
List<PaySurchargeRule> rules = paySurchargeRuleService.listForCalc(priced);
|
||||
priced.setBillingRules(rules == null ? new ArrayList<>() : rules);
|
||||
}
|
||||
|
||||
/** 附加费规则里已经写了邮编前缀时,偏远不再去应付邮编配置里查。 */
|
||||
private static boolean hasPrefixRules(List<PaySurchargeRule> rules, String calcRule)
|
||||
{
|
||||
if (rules == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (PaySurchargeRule rule : rules)
|
||||
{
|
||||
if (rule == null || !calcRule.equals(rule.getCalcRule()) || "0".equals(rule.getEnabled()) || rule.getDetail() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Object postcodes = rule.getDetail().get("postcodes");
|
||||
if (postcodes != null && !String.valueOf(postcodes).isBlank())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean ruleOn(List<PaySurchargeRule> rules, String calcRule)
|
||||
@@ -233,19 +261,49 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
}
|
||||
|
||||
/**
|
||||
* 用产品自己的偏远邮编判断这票是否偏远。没有偏远配置时返回 null,计费改看价卡上的邮编条件。
|
||||
* 判断这票是否偏远。产品报价表已经挂了偏远名单时只用那一份,没命中就不再回价卡邮编。
|
||||
* 没有这份产品名单时,改查目的国家的偏远邮编;国家名单没命中则返回 null,价卡上的邮编条件仍可用。
|
||||
*
|
||||
* @param linked 已对上的邮编组
|
||||
* @param postcode 收件邮编
|
||||
* @param countryCode 目的国二字码
|
||||
* @param countryName 目的国名称
|
||||
* @return 命中的偏远分区;有配置但没命中时返回空列表
|
||||
* @return 命中的偏远分区;产品有名单但没命中时返回空列表
|
||||
*/
|
||||
private List<PayRemoteBook.Hit> remoteHits(List<PayPostcodeGroup> linked, String postcode, String countryCode, String countryName)
|
||||
{
|
||||
boolean productBook = false;
|
||||
for (PayPostcodeGroup group : linked)
|
||||
{
|
||||
if (group != null && PayRemoteBook.remoteGroup(group))
|
||||
{
|
||||
productBook = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (productBook)
|
||||
{
|
||||
return hitsOf(linked, postcode, countryCode, countryName);
|
||||
}
|
||||
if (blank(countryCode) && blank(countryName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PayPostcodeGroup> countryGroups = payPostcodeMapper.selectRemoteGroupsByCountry(countryCode, countryName);
|
||||
if (countryGroups == null || countryGroups.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PayRemoteBook.Hit> hits = hitsOf(countryGroups, postcode, countryCode, countryName);
|
||||
return hits == null || hits.isEmpty() ? null : hits;
|
||||
}
|
||||
|
||||
/** 在给定邮编组里做偏远匹配。没有偏远组时返回 null,有组但邮编没命中时返回空列表。 */
|
||||
private List<PayRemoteBook.Hit> hitsOf(List<PayPostcodeGroup> groups, String postcode, String countryCode, String countryName)
|
||||
{
|
||||
List<Long> remoteIds = new ArrayList<>();
|
||||
boolean anyRemote = false;
|
||||
for (PayPostcodeGroup group : linked)
|
||||
for (PayPostcodeGroup group : groups)
|
||||
{
|
||||
if (group == null || group.getGroupId() == null || !PayRemoteBook.remoteGroup(group))
|
||||
{
|
||||
@@ -267,7 +325,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
}
|
||||
List<PayPostcodeLine> lines = postcode == null || postcode.isBlank()
|
||||
? new ArrayList<>() : payPostcodeMapper.selectLinesByGroups(remoteIds);
|
||||
return PayRemoteBook.hits(linked, lines, postcode, countryCode, countryName);
|
||||
return PayRemoteBook.hits(groups, lines, postcode, countryCode, countryName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -497,7 +555,6 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
PrcPayBill row = existed == null ? new PrcPayBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
row.setPayBillId(UUID.randomUUID().toString());
|
||||
row.setBillId(bill.getBillId());
|
||||
row.setCreateBy(operator);
|
||||
}
|
||||
@@ -527,7 +584,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
* @param payBillId 订单应付主表ID
|
||||
* @param fees 本次算出的费用
|
||||
*/
|
||||
private void saveFees(String billId, String payBillId, List<PayCostLine> fees)
|
||||
private void saveFees(Long billId, Long payBillId, List<PayCostLine> fees)
|
||||
{
|
||||
payBillFeeMapper.deleteByBillId(billId);
|
||||
List<PrcPayBillFee> rows = new java.util.ArrayList<>();
|
||||
@@ -535,7 +592,6 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
for (PayCostLine fee : fees)
|
||||
{
|
||||
PrcPayBillFee row = new PrcPayBillFee();
|
||||
row.setFeeId(UUID.randomUUID().toString());
|
||||
row.setBillId(billId);
|
||||
row.setPayBillId(payBillId);
|
||||
row.setFeeType(fee.getFeeType());
|
||||
|
||||
+3
-3
@@ -131,7 +131,7 @@ public class PayPaymentServiceImpl implements IPayPaymentService
|
||||
payment.setAllocs(payPaymentMapper.selectAllocs(paymentId));
|
||||
checkAllocs(payment);
|
||||
String operator = SecurityUtils.getUsername();
|
||||
if (operator.equals(payment.getCreateBy()))
|
||||
if (!SecurityUtils.isAdmin() && operator.equals(payment.getCreateBy()))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_SAME_PAY.exception();
|
||||
}
|
||||
@@ -170,7 +170,7 @@ public class PayPaymentServiceImpl implements IPayPaymentService
|
||||
throw PaymentMesEnum.BMS_PAY_NO_REVERSE.exception();
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
if (operator.equals(payment.getConfirmBy()))
|
||||
if (!SecurityUtils.isAdmin() && operator.equals(payment.getConfirmBy()))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_SAME_PAY.exception();
|
||||
}
|
||||
@@ -192,7 +192,7 @@ public class PayPaymentServiceImpl implements IPayPaymentService
|
||||
throw PaymentMesEnum.BMS_PAY_NO_REVERSE.exception();
|
||||
}
|
||||
String operator = SecurityUtils.getUsername();
|
||||
if (operator.equals(payment.getConfirmBy()))
|
||||
if (!SecurityUtils.isAdmin() && operator.equals(payment.getConfirmBy()))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_SAME_PAY.exception();
|
||||
}
|
||||
|
||||
+272
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -34,6 +36,227 @@ public class PayPostcodeServiceImpl implements IPayPostcodeService
|
||||
return payPostcodeMapper.selectGroupList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query)
|
||||
{
|
||||
return payPostcodeMapper.selectCountryList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query)
|
||||
{
|
||||
requireCountry(query);
|
||||
return payPostcodeMapper.selectZoneList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int addZone(PayPostcodeGroup zone, String username)
|
||||
{
|
||||
requireCountry(zone);
|
||||
String zoneName = requireZoneName(zone.getZoneName());
|
||||
zone.setZoneName(zoneName);
|
||||
if (payPostcodeMapper.countZoneName(zone) > 0)
|
||||
{
|
||||
throw new ServiceException("分区「" + zoneName + "」已存在");
|
||||
}
|
||||
PayPostcodeGroup sample = payPostcodeMapper.selectSampleGroup(zone);
|
||||
PayPostcodeGroup row = new PayPostcodeGroup();
|
||||
row.setSourceFile("手工新增");
|
||||
row.setFileMd5(UUID.randomUUID().toString().replace("-", ""));
|
||||
row.setBlockTitle(zoneName);
|
||||
row.setConfigKind("ZONE");
|
||||
row.setCoverage(normalizeCoverage(zone.getCoverage()));
|
||||
row.setCountryName(firstText(zone.getCountryName(), sample == null ? "" : sample.getCountryName()));
|
||||
row.setCountryCode(firstText(zone.getCountryCode(), sample == null ? "" : sample.getCountryCode()));
|
||||
row.setServiceType(sample == null ? "" : trimToEmpty(sample.getServiceType()));
|
||||
row.setCatalogCountry(sample == null ? "" : trimToEmpty(sample.getCatalogCountry()));
|
||||
if ("REMOTE".equals(row.getCoverage()))
|
||||
{
|
||||
row.setSheetName("手工偏远");
|
||||
row.setChannelName("");
|
||||
row.setProductName("");
|
||||
row.setQuoteSheet("");
|
||||
row.setFeeName("偏远");
|
||||
}
|
||||
else
|
||||
{
|
||||
row.setSheetName(sample != null && !trimToEmpty(sample.getSheetName()).isEmpty() ? sample.getSheetName() : zoneName);
|
||||
row.setChannelName(sample == null ? "" : trimToEmpty(sample.getChannelName()));
|
||||
row.setProductName(sample == null ? "" : trimToEmpty(sample.getProductName()));
|
||||
row.setQuoteSheet(sample == null ? "" : trimToEmpty(sample.getQuoteSheet()));
|
||||
row.setFeeName("");
|
||||
}
|
||||
row.setFeeText("");
|
||||
row.setLineCount(0);
|
||||
row.setCreateBy(username);
|
||||
return payPostcodeMapper.insertGroup(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateZone(PayPostcodeGroup zone)
|
||||
{
|
||||
requireCountry(zone);
|
||||
String zoneName = requireZoneName(zone.getZoneName());
|
||||
String oldName = requireZoneName(zone.getOldZoneName());
|
||||
zone.setZoneName(zoneName);
|
||||
zone.setOldZoneName(oldName);
|
||||
zone.setCoverage(normalizeCoverage(zone.getCoverage()));
|
||||
if (!oldName.equals(zoneName) && payPostcodeMapper.countZoneName(zone) > 0)
|
||||
{
|
||||
throw new ServiceException("分区「" + zoneName + "」已存在");
|
||||
}
|
||||
payPostcodeMapper.renameZoneLines(zone);
|
||||
return payPostcodeMapper.updateExclusiveZone(zone);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteZone(PayPostcodeGroup zone)
|
||||
{
|
||||
requireCountry(zone);
|
||||
zone.setZoneName(requireZoneName(zone.getZoneName()));
|
||||
payPostcodeMapper.deleteLinesByZone(zone);
|
||||
List<Long> groupIds = payPostcodeMapper.selectGroupIdsByCountry(zone);
|
||||
int removed = 0;
|
||||
if (groupIds != null)
|
||||
{
|
||||
for (Long groupId : groupIds)
|
||||
{
|
||||
payPostcodeMapper.refreshLineCount(groupId);
|
||||
PayPostcodeGroup group = payPostcodeMapper.selectGroupById(groupId);
|
||||
if (group != null && "手工新增".equals(group.getSourceFile()) && zone.getZoneName().equals(trimToEmpty(group.getBlockTitle()))
|
||||
&& (group.getLineCount() == null || group.getLineCount() == 0))
|
||||
{
|
||||
payPostcodeMapper.deleteGroups(List.of(groupId));
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCountry(PayPostcodeGroup country)
|
||||
{
|
||||
requireCountry(country);
|
||||
country.setServiceType(trimToEmpty(country.getServiceType()));
|
||||
country.setProductName(trimToEmpty(country.getProductName()));
|
||||
country.setChannelName(trimToEmpty(country.getChannelName()));
|
||||
return payPostcodeMapper.updateCountryProfile(country);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteCountry(PayPostcodeGroup country)
|
||||
{
|
||||
requireCountry(country);
|
||||
List<Long> ids = payPostcodeMapper.selectGroupIdsByCountry(country);
|
||||
if (ids == null || ids.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
payPostcodeMapper.deleteLines(ids);
|
||||
return payPostcodeMapper.deleteGroups(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int addLine(PayPostcodeLine line)
|
||||
{
|
||||
if (line == null)
|
||||
{
|
||||
throw new ServiceException("请填写邮编");
|
||||
}
|
||||
PayPostcodeGroup zone = countryOf(line);
|
||||
zone.setZoneName(requireZoneName(line.getZoneName()));
|
||||
Long groupId = payPostcodeMapper.selectZoneGroupId(zone);
|
||||
if (groupId == null)
|
||||
{
|
||||
addZone(zone, "system");
|
||||
groupId = payPostcodeMapper.selectZoneGroupId(zone);
|
||||
}
|
||||
if (groupId == null)
|
||||
{
|
||||
throw new ServiceException("分区不存在");
|
||||
}
|
||||
PayPostcodeGroup group = payPostcodeMapper.selectGroupById(groupId);
|
||||
line.setGroupId(groupId);
|
||||
line.setZoneName(zone.getZoneName());
|
||||
line.setCountryName(group == null ? zone.getCountryName() : group.getCountryName());
|
||||
line.setCountryCode(group == null ? zone.getCountryCode() : group.getCountryCode());
|
||||
line.setCityName(trimToEmpty(line.getCityName()));
|
||||
line.setPostcode(cleanPostcode(line.getPostcode()));
|
||||
line.setPostcodeRaw(trimToEmpty(line.getPostcodeRaw()).isEmpty() ? line.getPostcode() : trimToEmpty(line.getPostcodeRaw()));
|
||||
line.setPostcodeEnd(cleanOptionalPostcode(line.getPostcodeEnd()));
|
||||
if (line.getPostcode().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写邮编");
|
||||
}
|
||||
int rows = payPostcodeMapper.insertLine(line);
|
||||
payPostcodeMapper.refreshLineCount(groupId);
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateLine(PayPostcodeLine line)
|
||||
{
|
||||
if (line == null || line.getLineId() == null)
|
||||
{
|
||||
throw new ServiceException("请选择邮编");
|
||||
}
|
||||
PayPostcodeLine existed = payPostcodeMapper.selectLineById(line.getLineId());
|
||||
if (existed == null)
|
||||
{
|
||||
throw new ServiceException("邮编不存在或已删除");
|
||||
}
|
||||
line.setCityName(trimToEmpty(line.getCityName()));
|
||||
line.setZoneName(trimToEmpty(line.getZoneName()).isEmpty() ? existed.getZoneName() : trimToEmpty(line.getZoneName()));
|
||||
line.setPostcode(cleanPostcode(line.getPostcode()));
|
||||
line.setPostcodeRaw(line.getPostcode());
|
||||
line.setPostcodeEnd(cleanOptionalPostcode(line.getPostcodeEnd()));
|
||||
if (line.getPostcode().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写邮编");
|
||||
}
|
||||
int rows = payPostcodeMapper.updateLine(line);
|
||||
payPostcodeMapper.refreshLineCount(existed.getGroupId());
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteLines(Long[] lineIds)
|
||||
{
|
||||
List<Long> ids = new ArrayList<>();
|
||||
if (lineIds != null)
|
||||
{
|
||||
for (Long id : lineIds)
|
||||
{
|
||||
if (id != null)
|
||||
{
|
||||
ids.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
List<Long> groupIds = payPostcodeMapper.selectGroupIdsByLineIds(ids);
|
||||
int rows = payPostcodeMapper.deleteLineByIds(ids);
|
||||
if (groupIds != null)
|
||||
{
|
||||
for (Long groupId : groupIds)
|
||||
{
|
||||
payPostcodeMapper.refreshLineCount(groupId);
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> selectBlockTitlesByCountry(String countryCode, String countryName)
|
||||
{
|
||||
@@ -180,4 +403,53 @@ public class PayPostcodeServiceImpl implements IPayPostcodeService
|
||||
}
|
||||
throw PaymentMesEnum.BMS_PAY_ZIP_ATTR.exception();
|
||||
}
|
||||
|
||||
private static void requireCountry(PayPostcodeGroup country)
|
||||
{
|
||||
if (country == null || (trimToEmpty(country.getCountryCode()).isEmpty() && trimToEmpty(country.getCountryName()).isEmpty()))
|
||||
{
|
||||
throw new ServiceException("请选择国家");
|
||||
}
|
||||
}
|
||||
|
||||
private static String requireZoneName(String zoneName)
|
||||
{
|
||||
String name = trimToEmpty(zoneName);
|
||||
if (name.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写分区");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private static PayPostcodeGroup countryOf(PayPostcodeLine line)
|
||||
{
|
||||
PayPostcodeGroup country = new PayPostcodeGroup();
|
||||
country.setCountryCode(line.getCountryCode());
|
||||
country.setCountryName(line.getCountryName());
|
||||
requireCountry(country);
|
||||
return country;
|
||||
}
|
||||
|
||||
private static String firstText(String preferred, String fallback)
|
||||
{
|
||||
String value = trimToEmpty(preferred);
|
||||
return value.isEmpty() ? trimToEmpty(fallback) : value;
|
||||
}
|
||||
|
||||
private static String cleanPostcode(String postcode)
|
||||
{
|
||||
String value = trimToEmpty(postcode);
|
||||
while (value.endsWith("*"))
|
||||
{
|
||||
value = value.substring(0, value.length() - 1).trim();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private static String cleanOptionalPostcode(String postcode)
|
||||
{
|
||||
String value = cleanPostcode(postcode);
|
||||
return value.isEmpty() ? null : value;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-12
@@ -146,6 +146,14 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
try
|
||||
{
|
||||
PayPreview preview = parser.parseMatched(bytes, filename, dictValue, loadDictValues(), listener);
|
||||
if (!labelMode)
|
||||
{
|
||||
preview.setEffectiveDate(null);
|
||||
for (PayProduct product : preview.getProducts())
|
||||
{
|
||||
product.setEffectiveDate(null);
|
||||
}
|
||||
}
|
||||
writeProgress(progressKey, 98, "正在核对已有产品", PayParseProgress.RUNNING);
|
||||
String stored = storeSource(bytes, filename);
|
||||
rememberSource(preview.getFileMd5(), stored);
|
||||
@@ -271,6 +279,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
continue;
|
||||
}
|
||||
product.setProductType(PAY_TYPE_AP);
|
||||
product.setEffectiveDate(null);
|
||||
product.setFilePath(resolveSource(product));
|
||||
prepareCounts(product);
|
||||
fitColumns(product);
|
||||
@@ -279,7 +288,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
product.setCreateTime(new Date());
|
||||
if (existsId != null)
|
||||
{
|
||||
appendVersion(existsId, product, operator);
|
||||
appendVersion(existsId, product, operator, true);
|
||||
replaced++;
|
||||
}
|
||||
else
|
||||
@@ -628,16 +637,11 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
return payProductTermMapper.updateStatus(term);
|
||||
}
|
||||
|
||||
/** 给刚保存的这一版记一条生效记录。新版本从生效日开始,旧版本收到生效日前一天。 */
|
||||
/** 给刚保存的这一版记一条生效记录。应付导入不写生效开始。覆盖旧版时,旧版收到新生效日前一天;没有新生效日则收到昨天。 */
|
||||
private PayProductTerm openTerm(PayProduct product, boolean replacePrevious, Long priceSetId)
|
||||
{
|
||||
String key = termKey(product);
|
||||
boolean labelMode = priceSetId != null;
|
||||
// 应付:无生效日则默认今天;打单:创建不写默认生效日,由详情「启动」设置
|
||||
if (!labelMode && product.getEffectiveDate() == null)
|
||||
{
|
||||
product.setEffectiveDate(today());
|
||||
}
|
||||
if (replacePrevious)
|
||||
{
|
||||
Date endDate;
|
||||
@@ -1932,10 +1936,10 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
/** 在同一个产品编号下追加一版价格:复用稳定 product_id,明细挂新 term_id。 */
|
||||
private PayProduct appendVersion(Long rootId, PayProduct incoming, String operator)
|
||||
{
|
||||
return appendVersion(rootId, incoming, operator, null);
|
||||
return appendVersion(rootId, incoming, operator, false);
|
||||
}
|
||||
|
||||
private PayProduct appendVersion(Long rootId, PayProduct incoming, String operator, Long priceSetId)
|
||||
private PayProduct appendVersion(Long rootId, PayProduct incoming, String operator, boolean blankEffectiveStart)
|
||||
{
|
||||
Long root = resolveRoot(rootId);
|
||||
PayProduct base = payProductMapper.selectPayProductById(root);
|
||||
@@ -1944,13 +1948,17 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
copy.setOriginId(null);
|
||||
copy.setChannelId(null);
|
||||
copy.setDictValue(blankTo(copy.getDictValue(), base.getDictValue()));
|
||||
Integer maxVersion = payProductTermMapper.selectMaxVersionByProduct(root, priceSetId);
|
||||
Integer maxVersion = payProductTermMapper.selectMaxVersionByProduct(root, null);
|
||||
if (maxVersion == null || maxVersion < 1)
|
||||
{
|
||||
maxVersion = payProductMapper.selectMaxVersion(root);
|
||||
}
|
||||
copy.setVersionNo((maxVersion == null ? 1 : maxVersion) + 1);
|
||||
if (copy.getEffectiveDate() == null)
|
||||
if (blankEffectiveStart)
|
||||
{
|
||||
copy.setEffectiveDate(null);
|
||||
}
|
||||
else if (copy.getEffectiveDate() == null)
|
||||
{
|
||||
copy.setEffectiveDate(today());
|
||||
}
|
||||
@@ -1960,7 +1968,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
prepareCounts(copy);
|
||||
fitColumns(copy);
|
||||
payProductMapper.updatePayProduct(copy);
|
||||
openTerm(copy, true, priceSetId);
|
||||
openTerm(copy, true, null);
|
||||
insertBands(copy);
|
||||
insertSurcharges(copy);
|
||||
insertExtras(copy);
|
||||
|
||||
+294
-36
@@ -2,6 +2,8 @@ package com.bms.price.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -17,9 +19,11 @@ import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PayProductTerm;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
import com.bms.price.domain.PaySurchargeRuleLog;
|
||||
import com.bms.price.domain.PaySurchargeRuleSave;
|
||||
import com.bms.price.mapper.PayProductMapper;
|
||||
import com.bms.price.mapper.PayProductTermMapper;
|
||||
import com.bms.price.mapper.PaySurchargeRuleLogMapper;
|
||||
import com.bms.price.mapper.PaySurchargeRuleMapper;
|
||||
import com.bms.price.service.IPaySurchargeRuleService;
|
||||
|
||||
@@ -33,9 +37,16 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
"boxLength", "boxWidth", "boxHeight", "volumeMin", "volumeMax", "cubicMax", "weightMin", "weightMax",
|
||||
"exceedStepCm", "exceedRatio", "thresholdKg", "stepKg", "minCharge", "ratio");
|
||||
|
||||
private static final Map<String, String> RULE_LABELS = Map.of(
|
||||
"ALWAYS", "每票都收", "POSTCODE", "命中邮编", "ZONE", "命中分区", "EXTRA_KG", "超重续收",
|
||||
"WEIGHT", "超重", "SIZE", "超尺寸", "RETURN", "退件");
|
||||
|
||||
@Autowired
|
||||
private PaySurchargeRuleMapper ruleMapper;
|
||||
|
||||
@Autowired
|
||||
private PaySurchargeRuleLogMapper logMapper;
|
||||
|
||||
@Autowired
|
||||
private PayProductMapper productMapper;
|
||||
|
||||
@@ -45,30 +56,22 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
@Override
|
||||
public List<PaySurchargeRule> list(Long productId, Long termId)
|
||||
{
|
||||
if (productId == null || termId == null)
|
||||
if (productId == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
List<PaySurchargeRule> rows = ruleMapper.selectByProduct(productId, termId);
|
||||
rows.forEach(PaySurchargeRuleServiceImpl::hydrate);
|
||||
return rows;
|
||||
return hydrateAll(rulesOf(stableId(productId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaySurchargeRule> previous(Long productId)
|
||||
public List<PaySurchargeRule> listForCalc(PayProduct product)
|
||||
{
|
||||
if (productId == null)
|
||||
{
|
||||
throw new ServiceException("请选择产品版本");
|
||||
}
|
||||
PaySurchargeRule previous = ruleMapper.selectPreviousVersion(productId);
|
||||
if (previous == null || previous.getProductId() == null || previous.getTermId() == null)
|
||||
if (product == null || product.getProductId() == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
List<PaySurchargeRule> rows = ruleMapper.selectByProduct(previous.getProductId(), previous.getTermId());
|
||||
rows.forEach(PaySurchargeRuleServiceImpl::hydrate);
|
||||
return rows;
|
||||
Long stable = product.getOriginId() != null ? product.getOriginId() : stableId(product.getProductId());
|
||||
return hydrateAll(rulesOf(stable));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,28 +84,29 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
}
|
||||
List<PaySurchargeRule> rules = normalize(command.getRules());
|
||||
String operator = SecurityUtils.getUsername();
|
||||
Map<String, PaySurchargeRuleSave.PaySurchargeRuleBind> versions = new LinkedHashMap<>();
|
||||
Map<Long, PaySurchargeRuleSave.PaySurchargeRuleBind> products = new LinkedHashMap<>();
|
||||
for (PaySurchargeRuleSave.PaySurchargeRuleBind bind : command.getProducts())
|
||||
{
|
||||
if (bind == null || bind.getProductId() == null || bind.getTermId() == null)
|
||||
if (bind == null || bind.getProductId() == null)
|
||||
{
|
||||
throw new ServiceException("产品还没有可绑定的生效版本");
|
||||
throw new ServiceException("请选择要绑定的产品");
|
||||
}
|
||||
versions.put(bind.getProductId() + ":" + bind.getTermId(), bind);
|
||||
products.putIfAbsent(stableId(bind.getProductId()), bind);
|
||||
}
|
||||
for (PaySurchargeRuleSave.PaySurchargeRuleBind bind : versions.values())
|
||||
for (Long stableId : products.keySet())
|
||||
{
|
||||
PayProduct product = productMapper.selectPayProductById(bind.getProductId());
|
||||
if (product == null)
|
||||
List<Long> family = productMapper.selectFamilyIds(stableId);
|
||||
if (family == null || family.isEmpty())
|
||||
{
|
||||
throw new ServiceException("应付产品不存在");
|
||||
family = List.of(stableId);
|
||||
}
|
||||
PayProductTerm term = termMapper.selectById(bind.getTermId());
|
||||
if (term == null || term.getProductId() == null || !term.getProductId().equals(bind.getProductId()))
|
||||
List<PaySurchargeRule> before = hydrateAll(rulesOf(stableId));
|
||||
List<PaySurchargeRuleLog> logs = diffLogs(before, rules, stableId, 0L, null, operator);
|
||||
ruleMapper.deleteByProductIds(family);
|
||||
if (!logs.isEmpty())
|
||||
{
|
||||
throw new ServiceException("计费条件必须跟这一版有效期走");
|
||||
logMapper.insertBatch(logs);
|
||||
}
|
||||
ruleMapper.deleteByTerm(bind.getProductId(), bind.getTermId());
|
||||
if (rules.isEmpty())
|
||||
{
|
||||
continue;
|
||||
@@ -118,9 +122,9 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
lastRule = rule.getCalcRule();
|
||||
}
|
||||
PaySurchargeRule row = copy(rule);
|
||||
row.setProductId(bind.getProductId());
|
||||
row.setTermId(bind.getTermId());
|
||||
row.setVersionNo(term.getVersionNo() == null ? bind.getVersionNo() : term.getVersionNo());
|
||||
row.setProductId(stableId);
|
||||
row.setTermId(0L);
|
||||
row.setVersionNo(0);
|
||||
row.setSortNo(sort++);
|
||||
row.setCreateBy(operator);
|
||||
row.setUpdateBy(operator);
|
||||
@@ -161,9 +165,79 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
row.setWeightMax(decimal(detail.get("weightMax"), "重量上限"));
|
||||
rules.add(row);
|
||||
}
|
||||
Set<String> alwaysFees = new HashSet<>();
|
||||
for (PaySurchargeRule row : rules)
|
||||
{
|
||||
if (!"ALWAYS".equals(row.getCalcRule()) || row.getDetail() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String feeName = text(row.getDetail().get("feeName"));
|
||||
if (feeName != null && !alwaysFees.add(feeName))
|
||||
{
|
||||
throw new ServiceException("存在两笔同类型的附加费:" + feeName);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaySurchargeRuleLog> logs(Long productId, Long termId)
|
||||
{
|
||||
if (productId == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
List<Long> family = productMapper.selectFamilyIds(stableId(productId));
|
||||
if (family == null || family.isEmpty())
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
return logMapper.selectByProductIds(family);
|
||||
}
|
||||
|
||||
/** 产品上的一份。还没迁到产品上时,用当前生效版本里原来那份。 */
|
||||
private List<PaySurchargeRule> rulesOf(Long stableId)
|
||||
{
|
||||
List<PaySurchargeRule> rows = ruleMapper.selectByProductId(stableId);
|
||||
if (rows != null && !rows.isEmpty())
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
Long currentId = productMapper.selectEffectiveVersionId(stableId, new Date());
|
||||
if (currentId == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
PayProductTerm term = termMapper.selectByProductId(currentId);
|
||||
if (term == null || term.getTermId() == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
List<PaySurchargeRule> current = ruleMapper.selectByProduct(currentId, term.getTermId());
|
||||
return current == null ? List.of() : current;
|
||||
}
|
||||
|
||||
private Long stableId(Long productId)
|
||||
{
|
||||
PayProduct product = productMapper.selectPayProductById(productId);
|
||||
if (product == null)
|
||||
{
|
||||
throw new ServiceException("应付产品不存在");
|
||||
}
|
||||
return product.getOriginId() == null ? product.getProductId() : product.getOriginId();
|
||||
}
|
||||
|
||||
private static List<PaySurchargeRule> hydrateAll(List<PaySurchargeRule> rows)
|
||||
{
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
rows.forEach(PaySurchargeRuleServiceImpl::hydrate);
|
||||
return rows;
|
||||
}
|
||||
|
||||
private static void hydrate(PaySurchargeRule row)
|
||||
{
|
||||
Map<String, Object> detail = parse(row.getRuleDetail());
|
||||
@@ -274,9 +348,14 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
{
|
||||
require(detail.get("thresholdKg") != null, "超重续收要填写超过多少公斤后开始续收");
|
||||
}
|
||||
else if ("ALWAYS".equals(calcRule))
|
||||
{
|
||||
require(text(detail.get("feeName")) != null, "每票都收要选择费用项");
|
||||
}
|
||||
else if ("POSTCODE".equals(calcRule) || "ZONE".equals(calcRule))
|
||||
{
|
||||
detail.clear();
|
||||
require(text(detail.get("zoneName")) != null, "命中邮编和命中分区要选择分区");
|
||||
require(text(detail.get("postcodes")) != null, "命中邮编和命中分区要填写邮编前缀");
|
||||
}
|
||||
else if ("RETURN".equals(calcRule))
|
||||
{
|
||||
@@ -322,13 +401,13 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
|
||||
private static String summary(String calcRule, Map<String, Object> detail)
|
||||
{
|
||||
if ("POSTCODE".equals(calcRule))
|
||||
if ("POSTCODE".equals(calcRule) || "ZONE".equals(calcRule))
|
||||
{
|
||||
return "按应付邮编配置判断,邮编前缀和完整邮编都认";
|
||||
}
|
||||
if ("ZONE".equals(calcRule))
|
||||
{
|
||||
return "按应付邮编配置的分区判断";
|
||||
List<String> located = new ArrayList<>();
|
||||
add(located, text(detail.get("zoneName")));
|
||||
add(located, text(detail.get("postcodes")));
|
||||
add(located, text(detail.get("country")));
|
||||
return located.isEmpty() ? null : String.join(";", located);
|
||||
}
|
||||
List<String> parts = new ArrayList<>();
|
||||
add(parts, choice(detail.get("matchMode"), Map.of("ANY", "任一命中", "ALL", "全部命中")));
|
||||
@@ -384,6 +463,11 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
{
|
||||
add(parts, text(detail.get("remark")));
|
||||
}
|
||||
String feeName = text(detail.get("feeName"));
|
||||
if (feeName != null)
|
||||
{
|
||||
parts.add(0, feeName);
|
||||
}
|
||||
return parts.isEmpty() ? null : String.join(";", parts);
|
||||
}
|
||||
|
||||
@@ -560,4 +644,178 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static List<PaySurchargeRuleLog> diffLogs(List<PaySurchargeRule> before, List<PaySurchargeRule> after,
|
||||
Long productId, Long termId, Integer versionNo, String operator)
|
||||
{
|
||||
Map<String, Map<String, String>> oldRows = keyed(before);
|
||||
Map<String, Map<String, String>> newRows = keyed(after);
|
||||
List<PaySurchargeRuleLog> logs = new ArrayList<>();
|
||||
for (Map.Entry<String, Map<String, String>> entry : newRows.entrySet())
|
||||
{
|
||||
Map<String, String> previous = oldRows.remove(entry.getKey());
|
||||
if (previous == null)
|
||||
{
|
||||
logs.add(log(productId, termId, versionNo, "1", entry.getKey(), null, entry.getValue(), operator));
|
||||
continue;
|
||||
}
|
||||
Map<String, String> oldChanged = new LinkedHashMap<>();
|
||||
Map<String, String> newChanged = new LinkedHashMap<>();
|
||||
Set<String> labels = new java.util.LinkedHashSet<>();
|
||||
labels.addAll(previous.keySet());
|
||||
labels.addAll(entry.getValue().keySet());
|
||||
for (String label : labels)
|
||||
{
|
||||
String oldValue = previous.get(label);
|
||||
String newValue = entry.getValue().get(label);
|
||||
if (java.util.Objects.equals(oldValue, newValue))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (oldValue != null)
|
||||
{
|
||||
oldChanged.put(label, oldValue);
|
||||
}
|
||||
if (newValue != null)
|
||||
{
|
||||
newChanged.put(label, newValue);
|
||||
}
|
||||
}
|
||||
if (!oldChanged.isEmpty() || !newChanged.isEmpty())
|
||||
{
|
||||
logs.add(log(productId, termId, versionNo, "2", entry.getKey(), oldChanged, newChanged, operator));
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Map<String, String>> entry : oldRows.entrySet())
|
||||
{
|
||||
logs.add(log(productId, termId, versionNo, "3", entry.getKey(), entry.getValue(), null, operator));
|
||||
}
|
||||
return logs;
|
||||
}
|
||||
|
||||
private static Map<String, Map<String, String>> keyed(List<PaySurchargeRule> rules)
|
||||
{
|
||||
Map<String, Map<String, String>> rows = new LinkedHashMap<>();
|
||||
Map<String, Integer> index = new LinkedHashMap<>();
|
||||
if (rules == null)
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
for (PaySurchargeRule rule : rules)
|
||||
{
|
||||
if (rule == null || rule.getCalcRule() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Map<String, String> attrs = filled(rule);
|
||||
if (attrs.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String feeName = attrs.get("费用项");
|
||||
String key;
|
||||
if ("ALWAYS".equals(rule.getCalcRule()) && feeName != null)
|
||||
{
|
||||
key = "ALWAYS|" + feeName;
|
||||
}
|
||||
else if ("POSTCODE".equals(rule.getCalcRule()) || "ZONE".equals(rule.getCalcRule()))
|
||||
{
|
||||
int next = index.getOrDefault(rule.getCalcRule(), 0);
|
||||
index.put(rule.getCalcRule(), next + 1);
|
||||
String zone = attrs.get("分区");
|
||||
key = rule.getCalcRule() + "|" + (zone == null ? String.valueOf(next) : zone + "#" + next);
|
||||
}
|
||||
else
|
||||
{
|
||||
int next = index.getOrDefault(rule.getCalcRule(), 0);
|
||||
index.put(rule.getCalcRule(), next + 1);
|
||||
key = rule.getCalcRule() + "#" + next;
|
||||
}
|
||||
rows.put(key, attrs);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private static Map<String, String> filled(PaySurchargeRule rule)
|
||||
{
|
||||
Map<String, Object> detail = rule.getDetail() == null ? Map.of() : rule.getDetail();
|
||||
Map<String, String> attrs = new LinkedHashMap<>();
|
||||
putAttr(attrs, "计费条件", RULE_LABELS.getOrDefault(rule.getCalcRule(), rule.getCalcRule()));
|
||||
putAttr(attrs, "费用项", text(detail.get("feeName")));
|
||||
putAttr(attrs, "计费方式", choice(detail.get("rateMode"), Map.of("FIXED", "固定金额", "RATIO", "按比例")));
|
||||
putAttr(attrs, "比例", detail.get("ratio") == null ? null : plain(detail.get("ratio")) + "%");
|
||||
putAttr(attrs, "计费基数", choice(detail.get("chargeBase"), Map.of("HANDLE", "处理费", "DELIVERY", "派送费", "FREIGHT_FEE", "运费加附加费")));
|
||||
putAttr(attrs, "生效开始", text(detail.get("periodStart")));
|
||||
putAttr(attrs, "生效结束", text(detail.get("periodEnd")));
|
||||
putAttr(attrs, "说明", text(detail.get("remark")));
|
||||
putAttr(attrs, "命中方式", choice(detail.get("matchMode"), Map.of("ANY", "任一命中", "ALL", "全部命中")));
|
||||
putAttr(attrs, "邮编匹配", choice(detail.get("postcodeMode"), Map.of("PREFIX", "邮编开头", "EXACT", "完整邮编")));
|
||||
putAttr(attrs, "最长边下限", unit(detail.get("longestMin"), "cm"));
|
||||
putAttr(attrs, "最长边上限", unit(detail.get("longestMax"), "cm"));
|
||||
putAttr(attrs, "次长边下限", unit(detail.get("secondMin"), "cm"));
|
||||
putAttr(attrs, "次长边上限", unit(detail.get("secondMax"), "cm"));
|
||||
putAttr(attrs, "三边之和下限", unit(detail.get("sumMin"), "cm"));
|
||||
putAttr(attrs, "三边之和上限", unit(detail.get("sumMax"), "cm"));
|
||||
putAttr(attrs, "围长下限", unit(detail.get("girthMin"), "cm"));
|
||||
putAttr(attrs, "围长上限", unit(detail.get("girthMax"), "cm"));
|
||||
putAttr(attrs, "箱规比较", choice(detail.get("boxMode"), Map.of("OVER", "超过", "UNDER", "小于")));
|
||||
if (detail.get("boxLength") != null)
|
||||
{
|
||||
putAttr(attrs, "箱规", plain(detail.get("boxLength")) + "×" + plain(detail.get("boxWidth")) + "×" + plain(detail.get("boxHeight")) + "cm");
|
||||
}
|
||||
putAttr(attrs, "体积下限", unit(detail.get("volumeMin"), "m³"));
|
||||
putAttr(attrs, "体积上限", unit(detail.get("volumeMax"), "m³"));
|
||||
putAttr(attrs, "体积上限立方", unit(detail.get("cubicMax"), "cm³"));
|
||||
putAttr(attrs, "超出步长", unit(detail.get("exceedStepCm"), "cm"));
|
||||
putAttr(attrs, "加收比例", detail.get("exceedRatio") == null ? null : plain(detail.get("exceedRatio")) + "%");
|
||||
putAttr(attrs, "重量下限", unit(detail.get("weightMin"), "kg"));
|
||||
putAttr(attrs, "重量上限", unit(detail.get("weightMax"), "kg"));
|
||||
putAttr(attrs, "重量口径", choice(detail.get("weightBasis"), Map.of("ACTUAL", "实重", "CHARGE", "计费重")));
|
||||
putAttr(attrs, "超过重量", unit(detail.get("thresholdKg"), "kg"));
|
||||
putAttr(attrs, "每超出", unit(detail.get("stepKg"), "kg"));
|
||||
putAttr(attrs, "最低消费", plain(detail.get("minCharge")));
|
||||
putAttr(attrs, "分区", text(detail.get("zoneName")));
|
||||
putAttr(attrs, "邮编", text(detail.get("postcodes")));
|
||||
putAttr(attrs, "国家", text(detail.get("country") != null ? detail.get("country") : detail.get("countries")));
|
||||
putAttr(attrs, "退回方式", choice(detail.get("chargeMode"), Map.of("SAME", "同正向运费", "AIR", "空运退回", "ROAD", "陆运退回", "FIXED", "固定金额")));
|
||||
return attrs;
|
||||
}
|
||||
|
||||
private static void putAttr(Map<String, String> attrs, String label, String value)
|
||||
{
|
||||
if (value == null || value.isBlank())
|
||||
{
|
||||
return;
|
||||
}
|
||||
attrs.put(label, value);
|
||||
}
|
||||
|
||||
private static String unit(Object value, String unit)
|
||||
{
|
||||
String text = plain(value);
|
||||
return text == null ? null : text + unit;
|
||||
}
|
||||
|
||||
private static PaySurchargeRuleLog log(Long productId, Long termId, Integer versionNo, String operation,
|
||||
String ruleKey, Map<String, String> before, Map<String, String> after, String operator)
|
||||
{
|
||||
Map<String, Object> content = new LinkedHashMap<>();
|
||||
if (before != null && !before.isEmpty())
|
||||
{
|
||||
content.put("before", before);
|
||||
}
|
||||
if (after != null && !after.isEmpty())
|
||||
{
|
||||
content.put("after", after);
|
||||
}
|
||||
PaySurchargeRuleLog row = new PaySurchargeRuleLog();
|
||||
row.setProductId(productId);
|
||||
row.setTermId(termId);
|
||||
row.setVersionNo(versionNo);
|
||||
row.setOperationType(operation);
|
||||
row.setRuleKey(ruleKey.length() > 200 ? ruleKey.substring(0, 200) : ruleKey);
|
||||
row.setChangeContent(JSON.toJSONString(content));
|
||||
row.setCreateBy(operator);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -635,7 +635,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillByOrderNo(orderNo.trim());
|
||||
}
|
||||
if (bill == null && StringUtils.isNotEmpty(task.getBillId()))
|
||||
if (bill == null && task.getBillId() != null)
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillById(task.getBillId());
|
||||
}
|
||||
@@ -645,7 +645,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
}
|
||||
}
|
||||
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, String billId,
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, Long billId,
|
||||
String errorMessage, String failCode)
|
||||
{
|
||||
PrcBillingTask upd = new PrcBillingTask();
|
||||
|
||||
+73
-74
@@ -12,7 +12,6 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.slf4j.Logger;
|
||||
@@ -297,7 +296,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
}
|
||||
|
||||
PrcIncomeBillFee refundFee = new PrcIncomeBillFee();
|
||||
refundFee.setFeeId(UUID.randomUUID().toString());
|
||||
refundFee.setBillId(bill.getBillId());
|
||||
refundFee.setIncomeBillId(incomeBill == null ? null : incomeBill.getIncomeBillId());
|
||||
String refundFeeType = FEE_TYPE_REFUND;
|
||||
@@ -423,6 +421,19 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return cleaned.isEmpty() ? null : cleaned;
|
||||
}
|
||||
|
||||
/** 账单ID去空去重。 */
|
||||
private List<Long> normalizeIdList(List<Long> ids)
|
||||
{
|
||||
if (ids == null || ids.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Long> cleaned = ids.stream().filter(java.util.Objects::nonNull).distinct()
|
||||
.collect(Collectors.toList());
|
||||
return cleaned.isEmpty() ? null : cleaned;
|
||||
}
|
||||
|
||||
|
||||
/** 单号筛选按去重后的订单号/运单号/转单号数量限制,避免过大的 IN 参数。 */
|
||||
private List<String> normalizeOrderIdentifiers(List<String> identifiers)
|
||||
{
|
||||
@@ -435,14 +446,14 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult getBill(String billId)
|
||||
public TmsPriceQuoteResult getBill(Long billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
query.setBillId(billId.trim());
|
||||
query.setBillId(billId);
|
||||
// 走 selectBillList,复用销售员/结算员数据权限,避免越权查详情
|
||||
List<PrcOrderBill> list = self.selectBillList(query);
|
||||
if (list == null || list.isEmpty())
|
||||
@@ -456,14 +467,14 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
|
||||
@Override
|
||||
public OrderBillFailReasonVo getBillingFailReason(String billId)
|
||||
public OrderBillFailReasonVo getBillingFailReason(Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
query.setBillId(billId.trim());
|
||||
query.setBillId(billId);
|
||||
List<PrcOrderBill> list = self.selectBillList(query);
|
||||
if (list == null || list.isEmpty())
|
||||
{
|
||||
@@ -687,7 +698,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult addIncomeFee(AddIncomeBillFeeRequest request)
|
||||
{
|
||||
if (request == null || StringUtils.isEmpty(request.getBillId()))
|
||||
if (request == null || request.getBillId() == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
@@ -695,7 +706,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.fee.scIdRequired"));
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(request.getBillId().trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(request.getBillId());
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
@@ -734,7 +745,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
: surcharge.getRoundMode());
|
||||
existing.setRemark(request.getRemark());
|
||||
existing.setManualFlag("1");
|
||||
if (incomeBill != null && StringUtils.isEmpty(existing.getIncomeBillId()))
|
||||
if (incomeBill != null && existing.getIncomeBillId() == null)
|
||||
{
|
||||
existing.setIncomeBillId(incomeBill.getIncomeBillId());
|
||||
}
|
||||
@@ -743,7 +754,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
else
|
||||
{
|
||||
PrcIncomeBillFee fee = new PrcIncomeBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(bill.getBillId());
|
||||
fee.setIncomeBillId(incomeBill == null ? null : incomeBill.getIncomeBillId());
|
||||
fee.setFeeType(feeType);
|
||||
@@ -766,11 +776,11 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult updateIncomeFee(UpdateIncomeBillFeeRequest request)
|
||||
{
|
||||
if (request == null || StringUtils.isEmpty(request.getFeeId()))
|
||||
if (request == null || request.getFeeId() == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.fee.idRequired"));
|
||||
}
|
||||
PrcIncomeBillFee fee = requireEditableManualFee(request.getFeeId().trim());
|
||||
PrcIncomeBillFee fee = requireEditableManualFee(request.getFeeId());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(fee.getBillId());
|
||||
if (bill == null)
|
||||
{
|
||||
@@ -813,13 +823,13 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult deleteIncomeFee(String feeId)
|
||||
public TmsPriceQuoteResult deleteIncomeFee(Long feeId)
|
||||
{
|
||||
if (StringUtils.isEmpty(feeId))
|
||||
if (feeId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.fee.idRequired"));
|
||||
}
|
||||
PrcIncomeBillFee fee = requireEditableManualFee(feeId.trim());
|
||||
PrcIncomeBillFee fee = requireEditableManualFee(feeId);
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(fee.getBillId());
|
||||
if (bill == null)
|
||||
{
|
||||
@@ -858,10 +868,10 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
throw new ServiceException(MessageUtils.message("price.bill.fee.batch.tooMany",
|
||||
Integer.valueOf(BATCH_ADD_FEE_MAX)));
|
||||
}
|
||||
List<String> billIds = new ArrayList<String>();
|
||||
List<Long> billIds = new ArrayList<Long>();
|
||||
for (PrcOrderBill bill : bills)
|
||||
{
|
||||
if (bill != null && StringUtils.isNotEmpty(bill.getBillId()))
|
||||
if (bill != null && bill.getBillId() != null)
|
||||
{
|
||||
billIds.add(bill.getBillId());
|
||||
}
|
||||
@@ -913,10 +923,10 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
throw new ServiceException(MessageUtils.message("price.bill.recalc.tooMany",
|
||||
Integer.valueOf(RECALC_PRICE_MAX)));
|
||||
}
|
||||
List<String> billIds = new ArrayList<String>();
|
||||
List<Long> billIds = new ArrayList<Long>();
|
||||
for (PrcOrderBill bill : bills)
|
||||
{
|
||||
if (bill != null && StringUtils.isNotEmpty(bill.getBillId()))
|
||||
if (bill != null && bill.getBillId() != null)
|
||||
{
|
||||
billIds.add(bill.getBillId());
|
||||
}
|
||||
@@ -944,14 +954,14 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void recalcBillPriceByBillId(String billId, String mode)
|
||||
public void recalcBillPriceByBillId(Long billId, String mode)
|
||||
{
|
||||
boolean productMode = "PRODUCT".equals(normalizeRecalcMode(mode));
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
@@ -980,13 +990,13 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
* 其他情况走正常的 {@link #bill}。
|
||||
*/
|
||||
@Override
|
||||
public TmsPriceQuoteResult rebillLocalByBillId(String billId)
|
||||
public TmsPriceQuoteResult rebillLocalByBillId(Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
@@ -1012,7 +1022,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return refundLocalWithDbRetry(bill.getOrderNo().trim());
|
||||
}
|
||||
TmsPriceBillRequest req = buildBillRequestFromBill(bill);
|
||||
return billLocalWithDbRetry(billId.trim(), req);
|
||||
return billLocalWithDbRetry(billId, req);
|
||||
}
|
||||
|
||||
/** order_status 为 9/10 或 refund_status=REFUNDED。 */
|
||||
@@ -1029,9 +1039,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return BillRefundStatus.REFUNDED.getCode().equalsIgnoreCase(bill.getRefundStatus());
|
||||
}
|
||||
|
||||
private boolean hasRefundFeeLine(String billId)
|
||||
private boolean hasRefundFeeLine(Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1050,7 +1060,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return false;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult billLocalWithDbRetry(String billId, TmsPriceBillRequest billReq)
|
||||
private TmsPriceQuoteResult billLocalWithDbRetry(Long billId, TmsPriceBillRequest billReq)
|
||||
{
|
||||
RuntimeException last = null;
|
||||
for (int attempt = 1; attempt <= LOCAL_REBILL_DB_RETRY_MAX; attempt++)
|
||||
@@ -1170,7 +1180,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
Integer.valueOf(LOCAL_REBILL_MAX)));
|
||||
}
|
||||
// 仅取 ID:大数据量任务避免加载完整的 prc_order_bill 行。
|
||||
List<String> billIds = self.selectBillIdsForLocalRebill(query);
|
||||
List<Long> billIds = self.selectBillIdsForLocalRebill(query);
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.recalc.noMatch"));
|
||||
@@ -1292,15 +1302,15 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
@Override
|
||||
@DataScope(deptAlias = "su", deptField = "dept_id", userAlias = "su", userField = "user_id", permission = "price:billing:bill")
|
||||
public List<String> selectBillIdsForLocalRebill(PrcOrderBill query)
|
||||
public List<Long> selectBillIdsForLocalRebill(PrcOrderBill query)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<Long>();
|
||||
}
|
||||
normalizeLocalRebillQuery(query);
|
||||
List<String> ids = orderBillMapper.selectPrcOrderBillIds(query);
|
||||
return ids == null ? new ArrayList<String>() : ids;
|
||||
List<Long> ids = orderBillMapper.selectPrcOrderBillIds(query);
|
||||
return ids == null ? new ArrayList<Long>() : ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1321,7 +1331,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
if ("SELECTED".equals(scopeMode))
|
||||
{
|
||||
List<String> billIds = normalizeCodeList(request.getBillIds());
|
||||
List<Long> billIds = normalizeIdList(request.getBillIds());
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.recalc.selectedRequired"));
|
||||
@@ -1400,7 +1410,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
query.setTrackingNos(normalizeCodeList(query.getTrackingNos()));
|
||||
query.setTransferNos(normalizeCodeList(query.getTransferNos()));
|
||||
query.setOrderIdentifiers(normalizeOrderIdentifiers(query.getOrderIdentifiers()));
|
||||
query.setBillIds(normalizeCodeList(query.getBillIds()));
|
||||
query.setBillIds(normalizeIdList(query.getBillIds()));
|
||||
}
|
||||
|
||||
private static String normalizeRecalcMode(String mode)
|
||||
@@ -1421,7 +1431,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
if (insert)
|
||||
{
|
||||
incomeBill = new PrcIncomeBill();
|
||||
incomeBill.setIncomeBillId(UUID.randomUUID().toString());
|
||||
incomeBill.setBillId(bill.getBillId());
|
||||
incomeBill.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
|
||||
incomeBill.setSalesAmount(nz(bill.getIncomeTotal()));
|
||||
@@ -1507,7 +1516,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
* scopeMode:SELECTED 使用 billIds;ALL 使用筛选条件(至少需要一个)。
|
||||
* 仅传 orderStatuses 不算有效筛选(与导出规则一致)。
|
||||
*/
|
||||
private List<PrcOrderBill> resolveListScopedBills(String scopeModeRaw, List<String> billIdsRaw,
|
||||
private List<PrcOrderBill> resolveListScopedBills(String scopeModeRaw, List<Long> billIdsRaw,
|
||||
List<String> orderNosRaw, List<String> trackingNosRaw, List<String> transferNosRaw, List<String> orderIdentifiersRaw,
|
||||
List<String> customerCodesRaw, List<String> productCodesRaw, String countryCodeRaw,
|
||||
String creditArrearsStatusRaw, List<Integer> orderStatusesRaw, List<Integer> billingFailStatusesRaw,
|
||||
@@ -1556,7 +1565,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
if ("SELECTED".equals(scopeMode))
|
||||
{
|
||||
List<String> billIds = normalizeCodeList(billIdsRaw);
|
||||
List<Long> billIds = normalizeIdList(billIdsRaw);
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message(msgSelected));
|
||||
@@ -1624,7 +1633,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return surcharge;
|
||||
}
|
||||
|
||||
private PrcIncomeBillFee requireEditableManualFee(String feeId)
|
||||
private PrcIncomeBillFee requireEditableManualFee(Long feeId)
|
||||
{
|
||||
PrcIncomeBillFee fee = incomeBillFeeMapper.selectByFeeId(feeId);
|
||||
if (fee == null)
|
||||
@@ -1832,13 +1841,13 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult updateCreditArrearsStatus(String billId)
|
||||
public TmsPriceQuoteResult updateCreditArrearsStatus(Long billId)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
@@ -1999,10 +2008,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
assertOrderBillEditable(existed);
|
||||
BigDecimal previousIncome = existed == null ? BigDecimal.ZERO : nz(existed.getIncomeTotal());
|
||||
PrcOrderBill bill = existed == null ? new PrcOrderBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
bill.setBillId(UUID.randomUUID().toString());
|
||||
}
|
||||
bill.setBillKey(billKey);
|
||||
bill.setOrderNo(orderNo);
|
||||
// 上游表头覆盖(不做校验)。
|
||||
@@ -2140,7 +2145,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
bill.setRefundStatus(BillRefundStatus.NONE.getCode());
|
||||
}
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setOrderNo(orderNo);
|
||||
result.setTransferNo(bill.getTransferNo());
|
||||
result.setCustomerId(bill.getCustomerId());
|
||||
@@ -2175,6 +2179,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
// 应付暂不在范围内:跳过 prc_pay_bill_fee 的清理/写入。
|
||||
// payBillFeeMapper.deleteByBillId(bill.getBillId());
|
||||
}
|
||||
result.setBillId(bill.getBillId());
|
||||
PrcIncomeBill incomeBill = null;
|
||||
if (storeIncome)
|
||||
{
|
||||
@@ -2236,9 +2241,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
* 丢弃在 uk_bill_fee_item(bill_id, fee_type, sc_id)上与保留的人工行冲突的自动费用行。
|
||||
* 重算时以人工费用优先。
|
||||
*/
|
||||
private List<PrcIncomeBillFee> filterAutoFeesAgainstManual(String billId, List<PrcIncomeBillFee> autoFees)
|
||||
private List<PrcIncomeBillFee> filterAutoFeesAgainstManual(Long billId, List<PrcIncomeBillFee> autoFees)
|
||||
{
|
||||
if (autoFees == null || autoFees.isEmpty() || StringUtils.isEmpty(billId))
|
||||
if (autoFees == null || autoFees.isEmpty() || billId == null)
|
||||
{
|
||||
return autoFees == null ? new ArrayList<PrcIncomeBillFee>() : autoFees;
|
||||
}
|
||||
@@ -2439,7 +2444,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
private boolean isAlreadyInArBill(PrcOrderBill existed)
|
||||
{
|
||||
if (existed == null || StringUtils.isEmpty(existed.getBillId()))
|
||||
if (existed == null || existed.getBillId() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2462,7 +2467,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return v == null ? BigDecimal.ZERO : v;
|
||||
}
|
||||
|
||||
private List<PrcIncomeBillFee> toFeeRows(String billId, String incomeBillId, TmsPriceQuoteResult result)
|
||||
private List<PrcIncomeBillFee> toFeeRows(Long billId, Long incomeBillId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcIncomeBillFee> fees = new ArrayList<PrcIncomeBillFee>();
|
||||
if (result.getFeeDetails() == null)
|
||||
@@ -2472,7 +2477,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
for (TmsPriceQuoteFeeLine line : result.getFeeDetails())
|
||||
{
|
||||
PrcIncomeBillFee fee = new PrcIncomeBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setIncomeBillId(incomeBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
@@ -2494,7 +2498,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
/** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价,红线价=红线目录价(含 REDLINE 附加费)。 */
|
||||
private PrcIncomeBill persistIncomeBill(PrcOrderBill bill, TmsPriceQuoteResult result)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
if (bill == null || bill.getBillId() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -2503,7 +2507,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcIncomeBill row = existed == null ? new PrcIncomeBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
row.setIncomeBillId(UUID.randomUUID().toString());
|
||||
row.setBillId(bill.getBillId());
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
@@ -2532,7 +2535,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
}
|
||||
|
||||
|
||||
private List<PrcPayBillFee> toPayFeeRows(String billId, String payBillId, TmsPriceQuoteResult result)
|
||||
private List<PrcPayBillFee> toPayFeeRows(Long billId, Long payBillId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcPayBillFee> fees = new ArrayList<PrcPayBillFee>();
|
||||
if (result.getPayFeeDetails() == null)
|
||||
@@ -2542,7 +2545,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
for (TmsPriceQuoteFeeLine line : result.getPayFeeDetails())
|
||||
{
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setPayBillId(payBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
@@ -2560,7 +2562,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
/** 应付主表与订单计费一对一落库;product_amount 取产品目录价、redline_amount 取红线价;应付/成本价留空待接入真实成本源。 */
|
||||
private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
if (bill == null || bill.getBillId() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -2568,7 +2570,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcPayBill row = existed == null ? new PrcPayBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
row.setPayBillId(UUID.randomUUID().toString());
|
||||
row.setBillId(bill.getBillId());
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
@@ -2655,7 +2656,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
/** 仅在存在上游 TAB_ORDER 行时写入 prc_order_bill_ext。 */
|
||||
private void persistBillExt(PrcOrderBill bill, java.util.Map<String, Object> upstreamRow)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
if (bill == null || bill.getBillId() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2680,7 +2681,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
for (PrcIncomeBillFee fee : fees)
|
||||
{
|
||||
TmsPriceQuoteFeeLine line = new TmsPriceQuoteFeeLine();
|
||||
line.setFeeId(fee.getFeeId());
|
||||
line.setFeeId(fee.getFeeId() == null ? null : String.valueOf(fee.getFeeId()));
|
||||
line.setFeeType(fee.getFeeType());
|
||||
line.setFeeName(fee.getFeeName());
|
||||
line.setScId(fee.getScId());
|
||||
@@ -2792,26 +2793,26 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult updateChargeWeight(String billId, BigDecimal chargeWeight)
|
||||
public TmsPriceQuoteResult updateChargeWeight(Long billId, BigDecimal chargeWeight)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
// 通过列表查询做数据范围校验
|
||||
self.getBill(billId.trim());
|
||||
return self.updateChargeWeightByBillId(billId.trim(), chargeWeight);
|
||||
self.getBill(billId);
|
||||
return self.updateChargeWeightByBillId(billId, chargeWeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult updateChargeWeightByBillId(String billId, BigDecimal chargeWeight)
|
||||
public TmsPriceQuoteResult updateChargeWeightByBillId(Long billId, BigDecimal chargeWeight)
|
||||
{
|
||||
if (StringUtils.isEmpty(billId))
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
@@ -3058,7 +3059,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return rows;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult toResult(String billId)
|
||||
private TmsPriceQuoteResult toResult(Long billId)
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
@@ -3220,7 +3221,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
return name;
|
||||
}
|
||||
if (StringUtils.isEmpty(bill.getBillId()) || orderBillExtMapper == null)
|
||||
if (bill.getBillId() == null || orderBillExtMapper == null)
|
||||
{
|
||||
return StringUtils.isNotEmpty(name) ? name : null;
|
||||
}
|
||||
@@ -3264,7 +3265,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncUpstreamOverwrite(java.util.Map<String, Object> upstreamRow)
|
||||
public Long syncUpstreamOverwrite(java.util.Map<String, Object> upstreamRow)
|
||||
{
|
||||
if (upstreamRow == null || upstreamRow.isEmpty())
|
||||
{
|
||||
@@ -3312,7 +3313,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill bill = creating ? new PrcOrderBill() : existed;
|
||||
if (creating)
|
||||
{
|
||||
bill.setBillId(UUID.randomUUID().toString());
|
||||
bill.setArBillStatus(ArOrderBillStatus.UNBILLED.getCode());
|
||||
bill.setRefundStatus(BillRefundStatus.NONE.getCode());
|
||||
// 仅订单来源同步:在报价/计费执行前标记为未计费。
|
||||
@@ -3430,7 +3430,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill bill = existed == null ? new PrcOrderBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
bill.setBillId(UUID.randomUUID().toString());
|
||||
bill.setArBillStatus(ArOrderBillStatus.UNBILLED.getCode());
|
||||
bill.setRefundStatus(BillRefundStatus.NONE.getCode());
|
||||
}
|
||||
|
||||
+23
-10
@@ -38,16 +38,29 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
{
|
||||
return;
|
||||
}
|
||||
LinkedHashSet<String> billIds = new LinkedHashSet<>();
|
||||
LinkedHashSet<Long> billIds = new LinkedHashSet<>();
|
||||
for (int from = 0; from < fees.size(); from += BATCH_SIZE)
|
||||
{
|
||||
List<PrcPayBillFee> chunk = fees.subList(from, Math.min(from + BATCH_SIZE, fees.size()));
|
||||
payBillFeeMapper.insertBatch(chunk);
|
||||
List<Long> ownIds = new ArrayList<>();
|
||||
for (PrcPayBillFee fee : chunk)
|
||||
{
|
||||
if (fee != null && fee.getBillId() != null && !fee.getBillId().isBlank())
|
||||
if (fee != null && fee.getFeeId() != null
|
||||
&& (fee.getSourceId() == null || fee.getSourceId().isBlank()))
|
||||
{
|
||||
billIds.add(fee.getBillId().trim());
|
||||
ownIds.add(fee.getFeeId());
|
||||
}
|
||||
}
|
||||
if (!ownIds.isEmpty())
|
||||
{
|
||||
payBillFeeMapper.fillSourceIdByFeeIds(ownIds);
|
||||
}
|
||||
for (PrcPayBillFee fee : chunk)
|
||||
{
|
||||
if (fee != null && fee.getBillId() != null)
|
||||
{
|
||||
billIds.add(fee.getBillId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,25 +68,25 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshTotals(List<String> billIds)
|
||||
public void refreshTotals(List<Long> billIds)
|
||||
{
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LinkedHashSet<String> unique = new LinkedHashSet<>();
|
||||
for (String billId : billIds)
|
||||
LinkedHashSet<Long> unique = new LinkedHashSet<>();
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
if (billId != null && !billId.isBlank())
|
||||
if (billId != null)
|
||||
{
|
||||
unique.add(billId.trim());
|
||||
unique.add(billId);
|
||||
}
|
||||
}
|
||||
List<String> ids = new ArrayList<>(unique);
|
||||
List<Long> ids = new ArrayList<>(unique);
|
||||
String operator = currentOperator();
|
||||
for (int from = 0; from < ids.size(); from += BATCH_SIZE)
|
||||
{
|
||||
List<String> chunk = ids.subList(from, Math.min(from + BATCH_SIZE, ids.size()));
|
||||
List<Long> chunk = ids.subList(from, Math.min(from + BATCH_SIZE, ids.size()));
|
||||
payBillMapper.insertMissingPayBills(chunk, operator);
|
||||
payBillFeeMapper.bindPayBillId(chunk);
|
||||
payBillMapper.refreshPayTotal(chunk);
|
||||
|
||||
+7
-10
@@ -8,7 +8,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -95,7 +94,7 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
throw new ServiceException(fee.getBillCode() + " " + blankName(fee) + ":" + reason);
|
||||
}
|
||||
}
|
||||
Map<String, String> payBillIds = payBillIds(orders);
|
||||
Map<Long, Long> payBillIds = payBillIds(orders);
|
||||
List<PrcPayBillFee> batch = new ArrayList<>(BATCH_SIZE);
|
||||
int lineCount = 0;
|
||||
for (SrvBillAirAllocFee fee : fees)
|
||||
@@ -168,7 +167,7 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
Map<String, List<SrvBillAirAllocOrder>> grouped = new LinkedHashMap<>();
|
||||
for (SrvBillAirAllocOrder order : allocMapper.selectOrders(codes))
|
||||
{
|
||||
if (order.getBillId() == null || order.getBillId().isBlank())
|
||||
if (order.getBillId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -177,9 +176,9 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
return grouped;
|
||||
}
|
||||
|
||||
private Map<String, String> payBillIds(Map<String, List<SrvBillAirAllocOrder>> orders)
|
||||
private Map<Long, Long> payBillIds(Map<String, List<SrvBillAirAllocOrder>> orders)
|
||||
{
|
||||
List<String> billIds = new ArrayList<>();
|
||||
List<Long> billIds = new ArrayList<>();
|
||||
for (List<SrvBillAirAllocOrder> rows : orders.values())
|
||||
{
|
||||
for (SrvBillAirAllocOrder order : rows)
|
||||
@@ -187,10 +186,10 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
billIds.add(order.getBillId());
|
||||
}
|
||||
}
|
||||
Map<String, String> payIds = new LinkedHashMap<>();
|
||||
Map<Long, Long> payIds = new LinkedHashMap<>();
|
||||
for (int from = 0; from < billIds.size(); from += BATCH_SIZE)
|
||||
{
|
||||
List<String> chunk = billIds.subList(from, Math.min(from + BATCH_SIZE, billIds.size()));
|
||||
List<Long> chunk = billIds.subList(from, Math.min(from + BATCH_SIZE, billIds.size()));
|
||||
for (PrcPayBill payBill : allocMapper.selectPayBills(chunk))
|
||||
{
|
||||
if (payBill.getBillId() != null && payBill.getPayBillId() != null)
|
||||
@@ -231,10 +230,9 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
return "";
|
||||
}
|
||||
|
||||
private PrcPayBillFee toOrderFee(SrvBillAirAllocFee fee, SrvBillAirAllocOrder order, BigDecimal amount, Map<String, String> payBillIds)
|
||||
private PrcPayBillFee toOrderFee(SrvBillAirAllocFee fee, SrvBillAirAllocOrder order, BigDecimal amount, Map<Long, Long> payBillIds)
|
||||
{
|
||||
PrcPayBillFee row = new PrcPayBillFee();
|
||||
row.setFeeId(UUID.randomUUID().toString());
|
||||
row.setBillId(order.getBillId());
|
||||
row.setPayBillId(payBillIds.get(order.getBillId()));
|
||||
String name = blankName(fee);
|
||||
@@ -247,7 +245,6 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
row.setRoundMode("HALF_UP");
|
||||
row.setRemark(remark(fee));
|
||||
row.setFeeSource(FEE_SOURCE);
|
||||
row.setSourceId(fee.getLadingId().trim());
|
||||
row.setIsDeleted("0");
|
||||
return row;
|
||||
}
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
}
|
||||
Operator operator = operator();
|
||||
Date now = DateUtils.getNowDate();
|
||||
List<String> affectedBills = payBillFeeMapper.selectBillIdsByLadingFee(feeId);
|
||||
List<Long> affectedBills = payBillFeeMapper.selectBillIdsByLadingFee(feeId);
|
||||
payBillFeeMapper.markLadingFeeDeleted(feeId);
|
||||
payBillFeeService.refreshTotals(affectedBills);
|
||||
if (feeMapper.voidFee(feeId, code, operator.account, now) != 1)
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class PrcBatchAddIncomeFeeAsyncRunner
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void run(String taskId, List<String> billIds, Long scId, String feeType, BigDecimal amount,
|
||||
public void run(String taskId, List<Long> billIds, Long scId, String feeType, BigDecimal amount,
|
||||
String currency, String remark)
|
||||
{
|
||||
int total = billIds == null ? 0 : billIds.size();
|
||||
@@ -51,7 +51,7 @@ public class PrcBatchAddIncomeFeeAsyncRunner
|
||||
}
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
String billId = billIds.get(i);
|
||||
Long billId = billIds.get(i);
|
||||
try
|
||||
{
|
||||
AddIncomeBillFeeRequest req = new AddIncomeBillFeeRequest();
|
||||
|
||||
+4
-4
@@ -200,7 +200,7 @@ public class PrcChargeWeightImportAsyncRunner
|
||||
public static class ChargeWeightImportWorkItem implements java.io.Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String billId;
|
||||
private Long billId;
|
||||
private String orderNo;
|
||||
private BigDecimal chargeWeight;
|
||||
|
||||
@@ -208,19 +208,19 @@ public class PrcChargeWeightImportAsyncRunner
|
||||
{
|
||||
}
|
||||
|
||||
public ChargeWeightImportWorkItem(String billId, String orderNo, BigDecimal chargeWeight)
|
||||
public ChargeWeightImportWorkItem(Long billId, String orderNo, BigDecimal chargeWeight)
|
||||
{
|
||||
this.billId = billId;
|
||||
this.orderNo = orderNo;
|
||||
this.chargeWeight = chargeWeight;
|
||||
}
|
||||
|
||||
public String getBillId()
|
||||
public Long getBillId()
|
||||
{
|
||||
return billId;
|
||||
}
|
||||
|
||||
public void setBillId(String billId)
|
||||
public void setBillId(Long billId)
|
||||
{
|
||||
this.billId = billId;
|
||||
}
|
||||
|
||||
+13
-13
@@ -74,13 +74,13 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
private PrcOrderBillMapper orderBillMapper;
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void run(String taskId, List<String> billIds)
|
||||
public void run(String taskId, List<Long> billIds)
|
||||
{
|
||||
run(taskId, billIds, null);
|
||||
}
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void run(String taskId, List<String> billIds, LocalRebillRequest request)
|
||||
public void run(String taskId, List<Long> billIds, LocalRebillRequest request)
|
||||
{
|
||||
int total = billIds == null ? 0 : billIds.size();
|
||||
AtomicInteger success = new AtomicInteger(0);
|
||||
@@ -110,7 +110,7 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
return;
|
||||
}
|
||||
// 连续拉取:N 个工作线程取下一个 billId —— 没有分页屏障式空等。
|
||||
final List<String> ids = billIds;
|
||||
final List<Long> ids = billIds;
|
||||
List<Callable<Boolean>> workers = new ArrayList<Callable<Boolean>>(threads);
|
||||
for (int w = 0; w < threads; w++)
|
||||
{
|
||||
@@ -122,7 +122,7 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
{
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
String one = ids.get(i);
|
||||
Long one = ids.get(i);
|
||||
try
|
||||
{
|
||||
TmsPriceQuoteResult result = orderBillService.rebillLocalByBillId(one);
|
||||
@@ -269,12 +269,12 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
TabOrderSyncEsLog.save(billSearchStore, taskId, "LOCAL_REBILL_DONE", request, resp, status, errorMessage);
|
||||
}
|
||||
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, String billId, Exception e)
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, Long billId, Exception e)
|
||||
{
|
||||
collectFailDetail(failDetails, billId, errorMessage(e));
|
||||
}
|
||||
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, String billId, String message)
|
||||
private void collectFailDetail(List<Map<String, Object>> failDetails, Long billId, String message)
|
||||
{
|
||||
if (failDetails == null)
|
||||
{
|
||||
@@ -293,8 +293,8 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
String trackingNo = null;
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper == null || StringUtils.isEmpty(billId)
|
||||
? null : orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper == null || billId == null
|
||||
? null : orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill != null)
|
||||
{
|
||||
orderNo = bill.getOrderNo();
|
||||
@@ -475,19 +475,19 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
}
|
||||
|
||||
/** UI 提示优先用 transferNo;没有则退回 orderNo,再退回 billId。 */
|
||||
private String failTransferLabel(String billId, String transferNoHint)
|
||||
private String failTransferLabel(Long billId, String transferNoHint)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(transferNoHint))
|
||||
{
|
||||
return transferNoHint.trim();
|
||||
}
|
||||
if (StringUtils.isEmpty(billId) || orderBillMapper == null)
|
||||
if (billId == null || orderBillMapper == null)
|
||||
{
|
||||
return billId;
|
||||
return billId == null ? null : String.valueOf(billId);
|
||||
}
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill != null)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(bill.getTransferNo()))
|
||||
@@ -504,7 +504,7 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
{
|
||||
// 提示标签尽力而为
|
||||
}
|
||||
return billId;
|
||||
return billId == null ? null : String.valueOf(billId);
|
||||
}
|
||||
|
||||
private static String softFailMessage(TmsPriceQuoteResult result)
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ public class PrcRecalcBillPriceAsyncRunner
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Async("threadPoolTaskExecutor")
|
||||
public void run(String taskId, String mode, List<String> billIds)
|
||||
public void run(String taskId, String mode, List<Long> billIds)
|
||||
{
|
||||
int total = billIds == null ? 0 : billIds.size();
|
||||
int success = 0;
|
||||
@@ -45,7 +45,7 @@ public class PrcRecalcBillPriceAsyncRunner
|
||||
}
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
String billId = billIds.get(i);
|
||||
Long billId = billIds.get(i);
|
||||
try
|
||||
{
|
||||
orderBillService.recalcBillPriceByBillId(billId, mode);
|
||||
@@ -94,7 +94,7 @@ public class PrcRecalcBillPriceAsyncRunner
|
||||
return redisCache.getCacheObject(CACHE_KEY_PREFIX + taskId);
|
||||
}
|
||||
|
||||
private static void appendFail(StringBuilder failTips, String billId, Exception e)
|
||||
private static void appendFail(StringBuilder failTips, Long billId, Exception e)
|
||||
{
|
||||
if (failTips.length() >= 800)
|
||||
{
|
||||
|
||||
@@ -250,7 +250,7 @@ public class TabOrderSyncAsyncRunner
|
||||
item.put("transferOrderId", vo == null ? null : vo.getTransferOrderId());
|
||||
try
|
||||
{
|
||||
String billId = overwriteOne(one);
|
||||
Long billId = overwriteOne(one);
|
||||
item.put("successStatus", "SUCCESS");
|
||||
item.put("billId", billId);
|
||||
ok.incrementAndGet();
|
||||
@@ -317,7 +317,7 @@ public class TabOrderSyncAsyncRunner
|
||||
}
|
||||
|
||||
/** 解析出 Oracle 行后覆盖本地账单及其扩展信息(不计费)。 */
|
||||
private String overwriteOne(com.bms.price.oracle.TabOrderRow row)
|
||||
private Long overwriteOne(com.bms.price.oracle.TabOrderRow row)
|
||||
{
|
||||
Map<String, Object> raw = row == null ? null : row.getRaw();
|
||||
TabOrderMonitorVo vo = row == null ? null : row.getVo();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ArBillDetail implements Serializable {
|
||||
|
||||
private Long detailId;
|
||||
private Long arBillId;
|
||||
private String prcOrderBillId;
|
||||
private Long prcOrderBillId;
|
||||
private Integer detailNo;
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ArBillDetailFee implements Serializable {
|
||||
|
||||
private Long detailFeeId;
|
||||
private Long detailId;
|
||||
private String prcIncomeBillFeeId;
|
||||
private Long prcIncomeBillFeeId;
|
||||
private Integer feeNo;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ArBillGenerateTask implements Serializable {
|
||||
/**
|
||||
* 按 bill_id 字典序处理的游标。
|
||||
*/
|
||||
private String lastSourceBillId;
|
||||
private Long lastSourceBillId;
|
||||
/**
|
||||
* 待处理总数;全选模式统计完成前使用 -1。
|
||||
*/
|
||||
|
||||
+2
-2
@@ -29,11 +29,11 @@ public class ArBillGenerateRequest
|
||||
/** 截止日筛选字段:BIZ_DATE=计费时间,PICKUP_DATE=收货时间;历史任务默认计费时间。 */
|
||||
private String dateType = "BIZ_DATE";
|
||||
/** 手动模式选中的来源订单 ID;全选模式为空。 */
|
||||
private List<String> sourceBillIds;
|
||||
private List<Long> sourceBillIds;
|
||||
/** 选择模式:EXPLICIT 手动选择,ALL_MATCHED 全选查询结果。 */
|
||||
private String selectionMode = ArBillSelectionMode.EXPLICIT.getCode();
|
||||
/** 全选模式中用户明确排除的来源订单 ID。 */
|
||||
private List<String> excludedSourceBillIds;
|
||||
private List<Long> excludedSourceBillIds;
|
||||
/** 全选模式下按订单号、运单号或转单号排除;后台生成任务按批次应用该条件。 */
|
||||
private String excludedOrderOrTrackingNo;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface ArBillDetailMapper {
|
||||
List<ArBillDetail> selectByBillId(Long arBillId);
|
||||
|
||||
List<ArBillDetail> selectByBillIdAndSourceIds(@Param("arBillId") Long arBillId,
|
||||
@Param("sourceBillIds") List<String> sourceBillIds);
|
||||
@Param("sourceBillIds") List<Long> sourceBillIds);
|
||||
|
||||
List<ArBillDetail> selectExportPage(@Param("arBillId") Long arBillId,
|
||||
@Param("lastDetailNo") Integer lastDetailNo, @Param("pageSize") Integer pageSize);
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public interface ArBillGenerateTaskMapper {
|
||||
|
||||
int updateTotalCount(@Param("taskId") Long taskId, @Param("totalCount") Integer totalCount);
|
||||
|
||||
int updateProgress(@Param("taskId") Long taskId, @Param("lastSourceBillId") String lastSourceBillId,
|
||||
int updateProgress(@Param("taskId") Long taskId, @Param("lastSourceBillId") Long lastSourceBillId,
|
||||
@Param("processedCount") Integer processedCount, @Param("successCount") Integer successCount,
|
||||
@Param("totalAmount") java.math.BigDecimal totalAmount, @Param("heartbeatTime") Date heartbeatTime);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.bms.receivable.security.ArBillRowScope;
|
||||
import com.bms.customer.customerinfo.domain.BmsCustomerOption;
|
||||
|
||||
public interface ArBillScopeMapper {
|
||||
int countCustomerSourceBills(@Param("customerId") Long customerId, @Param("sourceIds") List<String> sourceIds);
|
||||
int countCustomerSourceBills(@Param("customerId") Long customerId, @Param("sourceIds") List<Long> sourceIds);
|
||||
|
||||
int countAccessibleBill(@Param("arBillId") Long arBillId, @Param("scope") ArBillRowScope scope);
|
||||
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ public class ArBillScopeResolver {
|
||||
return mapper.selectCustomerOptions(values, resolve());
|
||||
}
|
||||
|
||||
public void requireCustomerSourceBills(Long customerId, List<String> sourceIds) {
|
||||
public void requireCustomerSourceBills(Long customerId, List<Long> sourceIds) {
|
||||
if (!sourceIds.isEmpty() && withoutPagination(() -> mapper.countCustomerSourceBills(customerId, sourceIds)) != sourceIds.size()) {
|
||||
throw new ServiceException("所选订单不存在或不属于当前客户");
|
||||
}
|
||||
|
||||
+18
-18
@@ -419,8 +419,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
String selectionMode = selectionModeEnum.getCode();
|
||||
boolean allMatched = selectionModeEnum == ArBillSelectionMode.ALL_MATCHED;
|
||||
List<String> sourceBillIds = normalizeSourceBillIds(request.getSourceBillIds());
|
||||
List<String> excludedSourceBillIds = normalizeSourceBillIds(request.getExcludedSourceBillIds());
|
||||
List<Long> sourceBillIds = normalizeSourceBillIds(request.getSourceBillIds());
|
||||
List<Long> excludedSourceBillIds = normalizeSourceBillIds(request.getExcludedSourceBillIds());
|
||||
if (!allMatched && sourceBillIds.isEmpty()) {
|
||||
throw failure(null, ArLogObjectType.BILL, "", ArLogOperationType.GENERATE,
|
||||
null, "请至少选择一条有效订单", operator, requestId);
|
||||
@@ -638,8 +638,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
log.info("开始执行应收账单生成任务,taskId={}, arBillId={}, selectionMode={}",
|
||||
taskId, task.getArBillId(), task.getSelectionMode());
|
||||
ArBillGenerateRequest request = JSON.parseObject(task.getRequestPayload(), ArBillGenerateRequest.class);
|
||||
List<String> sourceBillIds = normalizeSourceBillIds(request.getSourceBillIds());
|
||||
List<String> excludedSourceBillIds = normalizeSourceBillIds(request.getExcludedSourceBillIds());
|
||||
List<Long> sourceBillIds = normalizeSourceBillIds(request.getSourceBillIds());
|
||||
List<Long> excludedSourceBillIds = normalizeSourceBillIds(request.getExcludedSourceBillIds());
|
||||
List<String> excludedOrderIdentifiers = ArBillSelectionMode.ALL_MATCHED.getCode().equals(task.getSelectionMode())
|
||||
? normalizeOrderIdentifiers(request.getExcludedOrderOrTrackingNo()) : new ArrayList<>();
|
||||
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
@@ -766,13 +766,13 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
* 每批最多 GENERATE_PAGE_SIZE 条,成功后原子更新任务进度。
|
||||
*/
|
||||
private GenerateBatchResult processGenerateBatch(ArBillGenerateTask task, ArBillGenerateRequest request,
|
||||
List<String> sourceBillIds, List<String> excludedSourceBillIds,
|
||||
List<Long> sourceBillIds, List<Long> excludedSourceBillIds,
|
||||
List<String> excludedOrderIdentifiers) {
|
||||
ArBillSelectionMode selectionMode = ArBillSelectionMode.of(task.getSelectionMode());
|
||||
if (selectionMode == null) {
|
||||
throw new ServiceException("账单生成任务的订单选择模式无效");
|
||||
}
|
||||
List<String> explicitIds = selectionMode == ArBillSelectionMode.EXPLICIT
|
||||
List<Long> explicitIds = selectionMode == ArBillSelectionMode.EXPLICIT
|
||||
? sourceBillIds : null;
|
||||
List<PrcOrderBill> sources = sourceBillMapper.selectPrcOrderBillByCustomerPeriodCursor(
|
||||
request.getCustomerId(), request.getCustomerCode(),
|
||||
@@ -792,7 +792,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
if (bill == null) {
|
||||
throw new ServiceException("应收账单不存在");
|
||||
}
|
||||
List<String> currentSourceBillIds = new ArrayList<>();
|
||||
List<Long> currentSourceBillIds = new ArrayList<>();
|
||||
for (PrcOrderBill source : sources) {
|
||||
currentSourceBillIds.add(source.getBillId());
|
||||
if (source.getCurrency() != null && !bill.getCurrency().equalsIgnoreCase(source.getCurrency())) {
|
||||
@@ -800,7 +800,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, PrcIncomeBill> sourceIncomeBillsByBillId = new HashMap<>();
|
||||
Map<Long, PrcIncomeBill> sourceIncomeBillsByBillId = new HashMap<>();
|
||||
List<PrcIncomeBill> sourceIncomeBills = sourceIncomeBillMapper.selectByBillIds(currentSourceBillIds);
|
||||
if (sourceIncomeBills != null) {
|
||||
for (PrcIncomeBill sourceIncomeBill : sourceIncomeBills) {
|
||||
@@ -814,8 +814,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
if (sourceFees == null) {
|
||||
sourceFees = new ArrayList<>();
|
||||
}
|
||||
Map<String, Integer> sourceFeeCounts = new HashMap<>();
|
||||
List<String> sourceFeeIds = new ArrayList<>(sourceFees.size());
|
||||
Map<Long, Integer> sourceFeeCounts = new HashMap<>();
|
||||
List<Long> sourceFeeIds = new ArrayList<>(sourceFees.size());
|
||||
for (PrcIncomeBillFee sourceFee : sourceFees) {
|
||||
sourceFeeCounts.merge(sourceFee.getBillId(), 1, Integer::sum);
|
||||
sourceFeeIds.add(sourceFee.getFeeId());
|
||||
@@ -853,7 +853,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
// 失败订单先落快照,再汇总占用状态,避免无费用订单被错误恢复为 UNBILLED。
|
||||
sourceBillMapper.refreshArBillStatusByBillIds(currentSourceBillIds);
|
||||
|
||||
Map<String, ArBillDetail> detailsBySourceBill = new HashMap<>();
|
||||
Map<Long, ArBillDetail> detailsBySourceBill = new HashMap<>();
|
||||
for (ArBillDetail detail : detailMapper.selectByBillIdAndSourceIds(bill.getArBillId(), currentSourceBillIds)) {
|
||||
detailsBySourceBill.put(detail.getPrcOrderBillId(), detail);
|
||||
}
|
||||
@@ -862,7 +862,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
|
||||
List<ArBillDetailFee> detailFees = new ArrayList<>(sourceFees == null ? 0 : sourceFees.size());
|
||||
Map<String, Integer> feeNumbers = new HashMap<>();
|
||||
Map<Long, Integer> feeNumbers = new HashMap<>();
|
||||
if (sourceFees != null) {
|
||||
for (PrcIncomeBillFee sourceFee : sourceFees) {
|
||||
ArBillDetail detail = detailsBySourceBill.get(sourceFee.getBillId());
|
||||
@@ -886,7 +886,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
Date periodStart = earliestDate(sources, request.getDateType());
|
||||
billMapper.updateArBillProgress(bill.getArBillId(), processedCount, totalAmount, totalAmount,
|
||||
periodStart, task.getCreateBy());
|
||||
String lastSourceBillId = sources.get(sources.size() - 1).getBillId();
|
||||
Long lastSourceBillId = sources.get(sources.size() - 1).getBillId();
|
||||
if (generateTaskMapper.updateProgress(task.getTaskId(), lastSourceBillId, processedCount,
|
||||
processedCount, totalAmount, new Date()) != 1) {
|
||||
throw new ServiceException("账单生成任务状态已发生变化,请稍后重试");
|
||||
@@ -2312,12 +2312,12 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
return type.getCode();
|
||||
}
|
||||
|
||||
private List<String> normalizeSourceBillIds(List<String> sourceBillIds) {
|
||||
LinkedHashSet<String> uniqueIds = new LinkedHashSet<>();
|
||||
private List<Long> normalizeSourceBillIds(List<Long> sourceBillIds) {
|
||||
LinkedHashSet<Long> uniqueIds = new LinkedHashSet<>();
|
||||
if (sourceBillIds != null) {
|
||||
for (String billId : sourceBillIds) {
|
||||
if (!StringUtils.isEmpty(billId) && billId.trim().length() <= 36) {
|
||||
uniqueIds.add(billId.trim());
|
||||
for (Long billId : sourceBillIds) {
|
||||
if (billId != null) {
|
||||
uniqueIds.add(billId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectByProductIdAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select m.id,
|
||||
m.channel_id as channelId,
|
||||
m.channel_code as channelCode,
|
||||
coalesce(nullif(m.channel_code, ''), c.channel_code) as channelCode,
|
||||
m.product_id as productId,
|
||||
c.channel_name as channelName,
|
||||
m.pay_type as payType,
|
||||
@@ -28,13 +28,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join srv_service_channel c on c.id = m.channel_id
|
||||
where m.product_id = #{productId}
|
||||
and m.pay_type = #{payType}
|
||||
order by m.channel_code asc, m.channel_id asc
|
||||
order by coalesce(nullif(m.channel_code, ''), c.channel_code) asc, m.channel_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectByProductIdsAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select m.id,
|
||||
m.channel_id as channelId,
|
||||
m.channel_code as channelCode,
|
||||
coalesce(nullif(m.channel_code, ''), c.channel_code) as channelCode,
|
||||
m.product_id as productId,
|
||||
c.channel_name as channelName,
|
||||
m.pay_type as payType,
|
||||
@@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
order by m.product_id asc, m.channel_code asc, m.channel_id asc
|
||||
order by m.product_id asc, coalesce(nullif(m.channel_code, ''), c.channel_code) asc, m.channel_id asc
|
||||
</select>
|
||||
|
||||
<insert id="upsert">
|
||||
@@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
on duplicate key update
|
||||
channel_code = values(channel_code),
|
||||
product_id = values(product_id),
|
||||
create_by = ifnull(create_by, values(create_by)),
|
||||
update_by = values(update_by),
|
||||
update_time = sysdate()
|
||||
</insert>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
select 1 from pay_bill_line l
|
||||
inner join pay_bill b on b.bill_id = l.bill_id
|
||||
where l.order_bill_id = o.bill_id
|
||||
and (l.fee_id is null or l.fee_id = '')
|
||||
and l.fee_id is null
|
||||
and b.status not in ('VOID', 'RED')
|
||||
)) as unbilledCount,
|
||||
(select b.bill_no from pay_bill_line l
|
||||
@@ -240,7 +240,7 @@
|
||||
select 1 from pay_bill_line l
|
||||
inner join pay_bill b on b.bill_id = l.bill_id
|
||||
where l.order_bill_id = f.bill_id
|
||||
and (l.fee_id is null or l.fee_id = '')
|
||||
and l.fee_id is null
|
||||
and b.status not in ('VOID', 'RED')
|
||||
)
|
||||
order by f.bill_id, f.fee_id
|
||||
|
||||
@@ -50,18 +50,292 @@
|
||||
order by block_title asc
|
||||
</select>
|
||||
|
||||
<select id="selectLineList" parameterType="com.bms.price.domain.PayPostcodeLine" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
|
||||
region_name as regionName, region_name_cn as regionNameCn, city_name as cityName, region_code as regionCode,
|
||||
zone_name as zoneName, postcode, postcode_raw as postcodeRaw, postcode_end as postcodeEnd,
|
||||
extra_text as extraText, sort_no as sortNo
|
||||
from pay_postcode_line
|
||||
<sql id="countryMatch">
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(trim(g.country_code)) = upper(trim(#{countryCode}))
|
||||
</when>
|
||||
<otherwise>
|
||||
and (g.country_code is null or trim(g.country_code) = '')
|
||||
and g.country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="zoneExpr">
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
</sql>
|
||||
|
||||
<select id="selectCountryList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select min(g.group_id) as groupId,
|
||||
max(g.country_name) as countryName,
|
||||
max(g.country_code) as countryCode,
|
||||
group_concat(distinct nullif(trim(g.coverage), '') order by g.coverage separator '、') as coverage,
|
||||
group_concat(distinct nullif(trim(g.service_type), '') order by g.service_type separator '、') as serviceType,
|
||||
group_concat(distinct nullif(trim(g.product_name), '') order by g.product_name separator '、') as productName,
|
||||
group_concat(distinct nullif(trim(g.channel_name), '') order by g.channel_name separator '、') as channelName,
|
||||
count(distinct
|
||||
case
|
||||
when l.line_id is not null then
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else null
|
||||
end
|
||||
) as zoneCount,
|
||||
count(l.line_id) as lineCount,
|
||||
max(g.create_time) as createTime
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<if test="groupId != null">and group_id = #{groupId}</if>
|
||||
<if test="postcode != null and postcode != ''">and postcode like concat('%', #{postcode}, '%')</if>
|
||||
<if test="regionName != null and regionName != ''">and (region_name like concat('%', #{regionName}, '%') or region_name_cn like concat('%', #{regionName}, '%') or zone_name like concat('%', #{regionName}, '%'))</if>
|
||||
<if test="countryName != null and countryName != ''">
|
||||
and (g.country_name like concat('%', #{countryName}, '%') or g.country_code like concat('%', #{countryName}, '%') or g.catalog_country like concat('%', #{countryName}, '%'))
|
||||
</if>
|
||||
<if test="serviceType != null and serviceType != ''">and g.service_type like concat('%', #{serviceType}, '%')</if>
|
||||
<if test="productName != null and productName != ''">and g.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="channelName != null and channelName != ''">and g.channel_name like concat('%', #{channelName}, '%')</if>
|
||||
<if test="coverage != null and coverage != ''">and g.coverage = #{coverage}</if>
|
||||
<if test="postcode != null and postcode != ''">
|
||||
and exists (
|
||||
select 1 from pay_postcode_line lp
|
||||
where lp.group_id = g.group_id and lp.postcode like concat('%', #{postcode}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by sort_no asc, line_id asc
|
||||
group by case
|
||||
when nullif(trim(g.country_code), '') is not null then upper(trim(g.country_code))
|
||||
when nullif(trim(g.country_name), '') is not null then trim(g.country_name)
|
||||
else '未填写国家'
|
||||
end
|
||||
order by max(g.create_time) desc
|
||||
</select>
|
||||
|
||||
<select id="selectZoneList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select t.zone_name as zoneName,
|
||||
min(t.group_id) as groupId,
|
||||
group_concat(distinct nullif(trim(t.coverage), '') order by t.coverage separator '、') as coverage,
|
||||
count(t.line_id) as lineCount,
|
||||
max(t.country_name) as countryName,
|
||||
max(t.country_code) as countryCode
|
||||
from (
|
||||
select g.group_id, g.coverage, g.country_name, g.country_code, l.line_id,
|
||||
case
|
||||
when l.line_id is null then nullif(trim(g.block_title), '')
|
||||
else
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
end as zone_name
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
) t
|
||||
where t.zone_name is not null and t.zone_name <> ''
|
||||
group by t.zone_name
|
||||
order by t.zone_name asc
|
||||
</select>
|
||||
|
||||
<select id="selectSampleGroup" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, source_file as sourceFile, file_md5 as fileMd5, sheet_name as sheetName,
|
||||
block_title as blockTitle, config_kind as configKind, coverage, channel_name as channelName,
|
||||
country_name as countryName, country_code as countryCode,
|
||||
service_type as serviceType, catalog_country as catalogCountry, product_name as productName, quote_sheet as quoteSheet
|
||||
from pay_postcode_group g
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
order by g.group_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="countZoneName" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="int">
|
||||
select count(*) from (
|
||||
select 1
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
(l.line_id is null and trim(g.block_title) = #{zoneName})
|
||||
or (l.line_id is not null and <include refid="zoneExpr"/> = #{zoneName})
|
||||
)
|
||||
</where>
|
||||
limit 1
|
||||
) hit
|
||||
</select>
|
||||
|
||||
<select id="selectZoneGroupId" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="long">
|
||||
select g.group_id
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
(g.source_file = '手工新增' and trim(g.block_title) = #{zoneName})
|
||||
or (l.line_id is not null and <include refid="zoneExpr"/> = #{zoneName})
|
||||
)
|
||||
</where>
|
||||
order by case when g.source_file = '手工新增' and trim(g.block_title) = #{zoneName} then 0 else 1 end, g.group_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateCountryProfile" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_group g
|
||||
set g.service_type = #{serviceType},
|
||||
g.product_name = #{productName},
|
||||
g.channel_name = #{channelName}
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<select id="selectGroupIdsByCountry" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="long">
|
||||
select g.group_id from pay_postcode_group g
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="renameZoneLines" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_line l
|
||||
inner join pay_postcode_group g on g.group_id = l.group_id
|
||||
set l.zone_name = #{zoneName}
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and <include refid="zoneExpr"/> = #{oldZoneName}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="updateExclusiveZone" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_group g
|
||||
set g.block_title = case
|
||||
when trim(g.block_title) = #{oldZoneName} or g.source_file = '手工新增' then #{zoneName}
|
||||
else g.block_title
|
||||
end,
|
||||
g.coverage = #{coverage},
|
||||
g.fee_name = case
|
||||
when #{coverage} = 'REMOTE' and (g.fee_name is null or trim(g.fee_name) = '') then '偏远'
|
||||
else g.fee_name
|
||||
end
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
trim(g.block_title) = #{oldZoneName}
|
||||
or (
|
||||
exists (
|
||||
select 1 from pay_postcode_line l
|
||||
where l.group_id = g.group_id and <include refid="zoneExpr"/> = #{zoneName}
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_postcode_line l
|
||||
where l.group_id = g.group_id and <include refid="zoneExpr"/> <> #{zoneName}
|
||||
)
|
||||
)
|
||||
)
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<insert id="insertLine" parameterType="com.bms.price.domain.PayPostcodeLine" useGeneratedKeys="true" keyProperty="lineId">
|
||||
insert into pay_postcode_line (
|
||||
group_id, country_name, country_code, region_name, region_name_cn, city_name, region_code,
|
||||
zone_name, postcode, postcode_raw, postcode_end, extra_text, sort_no
|
||||
) values (
|
||||
#{groupId}, #{countryName}, #{countryCode}, #{regionName}, #{regionNameCn}, #{cityName}, #{regionCode},
|
||||
#{zoneName}, #{postcode}, #{postcodeRaw}, #{postcodeEnd}, #{extraText}, ifnull(#{sortNo}, 0)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateLine" parameterType="com.bms.price.domain.PayPostcodeLine">
|
||||
update pay_postcode_line
|
||||
set city_name = #{cityName},
|
||||
zone_name = #{zoneName},
|
||||
postcode = #{postcode},
|
||||
postcode_raw = #{postcodeRaw},
|
||||
postcode_end = #{postcodeEnd}
|
||||
where line_id = #{lineId}
|
||||
</update>
|
||||
|
||||
<select id="selectLineById" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
|
||||
city_name as cityName, zone_name as zoneName, postcode, postcode_raw as postcodeRaw, postcode_end as postcodeEnd
|
||||
from pay_postcode_line
|
||||
where line_id = #{lineId}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupIdsByLineIds" resultType="long">
|
||||
select distinct group_id from pay_postcode_line
|
||||
where line_id in
|
||||
<foreach collection="lineIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteLineByIds">
|
||||
delete from pay_postcode_line where line_id in
|
||||
<foreach collection="lineIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteLinesByZone" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
delete l from pay_postcode_line l
|
||||
inner join pay_postcode_group g on g.group_id = l.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and <include refid="zoneExpr"/> = #{zoneName}
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<update id="refreshLineCount">
|
||||
update pay_postcode_group g
|
||||
set g.line_count = (select count(*) from pay_postcode_line l where l.group_id = g.group_id)
|
||||
where g.group_id = #{groupId}
|
||||
</update>
|
||||
|
||||
<select id="selectLineList" parameterType="com.bms.price.domain.PayPostcodeLine" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select l.line_id as lineId, l.group_id as groupId, l.country_name as countryName, l.country_code as countryCode,
|
||||
l.region_name as regionName, l.region_name_cn as regionNameCn, l.city_name as cityName, l.region_code as regionCode,
|
||||
l.zone_name as zoneName, l.postcode, l.postcode_raw as postcodeRaw, l.postcode_end as postcodeEnd,
|
||||
l.extra_text as extraText, l.sort_no as sortNo
|
||||
from pay_postcode_line l
|
||||
<where>
|
||||
<if test="groupId != null">and l.group_id = #{groupId}</if>
|
||||
<if test="postcode != null and postcode != ''">and l.postcode like concat('%', #{postcode}, '%')</if>
|
||||
<if test="regionName != null and regionName != ''">and (l.region_name like concat('%', #{regionName}, '%') or l.region_name_cn like concat('%', #{regionName}, '%') or l.zone_name like concat('%', #{regionName}, '%') or l.city_name like concat('%', #{regionName}, '%'))</if>
|
||||
<if test="zoneName != null and zoneName != ''">
|
||||
and (
|
||||
trim(l.zone_name) = #{zoneName}
|
||||
or ((l.zone_name is null or trim(l.zone_name) = '') and trim(l.region_name) = #{zoneName})
|
||||
or (
|
||||
(l.zone_name is null or trim(l.zone_name) = '')
|
||||
and (l.region_name is null or trim(l.region_name) = '')
|
||||
and l.group_id in (select g.group_id from pay_postcode_group g where trim(g.block_title) = #{zoneName})
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
and l.group_id in (
|
||||
select g.group_id from pay_postcode_group g where upper(trim(g.country_code)) = upper(trim(#{countryCode}))
|
||||
)
|
||||
</if>
|
||||
<if test="(countryCode == null or countryCode == '') and countryName != null and countryName != ''">
|
||||
and l.group_id in (
|
||||
select g.group_id from pay_postcode_group g
|
||||
where (g.country_code is null or trim(g.country_code) = '') and g.country_name = #{countryName}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by l.sort_no asc, l.line_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertGroup" parameterType="com.bms.price.domain.PayPostcodeGroup" useGeneratedKeys="true" keyProperty="groupId">
|
||||
@@ -134,6 +408,30 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectRemoteGroupsByCountry" 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,
|
||||
config_kind as configKind, coverage, fee_name as feeName, fee_text as feeText,
|
||||
country_name as countryName, country_code as countryCode
|
||||
from pay_postcode_group
|
||||
where (
|
||||
upper(ifnull(coverage, '')) = 'REMOTE'
|
||||
or ifnull(fee_name, '') like '%偏远%'
|
||||
or lower(ifnull(fee_name, '')) like '%remote%'
|
||||
)
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(trim(country_code)) = upper(trim(#{countryCode}))
|
||||
</when>
|
||||
<when test="countryName != null and countryName != ''">
|
||||
and trim(country_name) = trim(#{countryName})
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</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,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PaySurchargeRuleLogMapper">
|
||||
|
||||
<select id="selectByTerm" resultType="com.bms.price.domain.PaySurchargeRuleLog">
|
||||
select log_id as logId, product_id as productId, term_id as termId, version_no as versionNo,
|
||||
operation_type as operationType, rule_key as ruleKey, change_content as changeContent,
|
||||
create_by as createBy, create_time as createTime
|
||||
from pay_surcharge_rule_log
|
||||
where product_id = #{productId}
|
||||
and term_id = #{termId}
|
||||
order by log_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectByProductIds" resultType="com.bms.price.domain.PaySurchargeRuleLog">
|
||||
select log_id as logId, product_id as productId, term_id as termId, version_no as versionNo,
|
||||
operation_type as operationType, rule_key as ruleKey, change_content as changeContent,
|
||||
create_by as createBy, create_time as createTime
|
||||
from pay_surcharge_rule_log
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by log_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into pay_surcharge_rule_log (
|
||||
product_id, term_id, version_no, operation_type, rule_key, change_content, create_by, create_time
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, #{row.termId}, #{row.versionNo}, #{row.operationType}, #{row.ruleKey},
|
||||
#{row.changeContent}, #{row.createBy}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -12,12 +12,27 @@
|
||||
order by calc_rule, sort_no, rule_id
|
||||
</select>
|
||||
|
||||
<select id="selectByProductId" resultType="com.bms.price.domain.PaySurchargeRule">
|
||||
select rule_id as ruleId, product_id as productId, term_id as termId, version_no as versionNo,
|
||||
calc_rule as calcRule, enabled, calc_param as calcParam, rule_detail as ruleDetail, postcode_param as postcodeParam,
|
||||
zone_name as zoneName, weight_min as weightMin, weight_max as weightMax, sort_no as sortNo
|
||||
from pay_surcharge_rule
|
||||
where product_id = #{productId}
|
||||
order by calc_rule, sort_no, rule_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteByTerm">
|
||||
delete from pay_surcharge_rule
|
||||
where product_id = #{productId}
|
||||
and term_id = #{termId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductIds">
|
||||
delete from pay_surcharge_rule
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into pay_surcharge_rule (
|
||||
product_id, term_id, version_no, calc_rule, enabled, calc_param, rule_detail, postcode_param,
|
||||
@@ -29,18 +44,4 @@
|
||||
#{row.createBy}, sysdate(), #{row.updateBy}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectPreviousVersion" resultType="com.bms.price.domain.PaySurchargeRule">
|
||||
select v.product_id as productId, t.term_id as termId, ifnull(v.version_no, 1) as versionNo
|
||||
from pay_product cur
|
||||
join pay_product v on v.dict_value = cur.dict_value
|
||||
and v.dict_value is not null and v.dict_value <> ''
|
||||
and v.product_id <> cur.product_id
|
||||
and (v.channel_id is null or v.channel_id = '')
|
||||
and ifnull(v.version_no, 1) < ifnull(cur.version_no, 1)
|
||||
join pay_product_term t on t.product_id = v.product_id and t.price_set_id is null
|
||||
where cur.product_id = #{productId}
|
||||
order by ifnull(v.version_no, 1) desc, t.term_id desc
|
||||
limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcIncomeBillFeeResult">
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcIncomeBillFeeResult">
|
||||
select fee_id, bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
ar_bill_status, manual_flag, create_time
|
||||
from prc_income_bill_fee
|
||||
@@ -53,7 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by bill_id, field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectByFeeId" parameterType="String" resultMap="PrcIncomeBillFeeResult">
|
||||
<select id="selectByFeeId" parameterType="Long" resultMap="PrcIncomeBillFeeResult">
|
||||
select fee_id, bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
ar_bill_status, manual_flag, create_time
|
||||
from prc_income_bill_fee
|
||||
@@ -78,23 +78,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and fee_type = #{feeType}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcIncomeBillFee" parameterType="PrcIncomeBillFee">
|
||||
<insert id="insertPrcIncomeBillFee" parameterType="PrcIncomeBillFee" useGeneratedKeys="true" keyProperty="feeId">
|
||||
insert into prc_income_bill_fee (
|
||||
fee_id, bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
ar_bill_status, manual_flag, create_time
|
||||
) values (
|
||||
#{feeId}, #{billId}, #{incomeBillId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{productAmount}, #{redlineAmount}, #{currency}, #{roundMode}, #{remark},
|
||||
#{billId}, #{incomeBillId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{productAmount}, #{redlineAmount}, #{currency}, #{roundMode}, #{remark},
|
||||
#{arBillStatus}, #{manualFlag}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="feeId">
|
||||
insert into prc_income_bill_fee (
|
||||
fee_id, bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
bill_id, income_bill_id, fee_type, fee_name, sc_id, amount, product_amount, redline_amount, currency, round_mode, remark,
|
||||
ar_bill_status, manual_flag, create_time
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.feeId}, #{item.billId}, #{item.incomeBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.amount},
|
||||
(#{item.billId}, #{item.incomeBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.amount},
|
||||
#{item.productAmount}, #{item.redlineAmount},
|
||||
#{item.currency}, #{item.roundMode}, #{item.remark},
|
||||
#{item.arBillStatus}, #{item.manualFlag}, sysdate())
|
||||
@@ -173,15 +173,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</update>
|
||||
|
||||
<delete id="deleteByFeeId" parameterType="String">
|
||||
<delete id="deleteByFeeId" parameterType="Long">
|
||||
delete from prc_income_bill_fee where fee_id = #{feeId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_income_bill_fee where bill_id = #{billId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAutoFeesByBillId" parameterType="String">
|
||||
<delete id="deleteAutoFeesByBillId" parameterType="Long">
|
||||
delete from prc_income_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and (manual_flag is null or manual_flag <> '1')
|
||||
|
||||
@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from prc_income_bill
|
||||
</sql>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcIncomeBillResult">
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcIncomeBillResult">
|
||||
<include refid="selectPrcIncomeBillVo"/>
|
||||
where bill_id = #{billId}
|
||||
</select>
|
||||
@@ -44,19 +44,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectByIncomeBillId" parameterType="String" resultMap="PrcIncomeBillResult">
|
||||
<select id="selectByIncomeBillId" parameterType="Long" resultMap="PrcIncomeBillResult">
|
||||
<include refid="selectPrcIncomeBillVo"/>
|
||||
where income_bill_id = #{incomeBillId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcIncomeBill" parameterType="PrcIncomeBill">
|
||||
<insert id="insertPrcIncomeBill" parameterType="PrcIncomeBill" useGeneratedKeys="true" keyProperty="incomeBillId">
|
||||
insert into prc_income_bill (
|
||||
income_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
bill_id, currency, product_amount, redline_amount,
|
||||
sales_amount, income_total, refund_status,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time
|
||||
) values (
|
||||
#{incomeBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{salesAmount}, #{incomeTotal}, #{refundStatus},
|
||||
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
||||
#{createBy}, sysdate()
|
||||
@@ -80,14 +80,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<insert id="upsertPrcIncomeBill" parameterType="PrcIncomeBill">
|
||||
<insert id="upsertPrcIncomeBill" parameterType="PrcIncomeBill" useGeneratedKeys="true" keyProperty="incomeBillId">
|
||||
insert into prc_income_bill (
|
||||
income_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
bill_id, currency, product_amount, redline_amount,
|
||||
sales_amount, income_total, refund_status,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time
|
||||
) values (
|
||||
#{incomeBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{salesAmount}, #{incomeTotal}, #{refundStatus},
|
||||
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
||||
#{createBy}, sysdate()
|
||||
@@ -107,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update_time = sysdate()
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_income_bill where bill_id = #{billId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -189,7 +189,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from prc_order_bill_ext
|
||||
</sql>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcOrderBillExtResult">
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcOrderBillExtResult">
|
||||
<include refid="selectPrcOrderBillExtVo"/>
|
||||
where bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
@@ -157,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 2
|
||||
</select>
|
||||
|
||||
<select id="selectPrcOrderBillById" parameterType="String" resultMap="PrcOrderBillResult">
|
||||
<select id="selectPrcOrderBillById" parameterType="Long" resultMap="PrcOrderBillResult">
|
||||
<include refid="selectPrcOrderBillVo"/>
|
||||
where bill_id = #{billId}
|
||||
</select>
|
||||
@@ -578,7 +578,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<!-- Id-only for large local rebill (avoid loading full rows into memory). -->
|
||||
<select id="selectPrcOrderBillIds" parameterType="PrcOrderBill" resultType="string">
|
||||
<select id="selectPrcOrderBillIds" parameterType="PrcOrderBill" resultType="java.lang.Long">
|
||||
select p.bill_id
|
||||
from prc_order_bill p
|
||||
<where>
|
||||
@@ -785,7 +785,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectPrcOrderBillByCustomerPeriodCursor" resultMap="PrcOrderBillArSourceResult">
|
||||
<include refid="selectArBillSourceVo"/>
|
||||
<include refid="customerPeriodConditions"/>
|
||||
<if test="lastSourceBillId != null and lastSourceBillId != ''">
|
||||
<if test="lastSourceBillId != null">
|
||||
and p.bill_id > #{lastSourceBillId}
|
||||
</if>
|
||||
order by p.bill_id
|
||||
@@ -829,9 +829,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcOrderBill" parameterType="PrcOrderBill">
|
||||
<insert id="insertPrcOrderBill" parameterType="PrcOrderBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
insert into prc_order_bill (
|
||||
bill_id, bill_key, order_no, tracking_no, transfer_no,
|
||||
bill_key, order_no, tracking_no, transfer_no,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code, service_man, service_man_code,
|
||||
customer_id, customer_code, customer_name,
|
||||
pieces, actual_weight, receive_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height,
|
||||
@@ -845,7 +845,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
customer_active_status, credit_arrears_status, refund_status, billing_fail_status, error_message, round_mode,
|
||||
create_time
|
||||
) values (
|
||||
#{billId}, #{billKey}, #{orderNo}, #{trackingNo}, #{transferNo},
|
||||
#{billKey}, #{orderNo}, #{trackingNo}, #{transferNo},
|
||||
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode}, #{serviceMan}, #{serviceManCode},
|
||||
#{customerId}, #{customerCode}, #{customerName},
|
||||
#{pieces}, #{actualWeight}, #{receiveWeight}, #{volume}, #{volumeWeight}, #{pkgLength}, #{pkgWidth}, #{pkgHeight},
|
||||
|
||||
@@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcPayBillFeeResult">
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillFeeResult">
|
||||
select fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
from prc_pay_bill_fee
|
||||
@@ -31,23 +31,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPayBillFee" parameterType="PrcPayBillFee">
|
||||
<insert id="insertPrcPayBillFee" parameterType="PrcPayBillFee" useGeneratedKeys="true" keyProperty="feeId">
|
||||
insert into prc_pay_bill_fee (
|
||||
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
) values (
|
||||
#{feeId}, #{billId}, #{payBillId}, #{feeType}, #{feeName}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{roundMode}, #{remark},
|
||||
#{billId}, #{payBillId}, #{feeType}, #{feeName}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{roundMode}, #{remark},
|
||||
ifnull(#{feeSource}, 'CALC'), #{sourceId}, ifnull(#{isDeleted}, '0'), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="feeId">
|
||||
insert into prc_pay_bill_fee (
|
||||
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.feeId}, #{item.billId}, #{item.payBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.feeLevel},
|
||||
(#{item.billId}, #{item.payBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.feeLevel},
|
||||
#{item.amount}, #{item.currency}, #{item.roundMode}, #{item.remark}, ifnull(#{item.feeSource}, 'CALC'),
|
||||
#{item.sourceId}, ifnull(#{item.isDeleted}, '0'), sysdate())
|
||||
</foreach>
|
||||
@@ -69,19 +69,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update prc_pay_bill_fee f
|
||||
inner join prc_pay_bill b on b.bill_id = f.bill_id
|
||||
set f.pay_bill_id = b.pay_bill_id
|
||||
where (f.pay_bill_id is null or f.pay_bill_id = '')
|
||||
where f.pay_bill_id is null
|
||||
and f.bill_id in
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectBillIdsByLadingFee" resultType="String">
|
||||
<select id="selectBillIdsByLadingFee" resultType="java.lang.Long">
|
||||
select distinct bill_id
|
||||
from prc_pay_bill_fee
|
||||
where fee_source = 'LADING'
|
||||
and sc_id = #{feeId}
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
and bill_id is not null
|
||||
and bill_id != ''
|
||||
</select>
|
||||
|
||||
<update id="markLadingFeeDeleted">
|
||||
@@ -92,7 +91,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
<update id="fillSourceIdByFeeIds">
|
||||
update prc_pay_bill_fee
|
||||
set source_id = cast(fee_id as char)
|
||||
where (source_id is null or source_id = '')
|
||||
and fee_id in
|
||||
<foreach collection="feeIds" item="feeId" open="(" separator="," close=")">#{feeId}</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_pay_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and (fee_source is null or fee_source = '' or fee_source = 'CALC')
|
||||
|
||||
@@ -30,24 +30,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from prc_pay_bill
|
||||
</sql>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcPayBillResult">
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillResult">
|
||||
<include refid="selectPrcPayBillVo"/>
|
||||
where bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<select id="selectByPayBillId" parameterType="String" resultMap="PrcPayBillResult">
|
||||
<select id="selectByPayBillId" parameterType="Long" resultMap="PrcPayBillResult">
|
||||
<include refid="selectPrcPayBillVo"/>
|
||||
where pay_bill_id = #{payBillId}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPayBill" parameterType="PrcPayBill">
|
||||
<insert id="insertPrcPayBill" parameterType="PrcPayBill" useGeneratedKeys="true" keyProperty="payBillId">
|
||||
insert into prc_pay_bill (
|
||||
pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
bill_id, currency, product_amount, redline_amount,
|
||||
cost_amount, pay_total,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time
|
||||
) values (
|
||||
#{payBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{costAmount}, #{payTotal},
|
||||
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
||||
#{createBy}, sysdate()
|
||||
@@ -70,14 +70,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<insert id="upsertPrcPayBill" parameterType="PrcPayBill">
|
||||
<insert id="upsertPrcPayBill" parameterType="PrcPayBill" useGeneratedKeys="true" keyProperty="payBillId">
|
||||
insert into prc_pay_bill (
|
||||
pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
bill_id, currency, product_amount, redline_amount,
|
||||
cost_amount, pay_total,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time
|
||||
) values (
|
||||
#{payBillId}, #{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{billId}, #{currency}, #{productAmount}, #{redlineAmount},
|
||||
#{costAmount}, #{payTotal},
|
||||
#{belongSaler}, #{belongSalerCode}, #{settlementMan}, #{settlementManCode},
|
||||
#{createBy}, sysdate()
|
||||
@@ -98,11 +98,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertMissingPayBills">
|
||||
insert into prc_pay_bill (
|
||||
pay_bill_id, bill_id, currency, pay_total,
|
||||
bill_id, currency, pay_total,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time, update_by, update_time
|
||||
)
|
||||
select replace(uuid(), '-', ''), o.bill_id, ifnull(nullif(o.currency, ''), 'CNY'), 0,
|
||||
select o.bill_id, ifnull(nullif(o.currency, ''), 'CNY'), 0,
|
||||
o.belong_saler, o.belong_saler_code, o.settlement_man, o.settlement_man_code,
|
||||
#{operator}, sysdate(), #{operator}, sysdate()
|
||||
from prc_order_bill o
|
||||
@@ -129,7 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_pay_bill where bill_id = #{billId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,391 @@
|
||||
-- 夜间停机:计费/应收/应付 UUID(varchar36) -> bigint AUTO_INCREMENT
|
||||
-- 执行前:1)停 BMS 应用与异步任务 2)全库或至少关键表备份 3)建议先在从库/备份库干跑
|
||||
-- 范围 PK:prc_order_bill.bill_id / prc_income_bill.income_bill_id / prc_income_bill_fee.fee_id / prc_pay_bill.pay_bill_id / prc_pay_bill_fee.fee_id
|
||||
-- 范围 FK/引用:prc_order_bill_ext、income/pay 上 bill_id、prc_billing_task、ar_bill_detail*、ar_bill_generate_task、pay_bill_line/log/diff
|
||||
-- 不动:ar_bill 等已 bigint;prc_quote* 报价 UUID;任务 taskId
|
||||
-- 回滚:用宝塔/整库备份恢复 + 旧后端包(本脚本不再做同库 *_bak_uuid 拷贝)
|
||||
--
|
||||
-- FK盘点: fk_income_bill_order_bill, fk_income_bill_fee_order, fk_order_bill_ext_bill, fk_pay_bill_order_bill, fk_pay_bill_fee_order
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
-- 提高 GROUP_CONCAT 长度,避免动态拼 SQL 被截断(默认 1024 会报 1064)
|
||||
SET SESSION group_concat_max_len = 1024000;
|
||||
-- 若上次中途失败/校对规则报错,先:
|
||||
-- DROP TABLE IF EXISTS prc_order_bill_new, prc_income_bill_new, prc_income_bill_fee_new, prc_pay_bill_new, prc_pay_bill_fee_new;
|
||||
-- DROP TABLE IF EXISTS mig_map_order_bill, mig_map_income_bill, mig_map_income_fee, mig_map_pay_bill, mig_map_pay_fee;
|
||||
|
||||
-- ========== 0. 前置检查 ==========
|
||||
SELECT 'prc_order_bill' AS tbl, COUNT(*) AS cnt FROM prc_order_bill
|
||||
UNION ALL SELECT 'prc_order_bill_ext', COUNT(*) FROM prc_order_bill_ext
|
||||
UNION ALL SELECT 'prc_income_bill', COUNT(*) FROM prc_income_bill
|
||||
UNION ALL SELECT 'prc_income_bill_fee', COUNT(*) FROM prc_income_bill_fee
|
||||
UNION ALL SELECT 'prc_pay_bill', COUNT(*) FROM prc_pay_bill
|
||||
UNION ALL SELECT 'prc_pay_bill_fee', COUNT(*) FROM prc_pay_bill_fee
|
||||
UNION ALL SELECT 'ar_bill_detail', COUNT(*) FROM ar_bill_detail
|
||||
UNION ALL SELECT 'ar_bill_detail_fee', COUNT(*) FROM ar_bill_detail_fee;
|
||||
|
||||
SELECT CONSTRAINT_NAME, TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
|
||||
FROM information_schema.KEY_COLUMN_USAGE
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND REFERENCED_TABLE_NAME IN ('prc_order_bill','prc_income_bill','prc_income_bill_fee','prc_pay_bill','prc_pay_bill_fee')
|
||||
ORDER BY TABLE_NAME, CONSTRAINT_NAME;
|
||||
|
||||
-- ========== 1. 跳过同库 bak(已在宝塔做整库备份,避免再拷一份占盘/耗时) ==========
|
||||
-- 回滚请用宝塔备份恢复,不再依赖 *_bak_uuid
|
||||
|
||||
-- ========== 2. 映射表 ==========
|
||||
DROP TABLE IF EXISTS `mig_map_order_bill`;
|
||||
CREATE TABLE `mig_map_order_bill` (
|
||||
`old_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`new_id` bigint NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`old_id`),
|
||||
UNIQUE KEY `uk_new_id` (`new_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
INSERT INTO `mig_map_order_bill` (`old_id`)
|
||||
SELECT `bill_id` FROM `prc_order_bill` ORDER BY IFNULL(`create_time`, '1970-01-01'), `bill_id`;
|
||||
|
||||
DROP TABLE IF EXISTS `mig_map_income_bill`;
|
||||
CREATE TABLE `mig_map_income_bill` (
|
||||
`old_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`new_id` bigint NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`old_id`),
|
||||
UNIQUE KEY `uk_new_id` (`new_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
INSERT INTO `mig_map_income_bill` (`old_id`)
|
||||
SELECT `income_bill_id` FROM `prc_income_bill` ORDER BY IFNULL(`create_time`, '1970-01-01'), `income_bill_id`;
|
||||
|
||||
DROP TABLE IF EXISTS `mig_map_income_fee`;
|
||||
CREATE TABLE `mig_map_income_fee` (
|
||||
`old_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`new_id` bigint NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`old_id`),
|
||||
UNIQUE KEY `uk_new_id` (`new_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
INSERT INTO `mig_map_income_fee` (`old_id`)
|
||||
SELECT `fee_id` FROM `prc_income_bill_fee` ORDER BY IFNULL(`create_time`, '1970-01-01'), `fee_id`;
|
||||
|
||||
DROP TABLE IF EXISTS `mig_map_pay_bill`;
|
||||
CREATE TABLE `mig_map_pay_bill` (
|
||||
`old_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`new_id` bigint NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`old_id`),
|
||||
UNIQUE KEY `uk_new_id` (`new_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
INSERT INTO `mig_map_pay_bill` (`old_id`)
|
||||
SELECT `pay_bill_id` FROM `prc_pay_bill` ORDER BY IFNULL(`create_time`, '1970-01-01'), `pay_bill_id`;
|
||||
|
||||
DROP TABLE IF EXISTS `mig_map_pay_fee`;
|
||||
CREATE TABLE `mig_map_pay_fee` (
|
||||
`old_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`new_id` bigint NOT NULL AUTO_INCREMENT,
|
||||
PRIMARY KEY (`old_id`),
|
||||
UNIQUE KEY `uk_new_id` (`new_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
INSERT INTO `mig_map_pay_fee` (`old_id`)
|
||||
SELECT `fee_id` FROM `prc_pay_bill_fee` ORDER BY IFNULL(`create_time`, '1970-01-01'), `fee_id`;
|
||||
|
||||
-- ========== 3. 重建核心表(动态列,需 group_concat_max_len) ==========
|
||||
DROP TABLE IF EXISTS `prc_order_bill_new`;
|
||||
CREATE TABLE `prc_order_bill_new` LIKE `prc_order_bill`;
|
||||
ALTER TABLE `prc_order_bill_new` MODIFY COLUMN `bill_id` bigint NOT NULL AUTO_INCREMENT;
|
||||
SELECT GROUP_CONCAT(CONCAT('`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @cols_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_order_bill' AND COLUMN_NAME NOT IN ('bill_id');
|
||||
SELECT GROUP_CONCAT(CONCAT('t.`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @sels_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_order_bill' AND COLUMN_NAME NOT IN ('bill_id');
|
||||
SET @sql := CONCAT(
|
||||
'INSERT INTO `prc_order_bill_new`(`bill_id`,', @cols_rest, ') ',
|
||||
'SELECT mo.new_id,', @sels_rest, ' ',
|
||||
'FROM `prc_order_bill` t ',
|
||||
'JOIN `mig_map_order_bill` mo ON BINARY mo.old_id = BINARY t.`bill_id` '
|
||||
);
|
||||
-- 若仍报错可先:SELECT LEFT(@sql, 500), LENGTH(@cols_rest), LENGTH(@sels_rest);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE IF EXISTS `prc_income_bill_new`;
|
||||
CREATE TABLE `prc_income_bill_new` LIKE `prc_income_bill`;
|
||||
ALTER TABLE `prc_income_bill_new` MODIFY COLUMN `income_bill_id` bigint NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `prc_income_bill_new` MODIFY COLUMN `bill_id` bigint NOT NULL;
|
||||
SELECT GROUP_CONCAT(CONCAT('`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @cols_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill' AND COLUMN_NAME NOT IN ('income_bill_id','bill_id');
|
||||
SELECT GROUP_CONCAT(CONCAT('t.`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @sels_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill' AND COLUMN_NAME NOT IN ('income_bill_id','bill_id');
|
||||
SET @sql := CONCAT(
|
||||
'INSERT INTO `prc_income_bill_new`(`income_bill_id`, `bill_id`,', @cols_rest, ') ',
|
||||
'SELECT mi.new_id, mo.new_id,', @sels_rest, ' ',
|
||||
'FROM `prc_income_bill` t ',
|
||||
'JOIN `mig_map_income_bill` mi ON BINARY mi.old_id = BINARY t.`income_bill_id` '
|
||||
,'JOIN `mig_map_order_bill` mo ON BINARY mo.old_id = BINARY t.`bill_id` '
|
||||
);
|
||||
-- 若仍报错可先:SELECT LEFT(@sql, 500), LENGTH(@cols_rest), LENGTH(@sels_rest);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE IF EXISTS `prc_income_bill_fee_new`;
|
||||
CREATE TABLE `prc_income_bill_fee_new` LIKE `prc_income_bill_fee`;
|
||||
ALTER TABLE `prc_income_bill_fee_new` MODIFY COLUMN `fee_id` bigint NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `prc_income_bill_fee_new` MODIFY COLUMN `bill_id` bigint NOT NULL;
|
||||
ALTER TABLE `prc_income_bill_fee_new` MODIFY COLUMN `income_bill_id` bigint NULL;
|
||||
SELECT GROUP_CONCAT(CONCAT('`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @cols_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill_fee' AND COLUMN_NAME NOT IN ('fee_id','bill_id','income_bill_id');
|
||||
SELECT GROUP_CONCAT(CONCAT('t.`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @sels_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill_fee' AND COLUMN_NAME NOT IN ('fee_id','bill_id','income_bill_id');
|
||||
SET @sql := CONCAT(
|
||||
'INSERT INTO `prc_income_bill_fee_new`(`fee_id`, `bill_id`, `income_bill_id`,', @cols_rest, ') ',
|
||||
'SELECT mf.new_id, mo.new_id, mi.new_id,', @sels_rest, ' ',
|
||||
'FROM `prc_income_bill_fee` t ',
|
||||
'JOIN `mig_map_income_fee` mf ON BINARY mf.old_id = BINARY t.`fee_id` '
|
||||
,'JOIN `mig_map_order_bill` mo ON BINARY mo.old_id = BINARY t.`bill_id` '
|
||||
,'LEFT JOIN `mig_map_income_bill` mi ON BINARY mi.old_id = BINARY t.`income_bill_id` '
|
||||
);
|
||||
-- 若仍报错可先:SELECT LEFT(@sql, 500), LENGTH(@cols_rest), LENGTH(@sels_rest);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE IF EXISTS `prc_pay_bill_new`;
|
||||
CREATE TABLE `prc_pay_bill_new` LIKE `prc_pay_bill`;
|
||||
ALTER TABLE `prc_pay_bill_new` MODIFY COLUMN `pay_bill_id` bigint NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `prc_pay_bill_new` MODIFY COLUMN `bill_id` bigint NOT NULL;
|
||||
SELECT GROUP_CONCAT(CONCAT('`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @cols_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill' AND COLUMN_NAME NOT IN ('pay_bill_id','bill_id');
|
||||
SELECT GROUP_CONCAT(CONCAT('t.`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @sels_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill' AND COLUMN_NAME NOT IN ('pay_bill_id','bill_id');
|
||||
SET @sql := CONCAT(
|
||||
'INSERT INTO `prc_pay_bill_new`(`pay_bill_id`, `bill_id`,', @cols_rest, ') ',
|
||||
'SELECT mp.new_id, mo.new_id,', @sels_rest, ' ',
|
||||
'FROM `prc_pay_bill` t ',
|
||||
'JOIN `mig_map_pay_bill` mp ON BINARY mp.old_id = BINARY t.`pay_bill_id` '
|
||||
,'JOIN `mig_map_order_bill` mo ON BINARY mo.old_id = BINARY t.`bill_id` '
|
||||
);
|
||||
-- 若仍报错可先:SELECT LEFT(@sql, 500), LENGTH(@cols_rest), LENGTH(@sels_rest);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
DROP TABLE IF EXISTS `prc_pay_bill_fee_new`;
|
||||
CREATE TABLE `prc_pay_bill_fee_new` LIKE `prc_pay_bill_fee`;
|
||||
ALTER TABLE `prc_pay_bill_fee_new` MODIFY COLUMN `fee_id` bigint NOT NULL AUTO_INCREMENT;
|
||||
ALTER TABLE `prc_pay_bill_fee_new` MODIFY COLUMN `bill_id` bigint NOT NULL;
|
||||
ALTER TABLE `prc_pay_bill_fee_new` MODIFY COLUMN `pay_bill_id` bigint NULL;
|
||||
SELECT GROUP_CONCAT(CONCAT('`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @cols_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill_fee' AND COLUMN_NAME NOT IN ('fee_id','bill_id','pay_bill_id');
|
||||
SELECT GROUP_CONCAT(CONCAT('t.`', COLUMN_NAME, '`') ORDER BY ORDINAL_POSITION SEPARATOR ',') INTO @sels_rest
|
||||
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill_fee' AND COLUMN_NAME NOT IN ('fee_id','bill_id','pay_bill_id');
|
||||
SET @sql := CONCAT(
|
||||
'INSERT INTO `prc_pay_bill_fee_new`(`fee_id`, `bill_id`, `pay_bill_id`,', @cols_rest, ') ',
|
||||
'SELECT mf.new_id, mo.new_id, mp.new_id,', @sels_rest, ' ',
|
||||
'FROM `prc_pay_bill_fee` t ',
|
||||
'JOIN `mig_map_pay_fee` mf ON BINARY mf.old_id = BINARY t.`fee_id` '
|
||||
,'JOIN `mig_map_order_bill` mo ON BINARY mo.old_id = BINARY t.`bill_id` '
|
||||
,'LEFT JOIN `mig_map_pay_bill` mp ON BINARY mp.old_id = BINARY t.`pay_bill_id` '
|
||||
);
|
||||
-- 若仍报错可先:SELECT LEFT(@sql, 500), LENGTH(@cols_rest), LENGTH(@sels_rest);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
-- --- prc_order_bill_ext 阴影列 ---
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_order_bill_ext' AND COLUMN_NAME='bill_id_bi')=0,
|
||||
'ALTER TABLE `prc_order_bill_ext` ADD COLUMN `bill_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
UPDATE `prc_order_bill_ext` e JOIN `mig_map_order_bill` m ON BINARY m.old_id = BINARY e.bill_id SET e.bill_id_bi = m.new_id;
|
||||
|
||||
-- ========== 4. 引用表阴影列 ==========
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail' AND COLUMN_NAME='prc_order_bill_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail' AND COLUMN_NAME='prc_order_bill_id_bi')=0,
|
||||
'ALTER TABLE `ar_bill_detail` ADD COLUMN `prc_order_bill_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail' AND COLUMN_NAME='prc_order_bill_id')>0,
|
||||
'UPDATE `ar_bill_detail` x JOIN `mig_map_order_bill` m ON BINARY m.old_id = BINARY x.`prc_order_bill_id` SET x.`prc_order_bill_id_bi` = m.new_id',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail_fee' AND COLUMN_NAME='prc_income_bill_fee_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail_fee' AND COLUMN_NAME='prc_income_bill_fee_id_bi')=0,
|
||||
'ALTER TABLE `ar_bill_detail_fee` ADD COLUMN `prc_income_bill_fee_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail_fee' AND COLUMN_NAME='prc_income_bill_fee_id')>0,
|
||||
'UPDATE `ar_bill_detail_fee` x JOIN `mig_map_income_fee` m ON BINARY m.old_id = BINARY x.`prc_income_bill_fee_id` SET x.`prc_income_bill_fee_id_bi` = m.new_id',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_generate_task' AND COLUMN_NAME='last_source_bill_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_generate_task' AND COLUMN_NAME='last_source_bill_id_bi')=0,
|
||||
'ALTER TABLE `ar_bill_generate_task` ADD COLUMN `last_source_bill_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_generate_task' AND COLUMN_NAME='last_source_bill_id')>0,
|
||||
'UPDATE `ar_bill_generate_task` x JOIN `mig_map_order_bill` m ON BINARY m.old_id = BINARY x.`last_source_bill_id` SET x.`last_source_bill_id_bi` = m.new_id WHERE x.`last_source_bill_id` IS NOT NULL AND x.`last_source_bill_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_billing_task' AND COLUMN_NAME='bill_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_billing_task' AND COLUMN_NAME='bill_id_bi')=0,
|
||||
'ALTER TABLE `prc_billing_task` ADD COLUMN `bill_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_billing_task' AND COLUMN_NAME='bill_id')>0,
|
||||
'UPDATE `prc_billing_task` x JOIN `mig_map_order_bill` m ON BINARY m.old_id = BINARY x.`bill_id` SET x.`bill_id_bi` = m.new_id WHERE x.`bill_id` IS NOT NULL AND x.`bill_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='order_bill_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='order_bill_id_bi')=0,
|
||||
'ALTER TABLE `pay_bill_line` ADD COLUMN `order_bill_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='order_bill_id')>0,
|
||||
'UPDATE `pay_bill_line` x JOIN `mig_map_order_bill` m ON BINARY m.old_id = BINARY x.`order_bill_id` SET x.`order_bill_id_bi` = m.new_id WHERE x.`order_bill_id` IS NOT NULL AND x.`order_bill_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='fee_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='fee_id_bi')=0,
|
||||
'ALTER TABLE `pay_bill_line` ADD COLUMN `fee_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='fee_id')>0,
|
||||
'UPDATE `pay_bill_line` x JOIN `mig_map_pay_fee` m ON BINARY m.old_id = BINARY x.`fee_id` SET x.`fee_id_bi` = m.new_id WHERE x.`fee_id` IS NOT NULL AND x.`fee_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_log' AND COLUMN_NAME='fee_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_log' AND COLUMN_NAME='fee_id_bi')=0,
|
||||
'ALTER TABLE `pay_bill_log` ADD COLUMN `fee_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_log' AND COLUMN_NAME='fee_id')>0,
|
||||
'UPDATE `pay_bill_log` x JOIN `mig_map_pay_fee` m ON BINARY m.old_id = BINARY x.`fee_id` SET x.`fee_id_bi` = m.new_id WHERE x.`fee_id` IS NOT NULL AND x.`fee_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='fee_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='fee_id_bi')=0,
|
||||
'ALTER TABLE `pay_bill_diff` ADD COLUMN `fee_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='fee_id')>0,
|
||||
'UPDATE `pay_bill_diff` x JOIN `mig_map_pay_fee` m ON BINARY m.old_id = BINARY x.`fee_id` SET x.`fee_id_bi` = m.new_id WHERE x.`fee_id` IS NOT NULL AND x.`fee_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='adjust_fee_id')>0
|
||||
AND (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='adjust_fee_id_bi')=0,
|
||||
'ALTER TABLE `pay_bill_diff` ADD COLUMN `adjust_fee_id_bi` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='adjust_fee_id')>0,
|
||||
'UPDATE `pay_bill_diff` x JOIN `mig_map_pay_fee` m ON BINARY m.old_id = BINARY x.`adjust_fee_id` SET x.`adjust_fee_id_bi` = m.new_id WHERE x.`adjust_fee_id` IS NOT NULL AND x.`adjust_fee_id` <> \'\'',
|
||||
'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ========== 5. 校验(bad 必须为 0,行数必须一致) ==========
|
||||
SELECT 'ar_detail_orphan' AS chk, COUNT(*) AS bad FROM ar_bill_detail WHERE prc_order_bill_id_bi IS NULL;
|
||||
SELECT 'ar_fee_orphan' AS chk, COUNT(*) AS bad FROM ar_bill_detail_fee WHERE prc_income_bill_fee_id_bi IS NULL;
|
||||
SELECT 'ext_orphan' AS chk, COUNT(*) AS bad FROM prc_order_bill_ext WHERE bill_id_bi IS NULL;
|
||||
SELECT 'order_cnt' AS chk, (SELECT COUNT(*) FROM mig_map_order_bill) m, (SELECT COUNT(*) FROM prc_order_bill) s, (SELECT COUNT(*) FROM prc_order_bill_new) n;
|
||||
SELECT 'income_cnt' AS chk, (SELECT COUNT(*) FROM mig_map_income_bill) m, (SELECT COUNT(*) FROM prc_income_bill) s, (SELECT COUNT(*) FROM prc_income_bill_new) n;
|
||||
SELECT 'income_fee_cnt' AS chk, (SELECT COUNT(*) FROM mig_map_income_fee) m, (SELECT COUNT(*) FROM prc_income_bill_fee) s, (SELECT COUNT(*) FROM prc_income_bill_fee_new) n;
|
||||
SELECT 'pay_cnt' AS chk, (SELECT COUNT(*) FROM mig_map_pay_bill) m, (SELECT COUNT(*) FROM prc_pay_bill) s, (SELECT COUNT(*) FROM prc_pay_bill_new) n;
|
||||
SELECT 'pay_fee_cnt' AS chk, (SELECT COUNT(*) FROM mig_map_pay_fee) m, (SELECT COUNT(*) FROM prc_pay_bill_fee) s, (SELECT COUNT(*) FROM prc_pay_bill_fee_new) n;
|
||||
-- 若校验失败:STOP,不执行第 6 步
|
||||
|
||||
-- ========== 6. 掉旧 FK 后换表 ==========
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill' AND CONSTRAINT_NAME='fk_income_bill_order_bill')>0,
|
||||
'ALTER TABLE `prc_income_bill` DROP FOREIGN KEY `fk_income_bill_order_bill`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_income_bill_fee' AND CONSTRAINT_NAME='fk_income_bill_fee_order')>0,
|
||||
'ALTER TABLE `prc_income_bill_fee` DROP FOREIGN KEY `fk_income_bill_fee_order`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_order_bill_ext' AND CONSTRAINT_NAME='fk_order_bill_ext_bill')>0,
|
||||
'ALTER TABLE `prc_order_bill_ext` DROP FOREIGN KEY `fk_order_bill_ext_bill`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill' AND CONSTRAINT_NAME='fk_pay_bill_order_bill')>0,
|
||||
'ALTER TABLE `prc_pay_bill` DROP FOREIGN KEY `fk_pay_bill_order_bill`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_pay_bill_fee' AND CONSTRAINT_NAME='fk_pay_bill_fee_order')>0,
|
||||
'ALTER TABLE `prc_pay_bill_fee` DROP FOREIGN KEY `fk_pay_bill_fee_order`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
RENAME TABLE
|
||||
`prc_order_bill` TO `prc_order_bill_old_uuid`,
|
||||
`prc_order_bill_new` TO `prc_order_bill`,
|
||||
`prc_income_bill` TO `prc_income_bill_old_uuid`,
|
||||
`prc_income_bill_new` TO `prc_income_bill`,
|
||||
`prc_income_bill_fee` TO `prc_income_bill_fee_old_uuid`,
|
||||
`prc_income_bill_fee_new` TO `prc_income_bill_fee`,
|
||||
`prc_pay_bill` TO `prc_pay_bill_old_uuid`,
|
||||
`prc_pay_bill_new` TO `prc_pay_bill`,
|
||||
`prc_pay_bill_fee` TO `prc_pay_bill_fee_old_uuid`,
|
||||
`prc_pay_bill_fee_new` TO `prc_pay_bill_fee`;
|
||||
|
||||
-- --- ext / AR / task 引用列落地 ---
|
||||
ALTER TABLE `prc_order_bill_ext` DROP PRIMARY KEY;
|
||||
ALTER TABLE `prc_order_bill_ext` DROP COLUMN `bill_id`;
|
||||
ALTER TABLE `prc_order_bill_ext` CHANGE COLUMN `bill_id_bi` `bill_id` bigint NOT NULL;
|
||||
ALTER TABLE `prc_order_bill_ext` ADD PRIMARY KEY (`bill_id`);
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail' AND INDEX_NAME='uk_ar_bill_detail_source')>0,
|
||||
'ALTER TABLE `ar_bill_detail` DROP INDEX `uk_ar_bill_detail_source`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail' AND INDEX_NAME='idx_ar_bill_detail_source')>0,
|
||||
'ALTER TABLE `ar_bill_detail` DROP INDEX `idx_ar_bill_detail_source`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
ALTER TABLE `ar_bill_detail` DROP COLUMN `prc_order_bill_id`;
|
||||
ALTER TABLE `ar_bill_detail` CHANGE COLUMN `prc_order_bill_id_bi` `prc_order_bill_id` bigint NOT NULL;
|
||||
ALTER TABLE `ar_bill_detail` ADD UNIQUE KEY `uk_ar_bill_detail_source` (`ar_bill_id`,`prc_order_bill_id`);
|
||||
ALTER TABLE `ar_bill_detail` ADD KEY `idx_ar_bill_detail_source` (`prc_order_bill_id`);
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail_fee' AND INDEX_NAME='uk_ar_detail_prc_income_fee')>0,
|
||||
'ALTER TABLE `ar_bill_detail_fee` DROP INDEX `uk_ar_detail_prc_income_fee`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_detail_fee' AND INDEX_NAME='idx_ar_detail_prc_income_fee')>0,
|
||||
'ALTER TABLE `ar_bill_detail_fee` DROP INDEX `idx_ar_detail_prc_income_fee`', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
ALTER TABLE `ar_bill_detail_fee` DROP COLUMN `prc_income_bill_fee_id`;
|
||||
ALTER TABLE `ar_bill_detail_fee` CHANGE COLUMN `prc_income_bill_fee_id_bi` `prc_income_bill_fee_id` bigint NOT NULL;
|
||||
ALTER TABLE `ar_bill_detail_fee` ADD UNIQUE KEY `uk_ar_detail_prc_income_fee` (`detail_id`,`prc_income_bill_fee_id`);
|
||||
ALTER TABLE `ar_bill_detail_fee` ADD KEY `idx_ar_detail_prc_income_fee` (`prc_income_bill_fee_id`);
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='ar_bill_generate_task' AND COLUMN_NAME='last_source_bill_id_bi')>0,
|
||||
'ALTER TABLE `ar_bill_generate_task` DROP COLUMN `last_source_bill_id`, CHANGE COLUMN `last_source_bill_id_bi` `last_source_bill_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='prc_billing_task' AND COLUMN_NAME='bill_id_bi')>0,
|
||||
'ALTER TABLE `prc_billing_task` DROP COLUMN `bill_id`, CHANGE COLUMN `bill_id_bi` `bill_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='order_bill_id_bi')>0,
|
||||
'ALTER TABLE `pay_bill_line` DROP COLUMN `order_bill_id`, CHANGE COLUMN `order_bill_id_bi` `order_bill_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_line' AND COLUMN_NAME='fee_id_bi')>0,
|
||||
'ALTER TABLE `pay_bill_line` DROP COLUMN `fee_id`, CHANGE COLUMN `fee_id_bi` `fee_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_log' AND COLUMN_NAME='fee_id_bi')>0,
|
||||
'ALTER TABLE `pay_bill_log` DROP COLUMN `fee_id`, CHANGE COLUMN `fee_id_bi` `fee_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='fee_id_bi')>0,
|
||||
'ALTER TABLE `pay_bill_diff` DROP COLUMN `fee_id`, CHANGE COLUMN `fee_id_bi` `fee_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @sql := IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='pay_bill_diff' AND COLUMN_NAME='adjust_fee_id_bi')>0,
|
||||
'ALTER TABLE `pay_bill_diff` DROP COLUMN `adjust_fee_id`, CHANGE COLUMN `adjust_fee_id_bi` `adjust_fee_id` bigint NULL', 'SELECT 1');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- ========== 7. 重建 FK + AUTO_INCREMENT ==========
|
||||
ALTER TABLE `prc_order_bill_ext` ADD CONSTRAINT `fk_order_bill_ext_bill` FOREIGN KEY (`bill_id`) REFERENCES `prc_order_bill` (`bill_id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `prc_income_bill` ADD CONSTRAINT `fk_income_bill_order_bill` FOREIGN KEY (`bill_id`) REFERENCES `prc_order_bill` (`bill_id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `prc_income_bill_fee` ADD CONSTRAINT `fk_income_bill_fee_order` FOREIGN KEY (`bill_id`) REFERENCES `prc_order_bill` (`bill_id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `prc_pay_bill` ADD CONSTRAINT `fk_pay_bill_order_bill` FOREIGN KEY (`bill_id`) REFERENCES `prc_order_bill` (`bill_id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `prc_pay_bill_fee` ADD CONSTRAINT `fk_pay_bill_fee_order` FOREIGN KEY (`bill_id`) REFERENCES `prc_order_bill` (`bill_id`) ON DELETE CASCADE;
|
||||
|
||||
SET @ai := (SELECT IFNULL(MAX(`bill_id`),0)+1 FROM `prc_order_bill`);
|
||||
SET @sql := CONCAT('ALTER TABLE `prc_order_bill` AUTO_INCREMENT=', @ai);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @ai := (SELECT IFNULL(MAX(`income_bill_id`),0)+1 FROM `prc_income_bill`);
|
||||
SET @sql := CONCAT('ALTER TABLE `prc_income_bill` AUTO_INCREMENT=', @ai);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @ai := (SELECT IFNULL(MAX(`fee_id`),0)+1 FROM `prc_income_bill_fee`);
|
||||
SET @sql := CONCAT('ALTER TABLE `prc_income_bill_fee` AUTO_INCREMENT=', @ai);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @ai := (SELECT IFNULL(MAX(`pay_bill_id`),0)+1 FROM `prc_pay_bill`);
|
||||
SET @sql := CONCAT('ALTER TABLE `prc_pay_bill` AUTO_INCREMENT=', @ai);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
SET @ai := (SELECT IFNULL(MAX(`fee_id`),0)+1 FROM `prc_pay_bill_fee`);
|
||||
SET @sql := CONCAT('ALTER TABLE `prc_pay_bill_fee` AUTO_INCREMENT=', @ai);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
-- ========== 8. 抽查 ==========
|
||||
SELECT d.detail_id, d.prc_order_bill_id, o.order_no FROM ar_bill_detail d JOIN prc_order_bill o ON o.bill_id = d.prc_order_bill_id LIMIT 5;
|
||||
SELECT f.detail_fee_id, f.prc_income_bill_fee_id, i.fee_type FROM ar_bill_detail_fee f JOIN prc_income_bill_fee i ON i.fee_id = f.prc_income_bill_fee_id LIMIT 5;
|
||||
|
||||
-- ========== 9. 回滚说明(勿自动执行) ==========
|
||||
-- 用宝塔/整库备份恢复 + 部署旧后端包
|
||||
--
|
||||
-- ========== 10. 次日清理 ==========
|
||||
-- DROP TABLE IF EXISTS prc_order_bill_old_uuid, prc_income_bill_old_uuid,
|
||||
-- prc_income_bill_fee_old_uuid, prc_pay_bill_old_uuid, prc_pay_bill_fee_old_uuid;
|
||||
-- DROP TABLE IF EXISTS mig_map_order_bill, mig_map_income_bill, mig_map_income_fee, mig_map_pay_bill, mig_map_pay_fee;
|
||||
--
|
||||
-- 冒烟:1)新建/重计费 2)出应收 3)查应付费用 4)旧 AR 明细关联订单
|
||||
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
# 夜间停机:仅在数据库服务器(或能连库的跳板机)执行
|
||||
# 依赖:mysql 客户端
|
||||
#
|
||||
# export BMS_DB_HOST=127.0.0.1
|
||||
# export BMS_DB_PORT=3306
|
||||
# export BMS_DB_NAME=bms
|
||||
# export BMS_DB_USER=root
|
||||
# export BMS_DB_PASS='******'
|
||||
# chmod +x 20261113_uuid_to_bigint_run.sh
|
||||
# ./20261113_uuid_to_bigint_run.sh
|
||||
#
|
||||
# CONFIRM=YES ./20261113_uuid_to_bigint_run.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SQL_FILE="${SQL_FILE:-${SCRIPT_DIR}/20261113_uuid_to_bigint_order_bill.sql}"
|
||||
LOG_DIR="${LOG_DIR:-${SCRIPT_DIR}/logs}"
|
||||
TS="$(date +%Y%m%d_%H%M%S)"
|
||||
LOG_FILE="${LOG_DIR}/uuid_to_bigint_${TS}.log"
|
||||
|
||||
BMS_DB_HOST="${BMS_DB_HOST:-127.0.0.1}"
|
||||
BMS_DB_PORT="${BMS_DB_PORT:-3306}"
|
||||
BMS_DB_NAME="${BMS_DB_NAME:-bms}"
|
||||
BMS_DB_USER="${BMS_DB_USER:-root}"
|
||||
|
||||
if [[ -z "${BMS_DB_PASS:-}" ]]; then
|
||||
echo "请先设置环境变量 BMS_DB_PASS(不要把密码写进脚本)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${SQL_FILE}" ]]; then
|
||||
echo "找不到 SQL 文件: ${SQL_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v mysql >/dev/null 2>&1; then
|
||||
echo "未找到 mysql 客户端,请先安装"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${LOG_DIR}"
|
||||
|
||||
echo "========================================"
|
||||
echo " UUID -> bigint 迁移"
|
||||
echo " host=${BMS_DB_HOST} port=${BMS_DB_PORT} db=${BMS_DB_NAME} user=${BMS_DB_USER}"
|
||||
echo " sql=${SQL_FILE}"
|
||||
echo " log=${LOG_FILE}"
|
||||
echo "========================================"
|
||||
echo
|
||||
echo "【必须】先停 Java / BMS,再执行本脚本。"
|
||||
echo "执行前请确认:"
|
||||
echo " 1) Java / BMS 应用与异步 worker 已全部停掉(不要边跑边迁)"
|
||||
echo " 2) 已在宝塔做整库备份(SQL 不再同库拷份)"
|
||||
echo " 3) 磅盘空间足够(建议 >= 订单+ext+费用表 2~3 倍)"
|
||||
echo " 4) SQL 成功后,再部署 Long 版后端并启动"
|
||||
echo
|
||||
|
||||
if [[ "${CONFIRM:-}" != "YES" ]]; then
|
||||
read -r -p "已停 Java?输入 YES 开始执行 SQL: " ans
|
||||
if [[ "${ans}" != "YES" ]]; then
|
||||
echo "已取消(请先停 Java 再来)"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "CONFIRM=YES:假定你已停 Java,直接开始 SQL..."
|
||||
fi
|
||||
|
||||
MYSQL_OPTS=(
|
||||
-h "${BMS_DB_HOST}"
|
||||
-P "${BMS_DB_PORT}"
|
||||
-u "${BMS_DB_USER}"
|
||||
"-p${BMS_DB_PASS}"
|
||||
--default-character-set=utf8mb4
|
||||
--comments
|
||||
"${BMS_DB_NAME}"
|
||||
)
|
||||
|
||||
echo
|
||||
echo "[$(date '+%F %T')] 连接检查..." | tee -a "${LOG_FILE}"
|
||||
mysql "${MYSQL_OPTS[@]}" -e "SELECT DATABASE() AS db, NOW() AS now_ts;" | tee -a "${LOG_FILE}"
|
||||
|
||||
echo "[$(date '+%F %T')] 行数预览..." | tee -a "${LOG_FILE}"
|
||||
mysql "${MYSQL_OPTS[@]}" -e "
|
||||
SELECT 'prc_order_bill' AS tbl, COUNT(*) AS cnt FROM prc_order_bill
|
||||
UNION ALL SELECT 'prc_order_bill_ext', COUNT(*) FROM prc_order_bill_ext
|
||||
UNION ALL SELECT 'prc_income_bill', COUNT(*) FROM prc_income_bill
|
||||
UNION ALL SELECT 'prc_income_bill_fee', COUNT(*) FROM prc_income_bill_fee
|
||||
UNION ALL SELECT 'prc_pay_bill', COUNT(*) FROM prc_pay_bill
|
||||
UNION ALL SELECT 'prc_pay_bill_fee', COUNT(*) FROM prc_pay_bill_fee;
|
||||
" | tee -a "${LOG_FILE}"
|
||||
|
||||
START_TS="$(date +%s)"
|
||||
echo "[$(date '+%F %T')] 开始执行迁移 SQL..." | tee -a "${LOG_FILE}"
|
||||
|
||||
set +e
|
||||
mysql "${MYSQL_OPTS[@]}" < "${SQL_FILE}" 2>&1 | tee -a "${LOG_FILE}"
|
||||
RC=${PIPESTATUS[0]}
|
||||
set -e
|
||||
|
||||
END_TS="$(date +%s)"
|
||||
ELAPSED=$((END_TS - START_TS))
|
||||
|
||||
if [[ "${RC}" -ne 0 ]]; then
|
||||
echo "[$(date '+%F %T')] 失败 exit=${RC} 耗时=${ELAPSED}s,请查日志: ${LOG_FILE}" | tee -a "${LOG_FILE}"
|
||||
echo "若已换表中途失败:用宝塔备份恢复,不要部署新后端"
|
||||
exit "${RC}"
|
||||
fi
|
||||
|
||||
echo "[$(date '+%F %T')] 成功耗时=${ELAPSED}s (约 $((ELAPSED/60)) 分钟)" | tee -a "${LOG_FILE}"
|
||||
echo
|
||||
echo "下一步:"
|
||||
echo " 1) 抽查日志中校验/抽查结果"
|
||||
echo " 2) 部署 Long 版后端并启应用"
|
||||
echo " 3) 按 20261113_uuid_to_bigint_runbook.md 做冒烟"
|
||||
echo "日志: ${LOG_FILE}"
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# UUID -> bigint 夜间执行与冒烟清单
|
||||
|
||||
脚本:`bms-back/sql/20261113_uuid_to_bigint_order_bill.sql`
|
||||
|
||||
## 必须顺序(不要飞)
|
||||
|
||||
1. **先停 Java / BMS 服务**(含计费、出账、导出等异步 worker)
|
||||
2. **宝塔整库备份**(SQL 不再做同库 *_bak_uuid 拷贝)
|
||||
3. 在服务器执行 SQL(下面一键脚本)
|
||||
4. SQL 成功后,再部署 **Long 版** 后端并启动
|
||||
5. 冒烟
|
||||
|
||||
>旧包连新库或新包连旧库都会挂。**一定先停 Java,再跑 SQL。**
|
||||
|
||||
## 服务器一键执行
|
||||
|
||||
把同目录下 `20261113_uuid_to_bigint_order_bill.sql` 与 `20261113_uuid_to_bigint_run.sh` 一起上传到服务器。
|
||||
|
||||
```bash
|
||||
# 1) 先停 Java(按你们部署方式改,以下为示例)
|
||||
# systemctl stop bms-admin
|
||||
# 或:kill / docker stop / 停掉所有 java -jar bms-*.jar
|
||||
|
||||
# 2) 再跑迁移
|
||||
export BMS_DB_HOST=127.0.0.1
|
||||
export BMS_DB_PORT=3306
|
||||
export BMS_DB_NAME=bms
|
||||
export BMS_DB_USER=root
|
||||
export BMS_DB_PASS='******'
|
||||
chmod +x 20261113_uuid_to_bigint_run.sh
|
||||
./20261113_uuid_to_bigint_run.sh
|
||||
# 或非交互:CONFIRM=YES ./20261113_uuid_to_bigint_run.sh
|
||||
```
|
||||
|
||||
日志写在 `sql/logs/uuid_to_bigint_*.log`。
|
||||
|
||||
## 执行前
|
||||
1. **已停 Java / BMS**(含计费/出账/导出异步)
|
||||
2. **已在宝塔做整库备份**
|
||||
3. 建议在从库/备份库先干跑校验
|
||||
4. 准备好 Long 版后端包(SQL 成功后再发)
|
||||
|
||||
## 执行
|
||||
1. 确认 Java 已停
|
||||
2. 跑 `./20261113_uuid_to_bigint_run.sh`(内部会执行整份 SQL)
|
||||
3. 查日志校验/抽查通过
|
||||
4. 部署新后端,启应用
|
||||
|
||||
## 冒烟
|
||||
- [ ] 订单列表能打开,billId 为数字
|
||||
- [ ] 新建/重计费一票,生成新 bigint bill_id
|
||||
- [ ] 手动加一笔应收费用 / 查费用明细
|
||||
- [ ] 生成一笔应收账单,明细能关联订单
|
||||
- [ ] 旧应收账单明细 JOIN prc_order_bill 正常
|
||||
- [ ] 应付费用/应付账单查看正常
|
||||
|
||||
## 回滚
|
||||
1. 停新包
|
||||
2. **用宝塔整库备份恢复**
|
||||
3. 部署旧后端包
|
||||
|
||||
## 次日
|
||||
- 确认无误后 DROP `*_old_uuid` / `mig_map_*`
|
||||
+16
-16
@@ -127,7 +127,7 @@ CREATE TABLE `ar_bill_void_task` (
|
||||
CREATE TABLE `ar_bill_detail` (
|
||||
`detail_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账单订单明细ID',
|
||||
`ar_bill_id` bigint(20) NOT NULL COMMENT '应收账单ID',
|
||||
`prc_order_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源计费订单ID,对应 prc_order_bill.bill_id',
|
||||
`prc_order_bill_id` bigint(20) NOT NULL COMMENT '来源计费订单ID,对应 prc_order_bill.bill_id',
|
||||
`detail_no` int(11) NOT NULL COMMENT '账单内顺序号',
|
||||
`order_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单号快照',
|
||||
`tracking_no` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '运单号快照',
|
||||
@@ -170,7 +170,7 @@ CREATE TABLE `ar_bill_detail` (
|
||||
CREATE TABLE `ar_bill_detail_fee` (
|
||||
`detail_fee_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账单费用明细ID',
|
||||
`detail_id` bigint(20) NOT NULL COMMENT '账单订单明细ID',
|
||||
`prc_income_bill_fee_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源收入费用ID,对应 prc_income_bill_fee.fee_id',
|
||||
`prc_income_bill_fee_id` bigint(20) NOT NULL COMMENT '来源收入费用ID,对应 prc_income_bill_fee.fee_id',
|
||||
`fee_no` int(11) NOT NULL COMMENT '订单内费用顺序号',
|
||||
`fee_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用类型快照',
|
||||
`fee_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '费用名称快照',
|
||||
@@ -234,7 +234,7 @@ CREATE TABLE `ar_bill_generate_task` (
|
||||
`selection_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '选择模式:EXPLICIT=手动选择,ALL_MATCHED=全选查询结果',
|
||||
`request_payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '生成请求快照JSON',
|
||||
`snapshot_create_time` datetime DEFAULT NULL COMMENT '来源订单创建时间快照',
|
||||
`last_source_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源订单游标',
|
||||
`last_source_bill_id` bigint(20) DEFAULT NULL COMMENT '来源订单游标',
|
||||
`total_count` int(11) NOT NULL DEFAULT '-1' COMMENT '待处理订单数,-1表示尚未统计',
|
||||
`processed_count` int(11) NOT NULL DEFAULT '0' COMMENT '已处理订单数',
|
||||
`success_count` int(11) NOT NULL DEFAULT '0' COMMENT '成功订单数',
|
||||
@@ -789,7 +789,7 @@ CREATE TABLE `prc_billing_task` (
|
||||
`bill_type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费类型:PENDING待计费 REBILL重计费 REFUND退费',
|
||||
`success_status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'WAITING' COMMENT '是否计费成功:WAITING待处理 SUCCESS成功 FAILED失败',
|
||||
`bill_time` datetime DEFAULT NULL COMMENT '计费时间',
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计费订单ID prc_order_bill.bill_id',
|
||||
`bill_id` bigint(20) DEFAULT NULL COMMENT '计费订单ID prc_order_bill.bill_id',
|
||||
`fail_code` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '失败码',
|
||||
`error_message` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '失败原因',
|
||||
`create_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||
@@ -834,8 +834,8 @@ CREATE TABLE `prc_customer_price_set` (
|
||||
-- 表结构:`prc_income_bill`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_income_bill` (
|
||||
`income_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应收主表ID',
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id,一对一',
|
||||
`income_bill_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '应收主表ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id,一对一',
|
||||
`currency` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT 'CNY' COMMENT '币种',
|
||||
`product_amount` decimal(18,4) DEFAULT NULL COMMENT '产品价合计',
|
||||
`redline_amount` decimal(18,4) DEFAULT NULL COMMENT '红线价合计',
|
||||
@@ -880,9 +880,9 @@ CREATE TABLE `prc_profit_commission_rate` (
|
||||
-- 表结构:`prc_income_bill_fee`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_income_bill_fee` (
|
||||
`fee_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用明细ID',
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费ID',
|
||||
`income_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '应收主表ID,对应 prc_income_bill.income_bill_id',
|
||||
`fee_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '费用明细ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费ID',
|
||||
`income_bill_id` bigint(20) DEFAULT NULL COMMENT '应收主表ID,对应 prc_income_bill.income_bill_id',
|
||||
`fee_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用类型(字典bms_fee_type)',
|
||||
`fee_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '费用名称',
|
||||
`sc_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '附加费配置ID',
|
||||
@@ -908,7 +908,7 @@ CREATE TABLE `prc_income_bill_fee` (
|
||||
-- 表结构:`prc_order_bill`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_order_bill` (
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费ID',
|
||||
`bill_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '计费ID',
|
||||
`bill_key` char(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'MD5(order_no)',
|
||||
`order_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单号',
|
||||
`tracking_no` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '运单号',
|
||||
@@ -1003,7 +1003,7 @@ CREATE TABLE `prc_order_bill` (
|
||||
-- 表结构:`prc_order_bill_ext`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_order_bill_ext` (
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id',
|
||||
`order_no` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '订单号',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
@@ -1189,8 +1189,8 @@ CREATE TABLE `prc_order_bill_ext` (
|
||||
-- 表结构:`prc_pay_bill`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_pay_bill` (
|
||||
`pay_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '应付主表ID',
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id,一对一',
|
||||
`pay_bill_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '应付主表ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id,一对一',
|
||||
`currency` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT 'CNY' COMMENT '币种',
|
||||
`product_amount` decimal(18,4) DEFAULT NULL COMMENT '产品价合计',
|
||||
`redline_amount` decimal(18,4) DEFAULT NULL COMMENT '红线价合计',
|
||||
@@ -1215,9 +1215,9 @@ CREATE TABLE `prc_pay_bill` (
|
||||
-- 表结构:`prc_pay_bill_fee`
|
||||
-- ----------------------------
|
||||
CREATE TABLE `prc_pay_bill_fee` (
|
||||
`fee_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用明细ID',
|
||||
`bill_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '计费ID',
|
||||
`pay_bill_id` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '应付主表ID,对应 prc_pay_bill.pay_bill_id',
|
||||
`fee_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '费用明细ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费ID',
|
||||
`pay_bill_id` bigint(20) DEFAULT NULL COMMENT '应付主表ID,对应 prc_pay_bill.pay_bill_id',
|
||||
`fee_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用类型(字典bms_fee_type)',
|
||||
`fee_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '费用名称',
|
||||
`sc_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '附加费配置ID',
|
||||
|
||||
@@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS `pay_bill` (
|
||||
CREATE TABLE IF NOT EXISTS `pay_bill_line` (
|
||||
`line_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账单行ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '应付账单ID',
|
||||
`order_bill_id` varchar(36) DEFAULT NULL COMMENT '订单ID',
|
||||
`order_bill_id` bigint(20) DEFAULT NULL COMMENT '订单ID',
|
||||
`order_no` varchar(64) DEFAULT NULL COMMENT '订单号',
|
||||
`lading_no` varchar(64) DEFAULT NULL COMMENT '提单号',
|
||||
`lading_fee_id` bigint(20) DEFAULT NULL COMMENT '留在主单上的费用',
|
||||
|
||||
@@ -23,7 +23,7 @@ ALTER TABLE `bms`.`pay_bill` ADD COLUMN `confirm_by` varchar(64) CHARACTER SET u
|
||||
ALTER TABLE `bms`.`pay_bill` ADD COLUMN `confirm_time` datetime DEFAULT NULL COMMENT '审核时间' AFTER `confirm_by`;
|
||||
|
||||
-- `pay_bill_line` 增加费用明细ID
|
||||
ALTER TABLE `bms`.`pay_bill_line` ADD COLUMN `fee_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '应付费用明细ID' AFTER `bill_id`;
|
||||
ALTER TABLE `bms`.`pay_bill_line` ADD COLUMN `fee_id` bigint(20) DEFAULT NULL COMMENT '应付费用明细ID' AFTER `bill_id`;
|
||||
|
||||
-- `pay_bill_line` 增加费用来源
|
||||
ALTER TABLE `bms`.`pay_bill_line` ADD COLUMN `fee_source` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'CALC计算 LADING提单分摊 MANUAL人工' AFTER `fee_name`;
|
||||
@@ -53,7 +53,7 @@ ALTER TABLE `bms`.`pay_bill_log` ADD COLUMN `biz_id` bigint(20) DEFAULT NULL COM
|
||||
ALTER TABLE `bms`.`pay_bill_log` ADD COLUMN `line_id` bigint(20) DEFAULT NULL COMMENT '账单行ID' AFTER `biz_id`;
|
||||
|
||||
-- `pay_bill_log` 增加费用明细
|
||||
ALTER TABLE `bms`.`pay_bill_log` ADD COLUMN `fee_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '费用明细ID' AFTER `line_id`;
|
||||
ALTER TABLE `bms`.`pay_bill_log` ADD COLUMN `fee_id` bigint(20) DEFAULT NULL COMMENT '费用明细ID' AFTER `line_id`;
|
||||
|
||||
-- `pay_bill_log` 增加改前金额
|
||||
ALTER TABLE `bms`.`pay_bill_log` ADD COLUMN `amount_before` decimal(18,4) DEFAULT NULL COMMENT '改前金额' AFTER `operation_desc`;
|
||||
@@ -66,13 +66,13 @@ CREATE TABLE `bms`.`pay_bill_diff` (
|
||||
`diff_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '差异ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '应付账单ID',
|
||||
`line_id` bigint(20) NOT NULL COMMENT '账单行ID',
|
||||
`fee_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '费用明细ID',
|
||||
`fee_id` bigint(20) DEFAULT NULL COMMENT '费用明细ID',
|
||||
`our_amount` decimal(18,4) NOT NULL COMMENT '我方金额',
|
||||
`supplier_amount` decimal(18,4) NOT NULL COMMENT '对方金额',
|
||||
`diff_amount` decimal(18,4) NOT NULL COMMENT '差额,对方减我方',
|
||||
`reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '差异原因',
|
||||
`handle_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'OPEN未处理 ACCEPT_OURS接受我方 ACCEPT_THEIRS接受对方',
|
||||
`adjust_fee_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '接受对方时新增的调整费用',
|
||||
`adjust_fee_id` bigint(20) DEFAULT NULL COMMENT '接受对方时新增的调整费用',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`diff_id`),
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
-- 新增应付附加费配置操作记录表,按产品版本保存,内容只含有数据的属性
|
||||
CREATE TABLE IF NOT EXISTS `bms`.`pay_surcharge_rule_log` (
|
||||
`log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录ID',
|
||||
`product_id` bigint(20) NOT NULL COMMENT '应付产品版本ID',
|
||||
`term_id` bigint(20) NOT NULL COMMENT '价卡版本周期',
|
||||
`version_no` int(11) DEFAULT NULL COMMENT '版本号',
|
||||
`operation_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作:1新增 2修改 3删除',
|
||||
`rule_key` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '条件标识,每票都收带费用项',
|
||||
`change_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变更内容,只含有数据的属性',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '操作人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '操作时间',
|
||||
PRIMARY KEY (`log_id`),
|
||||
KEY `idx_pay_surcharge_rule_log_ver` (`product_id`, `term_id`, `log_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='应付附加费配置操作记录';
|
||||
@@ -51,3 +51,39 @@ export function delPayPostcode(groupIds) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function listPayPostcodeZone(query) {
|
||||
return request({ url: '/data/payPostcode/zones', method: 'get', params: query })
|
||||
}
|
||||
|
||||
export function addPayPostcodeZone(data) {
|
||||
return request({ url: '/data/payPostcode/zones', method: 'post', data })
|
||||
}
|
||||
|
||||
export function updatePayPostcodeZone(data) {
|
||||
return request({ url: '/data/payPostcode/zones', method: 'put', data })
|
||||
}
|
||||
|
||||
export function delPayPostcodeZone(query) {
|
||||
return request({ url: '/data/payPostcode/zones', method: 'delete', params: query })
|
||||
}
|
||||
|
||||
export function updatePayPostcodeCountry(data) {
|
||||
return request({ url: '/data/payPostcode/country', method: 'put', data })
|
||||
}
|
||||
|
||||
export function delPayPostcodeCountry(query) {
|
||||
return request({ url: '/data/payPostcode/country', method: 'delete', params: query })
|
||||
}
|
||||
|
||||
export function addPayPostcodeLine(data) {
|
||||
return request({ url: '/data/payPostcode/lines', method: 'post', data })
|
||||
}
|
||||
|
||||
export function updatePayPostcodeLine(data) {
|
||||
return request({ url: '/data/payPostcode/lines', method: 'put', data })
|
||||
}
|
||||
|
||||
export function delPayPostcodeLine(lineIds) {
|
||||
return request({ url: '/data/payPostcode/lines/' + lineIds, method: 'delete' })
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user