Compare commits
98 Commits
880b4751c5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ea62697b98 | |||
| 9273fcec56 | |||
| 5b8d4de262 | |||
| 215effe036 | |||
| 4503424cf0 | |||
| 3cf7fa30bd | |||
| e34e4f117c | |||
| 03043104bc | |||
| a5cd752005 | |||
| 5d44cc4edf | |||
| 0400f55838 | |||
| 1b43bcca4c | |||
| a38e2c7f57 | |||
| 63ded27fd5 | |||
| 2f25a99396 | |||
| 206e4e786b | |||
| 48b7fbc7cf | |||
| 15a72e3503 | |||
| 0179a35942 | |||
| 99651b6758 | |||
| 2342d34194 | |||
| 4de755ca60 | |||
| bcd9c789cb | |||
| bf7b46a231 | |||
| 358e5a46b9 | |||
| 6f78b813f3 | |||
| a71f0a164f | |||
| ee36c8c902 | |||
| f7c7d9fe8b | |||
| 7e699fb80e | |||
| 80d639d887 | |||
| 87ae3e6674 | |||
| 359c3c18e4 | |||
| 4f2f2db20f | |||
| 0094e4aaff | |||
| 8b7c346ec4 | |||
| bde1d7d86e | |||
| 87eab12d51 | |||
| 2d5ffc4e06 | |||
| f03aa7be6c | |||
| 73ce7f4eae | |||
| b49600ab9f | |||
| fb41b2a86c | |||
| fe30b8576b | |||
| 65fcb6895a | |||
| d4f5bb8a4c | |||
| e71103af58 | |||
| 79cc524c03 | |||
| efc7ecbd01 | |||
| b8bbf36767 | |||
| 92cb19fbea | |||
| 4cb82ec107 | |||
| e0dc755ee3 | |||
| 6a02de8069 | |||
| 974f12429a | |||
| e06f07b3dd | |||
| 956fb08bea | |||
| 8d34f84cbb | |||
| b9cdb6c3f9 | |||
| f57af555ea | |||
| 220b01127b | |||
| aa61dc2d1c | |||
| 86ed86fc68 | |||
| fba8b786c0 | |||
| a4bda4d636 | |||
| 00e36cdf3f | |||
| 8eb5dca4f0 | |||
| b671ebefae | |||
| fb5d6d46a8 | |||
| 039c0d4858 | |||
| 43299e5329 | |||
| 3fe34c471c | |||
| 134855fc31 | |||
| 01cee41301 | |||
| 1f0d757e29 | |||
| 762cad2c0d | |||
| 7ef3f40a4f | |||
| 58e41b669d | |||
| 9a48abbacd | |||
| f95edbdf0a | |||
| b30dfdf675 | |||
| 9a393fe7dc | |||
| a2468099c2 | |||
| cbed4dc2a3 | |||
| d66b96b2ff | |||
| cdfc90556d | |||
| dfa90d6e33 | |||
| 4a34075022 | |||
| 6a03300f2f | |||
| 7496f8cbc6 | |||
| 2f2305825a | |||
| b79cd6f995 | |||
| 70a3c34c20 | |||
| 2b5633190e | |||
| 77dfb4291b | |||
| d71b7f04fe | |||
| f8ae347846 | |||
| 94991a1ed3 |
+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")
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package com.bms.web.controller.monitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.price.migration.domain.MigBiJobLog;
|
||||
import com.bms.price.migration.service.IUuidToNewMonitorService;
|
||||
|
||||
/**
|
||||
* 监控:UUID -> bigint 阴影同步进度与开关
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/uuidToNew")
|
||||
public class UuidToNewMonitorController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IUuidToNewMonitorService monitorService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:uuidToNew:list')")
|
||||
@GetMapping("/progress")
|
||||
public AjaxResult progress()
|
||||
{
|
||||
return success(monitorService.getProgress());
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:uuidToNew:list')")
|
||||
@GetMapping("/jobLog/list")
|
||||
public TableDataInfo jobLogList(MigBiJobLog query)
|
||||
{
|
||||
startPage();
|
||||
List<MigBiJobLog> list = monitorService.selectJobLogList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开/关闭连续同步。
|
||||
* body: { "enabled": true, "threadCount": 2, "batchSize": 200 }
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:uuidToNew:switch')")
|
||||
@Log(title = "UUID阴影同步开关", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/enabled")
|
||||
public AjaxResult setEnabled(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
boolean enabled = false;
|
||||
Integer threadCount = null;
|
||||
Integer batchSize = null;
|
||||
if (body != null)
|
||||
{
|
||||
if (body.get("enabled") != null)
|
||||
{
|
||||
enabled = Boolean.parseBoolean(String.valueOf(body.get("enabled")));
|
||||
}
|
||||
threadCount = toInt(body.get("threadCount"));
|
||||
batchSize = toInt(body.get("batchSize"));
|
||||
}
|
||||
monitorService.setEnabled(enabled, threadCount, batchSize);
|
||||
return success(monitorService.getProgress());
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅开关关闭时修改线程/批次。
|
||||
* body: { "threadCount": 2, "batchSize": 200 }
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:uuidToNew:switch')")
|
||||
@Log(title = "UUID阴影同步配置", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/config")
|
||||
public AjaxResult updateConfig(@RequestBody Map<String, Object> body)
|
||||
{
|
||||
Integer threadCount = null;
|
||||
Integer batchSize = null;
|
||||
if (body != null)
|
||||
{
|
||||
threadCount = toInt(body.get("threadCount"));
|
||||
batchSize = toInt(body.get("batchSize"));
|
||||
}
|
||||
monitorService.updateRuntimeConfig(threadCount, batchSize);
|
||||
return success(monitorService.getProgress());
|
||||
}
|
||||
|
||||
private Integer toInt(Object v)
|
||||
{
|
||||
if (v == null || "".equals(String.valueOf(v).trim()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.valueOf(String.valueOf(v).trim());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -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
|
||||
{
|
||||
@@ -541,7 +541,7 @@ public class BillingController extends BaseController
|
||||
{
|
||||
msg = e.getClass().getSimpleName();
|
||||
}
|
||||
fails.add((billId == null ? "" : billId) + ": " + msg);
|
||||
fails.add((billId == null ? "" : String.valueOf(billId)) + ": " + msg);
|
||||
}
|
||||
}
|
||||
if (fails.isEmpty())
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
+1
-1
@@ -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("操作成功");
|
||||
|
||||
+3
-2
@@ -34,6 +34,7 @@ import com.bms.receivable.domain.vo.ArBillGenerateQuery;
|
||||
import com.bms.receivable.domain.vo.ArBillGenerateRequest;
|
||||
import com.bms.receivable.domain.vo.ArBillListExportRow;
|
||||
import com.bms.receivable.domain.vo.ArBillQuery;
|
||||
import com.bms.receivable.domain.vo.ArBillPreviewOrder;
|
||||
import com.bms.receivable.service.IArBillService;
|
||||
import com.bms.receivable.service.ArBillVoidTaskService;
|
||||
import com.bms.receivable.security.ArBillScopeResolver;
|
||||
@@ -175,7 +176,7 @@ public class ArBillController extends BaseController {
|
||||
List<PrcOrderBill> list = billService.previewBill(query);
|
||||
TableDataInfo pageData = getDataTable(list);
|
||||
AjaxResult result = success();
|
||||
result.put("rows", pageData.getRows());
|
||||
result.put("rows", list.stream().map(ArBillPreviewOrder::from).toList());
|
||||
result.put("total", pageData.getTotal());
|
||||
return result;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ public class ArBillController extends BaseController {
|
||||
List<PrcOrderBill> list = billService.previewExcludedBill(query);
|
||||
TableDataInfo pageData = getDataTable(list);
|
||||
AjaxResult result = success();
|
||||
result.put("rows", pageData.getRows());
|
||||
result.put("rows", list.stream().map(ArBillPreviewOrder::from).toList());
|
||||
result.put("total", pageData.getTotal());
|
||||
result.put("totalAmount", billService.sumPreviewBill(query));
|
||||
return result;
|
||||
|
||||
@@ -26,6 +26,16 @@ bms:
|
||||
tms:
|
||||
# Agreed API identification code for TMS callers
|
||||
api-code: BMS.TMS.ZYaOvlQzpcfau8TUaCFfO3Hp8ieHIqGw
|
||||
# UUID -> bigint shadow sync. Toggle on monitor page (no cron).
|
||||
mig:
|
||||
uuid-to-new:
|
||||
# disabled after Long PK cutover; do not enable
|
||||
enabled: false
|
||||
batch-size: 200
|
||||
# 1~16 (same ceiling as local-rebill default); 4c8g often 2~4
|
||||
thread-count: 2
|
||||
# sleep when no pending orders while switch is ON
|
||||
idle-sleep-ms: 3000
|
||||
billing:
|
||||
# MQ mode: redis (default list queue) | local (Spring event)
|
||||
mq-mode: redis
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.bms.price.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步配置(bms.mig.uuid-to-new)
|
||||
* 运行开关/线程/批次由监控页控制,不走 cron。
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "bms.mig.uuid-to-new")
|
||||
public class UuidToNewProperties
|
||||
{
|
||||
/** Master switch; default false after Long PK cutover. */
|
||||
private boolean enabled = false;
|
||||
/** 每轮抓取订单数(1~1000) */
|
||||
private int batchSize = 200;
|
||||
/**
|
||||
* 批内工作线程数(1~16)。
|
||||
* 默认1;冲刺可上到与本地重计费相近的16,4核机器需盯CPU/连接池。
|
||||
*/
|
||||
private int threadCount = 1;
|
||||
/** 无待处理订单时空转睡眠毫秒(开关仍为开时) */
|
||||
private long idleSleepMs = 3000L;
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public int getBatchSize()
|
||||
{
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
public void setBatchSize(int batchSize)
|
||||
{
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
/** 限定在 1~1000 */
|
||||
public int resolvedBatchSize()
|
||||
{
|
||||
int n = batchSize;
|
||||
if (n < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (n > 1000)
|
||||
{
|
||||
return 1000;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public int getThreadCount()
|
||||
{
|
||||
return threadCount;
|
||||
}
|
||||
|
||||
public void setThreadCount(int threadCount)
|
||||
{
|
||||
this.threadCount = threadCount;
|
||||
}
|
||||
|
||||
/** 限定在1~16 */
|
||||
public int resolvedThreadCount()
|
||||
{
|
||||
int n = threadCount;
|
||||
if (n < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (n > 16)
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public long getIdleSleepMs()
|
||||
{
|
||||
return idleSleepMs;
|
||||
}
|
||||
|
||||
public void setIdleSleepMs(long idleSleepMs)
|
||||
{
|
||||
this.idleSleepMs = idleSleepMs;
|
||||
}
|
||||
}
|
||||
@@ -107,4 +107,7 @@ public class LblProduct extends BaseEntity
|
||||
|
||||
/** 邮编→分区(保存时同步到 prc_zone,不落产品子表) */
|
||||
private Map<String, List<String>> zonePostcodes;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -59,4 +59,7 @@ public class LblSurcharge
|
||||
private BigDecimal weightMax;
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -57,4 +57,7 @@ public class LblWeightBand
|
||||
private String extraPriceUnit;
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ public class PayBillLine
|
||||
|
||||
private String feeId;
|
||||
|
||||
private String orderBillId;
|
||||
/** 计费订单ID,对应 prc_order_bill.bill_id */
|
||||
private Long orderBillId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import lombok.Data;
|
||||
@Data
|
||||
public class PayBillOrder
|
||||
{
|
||||
private String billId;
|
||||
/** 计费订单ID,对应 prc_order_bill.bill_id */
|
||||
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<>();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ public class PrcBillingTask extends BaseEntity
|
||||
/** 移动端传入的计费时间(非 Oracle 订单时间;回写时不会被覆盖) */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date billTime;
|
||||
private String billId;
|
||||
/** 对应 prc_order_bill.bill_id */
|
||||
private Long orderId;
|
||||
/** 用于查询的稳定失败码,例如 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;
|
||||
|
||||
@@ -14,8 +14,8 @@ public class PrcPayBill implements Serializable
|
||||
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
/** 计费订单ID */
|
||||
private String billId;
|
||||
/** 计费订单ID,对应 prc_order_bill.bill_id */
|
||||
private Long billId;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 产品价合计 */
|
||||
|
||||
@@ -13,7 +13,8 @@ public class PrcPayBillFee implements Serializable
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String feeId;
|
||||
private String billId;
|
||||
/** 计费订单ID,对应 prc_order_bill.bill_id */
|
||||
private Long billId;
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
private String feeType;
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@ package com.bms.price.domain.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -12,8 +11,8 @@ public class AddIncomeBillFeeRequest implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "billId required")
|
||||
private String billId;
|
||||
@NotNull(message = "billId required")
|
||||
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;
|
||||
|
||||
@@ -33,7 +33,9 @@ public class PrcProfitReportQuery extends BaseEntity
|
||||
private List<String> customerNames;
|
||||
private String belongSalerCode;
|
||||
private String productCode;
|
||||
private String productName;
|
||||
private String countryCode;
|
||||
private String countryName;
|
||||
private String currency;
|
||||
/** 订单维度应收状态筛选:UNBILLED、PARTIAL、BILLED。 */
|
||||
private String arBillStatus;
|
||||
|
||||
+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;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class TmsPriceQuoteFeeLine implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String feeId;
|
||||
private Long feeId;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
/** 附加费配置ID,运费/挂号费为 0 */
|
||||
|
||||
@@ -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;
|
||||
/** 转单号 */
|
||||
|
||||
+2
-3
@@ -3,7 +3,6 @@ package com.bms.price.domain.vo;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -13,8 +12,8 @@ public class UpdateChargeWeightRequest implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "billId is required")
|
||||
private String billId;
|
||||
@NotNull(message = "billId is required")
|
||||
private Long billId;
|
||||
|
||||
@NotNull(message = "chargeWeight is required")
|
||||
@DecimalMin(value = "0.001", message = "chargeWeight must be > 0")
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package com.bms.price.domain.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/** 修改计费明细上的手工应收费用行。 */
|
||||
@@ -11,8 +11,8 @@ public class UpdateIncomeBillFeeRequest implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "feeId required")
|
||||
private String feeId;
|
||||
@NotNull(message = "feeId required")
|
||||
private Long feeId;
|
||||
|
||||
/** 可选:更换附加费配置。 */
|
||||
private Long scId;
|
||||
|
||||
@@ -310,6 +310,8 @@ public final class LblBandNormalizer
|
||||
private static LblWeightBand copyBand(LblWeightBand src)
|
||||
{
|
||||
LblWeightBand b = new LblWeightBand();
|
||||
b.setBandId(src.getBandId());
|
||||
b.setDeleted(src.getDeleted());
|
||||
b.setProductId(src.getProductId());
|
||||
b.setVersionId(src.getVersionId());
|
||||
b.setSectionName(src.getSectionName());
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -36,6 +36,8 @@ public interface LblProductMapper
|
||||
|
||||
int deleteAllVersionsBySetAndNo(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo);
|
||||
|
||||
int deleteVersionById(@Param("versionId") Long versionId);
|
||||
|
||||
List<LblProductVersion> selectVersionsBySet(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
List<LblProductVersion> selectVersionsBySetAndNo(@Param("priceSetId") Long priceSetId,
|
||||
@@ -56,6 +58,8 @@ public interface LblProductMapper
|
||||
|
||||
int deleteWeightBandsByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
int deleteWeightBandById(@Param("bandId") Long bandId);
|
||||
|
||||
List<LblWeightBand> selectWeightBandsByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
int insertSurcharge(LblSurcharge surcharge);
|
||||
@@ -66,6 +70,8 @@ public interface LblProductMapper
|
||||
|
||||
int deleteSurchargesByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
int deleteSurchargeById(@Param("surchargeId") Long surchargeId);
|
||||
|
||||
List<LblSurcharge> selectSurchargesByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
List<Long> selectVersionIdsBySetAndProducts(@Param("priceSetId") Long priceSetId, @Param("productIds") Long[] productIds);
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 插入一张草稿应付账单。
|
||||
|
||||
@@ -24,5 +24,5 @@ public interface PayFinanceMapper
|
||||
|
||||
int stampFee(@Param("feeId") String 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);
|
||||
|
||||
+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<String> 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读取。
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 把仍是未分摊的费用改为已分摊。已经不是未分摊的行不会被改到。
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* mig_bi_job_log 批次日志
|
||||
*/
|
||||
public class MigBiJobLog
|
||||
{
|
||||
private Long id;
|
||||
private String batchNo;
|
||||
private Integer fetched;
|
||||
private Integer success;
|
||||
private Integer fail;
|
||||
private Integer skip;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startedAt;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date finishedAt;
|
||||
private String remark;
|
||||
/** 查询:开始时间起 */
|
||||
private String beginStartedAt;
|
||||
/** 查询:开始时间止 */
|
||||
private String endStartedAt;
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
public String getBatchNo() { return batchNo; }
|
||||
public void setBatchNo(String batchNo) { this.batchNo = batchNo; }
|
||||
public Integer getFetched() { return fetched; }
|
||||
public void setFetched(Integer fetched) { this.fetched = fetched; }
|
||||
public Integer getSuccess() { return success; }
|
||||
public void setSuccess(Integer success) { this.success = success; }
|
||||
public Integer getFail() { return fail; }
|
||||
public void setFail(Integer fail) { this.fail = fail; }
|
||||
public Integer getSkip() { return skip; }
|
||||
public void setSkip(Integer skip) { this.skip = skip; }
|
||||
public Date getStartedAt() { return startedAt; }
|
||||
public void setStartedAt(Date startedAt) { this.startedAt = startedAt; }
|
||||
public Date getFinishedAt() { return finishedAt; }
|
||||
public void setFinishedAt(Date finishedAt) { this.finishedAt = finishedAt; }
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
public String getBeginStartedAt() { return beginStartedAt; }
|
||||
public void setBeginStartedAt(String beginStartedAt) { this.beginStartedAt = beginStartedAt; }
|
||||
public String getEndStartedAt() { return endStartedAt; }
|
||||
public void setEndStartedAt(String endStartedAt) { this.endStartedAt = endStartedAt; }
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* 一批阴影同步结果(供运行器做失败退避/自动停开)
|
||||
*/
|
||||
public class UuidToNewBatchResult
|
||||
{
|
||||
private int fetched;
|
||||
private int success;
|
||||
private int fail;
|
||||
private int skip;
|
||||
/** 本批首条失败原因(截断) */
|
||||
private String sampleError;
|
||||
|
||||
public int getFetched() { return fetched; }
|
||||
public void setFetched(int fetched) { this.fetched = fetched; }
|
||||
public int getSuccess() { return success; }
|
||||
public void setSuccess(int success) { this.success = success; }
|
||||
public int getFail() { return fail; }
|
||||
public void setFail(int fail) { this.fail = fail; }
|
||||
public int getSkip() { return skip; }
|
||||
public void setSkip(int skip) { this.skip = skip; }
|
||||
public String getSampleError() { return sampleError; }
|
||||
public void setSampleError(String sampleError) { this.sampleError = sampleError; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* 旧收入费用行:逐行插入 income *_new 并建内存 Map
|
||||
*/
|
||||
public class UuidToNewFeeRow
|
||||
{
|
||||
private String feeId;
|
||||
private String parentId;
|
||||
|
||||
public String getFeeId() { return feeId; }
|
||||
public void setFeeId(String feeId) { this.feeId = feeId; }
|
||||
public String getParentId() { return parentId; }
|
||||
public void setParentId(String parentId) { this.parentId = parentId; }
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* 阴影插入传参 / 接收自增主键、批次日志
|
||||
*/
|
||||
public class UuidToNewIdHolder
|
||||
{
|
||||
private String oldBillId;
|
||||
private Long newBillId;
|
||||
/** 旧 income_bill_id / fee_id(UUID) */
|
||||
private String oldId;
|
||||
/** 新 income_bill_id / fee_id(bigint) */
|
||||
private Long newId;
|
||||
/** 新 income_bill_id(费用行用) */
|
||||
private Long newIncomeId;
|
||||
private String orderNo;
|
||||
private String status;
|
||||
private String failReason;
|
||||
private String batchNo;
|
||||
private Integer fetched;
|
||||
private Integer success;
|
||||
private Integer fail;
|
||||
private Integer skip;
|
||||
private Long jobLogId;
|
||||
|
||||
public String getOldBillId() { return oldBillId; }
|
||||
public void setOldBillId(String oldBillId) { this.oldBillId = oldBillId; }
|
||||
public Long getNewBillId() { return newBillId; }
|
||||
public void setNewBillId(Long newBillId) { this.newBillId = newBillId; }
|
||||
public String getOldId() { return oldId; }
|
||||
public void setOldId(String oldId) { this.oldId = oldId; }
|
||||
public Long getNewId() { return newId; }
|
||||
public void setNewId(Long newId) { this.newId = newId; }
|
||||
public Long getNewIncomeId() { return newIncomeId; }
|
||||
public void setNewIncomeId(Long newIncomeId) { this.newIncomeId = newIncomeId; }
|
||||
public String getOrderNo() { return orderNo; }
|
||||
public void setOrderNo(String orderNo) { this.orderNo = orderNo; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getFailReason() { return failReason; }
|
||||
public void setFailReason(String failReason) { this.failReason = failReason; }
|
||||
public String getBatchNo() { return batchNo; }
|
||||
public void setBatchNo(String batchNo) { this.batchNo = batchNo; }
|
||||
public Integer getFetched() { return fetched; }
|
||||
public void setFetched(Integer fetched) { this.fetched = fetched; }
|
||||
public Integer getSuccess() { return success; }
|
||||
public void setSuccess(Integer success) { this.success = success; }
|
||||
public Integer getFail() { return fail; }
|
||||
public void setFail(Integer fail) { this.fail = fail; }
|
||||
public Integer getSkip() { return skip; }
|
||||
public void setSkip(Integer skip) { this.skip = skip; }
|
||||
public Long getJobLogId() { return jobLogId; }
|
||||
public void setJobLogId(Long jobLogId) { this.jobLogId = jobLogId; }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 待同步订单(含游标 create_time)
|
||||
*/
|
||||
public class UuidToNewPendingRow
|
||||
{
|
||||
private String billId;
|
||||
private Date createTime;
|
||||
|
||||
public String getBillId() { return billId; }
|
||||
public void setBillId(String billId) { this.billId = billId; }
|
||||
public Date getCreateTime() { return createTime; }
|
||||
public void setCreateTime(Date createTime) { this.createTime = createTime; }
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.bms.price.migration.domain;
|
||||
|
||||
/**
|
||||
* UUID 阴影同步进度概览
|
||||
*/
|
||||
public class UuidToNewProgressVo
|
||||
{
|
||||
private long oldCnt;
|
||||
private long doneCnt;
|
||||
private long newCnt;
|
||||
private long pendingCnt;
|
||||
private double donePercent;
|
||||
/** 监控页开关:是否要跑 */
|
||||
private boolean enabled;
|
||||
/** 循环是否正在执行中 */
|
||||
private boolean running;
|
||||
private int batchSize;
|
||||
private int threadCount;
|
||||
|
||||
public long getOldCnt() { return oldCnt; }
|
||||
public void setOldCnt(long oldCnt) { this.oldCnt = oldCnt; }
|
||||
public long getDoneCnt() { return doneCnt; }
|
||||
public void setDoneCnt(long doneCnt) { this.doneCnt = doneCnt; }
|
||||
public long getNewCnt() { return newCnt; }
|
||||
public void setNewCnt(long newCnt) { this.newCnt = newCnt; }
|
||||
public long getPendingCnt() { return pendingCnt; }
|
||||
public void setPendingCnt(long pendingCnt) { this.pendingCnt = pendingCnt; }
|
||||
public double getDonePercent() { return donePercent; }
|
||||
public void setDonePercent(double donePercent) { this.donePercent = donePercent; }
|
||||
public boolean isEnabled() { return enabled; }
|
||||
public void setEnabled(boolean enabled) { this.enabled = enabled; }
|
||||
public boolean isRunning() { return running; }
|
||||
public void setRunning(boolean running) { this.running = running; }
|
||||
public int getBatchSize() { return batchSize; }
|
||||
public void setBatchSize(int batchSize) { this.batchSize = batchSize; }
|
||||
public int getThreadCount() { return threadCount; }
|
||||
public void setThreadCount(int threadCount) { this.threadCount = threadCount; }
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.bms.price.migration.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.migration.domain.MigBiJobLog;
|
||||
import com.bms.price.migration.domain.UuidToNewFeeRow;
|
||||
import com.bms.price.migration.domain.UuidToNewPendingRow;
|
||||
import java.util.Date;
|
||||
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||
import com.bms.price.migration.domain.UuidToNewProgressVo;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步 Mapper(订单+income *_new + order_id / income_fee_id)
|
||||
*/
|
||||
public interface UuidToNewSyncMapper
|
||||
{
|
||||
/**
|
||||
* 游标抓取未处理订单(避免每批从最早订单全量排序)
|
||||
* @param lastCreateTime 上批最后 create_time;空=从头
|
||||
* @param lastBillId 上批最后 bill_id;与 time 配对
|
||||
*/
|
||||
List<UuidToNewPendingRow> selectPendingBillIds(@Param("limit") int limit,
|
||||
@Param("lastCreateTime") Date lastCreateTime,
|
||||
@Param("lastBillId") String lastBillId);
|
||||
|
||||
/** done 已有进度且 Redis 无游标时:用最新 done 边界初始化 */
|
||||
UuidToNewPendingRow selectPendingCursorBootstrap();
|
||||
|
||||
String selectOrderNo(@Param("oldBillId") String oldBillId);
|
||||
|
||||
int countOrderBill(@Param("oldBillId") String oldBillId);
|
||||
|
||||
int insertOrderBillNew(UuidToNewIdHolder holder);
|
||||
|
||||
int insertOrderDone(UuidToNewIdHolder holder);
|
||||
|
||||
/** INSERT IGNORE 占坑;返回 0 表示已被占用 */
|
||||
int claimOrderDone(UuidToNewIdHolder holder);
|
||||
|
||||
int updateOrderDoneSuccess(UuidToNewIdHolder holder);
|
||||
|
||||
int updateOrderDoneFail(UuidToNewIdHolder holder);
|
||||
|
||||
int insertOrderExtNew(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
List<String> selectIncomeIds(@Param("oldBillId") String oldBillId);
|
||||
|
||||
int insertIncomeBillNew(UuidToNewIdHolder holder);
|
||||
|
||||
List<UuidToNewFeeRow> selectIncomeFees(@Param("oldBillId") String oldBillId);
|
||||
|
||||
int insertIncomeFeeNew(UuidToNewIdHolder holder);
|
||||
|
||||
/** 回写 ar_bill_detail_fee.income_fee_id(= prc_income_bill_fee_new.fee_id) */
|
||||
int updateArDetailFeeIncomeFeeId(@Param("oldFeeId") String oldFeeId, @Param("newFeeId") Long newFeeId);
|
||||
|
||||
/** 回写现网关联表 order_id(= prc_order_bill_new.bill_id) */
|
||||
|
||||
int updatePayBillOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updatePayFeeOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updateArDetailOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updatePayBillLineOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updateBillingTaskOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int updateArGenTaskOrderId(@Param("oldBillId") String oldBillId, @Param("newBillId") Long newBillId);
|
||||
|
||||
int insertJobLogStart(UuidToNewIdHolder holder);
|
||||
|
||||
int updateJobLogFinish(UuidToNewIdHolder holder);
|
||||
|
||||
UuidToNewProgressVo selectProgress();
|
||||
|
||||
List<MigBiJobLog> selectJobLogList(MigBiJobLog query);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.bms.price.migration.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bms.price.migration.domain.MigBiJobLog;
|
||||
import com.bms.price.migration.domain.UuidToNewProgressVo;
|
||||
|
||||
/**
|
||||
* UUID 阴影同步监控
|
||||
*/
|
||||
public interface IUuidToNewMonitorService
|
||||
{
|
||||
UuidToNewProgressVo getProgress();
|
||||
|
||||
List<MigBiJobLog> selectJobLogList(MigBiJobLog query);
|
||||
|
||||
/** 打开/关闭连续同步;开启前可带线程/批次 */
|
||||
void setEnabled(boolean enabled, Integer threadCount, Integer batchSize);
|
||||
|
||||
/**
|
||||
* 仅开关关闭时可改线程与批次。
|
||||
*/
|
||||
void updateRuntimeConfig(Integer threadCount, Integer batchSize);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.bms.price.migration.service;
|
||||
|
||||
import com.bms.price.migration.domain.UuidToNewBatchResult;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步服务
|
||||
*/
|
||||
public interface IUuidToNewSyncService
|
||||
{
|
||||
/**
|
||||
* 执行一批。
|
||||
* @return 本批统计(抓取/成功/失败/跳过)
|
||||
*/
|
||||
UuidToNewBatchResult syncBatch(int batchSize);
|
||||
|
||||
/** 一单一事务;返回 SUCCESS / FAIL / SKIP */
|
||||
String syncOneOrder(String oldBillId);
|
||||
|
||||
/** 独立事务占坑;false=已被占用 */
|
||||
boolean tryClaimOrder(String oldBillId);
|
||||
|
||||
/** 独立事务标记 FAIL,避免失败回滚后被无限重试 */
|
||||
void markOrderFail(String oldBillId, String failReason);
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.bms.price.migration.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.price.config.UuidToNewProperties;
|
||||
import com.bms.price.migration.domain.MigBiJobLog;
|
||||
import com.bms.price.migration.domain.UuidToNewProgressVo;
|
||||
import com.bms.price.migration.mapper.UuidToNewSyncMapper;
|
||||
import com.bms.price.migration.service.IUuidToNewMonitorService;
|
||||
import com.bms.price.task.UuidToNewSyncRunner;
|
||||
|
||||
/**
|
||||
* UUID 阴影同步监控
|
||||
*/
|
||||
@Service
|
||||
public class UuidToNewMonitorServiceImpl implements IUuidToNewMonitorService
|
||||
{
|
||||
@Autowired
|
||||
private UuidToNewSyncMapper syncMapper;
|
||||
|
||||
@Autowired
|
||||
private UuidToNewProperties properties;
|
||||
|
||||
@Autowired
|
||||
private UuidToNewSyncRunner syncRunner;
|
||||
|
||||
@Override
|
||||
public UuidToNewProgressVo getProgress()
|
||||
{
|
||||
UuidToNewProgressVo vo = syncMapper.selectProgress();
|
||||
if (vo == null)
|
||||
{
|
||||
vo = new UuidToNewProgressVo();
|
||||
}
|
||||
long pending = vo.getOldCnt() - vo.getDoneCnt();
|
||||
if (pending < 0L)
|
||||
{
|
||||
pending = 0L;
|
||||
}
|
||||
vo.setPendingCnt(pending);
|
||||
if (vo.getOldCnt() > 0L)
|
||||
{
|
||||
vo.setDonePercent(Math.round(vo.getDoneCnt() * 10000.0 / vo.getOldCnt()) / 100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
vo.setDonePercent(0.0);
|
||||
}
|
||||
vo.setEnabled(syncRunner.isEnabled());
|
||||
vo.setRunning(syncRunner.isRunning());
|
||||
if (properties != null)
|
||||
{
|
||||
vo.setBatchSize(properties.resolvedBatchSize());
|
||||
vo.setThreadCount(properties.resolvedThreadCount());
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MigBiJobLog> selectJobLogList(MigBiJobLog query)
|
||||
{
|
||||
return syncMapper.selectJobLogList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled, Integer threadCount, Integer batchSize)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
throw new ServiceException("切主后 UuidToNew 已停用,不允许开启连续同步");
|
||||
}
|
||||
syncRunner.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRuntimeConfig(Integer threadCount, Integer batchSize)
|
||||
{
|
||||
if (syncRunner.isEnabled() || syncRunner.isRunning())
|
||||
{
|
||||
throw new ServiceException("请先关闭连续同步再修改线程/批次");
|
||||
}
|
||||
applyConfig(threadCount, batchSize);
|
||||
}
|
||||
|
||||
private void applyConfig(Integer threadCount, Integer batchSize)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (threadCount != null)
|
||||
{
|
||||
int n = threadCount.intValue();
|
||||
if (n < 1)
|
||||
{
|
||||
n = 1;
|
||||
}
|
||||
if (n > 16)
|
||||
{
|
||||
n = 16;
|
||||
}
|
||||
properties.setThreadCount(n);
|
||||
}
|
||||
if (batchSize != null)
|
||||
{
|
||||
int n = batchSize.intValue();
|
||||
if (n < 1)
|
||||
{
|
||||
n = 1;
|
||||
}
|
||||
if (n > 1000)
|
||||
{
|
||||
n = 1000;
|
||||
}
|
||||
properties.setBatchSize(n);
|
||||
}
|
||||
if (syncRunner != null)
|
||||
{
|
||||
syncRunner.persistRuntimeConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
+493
@@ -0,0 +1,493 @@
|
||||
package com.bms.price.migration.service.impl;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.bms.common.core.redis.RedisCache;
|
||||
import com.bms.price.config.UuidToNewProperties;
|
||||
import com.bms.price.migration.domain.UuidToNewBatchResult;
|
||||
import com.bms.price.migration.domain.UuidToNewPendingRow;
|
||||
import com.bms.price.migration.domain.UuidToNewFeeRow;
|
||||
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||
import com.bms.price.migration.mapper.UuidToNewSyncMapper;
|
||||
import com.bms.price.migration.service.IUuidToNewSyncService;
|
||||
|
||||
/**
|
||||
* UUID -> bigint 阴影同步:订单+income *_new + 关联表回写 order_id。
|
||||
* 占坑独立提交;一单一事务;批内可多线程;游标抓取避全表排序。
|
||||
*/
|
||||
@Service
|
||||
public class UuidToNewSyncServiceImpl implements IUuidToNewSyncService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(UuidToNewSyncServiceImpl.class);
|
||||
|
||||
public static final String SUCCESS = "SUCCESS";
|
||||
public static final String FAIL = "FAIL";
|
||||
public static final String SKIP = "SKIP";
|
||||
public static final String RUNNING = "RUNNING";
|
||||
|
||||
@Autowired
|
||||
private UuidToNewSyncMapper syncMapper;
|
||||
|
||||
@Autowired
|
||||
private UuidToNewProperties properties;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private IUuidToNewSyncService self;
|
||||
|
||||
/** Redis:抓取游标 create_time */
|
||||
public static final String REDIS_KEY_CURSOR_TIME = "bms:mig:uuid-to-new:cursor-time";
|
||||
/** Redis:抓取游标 bill_id */
|
||||
public static final String REDIS_KEY_CURSOR_BILL_ID = "bms:mig:uuid-to-new:cursor-bill-id";
|
||||
private static final String CURSOR_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
@Override
|
||||
public UuidToNewBatchResult syncBatch(int batchSize)
|
||||
{
|
||||
int limit = Math.max(1, Math.min(batchSize, 1000));
|
||||
int threads = properties == null ? 1 : properties.resolvedThreadCount();
|
||||
String batchNo = UUID.randomUUID().toString().replace("-", "");
|
||||
UuidToNewIdHolder job = new UuidToNewIdHolder();
|
||||
job.setBatchNo(batchNo);
|
||||
syncMapper.insertJobLogStart(job);
|
||||
|
||||
Date lastCreateTime = loadCursorTime();
|
||||
String lastBillId = loadCursorBillId();
|
||||
if (lastCreateTime == null || lastBillId == null || lastBillId.isEmpty())
|
||||
{
|
||||
// done 已有进度时用边界初始化,避免从最早订单重扫
|
||||
UuidToNewPendingRow boot = syncMapper.selectPendingCursorBootstrap();
|
||||
if (boot != null && boot.getCreateTime() != null && boot.getBillId() != null)
|
||||
{
|
||||
lastCreateTime = boot.getCreateTime();
|
||||
lastBillId = boot.getBillId();
|
||||
saveCursor(lastCreateTime, lastBillId);
|
||||
log.info("uuid-to-new cursor bootstrap billId={} createTime={}", lastBillId, lastCreateTime);
|
||||
}
|
||||
}
|
||||
|
||||
List<UuidToNewPendingRow> pending = syncMapper.selectPendingBillIds(limit, lastCreateTime, lastBillId);
|
||||
List<String> billIds = new ArrayList<String>();
|
||||
for (UuidToNewPendingRow row : pending)
|
||||
{
|
||||
if (row != null && row.getBillId() != null)
|
||||
{
|
||||
billIds.add(row.getBillId());
|
||||
}
|
||||
}
|
||||
AtomicInteger success = new AtomicInteger(0);
|
||||
AtomicInteger fail = new AtomicInteger(0);
|
||||
AtomicInteger skip = new AtomicInteger(0);
|
||||
AtomicReference<String> sampleError = new AtomicReference<String>();
|
||||
|
||||
if (billIds.isEmpty())
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
else if (threads <= 1)
|
||||
{
|
||||
for (String oldBillId : billIds)
|
||||
{
|
||||
applyResult(self, oldBillId, success, fail, skip, sampleError);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecutorService pool = Executors.newFixedThreadPool(threads);
|
||||
try
|
||||
{
|
||||
List<Future<?>> futures = new ArrayList<Future<?>>();
|
||||
for (String oldBillId : billIds)
|
||||
{
|
||||
final String id = oldBillId;
|
||||
futures.add(pool.submit(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
applyResult(self, id, success, fail, skip, sampleError);
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (Future<?> f : futures)
|
||||
{
|
||||
try
|
||||
{
|
||||
f.get();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
sampleError.compareAndSet(null, abbreviate(e));
|
||||
log.warn("uuid-to-new worker future error: {}", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
pool.shutdown();
|
||||
try
|
||||
{
|
||||
if (!pool.awaitTermination(2, TimeUnit.HOURS))
|
||||
{
|
||||
pool.shutdownNow();
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ie)
|
||||
{
|
||||
pool.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
job.setFetched(billIds.size());
|
||||
job.setSuccess(success.get());
|
||||
job.setFail(fail.get());
|
||||
job.setSkip(skip.get());
|
||||
String remark = "threads=" + threads;
|
||||
if (sampleError.get() != null)
|
||||
{
|
||||
remark = remark + "; err=" + sampleError.get();
|
||||
}
|
||||
job.setFailReason(abbreviate(remark, 480));
|
||||
syncMapper.updateJobLogFinish(job);
|
||||
|
||||
// 批次结束后推进游标(本批已尝试的最后一单)
|
||||
if (!pending.isEmpty())
|
||||
{
|
||||
UuidToNewPendingRow last = pending.get(pending.size() - 1);
|
||||
if (last.getCreateTime() != null && last.getBillId() != null)
|
||||
{
|
||||
saveCursor(last.getCreateTime(), last.getBillId());
|
||||
}
|
||||
}
|
||||
|
||||
UuidToNewBatchResult result = new UuidToNewBatchResult();
|
||||
result.setFetched(billIds.size());
|
||||
result.setSuccess(success.get());
|
||||
result.setFail(fail.get());
|
||||
result.setSkip(skip.get());
|
||||
result.setSampleError(sampleError.get());
|
||||
log.info("uuid-to-new batch={} threads={} fetched={} success={} fail={} skip={} err={}",
|
||||
batchNo, threads, result.getFetched(), result.getSuccess(), result.getFail(),
|
||||
result.getSkip(), result.getSampleError());
|
||||
return result;
|
||||
}
|
||||
|
||||
private void applyResult(IUuidToNewSyncService svc, String oldBillId,
|
||||
AtomicInteger success, AtomicInteger fail, AtomicInteger skip,
|
||||
AtomicReference<String> sampleError)
|
||||
{
|
||||
try
|
||||
{
|
||||
String r = svc.syncOneOrder(oldBillId);
|
||||
if (SUCCESS.equals(r))
|
||||
{
|
||||
success.incrementAndGet();
|
||||
}
|
||||
else if (SKIP.equals(r))
|
||||
{
|
||||
skip.incrementAndGet();
|
||||
}
|
||||
else if (FAIL.equals(r))
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
}
|
||||
else
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
String msg = abbreviate(e);
|
||||
sampleError.compareAndSet(null, msg);
|
||||
try
|
||||
{
|
||||
svc.markOrderFail(oldBillId, msg);
|
||||
}
|
||||
catch (Exception markEx)
|
||||
{
|
||||
log.warn("uuid-to-new mark FAIL failed billId={}: {}", oldBillId, markEx.toString());
|
||||
}
|
||||
log.warn("uuid-to-new sync fail billId={}: {}", oldBillId, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 占坑临时 new_bill_id:负数,避免与自增正数冲突。
|
||||
*/
|
||||
static long claimTempNewBillId(String oldBillId)
|
||||
{
|
||||
long h = UUID.nameUUIDFromBytes(oldBillId.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits();
|
||||
if (h == 0L)
|
||||
{
|
||||
h = -1L;
|
||||
}
|
||||
else if (h > 0L)
|
||||
{
|
||||
h = -h;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
private static String abbreviate(Throwable e)
|
||||
{
|
||||
if (e == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Throwable root = e;
|
||||
while (root.getCause() != null && root.getCause() != root)
|
||||
{
|
||||
root = root.getCause();
|
||||
}
|
||||
String msg = root.getClass().getSimpleName() + ": " + root.getMessage();
|
||||
return abbreviate(msg, 450);
|
||||
}
|
||||
|
||||
private static String abbreviate(String s, int max)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String t = s.replace('\r', ' ').replace('\n', ' ');
|
||||
if (t.length() <= max)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return t.substring(0, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public boolean tryClaimOrder(String oldBillId)
|
||||
{
|
||||
if (oldBillId == null || oldBillId.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (syncMapper.countOrderBill(oldBillId) <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
String orderNo = syncMapper.selectOrderNo(oldBillId);
|
||||
UuidToNewIdHolder claim = new UuidToNewIdHolder();
|
||||
claim.setOldBillId(oldBillId);
|
||||
claim.setNewBillId(claimTempNewBillId(oldBillId));
|
||||
claim.setOrderNo(orderNo);
|
||||
claim.setStatus(RUNNING);
|
||||
return syncMapper.claimOrderDone(claim) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public void markOrderFail(String oldBillId, String failReason)
|
||||
{
|
||||
if (oldBillId == null || oldBillId.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
UuidToNewIdHolder h = new UuidToNewIdHolder();
|
||||
h.setOldBillId(oldBillId);
|
||||
h.setFailReason(abbreviate(failReason, 480));
|
||||
int n = syncMapper.updateOrderDoneFail(h);
|
||||
if (n <= 0)
|
||||
{
|
||||
// 占坑未成功时补一条 FAIL,阻止再被抓取
|
||||
h.setNewBillId(claimTempNewBillId(oldBillId));
|
||||
h.setOrderNo(syncMapper.selectOrderNo(oldBillId));
|
||||
h.setStatus(FAIL);
|
||||
syncMapper.insertOrderDone(h);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String syncOneOrder(String oldBillId)
|
||||
{
|
||||
if (oldBillId == null || oldBillId.isEmpty())
|
||||
{
|
||||
return SKIP;
|
||||
}
|
||||
if (!self.tryClaimOrder(oldBillId))
|
||||
{
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
UuidToNewIdHolder order = new UuidToNewIdHolder();
|
||||
order.setOldBillId(oldBillId);
|
||||
syncMapper.insertOrderBillNew(order);
|
||||
Long newBillId = order.getNewBillId();
|
||||
if (newBillId == null)
|
||||
{
|
||||
throw new IllegalStateException("insert prc_order_bill_new no generated bill_id");
|
||||
}
|
||||
|
||||
String orderNo = syncMapper.selectOrderNo(oldBillId);
|
||||
UuidToNewIdHolder done = new UuidToNewIdHolder();
|
||||
done.setOldBillId(oldBillId);
|
||||
done.setNewBillId(newBillId);
|
||||
done.setOrderNo(orderNo);
|
||||
syncMapper.updateOrderDoneSuccess(done);
|
||||
|
||||
syncMapper.insertOrderExtNew(oldBillId, newBillId);
|
||||
copyIncomeShadow(oldBillId, newBillId);
|
||||
fillRelatedOrderIds(oldBillId, newBillId);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝收入主表/费用到 *_new:income_bill_id、fee_id UUID -> bigint AI
|
||||
*/
|
||||
private void copyIncomeShadow(String oldBillId, Long newBillId)
|
||||
{
|
||||
Map<String, Long> incomeMap = new HashMap<String, Long>();
|
||||
for (String oldIncomeId : syncMapper.selectIncomeIds(oldBillId))
|
||||
{
|
||||
UuidToNewIdHolder h = new UuidToNewIdHolder();
|
||||
h.setOldId(oldIncomeId);
|
||||
h.setNewBillId(newBillId);
|
||||
syncMapper.insertIncomeBillNew(h);
|
||||
if (h.getNewId() == null)
|
||||
{
|
||||
throw new IllegalStateException("insert income_new no id for " + oldIncomeId);
|
||||
}
|
||||
incomeMap.put(oldIncomeId, h.getNewId());
|
||||
}
|
||||
|
||||
for (UuidToNewFeeRow row : syncMapper.selectIncomeFees(oldBillId))
|
||||
{
|
||||
Long newIncomeId = null;
|
||||
if (row.getParentId() != null && !row.getParentId().isEmpty())
|
||||
{
|
||||
newIncomeId = incomeMap.get(row.getParentId());
|
||||
if (newIncomeId == null)
|
||||
{
|
||||
throw new IllegalStateException("incomeMap miss " + row.getParentId());
|
||||
}
|
||||
}
|
||||
UuidToNewIdHolder h = new UuidToNewIdHolder();
|
||||
h.setOldId(row.getFeeId());
|
||||
h.setNewBillId(newBillId);
|
||||
h.setNewIncomeId(newIncomeId);
|
||||
syncMapper.insertIncomeFeeNew(h);
|
||||
Long newFeeId = h.getNewId();
|
||||
if (newFeeId == null)
|
||||
{
|
||||
throw new IllegalStateException("insert income_fee_new no id for " + row.getFeeId());
|
||||
}
|
||||
// 回写现网 AR 费用行:旧 UUID 列不动,income_fee_id=新 fee_id
|
||||
syncMapper.updateArDetailFeeIncomeFeeId(row.getFeeId(), newFeeId);
|
||||
}
|
||||
}
|
||||
|
||||
/** 现网关联表回写 order_id;旧 UUID 列不动 */
|
||||
private void fillRelatedOrderIds(String oldBillId, Long newBillId)
|
||||
{
|
||||
syncMapper.updatePayBillOrderId(oldBillId, newBillId);
|
||||
syncMapper.updatePayFeeOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateArDetailOrderId(oldBillId, newBillId);
|
||||
syncMapper.updatePayBillLineOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateBillingTaskOrderId(oldBillId, newBillId);
|
||||
syncMapper.updateArGenTaskOrderId(oldBillId, newBillId);
|
||||
}
|
||||
|
||||
private Date loadCursorTime()
|
||||
{
|
||||
if (redisCache == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
Object v = redisCache.getCacheObject(REDIS_KEY_CURSOR_TIME);
|
||||
if (v == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (v instanceof Date)
|
||||
{
|
||||
return (Date) v;
|
||||
}
|
||||
String s = String.valueOf(v).trim();
|
||||
if (s.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new SimpleDateFormat(CURSOR_TIME_PATTERN).parse(s);
|
||||
}
|
||||
catch (ParseException pe)
|
||||
{
|
||||
log.warn("uuid-to-new parse cursor time failed: {}", pe.toString());
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warn("uuid-to-new load cursor time failed: {}", e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String loadCursorBillId()
|
||||
{
|
||||
if (redisCache == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
Object v = redisCache.getCacheObject(REDIS_KEY_CURSOR_BILL_ID);
|
||||
return v == null ? null : String.valueOf(v).trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warn("uuid-to-new load cursor billId failed: {}", e.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCursor(Date createTime, String billId)
|
||||
{
|
||||
if (redisCache == null || createTime == null || billId == null || billId.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String t = new SimpleDateFormat(CURSOR_TIME_PATTERN).format(createTime);
|
||||
redisCache.setCacheObject(REDIS_KEY_CURSOR_TIME, t);
|
||||
redisCache.setCacheObject(REDIS_KEY_CURSOR_BILL_ID, billId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warn("uuid-to-new save cursor failed: {}", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -297,6 +297,7 @@ public final class PayCostCalculator
|
||||
return;
|
||||
}
|
||||
List<PayCostLine> sized = new ArrayList<>();
|
||||
List<PayCostLine> stepped = new ArrayList<>();
|
||||
for (PaySurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee == null || !inForce(fee, bizDate))
|
||||
@@ -314,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))
|
||||
@@ -413,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,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<>();
|
||||
@@ -660,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)
|
||||
{
|
||||
@@ -677,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;
|
||||
}
|
||||
@@ -694,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);
|
||||
@@ -712,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)
|
||||
@@ -747,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;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,7 @@ public final class PaySurchargeRules
|
||||
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)
|
||||
@@ -381,6 +382,14 @@ public final class PaySurchargeRules
|
||||
continue;
|
||||
}
|
||||
String ruleName = detail.get("feeName") == null ? "" : String.valueOf(detail.get("feeName")).trim();
|
||||
if (ruleName.isEmpty())
|
||||
{
|
||||
if (!hasPeriod(detail))
|
||||
{
|
||||
open = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!ruleName.equals(name))
|
||||
{
|
||||
continue;
|
||||
@@ -389,12 +398,9 @@ public final class PaySurchargeRules
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+309
-31
@@ -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;
|
||||
|
||||
@@ -210,15 +215,11 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
Long priceSetId = ensureLabelPriceSet(command);
|
||||
report(listener, 8, "套餐 " + priceSetId + " 就绪,开始落库产品");
|
||||
String operator = SecurityUtils.getUsername();
|
||||
Date keepStart = null;
|
||||
String keepStatus = TERM_PENDING;
|
||||
int nextVersionNo;
|
||||
boolean editPendingVersion = command.getVersionNo() != null;
|
||||
if (editPendingVersion)
|
||||
boolean editVersion = command.getVersionNo() != null;
|
||||
if (editVersion)
|
||||
{
|
||||
VersionKeep keep = clearEditableVersion(priceSetId, command.getVersionNo(), operator);
|
||||
keepStart = keep.effectiveStart;
|
||||
keepStatus = keep.status == null ? TERM_PENDING : keep.status;
|
||||
assertEditableVersionExists(priceSetId, command.getVersionNo());
|
||||
nextVersionNo = command.getVersionNo();
|
||||
}
|
||||
else
|
||||
@@ -229,13 +230,24 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
int saved = 0;
|
||||
int replaced = 0;
|
||||
int skipped = 0;
|
||||
int removed = 0;
|
||||
List<LblProduct> products = command.getProducts();
|
||||
int total = products.size();
|
||||
Map<String, Map<String, List<String>>> zoneSyncByCountry = new LinkedHashMap<String, Map<String, List<String>>>();
|
||||
for (int i = 0; i < products.size(); i++)
|
||||
{
|
||||
LblProduct product = products.get(i);
|
||||
if (product == null || isBlank(product.getProductName()) || isBlank(product.getSheetName())
|
||||
if (product == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PROD_FIELD.exception();
|
||||
}
|
||||
if (editVersion && Boolean.TRUE.equals(product.getDeleted()))
|
||||
{
|
||||
removeEditVersionProduct(priceSetId, nextVersionNo, product);
|
||||
removed++;
|
||||
continue;
|
||||
}
|
||||
if (isBlank(product.getProductName()) || isBlank(product.getSheetName())
|
||||
|| isBlank(product.getFileMd5()))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PROD_FIELD.exception();
|
||||
@@ -243,7 +255,15 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
String displayName = blankTo(product.getProductName(), product.getSheetName());
|
||||
int pct = 10 + (int) Math.floor((i * 75.0) / Math.max(total, 1));
|
||||
report(listener, pct, "正在保存「" + displayName + "」(" + (i + 1) + "/" + total + ")");
|
||||
LblBandNormalizer.normalizeProduct(product);
|
||||
if (editVersion && product.getVersionId() != null)
|
||||
{
|
||||
// 编辑已有版本:不做拆合归一,保留 bandId/surchargeId
|
||||
fillBandDefaults(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
LblBandNormalizer.normalizeProduct(product);
|
||||
}
|
||||
String dict = blankTo(product.getDictValue(), product.getProductName());
|
||||
product.setDictValue(dict);
|
||||
Long existsId = lblProductMapper.selectProductIdBySetAndDict(priceSetId, dict);
|
||||
@@ -252,7 +272,7 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
LblProduct byDict = lblProductMapper.selectProductByDict(dict);
|
||||
existsId = byDict == null ? null : byDict.getProductId();
|
||||
}
|
||||
boolean hasPending = !editPendingVersion && existsId != null && hasPending(priceSetId, existsId);
|
||||
boolean hasPending = !editVersion && existsId != null && hasPending(priceSetId, existsId);
|
||||
if (hasPending && !command.isOverwrite())
|
||||
{
|
||||
skipped++;
|
||||
@@ -265,20 +285,36 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
product.setCreateTime(new Date());
|
||||
if (existsId != null)
|
||||
{
|
||||
if (editPendingVersion || command.isOverwrite())
|
||||
{
|
||||
lblProductMapper.closePendingBySetProduct(priceSetId, existsId, yesterday(), operator);
|
||||
}
|
||||
product.setProductId(existsId);
|
||||
lblProductMapper.updateProduct(product);
|
||||
openVersion(product, priceSetId, nextVersionNo, operator);
|
||||
replaced++;
|
||||
if (editVersion && product.getVersionId() != null)
|
||||
{
|
||||
assertVersionBelongs(product.getVersionId(), priceSetId, nextVersionNo, existsId);
|
||||
upsertDetails(product, product.getVersionId());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!editVersion && command.isOverwrite())
|
||||
{
|
||||
lblProductMapper.closePendingBySetProduct(priceSetId, existsId, yesterday(), operator);
|
||||
}
|
||||
openVersion(product, priceSetId, nextVersionNo, operator);
|
||||
if (editVersion)
|
||||
{
|
||||
alignNewVersionMeta(priceSetId, nextVersionNo, product.getVersionId(), operator);
|
||||
}
|
||||
replaced++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
product.setProductId(null);
|
||||
lblProductMapper.insertProduct(product);
|
||||
openVersion(product, priceSetId, nextVersionNo, operator);
|
||||
if (editVersion)
|
||||
{
|
||||
alignNewVersionMeta(priceSetId, nextVersionNo, product.getVersionId(), operator);
|
||||
}
|
||||
}
|
||||
saved++;
|
||||
collectZoneSync(zoneSyncByCountry, product);
|
||||
@@ -288,20 +324,9 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
{
|
||||
prcZoneService.syncCountryZones(e.getKey(), e.getValue());
|
||||
}
|
||||
if (editPendingVersion && keepStart != null)
|
||||
{
|
||||
List<LblProductVersion> rows = lblProductMapper.selectVersionsBySetAndNo(priceSetId, nextVersionNo);
|
||||
for (LblProductVersion row : rows)
|
||||
{
|
||||
row.setEffectiveStart(keepStart);
|
||||
row.setStatus(keepStatus);
|
||||
row.setUpdateBy(operator);
|
||||
lblProductMapper.updateVersion(row);
|
||||
}
|
||||
}
|
||||
report(listener, 98, "保存完成,正在收尾");
|
||||
return editPendingVersion
|
||||
? ("套餐" + priceSetId + "版本V" + nextVersionNo + "已更新" + saved + "个产品")
|
||||
return editVersion
|
||||
? ("套餐" + priceSetId + "版本V" + nextVersionNo + "已更新" + saved + "个产品,删除" + removed + "个")
|
||||
: ("套餐" + priceSetId + "已保存" + saved + "个产品,新版本" + replaced + "个,跳过" + skipped + "个");
|
||||
}
|
||||
|
||||
@@ -546,12 +571,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() + "个渠道";
|
||||
@@ -661,6 +695,230 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void assertEditableVersionExists(Long priceSetId, Integer versionNo)
|
||||
{
|
||||
List<LblProductVersion> rows = lblProductMapper.selectVersionsBySetAndNo(priceSetId, versionNo);
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
throw new ServiceException("版本不存在");
|
||||
}
|
||||
for (LblProductVersion row : rows)
|
||||
{
|
||||
if (!TERM_PENDING.equals(row.getStatus()) && !TERM_EFFECT.equals(row.getStatus()))
|
||||
{
|
||||
throw new ServiceException("只能编辑待生效或已生效版本");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assertVersionBelongs(Long versionId, Long priceSetId, int versionNo, Long productId)
|
||||
{
|
||||
LblProductVersion ver = lblProductMapper.selectVersionById(versionId);
|
||||
if (ver == null)
|
||||
{
|
||||
throw new ServiceException("价卡版本不存在");
|
||||
}
|
||||
if (!priceSetId.equals(ver.getPriceSetId()) || ver.getVersionNo() == null || ver.getVersionNo().intValue() != versionNo)
|
||||
{
|
||||
throw new ServiceException("版本与当前编辑版不匹配");
|
||||
}
|
||||
if (productId != null && ver.getProductId() != null && !productId.equals(ver.getProductId()))
|
||||
{
|
||||
throw new ServiceException("版本产品不匹配");
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEditVersionProduct(Long priceSetId, int versionNo, LblProduct product)
|
||||
{
|
||||
Long versionId = product.getVersionId();
|
||||
if (versionId == null && product.getProductId() != null)
|
||||
{
|
||||
List<LblProductVersion> rows = lblProductMapper.selectVersionsBySetAndNo(priceSetId, versionNo);
|
||||
if (rows != null)
|
||||
{
|
||||
for (LblProductVersion row : rows)
|
||||
{
|
||||
if (product.getProductId().equals(row.getProductId()))
|
||||
{
|
||||
versionId = row.getVersionId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (versionId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LblProductVersion exists = lblProductMapper.selectVersionById(versionId);
|
||||
if (exists == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
assertVersionBelongs(versionId, priceSetId, versionNo, product.getProductId());
|
||||
lblProductMapper.deleteWeightBandsByVersion(versionId);
|
||||
lblProductMapper.deleteSurchargesByVersion(versionId);
|
||||
lblProductMapper.deleteVersionById(versionId);
|
||||
}
|
||||
|
||||
private void alignNewVersionMeta(Long priceSetId, int versionNo, Long newVersionId, String operator)
|
||||
{
|
||||
if (newVersionId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<LblProductVersion> rows = lblProductMapper.selectVersionsBySetAndNo(priceSetId, versionNo);
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
LblProductVersion sample = null;
|
||||
for (LblProductVersion row : rows)
|
||||
{
|
||||
if (row != null && row.getVersionId() != null && !newVersionId.equals(row.getVersionId()))
|
||||
{
|
||||
sample = row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sample == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LblProductVersion neu = lblProductMapper.selectVersionById(newVersionId);
|
||||
if (neu == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
neu.setEffectiveStart(sample.getEffectiveStart());
|
||||
neu.setEffectiveEnd(sample.getEffectiveEnd());
|
||||
neu.setStatus(sample.getStatus() == null ? TERM_PENDING : sample.getStatus());
|
||||
neu.setUpdateBy(operator);
|
||||
lblProductMapper.updateVersion(neu);
|
||||
}
|
||||
|
||||
private void fillBandDefaults(LblProduct product)
|
||||
{
|
||||
if (product == null || product.getWeightBands() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int sort = 0;
|
||||
for (LblWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band == null || Boolean.TRUE.equals(band.getDeleted()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (band.getFeeType() == null || band.getFeeType().isEmpty())
|
||||
{
|
||||
band.setFeeType("FREIGHT");
|
||||
}
|
||||
if (band.getChargeMode() == null || band.getChargeMode().isEmpty())
|
||||
{
|
||||
band.setChargeMode("ITEM");
|
||||
}
|
||||
if (band.getCountryCode() == null)
|
||||
{
|
||||
band.setCountryCode("");
|
||||
}
|
||||
if (band.getZoneCode() == null)
|
||||
{
|
||||
band.setZoneCode("");
|
||||
}
|
||||
if (band.getPostcodeParam() == null)
|
||||
{
|
||||
band.setPostcodeParam("");
|
||||
}
|
||||
if (band.getCalcParam() == null)
|
||||
{
|
||||
band.setCalcParam("");
|
||||
}
|
||||
band.setSortNo(sort++);
|
||||
}
|
||||
}
|
||||
|
||||
private void upsertDetails(LblProduct product, Long versionId)
|
||||
{
|
||||
if (product.getWeightBands() != null)
|
||||
{
|
||||
int i = 0;
|
||||
for (LblWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Boolean.TRUE.equals(band.getDeleted()))
|
||||
{
|
||||
if (band.getBandId() != null)
|
||||
{
|
||||
lblProductMapper.deleteWeightBandById(band.getBandId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
band.setProductId(product.getProductId());
|
||||
band.setVersionId(versionId);
|
||||
if (band.getCountryCode() == null)
|
||||
{
|
||||
band.setCountryCode("");
|
||||
}
|
||||
if (band.getZoneCode() == null)
|
||||
{
|
||||
band.setZoneCode("");
|
||||
}
|
||||
if (band.getPostcodeParam() == null)
|
||||
{
|
||||
band.setPostcodeParam("");
|
||||
}
|
||||
band.setSortNo(i++);
|
||||
if (band.getBandId() != null)
|
||||
{
|
||||
lblProductMapper.updateWeightBand(band);
|
||||
}
|
||||
else
|
||||
{
|
||||
lblProductMapper.insertWeightBand(band);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (product.getSurcharges() != null)
|
||||
{
|
||||
int i = 0;
|
||||
for (LblSurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Boolean.TRUE.equals(fee.getDeleted()))
|
||||
{
|
||||
if (fee.getSurchargeId() != null)
|
||||
{
|
||||
lblProductMapper.deleteSurchargeById(fee.getSurchargeId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (isBlank(fee.getFeeName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
fee.setProductId(product.getProductId());
|
||||
fee.setVersionId(versionId);
|
||||
fee.setSortNo(i++);
|
||||
if (fee.getSurchargeId() != null)
|
||||
{
|
||||
lblProductMapper.updateSurcharge(fee);
|
||||
}
|
||||
else
|
||||
{
|
||||
lblProductMapper.insertSurcharge(fee);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VersionKeep clearEditableVersion(Long priceSetId, Integer versionNo, String operator)
|
||||
{
|
||||
List<LblProductVersion> rows = lblProductMapper.selectVersionsBySetAndNo(priceSetId, versionNo);
|
||||
@@ -772,8 +1030,28 @@ public class LblProductServiceImpl implements ILblProductService
|
||||
|
||||
private void prepareCounts(LblProduct product)
|
||||
{
|
||||
int bands = product.getWeightBands() == null ? 0 : product.getWeightBands().size();
|
||||
int fees = product.getSurcharges() == null ? 0 : product.getSurcharges().size();
|
||||
int bands = 0;
|
||||
if (product.getWeightBands() != null)
|
||||
{
|
||||
for (LblWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band != null && !Boolean.TRUE.equals(band.getDeleted()))
|
||||
{
|
||||
bands++;
|
||||
}
|
||||
}
|
||||
}
|
||||
int fees = 0;
|
||||
if (product.getSurcharges() != null)
|
||||
{
|
||||
for (LblSurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee != null && !Boolean.TRUE.equals(fee.getDeleted()) && !isBlank(fee.getFeeName()))
|
||||
{
|
||||
fees++;
|
||||
}
|
||||
}
|
||||
}
|
||||
product.setWeightCount(bands);
|
||||
product.setSurchargeCount(fees);
|
||||
}
|
||||
|
||||
+18
-12
@@ -152,9 +152,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 +228,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)
|
||||
@@ -399,7 +399,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();
|
||||
}
|
||||
@@ -584,11 +584,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 ? null : source.getFeeId());
|
||||
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,11 +947,11 @@ 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)
|
||||
{
|
||||
if (order.getBillId().equals(billId))
|
||||
if (order.getBillId() != null && order.getBillId().equals(billId))
|
||||
{
|
||||
return order;
|
||||
}
|
||||
@@ -1107,11 +1111,12 @@ 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
|
||||
? (fee.getBillId() == null ? "" : String.valueOf(fee.getBillId())) : order.getOrderNo();
|
||||
String why = partyReason(fee, order, supplier, cards);
|
||||
if (why == null)
|
||||
{
|
||||
@@ -1127,7 +1132,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)
|
||||
{
|
||||
@@ -1148,7 +1153,8 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
{
|
||||
return "人工费用没有付款对象,未并入";
|
||||
}
|
||||
String card = cards.computeIfAbsent(fee.getBillId(), payOrderCostService::cardSupplierName);
|
||||
String card = cards.computeIfAbsent(fee.getBillId(),
|
||||
id -> payOrderCostService.cardSupplierName(id));
|
||||
if (card == null || card.isBlank())
|
||||
{
|
||||
return "价卡没有归属供应商,未并入";
|
||||
@@ -1263,7 +1269,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();
|
||||
|
||||
+44
-18
@@ -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();
|
||||
@@ -115,13 +115,9 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
boolean postcodeOn = ruleOn(billingRules, PaySurchargeRules.POSTCODE);
|
||||
boolean zoneOn = ruleOn(billingRules, PaySurchargeRules.ZONE);
|
||||
List<PayRemoteBook.Hit> remoteHits = null;
|
||||
if (postcodeOn && !hasPrefixRules(billingRules, PaySurchargeRules.POSTCODE))
|
||||
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,
|
||||
@@ -146,15 +142,15 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
}
|
||||
|
||||
@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 "";
|
||||
@@ -196,7 +192,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
priced.setBillingRules(rules == null ? new ArrayList<>() : rules);
|
||||
}
|
||||
|
||||
/** 配置页已经写了邮编前缀时,命中邮编不再去应付邮编配置里查偏远。 */
|
||||
/** 附加费规则里已经写了邮编前缀时,偏远不再去应付邮编配置里查。 */
|
||||
private static boolean hasPrefixRules(List<PaySurchargeRule> rules, String calcRule)
|
||||
{
|
||||
if (rules == null)
|
||||
@@ -265,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))
|
||||
{
|
||||
@@ -299,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -559,7 +585,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, String payBillId, List<PayCostLine> fees)
|
||||
{
|
||||
payBillFeeMapper.deleteByBillId(billId);
|
||||
List<PrcPayBillFee> rows = new java.util.ArrayList<>();
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -175,7 +175,7 @@ public class PaySurchargeRuleServiceImpl implements IPaySurchargeRuleService
|
||||
String feeName = text(row.getDetail().get("feeName"));
|
||||
if (feeName != null && !alwaysFees.add(feeName))
|
||||
{
|
||||
throw new ServiceException("每票都收的费用项不能重复:" + feeName);
|
||||
throw new ServiceException("存在两笔同类型的附加费:" + feeName);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
|
||||
+6
-6
@@ -524,7 +524,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
PrcBillingTask reset = new PrcBillingTask();
|
||||
reset.setTaskId(taskId);
|
||||
reset.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
|
||||
reset.setBillId(null);
|
||||
reset.setOrderId(null);
|
||||
reset.setFailCode(null);
|
||||
reset.setErrorMessage(null);
|
||||
billingTaskMapper.updateBillingResult(reset);
|
||||
@@ -622,7 +622,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
return existed == null ? BillTaskType.PENDING : BillTaskType.REBILL;
|
||||
}
|
||||
|
||||
/** 仅回写 status/billId/failCode/error;入参的 transfer/tracking/order/billTime 保持不变。 */
|
||||
/** 仅回写 status/orderId/failCode/error;入参的 transfer/tracking/order/billTime 保持不变。 */
|
||||
/** 任务无客户编码时优先使用已有账单的客户(REFUND 路径)。 */
|
||||
private void fillCustomerCodeFromBill(PrcBillingTask task, String orderNo)
|
||||
{
|
||||
@@ -635,9 +635,9 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillByOrderNo(orderNo.trim());
|
||||
}
|
||||
if (bill == null && StringUtils.isNotEmpty(task.getBillId()))
|
||||
if (bill == null && task.getOrderId() != null)
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillById(task.getBillId());
|
||||
bill = orderBillMapper.selectPrcOrderBillById(task.getOrderId());
|
||||
}
|
||||
if (bill != null && StringUtils.isNotEmpty(bill.getCustomerCode()))
|
||||
{
|
||||
@@ -645,13 +645,13 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
}
|
||||
}
|
||||
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, String billId,
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, Long orderId,
|
||||
String errorMessage, String failCode)
|
||||
{
|
||||
PrcBillingTask upd = new PrcBillingTask();
|
||||
upd.setTaskId(task.getTaskId());
|
||||
upd.setSuccessStatus(status.getCode());
|
||||
upd.setBillId(billId);
|
||||
upd.setOrderId(orderId);
|
||||
if (StringUtils.isNotEmpty(task.getCustomerCode()))
|
||||
{
|
||||
upd.setCustomerCode(task.getCustomerCode());
|
||||
|
||||
+83
-75
@@ -297,7 +297,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;
|
||||
@@ -407,6 +406,24 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
/**
|
||||
* 批量编码归一化:逐个 trim、拆开误传的逗号/分号/空白分隔串、去空去重
|
||||
*/
|
||||
|
||||
private List<Long> normalizeLongIdList(List<Long> ids)
|
||||
{
|
||||
if (ids == null || ids.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
LinkedHashSet<Long> set = new LinkedHashSet<Long>();
|
||||
for (Long id : ids)
|
||||
{
|
||||
if (id != null)
|
||||
{
|
||||
set.add(id);
|
||||
}
|
||||
}
|
||||
return set.isEmpty() ? null : new ArrayList<Long>(set);
|
||||
}
|
||||
|
||||
private List<String> normalizeCodeList(List<String> codes)
|
||||
{
|
||||
if (codes == null || codes.isEmpty())
|
||||
@@ -435,14 +452,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())
|
||||
@@ -450,20 +467,20 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
PrcOrderBill bill = list.get(0);
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
// 应付暂不在范围内:组装计费结果时不查 prc_pay_bill_fee
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()), null);
|
||||
}
|
||||
|
||||
|
||||
@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())
|
||||
{
|
||||
@@ -679,15 +696,14 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@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 +711,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 +750,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 +759,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 +781,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 +828,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 +873,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 +928,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 +959,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 +995,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 +1027,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 +1044,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 +1065,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 +1185,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 +1307,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 +1336,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
if ("SELECTED".equals(scopeMode))
|
||||
{
|
||||
List<String> billIds = normalizeCodeList(request.getBillIds());
|
||||
List<Long> billIds = normalizeLongIdList(request.getBillIds());
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.recalc.selectedRequired"));
|
||||
@@ -1400,7 +1415,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(normalizeLongIdList(query.getBillIds()));
|
||||
}
|
||||
|
||||
private static String normalizeRecalcMode(String mode)
|
||||
@@ -1421,7 +1436,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 +1521,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 +1570,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill query = new PrcOrderBill();
|
||||
if ("SELECTED".equals(scopeMode))
|
||||
{
|
||||
List<String> billIds = normalizeCodeList(billIdsRaw);
|
||||
List<Long> billIds = normalizeLongIdList(billIdsRaw);
|
||||
if (billIds == null || billIds.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message(msgSelected));
|
||||
@@ -1624,7 +1638,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)
|
||||
@@ -1691,7 +1705,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
bill.setRefundStatus(refundStatus);
|
||||
orderBillMapper.updatePrcOrderBill(bill);
|
||||
orderBillMapper.refreshArBillStatusByBillIds(Arrays.asList(bill.getBillId()));
|
||||
return toResult(bill, fees, payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
return toResult(bill, fees, null);
|
||||
}
|
||||
|
||||
private static String resolveRefundStatus(List<PrcIncomeBillFee> fees)
|
||||
@@ -1832,13 +1846,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"));
|
||||
@@ -1867,8 +1881,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
orderBillMapper.updateCreditArrearsStatus(bill.getBillId(), normal, operator);
|
||||
bill.setCreditArrearsStatus(normal);
|
||||
saveManualArrearsUpdateEsLog(bill, true, null);
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()), null);
|
||||
}
|
||||
|
||||
private void saveManualArrearsUpdateEsLog(PrcOrderBill bill, boolean success, String errorMessage)
|
||||
@@ -2001,7 +2014,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcOrderBill bill = existed == null ? new PrcOrderBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
bill.setBillId(UUID.randomUUID().toString());
|
||||
// billId filled by useGeneratedKeys after insert
|
||||
}
|
||||
bill.setBillKey(billKey);
|
||||
bill.setOrderNo(orderNo);
|
||||
@@ -2236,9 +2249,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 +2452,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 +2475,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 +2485,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 +2506,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 +2515,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 +2543,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
}
|
||||
|
||||
|
||||
private List<PrcPayBillFee> toPayFeeRows(String billId, String payBillId, TmsPriceQuoteResult result)
|
||||
private List<PrcPayBillFee> toPayFeeRows(Long billId, String payBillId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcPayBillFee> fees = new ArrayList<PrcPayBillFee>();
|
||||
if (result.getPayFeeDetails() == null)
|
||||
@@ -2560,7 +2571,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;
|
||||
}
|
||||
@@ -2655,7 +2666,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;
|
||||
}
|
||||
@@ -2792,26 +2803,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,15 +3069,14 @@ 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)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()), null);
|
||||
}
|
||||
|
||||
/** 存在上游 Oracle 行 => 同步/计费路径会同时覆盖 weight 与 charge_weight。 */
|
||||
@@ -3220,7 +3230,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 +3274,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 +3322,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 +3439,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<String> ownIds = new ArrayList<>();
|
||||
for (PrcPayBillFee fee : chunk)
|
||||
{
|
||||
if (fee != null && fee.getBillId() != null && !fee.getBillId().isBlank())
|
||||
if (fee != null && fee.getFeeId() != null && !fee.getFeeId().isBlank()
|
||||
&& (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
-8
@@ -95,7 +95,7 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
throw new ServiceException(fee.getBillCode() + " " + blankName(fee) + ":" + reason);
|
||||
}
|
||||
}
|
||||
Map<String, String> payBillIds = payBillIds(orders);
|
||||
Map<Long, String> payBillIds = payBillIds(orders);
|
||||
List<PrcPayBillFee> batch = new ArrayList<>(BATCH_SIZE);
|
||||
int lineCount = 0;
|
||||
for (SrvBillAirAllocFee fee : fees)
|
||||
@@ -168,7 +168,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 +177,9 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
return grouped;
|
||||
}
|
||||
|
||||
private Map<String, String> payBillIds(Map<String, List<SrvBillAirAllocOrder>> orders)
|
||||
private Map<Long, String> 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 +187,10 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
billIds.add(order.getBillId());
|
||||
}
|
||||
}
|
||||
Map<String, String> payIds = new LinkedHashMap<>();
|
||||
Map<Long, String> 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,7 +231,7 @@ 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, String> payBillIds)
|
||||
{
|
||||
PrcPayBillFee row = new PrcPayBillFee();
|
||||
row.setFeeId(UUID.randomUUID().toString());
|
||||
@@ -247,7 +247,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;
|
||||
}
|
||||
|
||||
+21
-11
@@ -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);
|
||||
@@ -131,10 +131,10 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
String tip = softFailMessage(result);
|
||||
String transferLabel = failTransferLabel(one,
|
||||
String transferLabel = failTransferLabel(String.valueOf(one),
|
||||
result == null ? null : result.getTransferNo());
|
||||
appendFail(failTips, transferLabel, tip);
|
||||
collectFailDetail(failDetails, one, tip);
|
||||
collectFailDetail(failDetails, String.valueOf(one), tip);
|
||||
log.warn("local rebill soft-fail taskId={} billId={} transferNo={} status={} msg={}",
|
||||
taskId, one, transferLabel,
|
||||
result == null ? null : result.getBillingFailStatus(), tip);
|
||||
@@ -147,9 +147,9 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
catch (Exception e)
|
||||
{
|
||||
fail.incrementAndGet();
|
||||
String transferLabel = failTransferLabel(one, null);
|
||||
String transferLabel = failTransferLabel(String.valueOf(one), null);
|
||||
appendFail(failTips, transferLabel, e);
|
||||
collectFailDetail(failDetails, one, e);
|
||||
collectFailDetail(failDetails, String.valueOf(one), e);
|
||||
log.warn("local rebill failed taskId={} billId={} transferNo={} msg={}",
|
||||
taskId, one, transferLabel, e.getMessage());
|
||||
}
|
||||
@@ -293,8 +293,18 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
String trackingNo = null;
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper == null || StringUtils.isEmpty(billId)
|
||||
? null : orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = null;
|
||||
if (orderBillMapper != null && StringUtils.isNotEmpty(billId))
|
||||
{
|
||||
try
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillById(Long.valueOf(billId.trim()));
|
||||
}
|
||||
catch (NumberFormatException ignore)
|
||||
{
|
||||
bill = null;
|
||||
}
|
||||
}
|
||||
if (bill != null)
|
||||
{
|
||||
orderNo = bill.getOrderNo();
|
||||
@@ -487,7 +497,7 @@ public class PrcOrderBillLocalRebillAsyncRunner
|
||||
}
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId.trim());
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(Long.valueOf(billId.trim()));
|
||||
if (bill != null)
|
||||
{
|
||||
if (StringUtils.isNotEmpty(bill.getTransferNo()))
|
||||
|
||||
+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();
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.bms.price.task;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.bms.common.core.redis.RedisCache;
|
||||
import com.bms.price.config.UuidToNewProperties;
|
||||
import com.bms.price.migration.domain.UuidToNewBatchResult;
|
||||
import com.bms.price.migration.service.IUuidToNewSyncService;
|
||||
|
||||
/**
|
||||
* UUID 阴影同步运行器:已默认停用(bms.mig.uuid-to-new.enabled=false)。
|
||||
* 不再实现 ApplicationRunner;setEnabled(true) 为 no-op,避免误开同步。
|
||||
*/
|
||||
@Component
|
||||
@Order(100)
|
||||
public class UuidToNewSyncRunner
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(UuidToNewSyncRunner.class);
|
||||
|
||||
/** Redis:连续同步开关 */
|
||||
public static final String REDIS_KEY_ENABLED = "bms:mig:uuid-to-new:enabled";
|
||||
/** Redis:线程数 */
|
||||
public static final String REDIS_KEY_THREAD_COUNT = "bms:mig:uuid-to-new:thread-count";
|
||||
/** Redis:批次大小 */
|
||||
public static final String REDIS_KEY_BATCH_SIZE = "bms:mig:uuid-to-new:batch-size";
|
||||
|
||||
/** 连续全失败批次达此值自动关闭 */
|
||||
private static final int AUTO_OFF_AFTER_ALL_FAIL_BATCHES = 2;
|
||||
/** 全失败退避基准(毫秒) */
|
||||
private static final long ALL_FAIL_BACKOFF_MS = 30000L;
|
||||
|
||||
private final AtomicBoolean wantRun = new AtomicBoolean(false);
|
||||
private final AtomicBoolean loopActive = new AtomicBoolean(false);
|
||||
private final AtomicInteger consecutiveAllFail = new AtomicInteger(0);
|
||||
|
||||
@Autowired
|
||||
private UuidToNewProperties properties;
|
||||
|
||||
@Autowired
|
||||
private IUuidToNewSyncService syncService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return wantRun.get();
|
||||
}
|
||||
|
||||
public boolean isRunning()
|
||||
{
|
||||
return loopActive.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enabling is disabled after Long PK cutover; only OFF is accepted.
|
||||
*/
|
||||
public synchronized void setEnabled(boolean enabled)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
log.warn("uuid-to-new enable refused: migration runner disabled after Long PK cutover");
|
||||
wantRun.set(false);
|
||||
persistEnabled(false);
|
||||
return;
|
||||
}
|
||||
wantRun.set(false);
|
||||
persistEnabled(false);
|
||||
log.info("uuid-to-new switch OFF, will stop after current batch");
|
||||
}
|
||||
|
||||
/** 将当前线程/批次写入 Redis(无过期) */
|
||||
public void persistRuntimeConfig()
|
||||
{
|
||||
if (redisCache == null || properties == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
redisCache.setCacheObject(REDIS_KEY_THREAD_COUNT, Integer.valueOf(properties.resolvedThreadCount()));
|
||||
redisCache.setCacheObject(REDIS_KEY_BATCH_SIZE, Integer.valueOf(properties.resolvedBatchSize()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warn("uuid-to-new persist runtime config to redis failed: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void persistEnabled(boolean enabled)
|
||||
{
|
||||
if (redisCache == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
redisCache.setCacheObject(REDIS_KEY_ENABLED, Boolean.valueOf(enabled));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.warn("uuid-to-new persist enabled={} to redis failed: {}", enabled, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void startLoopIfNeeded()
|
||||
{
|
||||
log.warn("uuid-to-new startLoop ignored: runner disabled after Long PK cutover");
|
||||
}
|
||||
|
||||
private void runLoop()
|
||||
{
|
||||
try
|
||||
{
|
||||
while (wantRun.get())
|
||||
{
|
||||
int batchSize = properties == null ? 200 : properties.resolvedBatchSize();
|
||||
UuidToNewBatchResult result = null;
|
||||
try
|
||||
{
|
||||
result = syncService.syncBatch(batchSize);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("uuid-to-new batch error", e);
|
||||
result = null;
|
||||
}
|
||||
if (!wantRun.get())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
long sleepMs = properties == null ? 3000L : Math.max(500L, properties.getIdleSleepMs());
|
||||
if (result == null)
|
||||
{
|
||||
sleepMs = Math.max(sleepMs, ALL_FAIL_BACKOFF_MS);
|
||||
bumpAllFailAndMaybeAutoOff("batch-exception");
|
||||
}
|
||||
else if (result.getFetched() <= 0)
|
||||
{
|
||||
consecutiveAllFail.set(0);
|
||||
}
|
||||
else if (result.getSuccess() <= 0 && result.getFail() > 0)
|
||||
{
|
||||
// 全失败:退避,避免立即重打
|
||||
sleepMs = Math.max(sleepMs, ALL_FAIL_BACKOFF_MS);
|
||||
bumpAllFailAndMaybeAutoOff(result.getSampleError());
|
||||
}
|
||||
else
|
||||
{
|
||||
consecutiveAllFail.set(0);
|
||||
// 有成功:不强制睡眠,但若失败率过高仍稍停
|
||||
if (result.getFail() > 0 && result.getFail() * 2 >= result.getFetched())
|
||||
{
|
||||
sleepMs = Math.max(sleepMs, 5000L);
|
||||
}
|
||||
else
|
||||
{
|
||||
sleepMs = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wantRun.get())
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (sleepMs > 0L)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(sleepMs);
|
||||
}
|
||||
catch (InterruptedException ie)
|
||||
{
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
loopActive.set(false);
|
||||
log.info("uuid-to-new loop stopped");
|
||||
}
|
||||
}
|
||||
|
||||
private void bumpAllFailAndMaybeAutoOff(String sampleError)
|
||||
{
|
||||
int n = consecutiveAllFail.incrementAndGet();
|
||||
log.error("uuid-to-new all-fail batch #{}, sampleErr={}", n, sampleError);
|
||||
if (n >= AUTO_OFF_AFTER_ALL_FAIL_BATCHES)
|
||||
{
|
||||
log.error("uuid-to-new auto switch OFF after {} consecutive all-fail batches", n);
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,8 @@ public class ArBillDetail implements Serializable {
|
||||
|
||||
private Long detailId;
|
||||
private Long arBillId;
|
||||
private String prcOrderBillId;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long prcOrderBillId;
|
||||
private Integer detailNo;
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
|
||||
@@ -16,7 +16,8 @@ public class ArBillDetailFee implements Serializable {
|
||||
|
||||
private Long detailFeeId;
|
||||
private Long detailId;
|
||||
private String prcIncomeBillFeeId;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long prcIncomeBillFeeId;
|
||||
private Integer feeNo;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
|
||||
@@ -40,9 +40,10 @@ public class ArBillGenerateTask implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date snapshotCreateTime;
|
||||
/**
|
||||
* 按 bill_id 字典序处理的游标。
|
||||
* 按 bill_id 数值顺序处理的游标。
|
||||
*/
|
||||
private String lastSourceBillId;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
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")
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.bms.receivable.domain.vo;
|
||||
|
||||
import com.bms.price.domain.PrcOrderBill;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
/** 应收生成预览中,订单 ID 以字符串传递,避免浏览器整数精度丢失。 */
|
||||
public class ArBillPreviewOrder extends PrcOrderBill {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static ArBillPreviewOrder from(PrcOrderBill source) {
|
||||
ArBillPreviewOrder result = new ArBillPreviewOrder();
|
||||
BeanUtils.copyProperties(source, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
public Long getBillId() {
|
||||
return super.getBillId();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
+5
-1
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.receivable.domain.ArBillGenerateTask;
|
||||
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||
|
||||
/**
|
||||
* 应收账单异步生成任务 Mapper。
|
||||
@@ -21,13 +22,16 @@ public interface ArBillGenerateTaskMapper {
|
||||
|
||||
List<ArBillGenerateTask> selectWaiting(@Param("limit") int limit);
|
||||
|
||||
/** 历史失败任务重试时,将请求快照中的旧订单 UUID 转为新 ID。 */
|
||||
List<UuidToNewIdHolder> selectMigratedOrderIds(@Param("oldIds") List<String> oldIds);
|
||||
|
||||
int insert(ArBillGenerateTask task);
|
||||
|
||||
int markRunning(@Param("taskId") Long taskId, @Param("startedAt") Date startedAt);
|
||||
|
||||
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("所选订单不存在或不属于当前客户");
|
||||
}
|
||||
|
||||
+69
-19
@@ -19,6 +19,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -45,6 +46,8 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bms.receivable.domain.ArBill;
|
||||
import com.bms.receivable.domain.ArBankAccount;
|
||||
import com.bms.receivable.domain.ArBillDetail;
|
||||
@@ -105,6 +108,7 @@ import com.bms.price.enums.BillBillingFailStatus;
|
||||
import com.bms.price.mapper.PrcIncomeBillMapper;
|
||||
import com.bms.price.mapper.PrcIncomeBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||
import com.bms.price.migration.domain.UuidToNewIdHolder;
|
||||
|
||||
/**
|
||||
* 应收账单核心业务实现。
|
||||
@@ -419,8 +423,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);
|
||||
@@ -605,7 +609,7 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
if (!ArBillGenerateTaskStatus.FAILED.equals(task.getStatus())) {
|
||||
throw new ServiceException("只有失败的账单生成任务可以重试");
|
||||
}
|
||||
ArBillGenerateRequest request = JSON.parseObject(task.getRequestPayload(), ArBillGenerateRequest.class);
|
||||
ArBillGenerateRequest request = parseRetryRequest(task.getRequestPayload());
|
||||
request.setRequestId(requestId);
|
||||
ArBillGenerateTask retried = generateBill(request, operator, requestId);
|
||||
log.info("应收账单生成任务重试请求已处理,operator={}, requestId={}, sourceTaskId={}, newTaskId={}, status={}, costMs={}",
|
||||
@@ -614,6 +618,52 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
return retried;
|
||||
}
|
||||
|
||||
/** 旧失败任务的选择快照可能保留 UUID;新任务始终使用 bigint ID。 */
|
||||
private ArBillGenerateRequest parseRetryRequest(String payload) {
|
||||
JSONObject data = JSON.parseObject(payload);
|
||||
Set<String> oldIds = new LinkedHashSet<>();
|
||||
for (String field : List.of("sourceBillIds", "excludedSourceBillIds")) {
|
||||
JSONArray ids = data.getJSONArray(field);
|
||||
if (ids == null) continue;
|
||||
for (Object value : ids) {
|
||||
if (value instanceof String text && !isLongId(text)) oldIds.add(text.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
if (!oldIds.isEmpty()) {
|
||||
List<String> ids = new ArrayList<>(oldIds);
|
||||
Map<String, Long> mapping = new HashMap<>();
|
||||
for (int start = 0; start < ids.size(); start += 500) {
|
||||
for (UuidToNewIdHolder row : generateTaskMapper.selectMigratedOrderIds(
|
||||
ids.subList(start, Math.min(start + 500, ids.size())))) {
|
||||
mapping.put(row.getOldBillId().toLowerCase(Locale.ROOT), row.getNewBillId());
|
||||
}
|
||||
}
|
||||
if (mapping.size() != oldIds.size()) {
|
||||
throw new ServiceException("历史任务的部分订单尚未完成 ID 映射,请重新选择订单生成账单");
|
||||
}
|
||||
for (String field : List.of("sourceBillIds", "excludedSourceBillIds")) {
|
||||
JSONArray values = data.getJSONArray(field);
|
||||
if (values == null) continue;
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
Object value = values.get(i);
|
||||
if (value instanceof String text && mapping.containsKey(text.toLowerCase(Locale.ROOT))) {
|
||||
values.set(i, mapping.get(text.toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return JSON.parseObject(data.toJSONString(), ArBillGenerateRequest.class);
|
||||
}
|
||||
|
||||
private boolean isLongId(String value) {
|
||||
try {
|
||||
Long.parseLong(value);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行异步生成任务。每个批次使用短事务,事务内完成来源订单占用、明细落库、
|
||||
* 费用落库和任务游标更新;异常统一进入独立事务清理,避免任务永久卡在运行中。
|
||||
@@ -638,8 +688,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 +816,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 +842,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 +850,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 +864,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 +903,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 +912,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 +936,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 +2362,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>
|
||||
|
||||
@@ -117,6 +117,10 @@
|
||||
where price_set_id = #{priceSetId} and version_no = #{versionNo}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteVersionById">
|
||||
delete from prc_label_product_version where version_id = #{versionId}
|
||||
</delete>
|
||||
|
||||
<select id="selectVersionsBySet" resultType="com.bms.price.domain.LblProductVersion">
|
||||
select v.version_id as versionId, v.price_set_id as priceSetId, v.product_id as productId, v.dict_value as dictValue,
|
||||
v.version_no as versionNo, v.effective_start as effectiveStart, v.effective_end as effectiveEnd, v.file_path as filePath,
|
||||
@@ -200,6 +204,10 @@
|
||||
delete from prc_label_weight_band where version_id = #{versionId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteWeightBandById">
|
||||
delete from prc_label_weight_band where band_id = #{bandId}
|
||||
</delete>
|
||||
|
||||
<select id="selectWeightBandsByVersion" resultType="com.bms.price.domain.LblWeightBand">
|
||||
select band_id as bandId, product_id as productId, version_id as versionId, fee_type as feeType,
|
||||
country_name as countryName, country_code as countryCode, zone_code as zoneCode, zone_name as zoneName,
|
||||
@@ -251,6 +259,10 @@
|
||||
delete from prc_label_surcharge where version_id = #{versionId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSurchargeById">
|
||||
delete from prc_label_surcharge where surcharge_id = #{surchargeId}
|
||||
</delete>
|
||||
|
||||
<select id="selectSurchargesByVersion" resultType="com.bms.price.domain.LblSurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, version_id as versionId, fee_name as feeName, sc_id as scId,
|
||||
zone_code as zoneCode, zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="billType" column="bill_type" />
|
||||
<result property="successStatus" column="success_status" />
|
||||
<result property="billTime" column="bill_time" />
|
||||
<result property="billId" column="bill_id" />
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="failCode" column="fail_code" />
|
||||
<result property="errorMessage" column="error_message" />
|
||||
<result property="createBy" column="create_by" />
|
||||
@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcBillingTaskVo">
|
||||
select task_id, transfer_no, tracking_no, order_no, customer_code, bill_type, success_status,
|
||||
bill_time, bill_id, fail_code, error_message, create_by, create_time, update_by, update_time
|
||||
bill_time, order_id, fail_code, error_message, create_by, create_time, update_by, update_time
|
||||
from prc_billing_task
|
||||
</sql>
|
||||
|
||||
@@ -111,10 +111,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertPrcBillingTask" parameterType="PrcBillingTask" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into prc_billing_task (
|
||||
transfer_no, tracking_no, order_no, customer_code, bill_type, success_status,
|
||||
bill_time, bill_id, fail_code, error_message, create_by, create_time
|
||||
bill_time, order_id, fail_code, error_message, create_by, create_time
|
||||
) values (
|
||||
#{transferNo}, #{trackingNo}, #{orderNo}, #{customerCode}, #{billType}, #{successStatus},
|
||||
#{billTime}, #{billId}, #{failCode}, #{errorMessage}, #{createBy}, sysdate()
|
||||
#{billTime}, #{orderId}, #{failCode}, #{errorMessage}, #{createBy}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -128,7 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="billType != null">bill_type = #{billType},</if>
|
||||
<if test="successStatus != null">success_status = #{successStatus},</if>
|
||||
<if test="billTime != null">bill_time = #{billTime},</if>
|
||||
<if test="billId != null">bill_id = #{billId},</if>
|
||||
<if test="orderId != null">order_id = #{orderId},</if>
|
||||
<if test="failCode != null">fail_code = #{failCode},</if>
|
||||
<if test="errorMessage != null">error_message = #{errorMessage},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@@ -141,7 +141,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateBillingResult" parameterType="PrcBillingTask">
|
||||
update prc_billing_task
|
||||
set success_status = #{successStatus},
|
||||
bill_id = #{billId},
|
||||
order_id = #{orderId},
|
||||
fail_code = #{failCode},
|
||||
error_message = #{errorMessage},
|
||||
<if test="customerCode != null">
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user