Compare commits
51 Commits
a024b45940
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| ca45e15559 | |||
| 6b2b205083 | |||
| 4f2954ebce | |||
| 8d45439931 | |||
| e2deccc65a | |||
| 2aec7fdd5c | |||
| 5c8e905a37 | |||
| 8fb042f171 | |||
| d8f6ceda59 | |||
| e104c5a3e9 | |||
| fcaf0dc9be | |||
| 9483bb4899 | |||
| 69d9971a79 | |||
| f6012f96e3 | |||
| 111176e767 | |||
| cce123890e | |||
| b76b26b2b1 | |||
| 6e01167f41 | |||
| e0b8eec98d | |||
| 54ac6428e7 | |||
| ee5c79ba29 | |||
| f00f8c619a | |||
| f9038c62ac | |||
| 49f24a6b1b | |||
| 5b8d4de262 | |||
| 215effe036 | |||
| 4503424cf0 | |||
| 3cf7fa30bd | |||
| e34e4f117c | |||
| 03043104bc | |||
| a5cd752005 | |||
| 5d44cc4edf | |||
| 1b43bcca4c | |||
| a38e2c7f57 | |||
| 63ded27fd5 | |||
| 206e4e786b | |||
| 0179a35942 | |||
| 4de755ca60 | |||
| 358e5a46b9 | |||
| ee36c8c902 | |||
| 7e699fb80e | |||
| 80d639d887 | |||
| 87ae3e6674 | |||
| 359c3c18e4 | |||
| 4f2f2db20f | |||
| 0094e4aaff | |||
| 8b7c346ec4 | |||
| bde1d7d86e | |||
| 87eab12d51 | |||
| 880b4751c5 | |||
| 3a104d2d8c |
+10
@@ -90,6 +90,16 @@ public class BmsSupplierController extends BaseController
|
||||
return toAjax(bmsSupplierService.updateBmsSupplier(bmsSupplier));
|
||||
}
|
||||
|
||||
/** 只绑定这一家供应商的渠道 */
|
||||
@PreAuthorize("@ss.hasPermi('customersupplier:supplierinfo:bindChannel')")
|
||||
@Log(title = "供应商绑定渠道", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{supplierId}/channels")
|
||||
public AjaxResult bindChannels(@PathVariable("supplierId") Long supplierId, @RequestBody BmsSupplier bmsSupplier)
|
||||
{
|
||||
String channelIds = bmsSupplier == null ? "" : bmsSupplier.getChannelIds();
|
||||
return toAjax(bmsSupplierService.bindChannels(supplierId, channelIds));
|
||||
}
|
||||
|
||||
/** 删除供应商 */
|
||||
@PreAuthorize("@ss.hasPermi('customersupplier:supplierinfo:remove')")
|
||||
@Log(title = "供应商信息", businessType = BusinessType.DELETE)
|
||||
|
||||
+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")
|
||||
|
||||
+5
-6
@@ -33,16 +33,15 @@ public class BillingTaskMonitorController extends BaseController
|
||||
@Autowired
|
||||
private IPrcBillingTaskService billingTaskService;
|
||||
|
||||
/** 默认列表 = FAILED 异常任务。 */
|
||||
/** 列表默认不过滤状态(全部);successStatus=ALL 同样不过滤。 */
|
||||
@PreAuthorize("@ss.hasPermi('monitor:billingTask:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrcBillingTask query)
|
||||
{
|
||||
if (query.getSuccessStatus() == null || query.getSuccessStatus().isEmpty())
|
||||
{
|
||||
query.setSuccessStatus(BillTaskSuccessStatus.FAILED.getCode());
|
||||
}
|
||||
else if ("ALL".equalsIgnoreCase(query.getSuccessStatus()))
|
||||
// 空/全部:不过滤状态;仍可按 FAILED/WAITING/SUCCESS 筛选
|
||||
if (query.getSuccessStatus() == null
|
||||
|| query.getSuccessStatus().isEmpty()
|
||||
|| "ALL".equalsIgnoreCase(query.getSuccessStatus()))
|
||||
{
|
||||
query.setSuccessStatus(null);
|
||||
}
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -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));
|
||||
}
|
||||
@@ -378,9 +378,9 @@ public class BillingController extends BaseController
|
||||
return query;
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list') or @ss.hasPermi('price:payOrder:query')")
|
||||
@GetMapping("/bill/{billId}")
|
||||
public AjaxResult getBill(@PathVariable String billId)
|
||||
public AjaxResult getBill(@PathVariable Long billId)
|
||||
{
|
||||
return success(prcOrderBillService.getBill(billId));
|
||||
}
|
||||
@@ -389,15 +389,15 @@ public class BillingController extends BaseController
|
||||
* 该订单的 ES BILL 日志(计费 / 上游同步 / 失败快照)。
|
||||
* bizId 优先取 transferNo,其次取 orderNo(与写入路径一致)。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list') or @ss.hasPermi('price:payOrder:query')")
|
||||
@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));
|
||||
}
|
||||
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
package com.bms.web.controller.price;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
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.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRecalcCommand;
|
||||
import com.bms.price.domain.PayOrderRecalcTask;
|
||||
import com.bms.price.service.IPayOrderListService;
|
||||
import com.bms.price.service.IPrcOrderBillService;
|
||||
|
||||
/** 提单管理下的应付列表。 */
|
||||
@RestController
|
||||
@RequestMapping("/price/payOrder")
|
||||
public class PayOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPayOrderListService payOrderListService;
|
||||
|
||||
@Autowired
|
||||
private IPrcOrderBillService orderBillService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PayOrderQuery query)
|
||||
{
|
||||
startPage();
|
||||
return getDataTable(payOrderListService.list(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按订单号或提单号批量重算尾程应付。一票失败不影响其他订单。
|
||||
*
|
||||
* @param command sourceType 为 ORDER 或 LADING,text 为单号原文
|
||||
* @return 成功数、失败数和每一票的结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:recalc')")
|
||||
@PostMapping("/recalc")
|
||||
public AjaxResult recalc(@RequestBody PayOrderRecalcCommand command)
|
||||
{
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("taskId", payOrderListService.submitRecalc(command));
|
||||
return success(payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询应付费用重算进度。
|
||||
*
|
||||
* @param taskId 任务号
|
||||
* @return Redis 中的进度和每一票结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:recalc')")
|
||||
@GetMapping("/recalc/task/{taskId}")
|
||||
public AjaxResult recalcTask(@PathVariable String taskId)
|
||||
{
|
||||
PayOrderRecalcTask task = payOrderListService.getRecalcTask(taskId);
|
||||
if (task == null)
|
||||
{
|
||||
return error("重算任务不存在或已过期");
|
||||
}
|
||||
return success(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消还没开始的应付费用重算。正在计算的这一票会算完。
|
||||
*
|
||||
* @param taskId 任务号
|
||||
* @return 更新后的进度
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:recalc')")
|
||||
@PostMapping("/recalc/task/{taskId}/cancel")
|
||||
public AjaxResult cancelRecalc(@PathVariable String taskId)
|
||||
{
|
||||
return success(payOrderListService.cancelRecalc(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 应付列表里的订单详情。带出应收费用和应付费用,不按计费列表的销售员权限过滤。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 订单、应收明细和应付明细
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:query')")
|
||||
@GetMapping("/{billId}")
|
||||
public AjaxResult detail(@PathVariable Long billId)
|
||||
{
|
||||
return success(orderBillService.getPayOrderBill(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看一票订单的应付费用,按 A、B、C、D 四段返回。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 四段费用
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:fee')")
|
||||
@GetMapping("/{billId}/fees")
|
||||
public AjaxResult fees(@PathVariable String billId)
|
||||
{
|
||||
return success(payOrderListService.fees(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在某一段手工增加一行应付费用。创建人取当前登录用户。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param line 费用项、金额、币种、说明和所属阶段
|
||||
* @return 写入后的费用行
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:feeAdd')")
|
||||
@PostMapping("/{billId}/fees")
|
||||
public AjaxResult addFee(@PathVariable String billId, @RequestBody PayOrderFeeLine line)
|
||||
{
|
||||
return success(payOrderListService.addManualFee(billId, line));
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除一条应付费用。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:feeRemove')")
|
||||
@DeleteMapping("/fees/{feeId}")
|
||||
public AjaxResult removeFee(@PathVariable String feeId)
|
||||
{
|
||||
payOrderListService.removeFee(feeId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查看一票订单的费用操作日志,含变更前和变更后。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 当前页日志
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:log')")
|
||||
@GetMapping("/{billId}/feeLogs")
|
||||
public TableDataInfo feeLogs(@PathVariable String billId)
|
||||
{
|
||||
return getDataTable(payOrderListService.feeLogs(billId));
|
||||
}
|
||||
}
|
||||
+28
-24
@@ -30,14 +30,14 @@ import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PayProductTerm;
|
||||
import com.bms.price.domain.PaySaveCommand;
|
||||
import com.bms.price.pay.PayDetailExporter;
|
||||
import com.bms.price.domain.PaySurchargeRuleSave;
|
||||
import com.bms.price.pay.PayChargeMode;
|
||||
import com.bms.price.pay.PayTemplateWorkbook;
|
||||
import com.bms.price.service.IPayOrderCostService;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
import com.bms.price.service.IPaySurchargeRuleService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 价格基础下的应付配置。导入先预览,确认后才入库。
|
||||
* 应付管理下的应付配置。导入先预览,确认后才入库。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/pay")
|
||||
@@ -49,9 +49,6 @@ public class PayProductController extends BaseController
|
||||
@Autowired
|
||||
private IPayOrderCostService payOrderCostService;
|
||||
|
||||
@Autowired
|
||||
private IPaySurchargeRuleService paySurchargeRuleService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PayProduct query)
|
||||
@@ -89,7 +86,7 @@ public class PayProductController extends BaseController
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:billing:bill,price:pay:edit')")
|
||||
@Log(title = "应付账单", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/order/{billId}")
|
||||
public AjaxResult generateOrderCost(@PathVariable String billId)
|
||||
public AjaxResult generateOrderCost(@PathVariable Long billId)
|
||||
{
|
||||
payOrderCostService.generate(billId);
|
||||
return success("操作成功");
|
||||
@@ -107,29 +104,36 @@ public class PayProductController extends BaseController
|
||||
payProductService.writeSource(productId, response.getOutputStream());
|
||||
}
|
||||
|
||||
/** 当前版本的附加费计费条件。同一版本只有一份。 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:query,price:pay:edit')")
|
||||
@GetMapping("/surchargeRule")
|
||||
public AjaxResult surchargeRule(@RequestParam Long productId, @RequestParam Long termId)
|
||||
/** 下载所选计费模式的标准模板 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:import,price:pay:add')")
|
||||
@PostMapping("/template")
|
||||
public void template(HttpServletResponse response, @RequestParam String chargeType) throws Exception
|
||||
{
|
||||
return success(paySurchargeRuleService.list(productId, termId));
|
||||
String mode = PayChargeMode.code(chargeType);
|
||||
String filename = (mode.isEmpty() ? "价卡" : PayChargeMode.label(mode)) + "模板.xlsx";
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
FileUtils.setAttachmentResponseHeader(response, filename);
|
||||
PayTemplateWorkbook.write(mode, response.getOutputStream());
|
||||
}
|
||||
|
||||
/** 上一版条件,复制到当前页后再保存。 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:query,price:pay:edit')")
|
||||
@GetMapping("/surchargeRule/previous")
|
||||
public AjaxResult previousSurchargeRule(@RequestParam Long productId)
|
||||
/** 按标准模板预览,不写数据库 */
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:import')")
|
||||
@Log(title = "应付配置", businessType = BusinessType.IMPORT)
|
||||
@PostMapping(value = "/template/preview", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public AjaxResult previewTemplate(MultipartFile file, @RequestParam String chargeType) throws Exception
|
||||
{
|
||||
return success(paySurchargeRuleService.previous(productId));
|
||||
assertWorkbook(file);
|
||||
return success(payProductService.previewTemplate(file.getBytes(), file.getOriginalFilename(), chargeType));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:edit')")
|
||||
@Log(title = "应付附加费计费条件", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/surchargeRule")
|
||||
public AjaxResult saveSurchargeRule(@RequestBody PaySurchargeRuleSave command)
|
||||
/** 按所选计费模式手工新增一条价卡 */
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:add')")
|
||||
@Log(title = "应付配置", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/manual")
|
||||
public AjaxResult manual(@RequestBody PayProduct product)
|
||||
{
|
||||
paySurchargeRuleService.save(command);
|
||||
return success();
|
||||
return success(payProductService.saveManual(product));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:query')")
|
||||
@@ -173,7 +177,7 @@ public class PayProductController extends BaseController
|
||||
}
|
||||
|
||||
/** 批量绑定渠道应收/应付产品 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:edit,data:serviceChannel:edit')")
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:edit,price:pay:bind,data:serviceChannel:edit')")
|
||||
@Log(title = "渠道批量绑定产品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/channel/batchBind")
|
||||
public AjaxResult batchBindChannel(@RequestBody Map<String, Object> body)
|
||||
|
||||
+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;
|
||||
|
||||
+22
-9
@@ -8,6 +8,8 @@ import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.bms.common.annotation.Log;
|
||||
@@ -38,6 +41,7 @@ import com.bms.price.domain.vo.PrcProfitReportProductRow;
|
||||
import com.bms.price.domain.vo.PrcProfitReportQuery;
|
||||
import com.bms.price.domain.vo.PrcProfitReportSummary;
|
||||
import com.bms.price.service.IPrcProfitReportService;
|
||||
import com.bms.price.task.PrcProfitReportExportRunner;
|
||||
|
||||
/** 产品/订单维度毛利报表。 */
|
||||
@RestController
|
||||
@@ -50,6 +54,9 @@ public class PrcProfitReportController extends BaseController
|
||||
@Autowired
|
||||
private OssStorage ossStorage;
|
||||
|
||||
@Autowired
|
||||
private PrcProfitReportExportRunner exportRunner;
|
||||
|
||||
/** 客户筛选选项,沿用毛利报表的访问权限和查询范围。 */
|
||||
@PreAuthorize("@ss.hasPermi('report:profit:list')")
|
||||
@GetMapping("/customer-options")
|
||||
@@ -105,6 +112,8 @@ public class PrcProfitReportController extends BaseController
|
||||
public TableDataInfo orders(PrcProfitReportQuery query)
|
||||
{
|
||||
startPage();
|
||||
// 分页总数由页面复用汇总订单数,订单明细仅执行分页查询。
|
||||
PageHelper.getLocalPage().setCount(false);
|
||||
List<PrcProfitReportOrderRow> rows = profitReportService.selectOrderRows(query);
|
||||
return getDataTable(rows);
|
||||
}
|
||||
@@ -121,19 +130,23 @@ public class PrcProfitReportController extends BaseController
|
||||
@Log(title = "毛利报表-订单维度", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('report:profit:export')")
|
||||
@PostMapping("/orders/export")
|
||||
public AjaxResult exportOrders(PrcProfitReportQuery query)
|
||||
public AjaxResult exportOrders(@RequestBody PrcProfitReportQuery query)
|
||||
{
|
||||
PrcProfitReportExport export = beginExport("ORDER", "订单维度毛利分析");
|
||||
try
|
||||
{
|
||||
List<PrcProfitReportOrderRow> rows = profitReportService.selectOrderRows(query);
|
||||
return finishExport(export, rows, PrcProfitReportOrderRow.class, "订单毛利报表", query.getProfitRule());
|
||||
return success(Map.of("taskId", exportRunner.submit(query, getUserId())));
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('report:profit:export')")
|
||||
@GetMapping("/orders/export/task/{taskId}")
|
||||
public AjaxResult orderExportTask(@PathVariable String taskId)
|
||||
{
|
||||
failExport(export, e);
|
||||
throw e;
|
||||
return success(exportRunner.getTask(taskId, getUserId()));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('report:profit:export')")
|
||||
@GetMapping("/orders/export/download/{taskId}")
|
||||
public void downloadOrderExport(@PathVariable String taskId, HttpServletResponse response) throws Exception
|
||||
{
|
||||
exportRunner.download(taskId, getUserId(), response);
|
||||
}
|
||||
|
||||
@Log(title = "毛利报表-产品维度", businessType = BusinessType.EXPORT)
|
||||
|
||||
@@ -10,6 +10,11 @@ oss:
|
||||
|
||||
# 项目相关配置
|
||||
bms:
|
||||
# 毛利报表区域客户 ID 过滤:默认关闭,完成生产计划和耗时对比后再启用。
|
||||
profit-report:
|
||||
customer-id-filter-enabled: ${BMS_PROFIT_REPORT_CUSTOMER_ID_FILTER_ENABLED:false}
|
||||
# 超过此客户数时自动回退客户表关联;小于等于 0 时停用,上限为 5000。
|
||||
max-customer-ids: ${BMS_PROFIT_REPORT_MAX_CUSTOMER_IDS:1000}
|
||||
# 名称
|
||||
name: BMS
|
||||
# 版本
|
||||
@@ -26,6 +31,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();
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.bms.price.pay;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.bms.price.domain.PayPreview;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.pay.PayCostCalculator;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
|
||||
/** 三种标准模板都能导回,并且按各自公式算出运费。 */
|
||||
class PayTemplateWorkbookTest
|
||||
{
|
||||
@Test
|
||||
void flatTemplateChargesTheBandPrice() throws Exception
|
||||
{
|
||||
byte[] file = workbook(PayChargeMode.FLAT);
|
||||
PayPreview preview = PayTemplateWorkbook.parse(replaceSample(file,
|
||||
"法国Colissimo", "威狮", "EUR", "法国", "FR", "", "0", "1", "3.03"), "一口价.xlsx", PayChargeMode.FLAT);
|
||||
PayProduct product = preview.getProducts().get(0);
|
||||
assertEquals(PayChargeMode.FLAT, product.getChargeType());
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, new BigDecimal("0.6"), null, null, null, null, null, null);
|
||||
assertEquals(new BigDecimal("3.03"), result.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void perKgTemplateMultipliesWeight() throws Exception
|
||||
{
|
||||
byte[] file = workbook(PayChargeMode.PER_KG);
|
||||
PayPreview preview = PayTemplateWorkbook.parse(replaceSample(file,
|
||||
"DHL泛欧", "威狮", "EUR", "奥地利", "AT", "", "0", "31.5", "0.29"), "常规计费.xlsx", PayChargeMode.PER_KG);
|
||||
PayProduct product = preview.getProducts().get(0);
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, new BigDecimal("2.4"), null, null, null, null, null, null);
|
||||
assertEquals(new BigDecimal("0.70"), result.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void extraTemplateAddsWeightBeyondTheFirstKilo() throws Exception
|
||||
{
|
||||
byte[] file = workbook(PayChargeMode.EXTRA);
|
||||
PayPreview preview = PayTemplateWorkbook.parse(replaceSample(file,
|
||||
"CTT", "威狮", "EUR", "西班牙", "ES", "马德里", "1", "2.05", "0.29"), "续重价.xlsx", PayChargeMode.EXTRA);
|
||||
PayProduct product = preview.getProducts().get(0);
|
||||
assertTrue(product.getSurcharges().stream().anyMatch(fee -> "EXTRA_KG".equals(fee.getCalcRule())));
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, new BigDecimal("2.4"), null, null, null, null, null, null);
|
||||
assertEquals(new BigDecimal("2.46"), result.getPayTotal());
|
||||
}
|
||||
|
||||
private static byte[] workbook(String mode) throws Exception
|
||||
{
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PayTemplateWorkbook.write(mode, out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
/** 用真实数据换掉模板里的示例行,避免示例被跳过。 */
|
||||
private static byte[] replaceSample(byte[] source, String... values) throws Exception
|
||||
{
|
||||
try (org.apache.poi.xssf.usermodel.XSSFWorkbook book = new org.apache.poi.xssf.usermodel.XSSFWorkbook(new java.io.ByteArrayInputStream(source)))
|
||||
{
|
||||
org.apache.poi.ss.usermodel.Row row = book.getSheetAt(0).getRow(1);
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
row.getCell(i).setCellValue(values[i]);
|
||||
}
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
book.write(out);
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ class PayWorkbookParserTest
|
||||
"西班牙CTT带电专线(主要地区)", List.of("西班牙CTT带电专线(主要地区)"));
|
||||
PayProduct ctt = preview.getProducts().get(0);
|
||||
assertEquals("OK", ctt.getParseStatus());
|
||||
assertEquals("单票价", ctt.getChargeType());
|
||||
assertEquals("FLAT", ctt.getChargeType());
|
||||
assertTrue(ctt.getExtraPerKg() == null || ctt.getExtraPerKg().isBlank());
|
||||
assertEquals(150, ctt.getWeightBands().size());
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "1".equals(band.getWeightLabel())
|
||||
@@ -534,7 +534,7 @@ class PayWorkbookParserTest
|
||||
PayProduct ctt = preview.getProducts().get(0);
|
||||
assertEquals("OK", ctt.getParseStatus());
|
||||
assertEquals("EUR", ctt.getCurrency());
|
||||
assertEquals("续重计费", ctt.getChargeType());
|
||||
assertEquals("EXTRA", ctt.getChargeType());
|
||||
assertTrue(covers(ctt.getExtraPerKg(), "1.86"));
|
||||
assertTrue(covers(ctt.getExtraPerKg(), "5.79"));
|
||||
assertEquals(24, ctt.getWeightBands().size());
|
||||
@@ -607,7 +607,7 @@ class PayWorkbookParserTest
|
||||
PayProduct ctt = preview.getProducts().get(0);
|
||||
assertEquals("OK", ctt.getParseStatus());
|
||||
assertEquals("西班牙", ctt.getCountryScope());
|
||||
assertEquals("续重计费", ctt.getChargeType());
|
||||
assertEquals("EXTRA", ctt.getChargeType());
|
||||
assertTrue(covers(ctt.getExtraPerKg(), "0.82"));
|
||||
assertEquals(60, ctt.getWeightBands().size());
|
||||
assertTrue(ctt.getWeightBands().stream().anyMatch(band -> "西班牙".equals(band.getCountryName()) && "ES".equals(band.getCountryCode())
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.bms.report;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import com.bms.price.domain.PrcProfitReportExport;
|
||||
import com.bms.price.domain.vo.PrcProfitReportOrderRow;
|
||||
import com.bms.price.domain.vo.PrcProfitReportProductRow;
|
||||
import com.bms.price.domain.vo.PrcProfitReportQuery;
|
||||
import com.bms.price.domain.vo.PrcProfitReportSummary;
|
||||
import com.bms.price.mapper.PrcProfitReportMapper;
|
||||
import com.bms.price.service.impl.PrcProfitReportServiceImpl;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
class ProfitReportAreaFilterTest
|
||||
{
|
||||
@AfterEach
|
||||
void clearPage()
|
||||
{
|
||||
PageHelper.clearPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
void customerLookupPreservesPaginationAndUsesOnlyServerResolvedIds()
|
||||
{
|
||||
AtomicReference<List<Long>> ids = new AtomicReference<>(List.of(2L, 3L));
|
||||
AtomicReference<PrcProfitReportQuery> seen = new AtomicReference<>();
|
||||
Page<?> page = PageHelper.startPage(2, 10);
|
||||
PrcProfitReportMapper mapper = mapper(ids, seen, page);
|
||||
PrcProfitReportServiceImpl service = service(mapper, true, 2);
|
||||
PrcProfitReportQuery query = new PrcProfitReportQuery();
|
||||
query.setCustomerArea(" C ");
|
||||
query.setAreaCustomerIds(List.of(999L));
|
||||
|
||||
service.selectOrderRows(query);
|
||||
assertSame(query, seen.get());
|
||||
assertEquals(List.of(2L, 3L), query.getAreaCustomerIds());
|
||||
assertSame(page, PageHelper.getLocalPage());
|
||||
|
||||
ids.set(List.of());
|
||||
service.selectSummary(query);
|
||||
assertEquals(List.of(), query.getAreaCustomerIds());
|
||||
|
||||
ids.set(List.of(1L, 2L, 3L));
|
||||
service.selectProductRows(query);
|
||||
assertNull(query.getAreaCustomerIds());
|
||||
}
|
||||
|
||||
@Test
|
||||
void customerLookupFailureClearsPageContext()
|
||||
{
|
||||
PrcProfitReportMapper mapper = (PrcProfitReportMapper) Proxy.newProxyInstance(
|
||||
getClass().getClassLoader(), new Class<?>[] { PrcProfitReportMapper.class },
|
||||
(proxy, method, args) -> { throw new IllegalStateException("lookup failed"); });
|
||||
PrcProfitReportServiceImpl service = service(mapper, true, 2);
|
||||
PrcProfitReportQuery query = new PrcProfitReportQuery();
|
||||
query.setCustomerArea("C");
|
||||
PageHelper.startPage(1, 10);
|
||||
assertThrows(IllegalStateException.class, () -> service.selectOrderRows(query));
|
||||
assertNull(PageHelper.getLocalPage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void sqlUsesAreaJoinOrCustomerIdsAndEmptyIdsMatchNothing() throws Exception
|
||||
{
|
||||
Configuration config = new Configuration();
|
||||
for (Class<?> type : new Class<?>[] { PrcProfitReportExport.class, PrcProfitReportOrderRow.class,
|
||||
PrcProfitReportProductRow.class, PrcProfitReportSummary.class })
|
||||
{
|
||||
config.getTypeAliasRegistry().registerAlias(type);
|
||||
}
|
||||
String resource = "mapper/price/PrcProfitReportMapper.xml";
|
||||
try (InputStream input = getClass().getClassLoader().getResourceAsStream(resource))
|
||||
{
|
||||
assertNotNull(input);
|
||||
new XMLMapperBuilder(input, config, resource, config.getSqlFragments()).parse();
|
||||
}
|
||||
PrcProfitReportQuery query = new PrcProfitReportQuery();
|
||||
query.setCustomerArea("C");
|
||||
for (String id : List.of("selectOrderRows", "selectProductRows", "selectSummary"))
|
||||
{
|
||||
var statement = config.getMappedStatement("com.bms.price.mapper.PrcProfitReportMapper." + id);
|
||||
query.setAreaCustomerIds(null);
|
||||
String joinSql = statement.getBoundSql(query).getSql();
|
||||
assertTrue(joinSql.contains("join ctr_customer c"));
|
||||
assertTrue(joinSql.contains("c.customer_area = ?"));
|
||||
assertTrue(joinSql.contains("c.del_flag = '0'"));
|
||||
|
||||
query.setAreaCustomerIds(List.of(2L, 3L));
|
||||
String inSql = statement.getBoundSql(query).getSql();
|
||||
assertFalse(inSql.contains("join ctr_customer c"));
|
||||
assertTrue(inSql.contains("p.customer_id in"));
|
||||
|
||||
query.setAreaCustomerIds(List.of());
|
||||
String emptySql = statement.getBoundSql(query).getSql();
|
||||
assertFalse(emptySql.contains("join ctr_customer c"));
|
||||
assertTrue(emptySql.contains("and 1 = 0"));
|
||||
|
||||
query.setAreaCustomerIds(null);
|
||||
query.setProductKeyword("EXP");
|
||||
String productSql = statement.getBoundSql(query).getSql();
|
||||
assertTrue(productSql.contains("p.product_code like concat('%', ?, '%')"));
|
||||
assertTrue(productSql.contains("p.product_name like concat('%', ?, '%')"));
|
||||
}
|
||||
}
|
||||
|
||||
private PrcProfitReportServiceImpl service(PrcProfitReportMapper mapper, boolean enabled, int max)
|
||||
{
|
||||
PrcProfitReportServiceImpl service = new PrcProfitReportServiceImpl();
|
||||
ReflectionTestUtils.setField(service, "profitReportMapper", mapper);
|
||||
ReflectionTestUtils.setField(service, "customerIdFilterEnabled", enabled);
|
||||
ReflectionTestUtils.setField(service, "maxCustomerIds", max);
|
||||
return service;
|
||||
}
|
||||
|
||||
private PrcProfitReportMapper mapper(AtomicReference<List<Long>> ids,
|
||||
AtomicReference<PrcProfitReportQuery> seen, Page<?> page)
|
||||
{
|
||||
return (PrcProfitReportMapper) Proxy.newProxyInstance(getClass().getClassLoader(),
|
||||
new Class<?>[] { PrcProfitReportMapper.class }, (proxy, method, args) -> {
|
||||
if (method.getName().equals("selectAreaCustomerIds"))
|
||||
{
|
||||
assertNull(PageHelper.getLocalPage());
|
||||
assertEquals("C", args[0]);
|
||||
assertEquals(3, args[1]);
|
||||
return ids.get();
|
||||
}
|
||||
assertSame(page, PageHelper.getLocalPage());
|
||||
seen.set((PrcProfitReportQuery) args[0]);
|
||||
return List.of();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package com.bms.report;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.zip.ZipFile;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.WorkbookFactory;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import com.bms.common.config.BmsConfig;
|
||||
import com.bms.common.core.redis.RedisCache;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.poi.ExcelUtil;
|
||||
import com.bms.price.domain.PrcProfitReportExportTask;
|
||||
import com.bms.price.domain.vo.PrcProfitReportOrderRow;
|
||||
import com.bms.price.domain.vo.PrcProfitReportQuery;
|
||||
import com.bms.price.enums.ProfitAreaRule;
|
||||
import com.bms.price.service.IPrcProfitReportService;
|
||||
import com.bms.price.task.PrcProfitReportExportRunner;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
|
||||
class ProfitReportAsyncExportTest
|
||||
{
|
||||
@TempDir
|
||||
Path tempDir;
|
||||
private String previousProfile;
|
||||
|
||||
@BeforeEach
|
||||
void useTempProfile()
|
||||
{
|
||||
previousProfile = BmsConfig.getProfile();
|
||||
new BmsConfig().setProfile(tempDir.toString());
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void restoreProfile()
|
||||
{
|
||||
new BmsConfig().setProfile(previousProfile);
|
||||
PageHelper.clearPage();
|
||||
}
|
||||
|
||||
@Test
|
||||
void submissionQueuesWorkAndExportsAllRowsUsingTheSubmittedFiltersAndRegionColumns() throws Exception
|
||||
{
|
||||
for (String area : List.of("C", "GZ"))
|
||||
{
|
||||
AtomicInteger calls = new AtomicInteger();
|
||||
HoldingExecutor executor = new HoldingExecutor();
|
||||
PrcProfitReportExportRunner runner = new PrcProfitReportExportRunner(service(query -> {
|
||||
calls.incrementAndGet();
|
||||
assertNull(PageHelper.getLocalPage());
|
||||
assertEquals(area, query.getCustomerArea());
|
||||
assertEquals("UNBILLED", query.getArBillStatus());
|
||||
assertEquals("P1", query.getProductCode());
|
||||
query.setProfitRule(ProfitAreaRule.fromCustomerArea(area).name());
|
||||
return List.of(row("ORDER-A"), row("ORDER-B"));
|
||||
}), new MemoryRedis(), executor);
|
||||
PrcProfitReportQuery query = query(area);
|
||||
query.setProductCode("P1");
|
||||
String taskId = runner.submit(query, 1L);
|
||||
|
||||
assertEquals(0, calls.get());
|
||||
assertEquals("PENDING", runner.getTask(taskId, 1L).getStatus());
|
||||
assertThrows(ServiceException.class, () -> runner.download(taskId, 1L, new MockHttpServletResponse()));
|
||||
query.setProductCode("CHANGED-AFTER-SUBMIT");
|
||||
PageHelper.startPage(2, 1);
|
||||
executor.work.run();
|
||||
|
||||
PrcProfitReportExportTask task = runner.getTask(taskId, 1L);
|
||||
assertEquals("SUCCESS", task.getStatus());
|
||||
assertEquals(100, task.getPercent());
|
||||
assertEquals(2, task.getRowCount());
|
||||
assertEquals(1, calls.get());
|
||||
assertNull(PageHelper.getLocalPage());
|
||||
assertThrows(ServiceException.class, () -> runner.getTask(taskId, 2L));
|
||||
assertThrows(ServiceException.class, () -> runner.download(taskId, 2L, new MockHttpServletResponse()));
|
||||
Path file = tempDir.resolve("download").resolve(task.getStorageKey());
|
||||
try (InputStream input = Files.newInputStream(file); Workbook workbook = WorkbookFactory.create(input))
|
||||
{
|
||||
var sheet = workbook.getSheetAt(0);
|
||||
assertEquals(2, sheet.getLastRowNum());
|
||||
Row header = sheet.getRow(0);
|
||||
assertEquals(area.equals("C"), hasColumn(header, "产品价(目录价)"));
|
||||
assertEquals(area.equals("C"), hasColumn(header, "红线毛利"));
|
||||
assertTrue(hasColumn(header, "销售价"));
|
||||
}
|
||||
MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
runner.download(taskId, 1L, response);
|
||||
assertArrayEquals(Files.readAllBytes(file), response.getContentAsByteArray());
|
||||
assertTrue(response.getHeader("Content-Disposition").contains(".xlsx"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectedExecutionAndQueryFailuresBecomeVisibleFailedTasks() throws Exception
|
||||
{
|
||||
ThreadPoolTaskExecutor rejected = new ThreadPoolTaskExecutor() {
|
||||
@Override
|
||||
public void execute(Runnable task) { throw new TaskRejectedException("busy"); }
|
||||
};
|
||||
PrcProfitReportExportRunner runner = new PrcProfitReportExportRunner(service(query -> {
|
||||
fail("Rejected tasks must not query orders");
|
||||
return List.of();
|
||||
}), new MemoryRedis(), rejected);
|
||||
String rejectedId = runner.submit(query("C"), 1L);
|
||||
assertEquals("FAIL", runner.getTask(rejectedId, 1L).getStatus());
|
||||
assertEquals("导出任务较多,请稍后重试", runner.getTask(rejectedId, 1L).getError());
|
||||
|
||||
HoldingExecutor executor = new HoldingExecutor();
|
||||
PrcProfitReportExportRunner failing = new PrcProfitReportExportRunner(service(query -> {
|
||||
throw new ServiceException("该客户区域未配置毛利规则");
|
||||
}), new MemoryRedis(), executor);
|
||||
String failedId = failing.submit(query("INVALID"), 1L);
|
||||
executor.work.run();
|
||||
PrcProfitReportExportTask failed = failing.getTask(failedId, 1L);
|
||||
assertEquals("FAIL", failed.getStatus());
|
||||
assertEquals("该客户区域未配置毛利规则", failed.getError());
|
||||
assertNull(failed.getStorageKey());
|
||||
assertThrows(ServiceException.class, () -> failing.download(failedId, 1L, new MockHttpServletResponse()));
|
||||
assertFalse(Files.exists(tempDir.resolve("download/profitReportExport/" + failedId + ".xlsx")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exportsMoreThanLegacySheetLimitIntoOneSheet() throws Exception
|
||||
{
|
||||
int rowCount = ExcelUtil.sheetSize + 1;
|
||||
List<PrcProfitReportOrderRow> rows = Collections.nCopies(rowCount, row("ORDER-LARGE"));
|
||||
HoldingExecutor executor = new HoldingExecutor();
|
||||
PrcProfitReportExportRunner runner = new PrcProfitReportExportRunner(service(query -> rows),
|
||||
new MemoryRedis(), executor);
|
||||
String taskId = runner.submit(query("C"), 1L);
|
||||
executor.work.run();
|
||||
|
||||
PrcProfitReportExportTask task = runner.getTask(taskId, 1L);
|
||||
assertEquals("SUCCESS", task.getStatus());
|
||||
assertEquals(rowCount, task.getRowCount());
|
||||
Path file = tempDir.resolve("download").resolve(task.getStorageKey());
|
||||
assertEquals(1, countWorkbookSheets(file));
|
||||
assertEquals(rowCount + 1, lastWorksheetRowNumber(file));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsRowsBeyondTheSingleSheetLimit()
|
||||
{
|
||||
List<PrcProfitReportOrderRow> rows = Collections.nCopies(ExcelUtil.XLSX_MAX_ROW_COUNT, row("ORDER-LARGE"));
|
||||
HoldingExecutor executor = new HoldingExecutor();
|
||||
PrcProfitReportExportRunner runner = new PrcProfitReportExportRunner(service(query -> rows),
|
||||
new MemoryRedis(), executor);
|
||||
String taskId = runner.submit(query("C"), 1L);
|
||||
executor.work.run();
|
||||
|
||||
PrcProfitReportExportTask task = runner.getTask(taskId, 1L);
|
||||
assertEquals("FAIL", task.getStatus());
|
||||
assertTrue(task.getError().contains("单个工作表最多支持1048575条订单"));
|
||||
assertFalse(Files.exists(tempDir.resolve("download/profitReportExport/" + taskId + ".xlsx")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cleanupRemovesOnlyExpiredExportFiles() throws Exception
|
||||
{
|
||||
Path dir = Files.createDirectories(tempDir.resolve("download/profitReportExport"));
|
||||
Path old = Files.writeString(dir.resolve("a".repeat(32) + ".xlsx"), "old");
|
||||
Path recent = Files.writeString(dir.resolve("b".repeat(32) + ".xlsx"), "new");
|
||||
Path other = Files.writeString(dir.resolve("unrelated.xlsx"), "other");
|
||||
FileTime expired = FileTime.from(Instant.now().minusSeconds(TimeUnit.HOURS.toSeconds(25)));
|
||||
Files.setLastModifiedTime(old, expired);
|
||||
Files.setLastModifiedTime(other, expired);
|
||||
PrcProfitReportExportRunner runner = new PrcProfitReportExportRunner(service(query -> List.of()),
|
||||
new MemoryRedis(), new HoldingExecutor());
|
||||
runner.cleanupExpiredFiles();
|
||||
assertFalse(Files.exists(old));
|
||||
assertTrue(Files.exists(recent));
|
||||
assertTrue(Files.exists(other));
|
||||
}
|
||||
|
||||
@Test
|
||||
void jsonSubmissionRetainsTheListDateRangeAndFilters() throws Exception
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
||||
PrcProfitReportQuery query = mapper.readValue("""
|
||||
{"customerArea":"C", "beginBizDate":"2026-10-18 00:00:00",
|
||||
"endBizDate":"2026-11-17 23:59:59", "arBillStatus":"UNBILLED", "orderNo":"A\\nB"}
|
||||
""", PrcProfitReportQuery.class);
|
||||
assertEquals(Instant.parse("2026-10-17T16:00:00Z"), query.getBeginBizDate().toInstant());
|
||||
assertEquals(Instant.parse("2026-11-17T15:59:59Z"), query.getEndBizDate().toInstant());
|
||||
assertEquals("A\nB", query.getOrderNo());
|
||||
assertEquals("UNBILLED", query.getArBillStatus());
|
||||
}
|
||||
|
||||
private static PrcProfitReportQuery query(String area)
|
||||
{
|
||||
PrcProfitReportQuery query = new PrcProfitReportQuery();
|
||||
query.setCustomerArea(area);
|
||||
query.setArBillStatus("UNBILLED");
|
||||
return query;
|
||||
}
|
||||
|
||||
private static PrcProfitReportOrderRow row(String orderNo)
|
||||
{
|
||||
PrcProfitReportOrderRow row = new PrcProfitReportOrderRow();
|
||||
row.setOrderNo(orderNo);
|
||||
row.setSalesAmount(new BigDecimal("26.60"));
|
||||
row.setArBillStatus("UNBILLED");
|
||||
return row;
|
||||
}
|
||||
|
||||
private static boolean hasColumn(Row header, String name)
|
||||
{
|
||||
for (var cell : header) if (name.equals(cell.getStringCellValue())) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int countWorkbookSheets(Path file) throws Exception
|
||||
{
|
||||
try (ZipFile workbook = new ZipFile(file.toFile());
|
||||
InputStream input = workbook.getInputStream(workbook.getEntry("xl/workbook.xml")))
|
||||
{
|
||||
XMLStreamReader reader = xmlInputFactory().createXMLStreamReader(input);
|
||||
int count = 0;
|
||||
try
|
||||
{
|
||||
while (reader.hasNext())
|
||||
{
|
||||
if (reader.next() == XMLStreamReader.START_ELEMENT && "sheet".equals(reader.getLocalName()))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
private static int lastWorksheetRowNumber(Path file) throws Exception
|
||||
{
|
||||
try (ZipFile workbook = new ZipFile(file.toFile());
|
||||
InputStream input = workbook.getInputStream(workbook.getEntry("xl/worksheets/sheet1.xml")))
|
||||
{
|
||||
XMLStreamReader reader = xmlInputFactory().createXMLStreamReader(input);
|
||||
int lastRowNumber = 0;
|
||||
try
|
||||
{
|
||||
while (reader.hasNext())
|
||||
{
|
||||
if (reader.next() == XMLStreamReader.START_ELEMENT && "row".equals(reader.getLocalName()))
|
||||
{
|
||||
lastRowNumber = Integer.parseInt(reader.getAttributeValue(null, "r"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
return lastRowNumber;
|
||||
}
|
||||
}
|
||||
|
||||
private static XMLInputFactory xmlInputFactory()
|
||||
{
|
||||
XMLInputFactory factory = XMLInputFactory.newFactory();
|
||||
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
|
||||
factory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);
|
||||
return factory;
|
||||
}
|
||||
|
||||
private static IPrcProfitReportService service(Function<PrcProfitReportQuery, List<PrcProfitReportOrderRow>> query)
|
||||
{
|
||||
return (IPrcProfitReportService) Proxy.newProxyInstance(ProfitReportAsyncExportTest.class.getClassLoader(),
|
||||
new Class<?>[] { IPrcProfitReportService.class }, (proxy, method, args) -> {
|
||||
if ("selectOrderRows".equals(method.getName())) return query.apply((PrcProfitReportQuery) args[0]);
|
||||
throw new AssertionError("Unexpected service call: " + method.getName());
|
||||
});
|
||||
}
|
||||
|
||||
private static class HoldingExecutor extends ThreadPoolTaskExecutor
|
||||
{
|
||||
private Runnable work;
|
||||
@Override
|
||||
public void execute(Runnable task) { work = task; }
|
||||
}
|
||||
|
||||
private static class MemoryRedis extends RedisCache
|
||||
{
|
||||
private final Map<String, Object> values = new HashMap<>();
|
||||
@Override
|
||||
public <T> void setCacheObject(String key, T value, Integer timeout, TimeUnit unit)
|
||||
{
|
||||
values.put(key, value);
|
||||
}
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getCacheObject(String key) { return (T) values.get(key); }
|
||||
}
|
||||
}
|
||||
@@ -111,11 +111,12 @@ public class ExcelUtil<T>
|
||||
*/
|
||||
private Map<String, CellStyle> cellStyleCache = new HashMap<String, CellStyle>();
|
||||
|
||||
/**
|
||||
* Excel sheet最大行数,默认65536
|
||||
*/
|
||||
/** 通用导出的默认每个工作表数据行数;单工作表 XLSX 导出使用 XLSX 实际上限。 */
|
||||
public static final int sheetSize = 65536;
|
||||
|
||||
/** XLSX 工作表的最大行数。 */
|
||||
public static final int XLSX_MAX_ROW_COUNT = 1_048_576;
|
||||
|
||||
/**
|
||||
* 工作表名称
|
||||
*/
|
||||
@@ -796,6 +797,28 @@ public class ExcelUtil<T>
|
||||
}
|
||||
}
|
||||
|
||||
/** 写入单个 XLSX 工作表;超出 Excel 行数上限时返回明确错误。 */
|
||||
public void exportExcelToSingleSheetStream(List<T> list, String sheetName, OutputStream output) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
this.init(list, sheetName, StringUtils.EMPTY, Type.EXPORT);
|
||||
int reservedRows = rownum + 1 + (hasStatisticsColumns() ? 1 : 0);
|
||||
int maxDataRows = XLSX_MAX_ROW_COUNT - reservedRows;
|
||||
if (this.list.size() > maxDataRows)
|
||||
{
|
||||
throw new IOException(StringUtils.format("单个工作表最多支持{}条数据,当前{}条,请缩小查询范围",
|
||||
maxDataRows, this.list.size()));
|
||||
}
|
||||
writeSheet(maxDataRows);
|
||||
wb.write(output);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(wb);
|
||||
}
|
||||
}
|
||||
|
||||
/** 对 list 数据源生成本地 Excel 文件,返回文件名。 */
|
||||
public AjaxResult exportExcel()
|
||||
{
|
||||
@@ -824,9 +847,14 @@ public class ExcelUtil<T>
|
||||
* 创建写入数据到Sheet
|
||||
*/
|
||||
public void writeSheet()
|
||||
{
|
||||
writeSheet(sheetSize);
|
||||
}
|
||||
|
||||
private void writeSheet(int rowsPerSheet)
|
||||
{
|
||||
// 取出一共有多少个sheet.
|
||||
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
|
||||
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / rowsPerSheet));
|
||||
for (int index = 0; index < sheetNo; index++)
|
||||
{
|
||||
createSheet(sheetNo, index);
|
||||
@@ -855,7 +883,7 @@ public class ExcelUtil<T>
|
||||
}
|
||||
if (Type.EXPORT.equals(type))
|
||||
{
|
||||
fillExcelData(index);
|
||||
fillExcelData(index, rowsPerSheet);
|
||||
addStatisticsRow();
|
||||
}
|
||||
}
|
||||
@@ -869,8 +897,13 @@ public class ExcelUtil<T>
|
||||
@SuppressWarnings("unchecked")
|
||||
public void fillExcelData(int index)
|
||||
{
|
||||
int startNo = index * sheetSize;
|
||||
int endNo = Math.min(startNo + sheetSize, list.size());
|
||||
fillExcelData(index, sheetSize);
|
||||
}
|
||||
|
||||
private void fillExcelData(int index, int rowsPerSheet)
|
||||
{
|
||||
int startNo = index * rowsPerSheet;
|
||||
int endNo = Math.min(startNo + rowsPerSheet, list.size());
|
||||
int currentRowNum = rownum + 1; // 从标题行后开始
|
||||
|
||||
for (int i = startNo; i < endNo; i++)
|
||||
@@ -931,6 +964,18 @@ public class ExcelUtil<T>
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasStatisticsColumns()
|
||||
{
|
||||
for (Object[] field : fields)
|
||||
{
|
||||
if (((Excel) field[1]).isStatistics())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子列表最大数
|
||||
*/
|
||||
|
||||
+4
@@ -136,6 +136,10 @@ public class BmsSupplier extends BaseEntity
|
||||
@Excel(name = "合作状态", readConverterExp = "0=正常,1=暂停,2=终止")
|
||||
private String cooperationStatus;
|
||||
|
||||
/** 数据来源,字典 bms_supplier_data_source。空表示未填写 */
|
||||
@Excel(name = "数据来源", dictType = "bms_supplier_data_source")
|
||||
private String dataSource;
|
||||
|
||||
/** 绑定的渠道/服务ID */
|
||||
private String channelIds;
|
||||
|
||||
|
||||
+3
@@ -26,6 +26,9 @@ public interface BmsSupplierMapper
|
||||
/** 修改供应商 */
|
||||
public int updateBmsSupplier(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 只更新供应商绑定的渠道编码。 */
|
||||
public int updateSupplierChannels(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 删除供应商 */
|
||||
public int deleteBmsSupplierBySupplierId(Long supplierId);
|
||||
|
||||
|
||||
+3
@@ -26,6 +26,9 @@ public interface IBmsSupplierService
|
||||
/** 修改供应商 */
|
||||
public int updateBmsSupplier(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 只改这一家供应商绑定的渠道,其它资料不动。 */
|
||||
public int bindChannels(Long supplierId, String channelIds);
|
||||
|
||||
/** 批量删除供应商 */
|
||||
public int deleteBmsSupplierBySupplierIds(Long[] supplierIds);
|
||||
|
||||
|
||||
+56
@@ -1,6 +1,7 @@
|
||||
package com.bms.customer.supplierinfo.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.bms.common.annotation.DataScope;
|
||||
@@ -302,6 +303,61 @@ public class BmsSupplierServiceImpl implements IBmsSupplierService
|
||||
return bmsSupplierMapper.updateBmsSupplier(bmsSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只改绑定渠道。不走整单修改,避免把附件、采购员和合同日期清掉。
|
||||
*/
|
||||
@Override
|
||||
public int bindChannels(Long supplierId, String channelIds)
|
||||
{
|
||||
if (supplierId == null)
|
||||
{
|
||||
throw new ServiceException("请选择供应商");
|
||||
}
|
||||
if (bmsSupplierMapper.selectBmsSupplierBySupplierId(supplierId) == null)
|
||||
{
|
||||
throw new ServiceException("供应商不存在");
|
||||
}
|
||||
String value = joinChannels(channelIds);
|
||||
if (value.length() > 1000)
|
||||
{
|
||||
throw new ServiceException("绑定的渠道过多,请减少后再保存");
|
||||
}
|
||||
BmsSupplier row = new BmsSupplier();
|
||||
row.setSupplierId(supplierId);
|
||||
row.setChannelIds(value);
|
||||
row.setUpdateBy(SecurityUtils.getUsername());
|
||||
row.setUpdateTime(DateUtils.getNowDate());
|
||||
int rows = bmsSupplierMapper.updateSupplierChannels(row);
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new ServiceException("供应商不存在");
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** 渠道编码去空白、去重,仍按选择顺序用逗号拼起来。 */
|
||||
private static String joinChannels(String channelIds)
|
||||
{
|
||||
if (StringUtils.isEmpty(channelIds))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
LinkedHashSet<String> codes = new LinkedHashSet<>();
|
||||
for (String part : channelIds.split(","))
|
||||
{
|
||||
if (part == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String code = part.trim();
|
||||
if (!code.isEmpty())
|
||||
{
|
||||
codes.add(code);
|
||||
}
|
||||
}
|
||||
return String.join(",", codes);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteBmsSupplierBySupplierIds(Long[] supplierIds)
|
||||
|
||||
+8
-1
@@ -1,6 +1,7 @@
|
||||
package com.bms.price.airbill.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/** 待分摊的一条提单费用,供费用处理弹框展示。 */
|
||||
@@ -11,7 +12,7 @@ public class SrvBillAirAllocFee
|
||||
|
||||
private String billCode;
|
||||
|
||||
/** 提单主键 srv_bill_air.guid,写入订单费用的 source_id */
|
||||
/** 提单主键 srv_bill_air.guid */
|
||||
private String ladingId;
|
||||
|
||||
/** 费用阶段,字典 bms_fee_level */
|
||||
@@ -20,12 +21,18 @@ public class SrvBillAirAllocFee
|
||||
/** 费用状态,字典 bill_fee_status */
|
||||
private String billFeeStatus;
|
||||
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
private String feeName;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
private String currency;
|
||||
|
||||
/** 费用录入时间,用来取汇率 */
|
||||
private Date createTime;
|
||||
|
||||
/** 分摊维度:1订单 2重量 */
|
||||
private String allocDim;
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ public class SrvBillAirAllocOrder
|
||||
private String orderNo;
|
||||
|
||||
/** 计费订单 ID,对应 prc_order_bill.bill_id */
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
/** 计费重,没有计费重时依次取实际重量、收货重量 */
|
||||
private BigDecimal chargeWeight;
|
||||
|
||||
@@ -15,9 +15,12 @@ public class SrvBillAirFee
|
||||
|
||||
private String billCode;
|
||||
|
||||
/** 附加费编号 prc_surcharge.sc_id */
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
/** 附加费配置ID,对应 prc_surcharge.sc_id */
|
||||
private Long scId;
|
||||
|
||||
/** 附加费名称,仅展示,不入库 */
|
||||
private String feeName;
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.bms.price.config;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
/** 毛利分析导出专用线程池,限制全量订单查询与 Excel 生成的并发。 */
|
||||
@Configuration
|
||||
public class ProfitReportExportTaskConfig
|
||||
{
|
||||
@Bean(name = "profitReportExportTaskExecutor")
|
||||
public ThreadPoolTaskExecutor profitReportExportTaskExecutor()
|
||||
{
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(1);
|
||||
executor.setMaxPoolSize(1);
|
||||
executor.setQueueCapacity(2);
|
||||
executor.setThreadNamePrefix("profit-report-export-");
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@ package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
/** 按订单生成应付的结果。skipped 是价卡里有、但这票算不了的附加费。 */
|
||||
@Data
|
||||
public class PayOrderCostResult
|
||||
{
|
||||
private String billId;
|
||||
private Long billId;
|
||||
|
||||
private String channelId;
|
||||
|
||||
@@ -29,4 +30,12 @@ public class PayOrderCostResult
|
||||
private List<PayCostLine> fees;
|
||||
|
||||
private List<String> skipped;
|
||||
|
||||
/** 本次落库的应付费用,供提交成功后写日志。不返回给页面。 */
|
||||
@JsonIgnore
|
||||
private transient List<PrcPayBillFee> loggedFees;
|
||||
|
||||
/** 本次费用日志的操作类型,字典 bms_pay_fee_log_type */
|
||||
@JsonIgnore
|
||||
private transient String feeLogType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 一票订单的应付费用,按 abcd 四段排好。 */
|
||||
@Data
|
||||
public class PayOrderFeeBoard
|
||||
{
|
||||
private String billId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String ladingNo;
|
||||
|
||||
private List<PayOrderFeeSection> sections = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表费用弹框里的一条费用。 */
|
||||
@Data
|
||||
public class PayOrderFeeLine
|
||||
{
|
||||
/** 费用明细 ID。新增时为空 */
|
||||
private String feeId;
|
||||
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码。手输名称放不下时记 MANUAL */
|
||||
private String feeType;
|
||||
|
||||
/** 费用项名称。手工费用按填写的名称保存 */
|
||||
private String feeName;
|
||||
|
||||
/** 1A 2B 3C 4D */
|
||||
private String level;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String currency;
|
||||
|
||||
/** CALC 尾程计算,LADING 提单分摊,MANUAL 手工 */
|
||||
private String feeSource;
|
||||
|
||||
private String remark;
|
||||
|
||||
/** 已进入应付账单时不能删除 */
|
||||
private Long statementLineId;
|
||||
|
||||
/** 创建人 */
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付费用的一个阶段。1A 头程仓储,2B 提单运输,3C 清关,4D 尾程。 */
|
||||
@Data
|
||||
public class PayOrderFeeSection
|
||||
{
|
||||
private String level;
|
||||
|
||||
private String title;
|
||||
|
||||
private List<PayOrderFeeLine> fees = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表查询条件。 */
|
||||
@Data
|
||||
public class PayOrderQuery
|
||||
{
|
||||
private String orderNo;
|
||||
|
||||
/** 多个订单号。由服务按逗号、空格或换行拆开。 */
|
||||
private java.util.List<String> orderNos;
|
||||
|
||||
private String ladingNo;
|
||||
|
||||
private String customerName;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表上的费用重算条件。一次只按订单号或提单号其中一种。 */
|
||||
@Data
|
||||
public class PayOrderRecalcCommand
|
||||
{
|
||||
/** ORDER 按订单号,LADING 按提单号 */
|
||||
private String sourceType;
|
||||
|
||||
/** 单号原文。可用逗号、空格或换行分隔 */
|
||||
private String text;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/** 费用重算里的一票结果。 */
|
||||
@Data
|
||||
public class PayOrderRecalcLine
|
||||
{
|
||||
private String billId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String ladingNo;
|
||||
|
||||
/** 这一条是否已经处理完 */
|
||||
private boolean finished;
|
||||
|
||||
/** 这一票是否已经生成应付费用 */
|
||||
private boolean success;
|
||||
|
||||
/** 失败原因。成功时为空 */
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 一次费用重算的结果。失败行不影响已经成功的订单。 */
|
||||
@Data
|
||||
public class PayOrderRecalcResult
|
||||
{
|
||||
/** 计费成功的订单数 */
|
||||
private int successCount;
|
||||
|
||||
/** 未生成费用的订单数,含找不到的单号 */
|
||||
private int failCount;
|
||||
|
||||
/** 每一票或每一个没对上的单号 */
|
||||
private List<PayOrderRecalcLine> lines = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付费用重算任务。待处理订单和进度都放在 Redis。 */
|
||||
@Data
|
||||
public class PayOrderRecalcTask implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String PENDING = "PENDING";
|
||||
|
||||
public static final String RUNNING = "RUNNING";
|
||||
|
||||
public static final String SUCCESS = "SUCCESS";
|
||||
|
||||
public static final String FAIL = "FAIL";
|
||||
|
||||
public static final String CANCELLED = "CANCELLED";
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String status;
|
||||
|
||||
private int percent;
|
||||
|
||||
private String message;
|
||||
|
||||
private int total;
|
||||
|
||||
private int successCount;
|
||||
|
||||
private int failCount;
|
||||
|
||||
/** 查出来的订单,以及没对上的单号。处理完一条就更新这一条。 */
|
||||
private List<PayOrderRecalcLine> lines = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表里的一票订单。提单号来自订单扩展上的空运单号。 */
|
||||
@Data
|
||||
public class PayOrderRow
|
||||
{
|
||||
private String billId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
private String ladingNo;
|
||||
|
||||
private String trackingNo;
|
||||
|
||||
private String customerName;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String countryName;
|
||||
|
||||
private String channelName;
|
||||
|
||||
private BigDecimal chargeWeight;
|
||||
|
||||
private BigDecimal payTotal;
|
||||
|
||||
private String currency;
|
||||
|
||||
/** 应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败 */
|
||||
private Integer payCalcStatus;
|
||||
|
||||
/** 计费失败原因 */
|
||||
private String payCalcMsg;
|
||||
|
||||
/** 应付主表更新人 */
|
||||
private String updateBy;
|
||||
|
||||
/** 应付主表更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date bizDate;
|
||||
}
|
||||
@@ -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<>();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class PayProduct extends BaseEntity
|
||||
@Excel(name = "国家/口岸", width = 18)
|
||||
private String countryScope;
|
||||
|
||||
/** 字典 order_charge_type:续重计费、单票价、常规计重价 */
|
||||
/** 字典 order_charge_type:PER_KG 常规计费、FLAT 一口价、EXTRA 续重价 */
|
||||
@Excel(name = "费用类型", width = 14)
|
||||
private String chargeType;
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 把同一套计费条件写到若干产品的当前版本。每个版本只保留这一份。
|
||||
*/
|
||||
@Data
|
||||
public class PaySurchargeRuleSave
|
||||
{
|
||||
private List<PaySurchargeRuleBind> products = new ArrayList<>();
|
||||
|
||||
private List<PaySurchargeRule> rules = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class PaySurchargeRuleBind
|
||||
{
|
||||
private Long productId;
|
||||
|
||||
private Long termId;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
private String productName;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
/** 产品价合计 */
|
||||
@@ -24,8 +24,15 @@ public class PrcPayBill implements Serializable
|
||||
private BigDecimal redlineAmount;
|
||||
/** 成本价合计(当前计费结果) */
|
||||
private BigDecimal costAmount;
|
||||
/** 应付合计(当前等于成本价) */
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细重算) */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** 应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败 */
|
||||
private Integer payCalcStatus;
|
||||
|
||||
/** 计费失败原因,最长 100 字 */
|
||||
private String payCalcMsg;
|
||||
|
||||
/** 业务员/销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付费用明细 prc_pay_bill_fee */
|
||||
@@ -13,11 +14,17 @@ 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;
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
/** 展示用的费用项名称,不入库。附加费取配置名称,其余取字典标签 */
|
||||
private String feeName;
|
||||
|
||||
/** 尾程计算时是附加费配置ID。提单分摊时是 srv_bill_air_fee.id */
|
||||
private Long scId;
|
||||
|
||||
/** 费用所属阶段:1 a段,2 b段,3 c段,4 d段 */
|
||||
@@ -30,7 +37,7 @@ public class PrcPayBillFee implements Serializable
|
||||
/** CALC 计算,LADING 提单分摊,MANUAL 人工 */
|
||||
private String feeSource;
|
||||
|
||||
/** 来源数据id */
|
||||
/** 来源数据id。提单分摊时为 srv_bill_air_fee.id */
|
||||
private String sourceId;
|
||||
|
||||
/** 是否删除:0未删除 1已删除 */
|
||||
@@ -43,6 +50,32 @@ public class PrcPayBillFee implements Serializable
|
||||
private Long settleSupplierId;
|
||||
|
||||
private String settleSupplierName;
|
||||
|
||||
/** 创建人 */
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 写日志时带上的变更前费用项,不入库 */
|
||||
@JsonIgnore
|
||||
private String logBeforeName;
|
||||
|
||||
/** 写日志时带上的变更前金额,不入库 */
|
||||
@JsonIgnore
|
||||
private BigDecimal logBeforeAmount;
|
||||
|
||||
/** 写日志时带上的变更前币种,不入库 */
|
||||
@JsonIgnore
|
||||
private String logBeforeCurrency;
|
||||
|
||||
/** 为 true 时日志只记变更前。重算后消失的计算费用用,不入库 */
|
||||
@JsonIgnore
|
||||
private Boolean logAfterBlank;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付费用日志 prc_pay_bill_fee_log */
|
||||
@Data
|
||||
public class PrcPayBillFeeLog implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long logId;
|
||||
|
||||
private String feeId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
/** 费用项 */
|
||||
private String feeName;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String currency;
|
||||
|
||||
/** 变更前费用项 */
|
||||
private String beforeFeeName;
|
||||
|
||||
/** 变更前金额 */
|
||||
private BigDecimal beforeAmount;
|
||||
|
||||
/** 变更前币种 */
|
||||
private String beforeCurrency;
|
||||
|
||||
/** 变更后费用项 */
|
||||
private String afterFeeName;
|
||||
|
||||
/** 变更后金额 */
|
||||
private BigDecimal afterAmount;
|
||||
|
||||
/** 变更后币种 */
|
||||
private String afterCurrency;
|
||||
|
||||
/** 操作类型,字典 bms_pay_fee_log_type */
|
||||
private String operationType;
|
||||
|
||||
/** 备注。费用重算失败时写入失败原因 */
|
||||
private String remark;
|
||||
|
||||
/** 操作人 */
|
||||
private String createBy;
|
||||
|
||||
/** 操作时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/** 毛利分析订单异步导出任务的临时状态。 */
|
||||
@Data
|
||||
public class PrcProfitReportExportTask implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String taskId;
|
||||
private Long userId;
|
||||
private String status;
|
||||
private int percent;
|
||||
private String message;
|
||||
private String error;
|
||||
private int rowCount;
|
||||
private String fileName;
|
||||
private String storageKey;
|
||||
}
|
||||
+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;
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ public class PrcBillingBillListExportRow implements Serializable
|
||||
private String countryName;
|
||||
@Excel(name = "件数", width = 10)
|
||||
private Integer pieces;
|
||||
@Excel(name = "计费重", scale = 3, width = 12)
|
||||
@Excel(name = "客户确认重", scale = 3, width = 12)
|
||||
private BigDecimal chargeWeight;
|
||||
@Excel(name = "原计费重", scale = 3, width = 12)
|
||||
@Excel(name = "计费重", scale = 3, width = 12)
|
||||
private BigDecimal weight;
|
||||
@Excel(name = "收货重", scale = 3, width = 12)
|
||||
private BigDecimal receiveWeight;
|
||||
|
||||
+2
@@ -35,6 +35,8 @@ public class PrcOrderBillListExportRow implements Serializable
|
||||
private Integer pieces;
|
||||
@Excel(name = "计费重", scale = 3, width = 12)
|
||||
private BigDecimal weight;
|
||||
@Excel(name = "客户确认重", scale = 3, width = 12)
|
||||
private BigDecimal chargeWeight;
|
||||
@Excel(name = "体积重", scale = 3, width = 12)
|
||||
private BigDecimal volumeWeight;
|
||||
@Excel(name = "实重", scale = 3, width = 12)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bms.price.domain.vo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
@@ -15,8 +16,10 @@ public class PrcProfitReportQuery extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date beginBizDate;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date endBizDate;
|
||||
private String orderNo;
|
||||
/** 订单号拆分后的多值查询条件。 */
|
||||
@@ -26,14 +29,20 @@ public class PrcProfitReportQuery extends BaseEntity
|
||||
private List<String> customerCodes;
|
||||
/** 按客户当前区域筛选。 */
|
||||
private String customerArea;
|
||||
/** 服务端解析的区域客户 ID;null 表示使用客户表关联,空列表表示无匹配客户。 */
|
||||
private List<Long> areaCustomerIds;
|
||||
/** 服务端根据客户区域确定的计算规则。 */
|
||||
private String profitRule;
|
||||
private String customerName;
|
||||
/** 客户名称拆分后的多值查询条件。 */
|
||||
private List<String> customerNames;
|
||||
private String belongSalerCode;
|
||||
/** 产品代码或产品名称的统一模糊查询关键字。 */
|
||||
private String productKeyword;
|
||||
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;
|
||||
|
||||
@@ -42,6 +42,8 @@ public class TmsPriceBillRequest extends TmsPriceQuoteRequest
|
||||
private BigDecimal actualWeight;
|
||||
/** 上游 TAB_ORDER.WEIGHT(收货重量) */
|
||||
private BigDecimal receiveWeight;
|
||||
/** 计费重覆盖:上游 CONFIRM_WEIGHT(客户确认重)或本地人工修改;无值则为 null */
|
||||
private BigDecimal chargeWeight;
|
||||
private BigDecimal volume;
|
||||
private BigDecimal volumeWeight;
|
||||
private BigDecimal pkgLength;
|
||||
|
||||
@@ -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 */
|
||||
@@ -23,6 +23,8 @@ public class TmsPriceQuoteFeeLine implements Serializable
|
||||
private String currency;
|
||||
private String roundMode;
|
||||
private String remark;
|
||||
/** CALC 计算,LADING 提单分摊,MANUAL 手工 */
|
||||
private String feeSource;
|
||||
/** UNBILLED / BILLED */
|
||||
private String arBillStatus;
|
||||
/** 0=系统 1=人工 */
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRow;
|
||||
|
||||
/** 应付列表。 */
|
||||
public interface PayOrderListMapper
|
||||
{
|
||||
List<PayOrderRow> selectList(PayOrderQuery query);
|
||||
|
||||
PayOrderRow selectRow(@Param("billId") String billId);
|
||||
|
||||
/**
|
||||
* 按订单号精确找出要重算的订单。
|
||||
*
|
||||
* @param orderNos 订单号,已去重
|
||||
* @return 订单号和提单号
|
||||
*/
|
||||
List<PayOrderRow> selectByOrderNos(@Param("orderNos") List<String> orderNos);
|
||||
|
||||
/**
|
||||
* 按提单号找出下面的全部订单。提单号对应订单扩展上的空运单号。
|
||||
*
|
||||
* @param ladingNos 提单号,已去重
|
||||
* @return 这些提单下的订单
|
||||
*/
|
||||
List<PayOrderRow> selectByLadingNos(@Param("ladingNos") List<String> ladingNos);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
|
||||
/** 应付附加费计费条件。一个产品版本一份。 */
|
||||
public interface PaySurchargeRuleMapper
|
||||
{
|
||||
List<PaySurchargeRule> selectByProduct(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
int deleteByTerm(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
int insertBatch(@Param("list") List<PaySurchargeRule> rules);
|
||||
|
||||
/** 同一产品字典下,比当前版本号小的最近一版 */
|
||||
PaySurchargeRule selectPreviousVersion(@Param("productId") Long productId);
|
||||
}
|
||||
+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);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPayBillFeeLog;
|
||||
|
||||
/** 应付费用日志 prc_pay_bill_fee_log。 */
|
||||
public interface PrcPayBillFeeLogMapper
|
||||
{
|
||||
/**
|
||||
* 批量写入应付费用日志。
|
||||
*
|
||||
* @param logs 本次操作的费用快照
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("list") List<PrcPayBillFeeLog> logs);
|
||||
|
||||
/**
|
||||
* 按订单读取费用日志,新的在前。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 日志
|
||||
*/
|
||||
List<PrcPayBillFeeLog> selectByBillId(@Param("billId") Long billId);
|
||||
}
|
||||
@@ -13,7 +13,40 @@ public interface PrcPayBillFeeMapper
|
||||
* @param billId 计费订单ID
|
||||
* @return 费用明细
|
||||
*/
|
||||
public List<PrcPayBillFee> selectByBillId(String billId);
|
||||
public List<PrcPayBillFee> selectByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 按费用明细 ID 读取一行。已逻辑删除的也返回,调用方自己判断。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
* @return 费用行,没有时为 null
|
||||
*/
|
||||
public PrcPayBillFee selectByFeeId(@Param("feeId") String feeId);
|
||||
|
||||
/**
|
||||
* 写入一条手工费用。来源固定为 MANUAL,并记下创建人、更新人。
|
||||
*
|
||||
* @param fee 费用项、金额、币种、说明和所属阶段
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int insertManual(PrcPayBillFee fee);
|
||||
|
||||
/**
|
||||
* 逻辑删除一条费用。已经进入应付账单的行不删。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
* @param operator 当前登录人
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int markFeeDeleted(@Param("feeId") String feeId, @Param("operator") String operator);
|
||||
|
||||
/**
|
||||
* 这票订单里已经进入应付账单的计算费用条数。有则不能重算覆盖。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 已出账的计算费用条数
|
||||
*/
|
||||
public int countSettledCalc(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 插入一条订单应付费用。
|
||||
@@ -31,13 +64,18 @@ public interface PrcPayBillFeeMapper
|
||||
*/
|
||||
public int insertBatch(@Param("list") List<PrcPayBillFee> fees);
|
||||
|
||||
/** 把还没标明来源的费用,关联到本行主键 id。 */
|
||||
public int fillSourceIdByFeeIds(@Param("feeIds") List<String> feeIds);
|
||||
|
||||
/**
|
||||
* 删除一票订单上来源为计算的费用。提单分摊和人工费用保留。
|
||||
* 逻辑删除一票订单上来源为计算的费用。提单分摊和人工费用保留。
|
||||
* 已进入应付账单的行不删。删除标记写成主键,避免重新生成时撞上唯一键。
|
||||
*
|
||||
* @param billId 计费订单ID
|
||||
* @param operator 操作人
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int deleteByBillId(String billId);
|
||||
public int markCalcDeleted(@Param("billId") Long billId, @Param("operator") String operator);
|
||||
|
||||
/**
|
||||
* 逻辑删除某一条提单费用分摊到订单上的明细。
|
||||
@@ -48,10 +86,13 @@ 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);
|
||||
|
||||
/** 这条提单费用已经分摊、且还没删除的订单费用。作废前取出,用来记日志。 */
|
||||
public List<PrcPayBillFee> selectAliveByLadingFee(@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,20 @@ 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);
|
||||
|
||||
/**
|
||||
* 写下这票应付的计费状态和失败原因。成功时原因传空。
|
||||
*
|
||||
* @param billId 计费订单 ID,对应 prc_pay_bill.bill_id
|
||||
* @param status 1计费成功,2计费失败
|
||||
* @param message 失败原因,最长 100 字;成功时为 null
|
||||
* @param operator 操作人账号
|
||||
* @return 影响行数
|
||||
*/
|
||||
int markCalcStatus(@Param("billId") Long billId, @Param("status") Integer status,
|
||||
@Param("message") String message, @Param("operator") String operator);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.bms.price.domain.vo.PrcProfitReportSummary;
|
||||
/** 毛利报表 mapper;金额事实取自 prc_income_bill。 */
|
||||
public interface PrcProfitReportMapper
|
||||
{
|
||||
List<Long> selectAreaCustomerIds(@Param("customerArea") String customerArea, @Param("limit") int limit);
|
||||
|
||||
List<PrcProfitReportOrderRow> selectOrderRows(PrcProfitReportQuery query);
|
||||
|
||||
List<PrcProfitReportProductRow> selectProductRows(PrcProfitReportQuery query);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,9 +49,11 @@ public class OracleOrderBillMapper
|
||||
String countryName = firstStr(row, "COUNTRY_NAME", "COUNTRY_EINGTH_NAME", "COUNTRY");
|
||||
req.setCountryName(countryName);
|
||||
req.setDestPostcode(StringUtils.normalizePostcode(firstStr(row, "CONSIGNEE_POSTCODE")));
|
||||
// 优先取 CONFIRM_WEIGHT(客户确认重量);回退取 DIMENSIONAL_WEIGHT_FACTOR(计费重量)。
|
||||
BigDecimal weight = firstPositiveDecimal(row, "CONFIRM_WEIGHT", "DIMENSIONAL_WEIGHT_FACTOR");
|
||||
// weight = 上游计费重 DIMENSIONAL_WEIGHT_FACTOR
|
||||
BigDecimal weight = firstPositiveDecimal(row, "DIMENSIONAL_WEIGHT_FACTOR");
|
||||
req.setWeight(weight);
|
||||
// charge_weight 仅在客户确认重 CONFIRM_WEIGHT 有值时落库
|
||||
req.setChargeWeight(firstPositiveDecimal(row, "CONFIRM_WEIGHT"));
|
||||
// TAB_ORDER.WEIGHT = 收货重
|
||||
req.setReceiveWeight(firstDecimal(row, "WEIGHT"));
|
||||
req.setActualWeight(firstPositiveDecimal(row, "ACTUAL_WEIGHT", "PUSH_WEIGHT", "WEIGHT"));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.bms.price.pay;
|
||||
|
||||
/**
|
||||
* 应付价卡的三种计费模式,对应字典 order_charge_type 的键值。
|
||||
*/
|
||||
public final class PayChargeMode
|
||||
{
|
||||
private PayChargeMode()
|
||||
{
|
||||
}
|
||||
|
||||
/** 单价乘以公斤重 */
|
||||
public static final String PER_KG = "PER_KG";
|
||||
|
||||
/** 重量段内按票收取固定金额 */
|
||||
public static final String FLAT = "FLAT";
|
||||
|
||||
/** 首重一口价,超出部分按每公斤续重 */
|
||||
public static final String EXTRA = "EXTRA";
|
||||
|
||||
/**
|
||||
* 把字典键、中文名和历史名称收成这三种键值。认不出时返回空字符串。
|
||||
*
|
||||
* @param raw 页面或库里的计费模式
|
||||
* @return PER_KG、FLAT、EXTRA 之一,空表示不是这三种
|
||||
*/
|
||||
public static String code(String raw)
|
||||
{
|
||||
if (raw == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String text = raw.trim();
|
||||
if (text.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (PER_KG.equalsIgnoreCase(text) || "常规计费".equals(text) || "常规计重价".equals(text))
|
||||
{
|
||||
return PER_KG;
|
||||
}
|
||||
if (FLAT.equalsIgnoreCase(text) || "一口价".equals(text) || "单票价".equals(text))
|
||||
{
|
||||
return FLAT;
|
||||
}
|
||||
if (EXTRA.equalsIgnoreCase(text) || "续重价".equals(text) || "续重计费".equals(text))
|
||||
{
|
||||
return EXTRA;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典上的显示名。
|
||||
*
|
||||
* @param raw 计费模式键值或历史名称
|
||||
* @return 常规计费、一口价、续重价;认不出时退回原文
|
||||
*/
|
||||
public static String label(String raw)
|
||||
{
|
||||
String mode = code(raw);
|
||||
if (PER_KG.equals(mode))
|
||||
{
|
||||
return "常规计费";
|
||||
}
|
||||
if (FLAT.equals(mode))
|
||||
{
|
||||
return "一口价";
|
||||
}
|
||||
if (EXTRA.equals(mode))
|
||||
{
|
||||
return "续重价";
|
||||
}
|
||||
return raw == null ? "" : raw.trim();
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,17 @@ public final class PayCostCalculator
|
||||
public static PayOrderCostResult calculate(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, List<PayRemoteBook.Hit> remoteHits,
|
||||
boolean postcodeOn, boolean zoneOn)
|
||||
{
|
||||
return calculate(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, remoteHits,
|
||||
postcodeOn, zoneOn, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算一票尾程应付。countryCode、countryName 用来核对配置页上写了国家的命中邮编和命中分区。
|
||||
*/
|
||||
public static PayOrderCostResult calculate(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, List<PayRemoteBook.Hit> remoteHits,
|
||||
boolean postcodeOn, boolean zoneOn, String countryCode, String countryName)
|
||||
{
|
||||
PayOrderCostResult result = new PayOrderCostResult();
|
||||
result.setFees(new ArrayList<>());
|
||||
@@ -158,7 +169,7 @@ public final class PayCostCalculator
|
||||
result.getFees().add(freightLine);
|
||||
result.setCurrency(currency);
|
||||
addSurcharges(product, weight, length, width, height, postcode, zoneName, bizDate, orderStatus, freight, currency,
|
||||
band.getSectionName(), remoteHits, postcodeOn, zoneOn, result);
|
||||
band.getSectionName(), remoteHits, postcodeOn, zoneOn, countryCode, countryName, result);
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
@@ -278,13 +289,15 @@ public final class PayCostCalculator
|
||||
*/
|
||||
private static void addSurcharges(PayProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus, BigDecimal freight, String currency,
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, boolean postcodeOn, boolean zoneOn, PayOrderCostResult result)
|
||||
String freightSection, List<PayRemoteBook.Hit> remoteHits, boolean postcodeOn, boolean zoneOn,
|
||||
String countryCode, String countryName, PayOrderCostResult result)
|
||||
{
|
||||
if (product.getSurcharges() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<PayCostLine> sized = new ArrayList<>();
|
||||
List<PayCostLine> stepped = new ArrayList<>();
|
||||
for (PaySurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee == null || !inForce(fee, bizDate))
|
||||
@@ -292,7 +305,9 @@ public final class PayCostCalculator
|
||||
continue;
|
||||
}
|
||||
String rule = fee.getCalcRule() == null || fee.getCalcRule().isBlank() ? PaySurchargeRules.MANUAL : fee.getCalcRule();
|
||||
if (remoteHits != null && remoteFee(fee))
|
||||
List<Map<String, Object>> postcodeRules = prefixRules(product, PaySurchargeRules.POSTCODE);
|
||||
List<Map<String, Object>> zoneRules = prefixRules(product, PaySurchargeRules.ZONE);
|
||||
if (remoteHits != null && remoteFee(fee) && postcodeRules.isEmpty())
|
||||
{
|
||||
String name = blank(fee.getFeeName());
|
||||
boolean added = false;
|
||||
@@ -300,7 +315,7 @@ public final class PayCostCalculator
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (bookApplies(remoteHits, fee, rule))
|
||||
else if (bookApplies(remoteHits, fee, rule, postcode))
|
||||
{
|
||||
String remark = "邮编 " + postcode.trim();
|
||||
if (PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
@@ -332,14 +347,21 @@ public final class PayCostCalculator
|
||||
result.getSkipped().add(blank(fee.getFeeName()) + ":未打开命中分区");
|
||||
continue;
|
||||
}
|
||||
boolean configuredZone = PaySurchargeRules.ZONE.equals(rule) && !zoneRules.isEmpty();
|
||||
boolean postcodeDriven = PaySurchargeRules.POSTCODE.equals(rule) || !blank(fee.getPostcodeParam()).isEmpty();
|
||||
if (!postcodeDriven && zoneName != null && !zoneName.isBlank() && fee.getZoneName() != null && !fee.getZoneName().isBlank()
|
||||
if (!configuredZone && !postcodeDriven && zoneName != null && !zoneName.isBlank() && fee.getZoneName() != null && !fee.getZoneName().isBlank()
|
||||
&& !PayZoneMatcher.sameZone(fee.getZoneName(), zoneName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = blank(fee.getFeeName());
|
||||
if (PaySurchargeRules.POSTCODE.equals(rule))
|
||||
{
|
||||
if (!postcodeRules.isEmpty())
|
||||
{
|
||||
addConfiguredZoneFee(result, fee, weight, currency, postcode, countryCode, countryName, postcodeRules, "邮编 ");
|
||||
}
|
||||
else
|
||||
{
|
||||
String param = blank(fee.getPostcodeParam()).isEmpty() ? fee.getCalcParam() : fee.getPostcodeParam();
|
||||
if (postcode == null || postcode.isBlank())
|
||||
@@ -351,7 +373,23 @@ public final class PayCostCalculator
|
||||
addFlat(result.getFees(), fee, currency, "邮编 " + postcode.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PaySurchargeRules.ZONE.equals(rule))
|
||||
{
|
||||
if (!zoneRules.isEmpty())
|
||||
{
|
||||
String hit = PaySurchargeRules.matchedZone(zoneRules, postcode, countryCode, countryName);
|
||||
boolean already = result.getFees().stream().anyMatch(line -> name.equals(line.getFeeName()));
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
}
|
||||
else if (!already && hit != null && PayZoneMatcher.sameZone(fee.getZoneName(), hit) && weightIn(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, "地区 " + hit.replace('\n', ' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean already = result.getFees().stream().anyMatch(line -> name.equals(line.getFeeName()));
|
||||
if (!already && zoneName != null && !zoneName.isBlank() && PayZoneMatcher.sameZone(fee.getZoneName(), zoneName) && weightIn(fee, weight))
|
||||
@@ -359,6 +397,7 @@ public final class PayCostCalculator
|
||||
addFlat(result.getFees(), fee, currency, "地区 " + zoneName.replace('\n', ' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PaySurchargeRules.WEIGHT.equals(rule))
|
||||
{
|
||||
if (PaySurchargeRules.matchesWeight(fee.getCalcParam(), weight))
|
||||
@@ -375,13 +414,20 @@ 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)
|
||||
{
|
||||
if (stepPriced(fee))
|
||||
{
|
||||
stepped.add(matched);
|
||||
}
|
||||
else
|
||||
{
|
||||
sized.add(matched);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 退件费用
|
||||
else if (PaySurchargeRules.RETURN.equals(rule))
|
||||
{
|
||||
@@ -427,9 +473,10 @@ public final class PayCostCalculator
|
||||
}
|
||||
}
|
||||
result.getFees().addAll(keepHighestByName(sized));
|
||||
result.getFees().addAll(stepped);
|
||||
}
|
||||
|
||||
/** 同一费用名的尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。 */
|
||||
/** 同一费用名的按票尺寸档同时命中时,只收较高的一档,例如 70% 覆盖 35%。按超出单位计的不并进这一档。 */
|
||||
private static List<PayCostLine> keepHighestByName(List<PayCostLine> lines)
|
||||
{
|
||||
List<PayCostLine> kept = new ArrayList<>();
|
||||
@@ -566,6 +613,38 @@ public final class PayCostCalculator
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 配置页写了邮编前缀的命中邮编或命中分区。命中后只收同一分区的那一档附加费。 */
|
||||
private static void addConfiguredZoneFee(PayOrderCostResult result, PaySurcharge fee, BigDecimal weight, String currency, String postcode,
|
||||
String countryCode, String countryName, List<Map<String, Object>> rules, String remark)
|
||||
{
|
||||
String name = blank(fee.getFeeName());
|
||||
if (postcode == null || postcode.isBlank())
|
||||
{
|
||||
result.getSkipped().add(name + ":订单没有邮编");
|
||||
return;
|
||||
}
|
||||
String hit = PaySurchargeRules.matchedZone(rules, postcode, countryCode, countryName);
|
||||
if (hit != null && PayZoneMatcher.sameZone(fee.getZoneName(), hit) && weightAtLeast(fee, weight))
|
||||
{
|
||||
addFlat(result.getFees(), fee, currency, remark + postcode.trim());
|
||||
}
|
||||
}
|
||||
|
||||
/** 只留下写了邮编前缀的配置。没写前缀的旧开关仍走原来的邮编配置。 */
|
||||
private static List<Map<String, Object>> prefixRules(PayProduct product, String calcRule)
|
||||
{
|
||||
List<Map<String, Object>> rules = new ArrayList<>();
|
||||
for (Map<String, Object> detail : ruleDetails(product, calcRule))
|
||||
{
|
||||
Object postcodes = detail.get("postcodes");
|
||||
if (postcodes != null && !String.valueOf(postcodes).isBlank())
|
||||
{
|
||||
rules.add(detail);
|
||||
}
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
private static List<Map<String, Object>> ruleDetails(PayProduct product, String calcRule)
|
||||
{
|
||||
List<Map<String, Object>> details = new ArrayList<>();
|
||||
@@ -590,10 +669,11 @@ public final class PayCostCalculator
|
||||
return name.contains("偏远") || name.contains("岛屿") || name.contains("remote") || name.contains("island");
|
||||
}
|
||||
|
||||
/** 邮编配置命中后,金额相同的那一档才收;分区写明时还要对上地区。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule)
|
||||
/** 邮编配置命中后,金额相同的那一档才收。命中写了地区时要对上分区;没写地区时用价卡上的邮编前缀选档。 */
|
||||
private static boolean bookApplies(List<PayRemoteBook.Hit> hits, PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
boolean extra = PaySurchargeRules.EXTRA_KG.equals(rule);
|
||||
boolean tier = extra || PaySurchargeRules.POSTCODE.equals(rule);
|
||||
boolean zoned = !blank(fee.getZoneName()).isEmpty();
|
||||
for (PayRemoteBook.Hit hit : hits)
|
||||
{
|
||||
@@ -607,15 +687,19 @@ public final class PayCostCalculator
|
||||
continue;
|
||||
}
|
||||
boolean areaKnown = !blank(hit.getZoneName()).isEmpty() || !blank(hit.getRegionName()).isEmpty();
|
||||
if (zoned && (!areaKnown || !sameArea(hit, fee)))
|
||||
if (zoned && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && zoned && !sameArea(hit, fee))
|
||||
if ((zoned && !areaKnown || !zoned && tier) && !feePostcodeMatches(fee, rule, postcode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && !sameArea(hit, fee))
|
||||
if (extra && zoned && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (extra && amountKnown && hit.getAmount().compareTo(fee.getAmount()) != 0 && areaKnown && !sameArea(hit, fee))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -624,6 +708,21 @@ public final class PayCostCalculator
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 价卡这一档写了邮编时,订单邮编必须落在里面。续重的重量门槛不算邮编。 */
|
||||
private static boolean feePostcodeMatches(PaySurcharge fee, String rule, String postcode)
|
||||
{
|
||||
String param = blank(fee.getPostcodeParam());
|
||||
if (param.isEmpty() && !PaySurchargeRules.EXTRA_KG.equals(rule))
|
||||
{
|
||||
param = blank(fee.getCalcParam());
|
||||
}
|
||||
if (param.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return PaySurchargeRules.matchesPostcode(param, postcode);
|
||||
}
|
||||
|
||||
private static boolean sameFeeName(String bookName, String feeName)
|
||||
{
|
||||
String book = feeKey(bookName);
|
||||
@@ -642,8 +741,11 @@ public final class PayCostCalculator
|
||||
|
||||
private static boolean sameArea(PayRemoteBook.Hit hit, PaySurcharge fee)
|
||||
{
|
||||
return PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName())
|
||||
|| PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
if (!blank(hit.getZoneName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getZoneName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !blank(hit.getRegionName()).isEmpty() && PayZoneMatcher.sameZone(fee.getZoneName(), hit.getRegionName());
|
||||
}
|
||||
|
||||
private static boolean perKg(PaySurcharge fee)
|
||||
@@ -677,6 +779,107 @@ public final class PayCostCalculator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 收费标准写了每增加若干厘米时,按三边之和超出下限的档数乘单价。
|
||||
* 没有步长配置的尺寸费仍按价卡金额收一次。
|
||||
*/
|
||||
private static PayCostLine sizedFee(PayProduct product, PaySurcharge fee, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, BigDecimal freight, String currency)
|
||||
{
|
||||
if (stepPriced(fee))
|
||||
{
|
||||
PayCostLine stepped = stepBySum(product, fee, length, width, height, currency);
|
||||
if (stepped != null || hasSumStep(product))
|
||||
{
|
||||
return stepped;
|
||||
}
|
||||
}
|
||||
return matchedFee(fee, freight, currency, "尺寸命中");
|
||||
}
|
||||
|
||||
/** 价卡写成每增加、每超出时,金额是一个步长的单价。 */
|
||||
private static boolean stepPriced(PaySurcharge fee)
|
||||
{
|
||||
String charge = fee.getChargeText() == null ? "" : fee.getChargeText();
|
||||
return charge.contains("增加") || charge.contains("每超出");
|
||||
}
|
||||
|
||||
private static boolean hasSumStep(PayProduct product)
|
||||
{
|
||||
for (Map<String, Object> detail : ruleDetails(product, PaySurchargeRules.SIZE))
|
||||
{
|
||||
BigDecimal step = decimal(detail.get("exceedStepCm"));
|
||||
BigDecimal threshold = decimal(detail.get("sumMin"));
|
||||
if (step != null && step.compareTo(BigDecimal.ZERO) > 0 && threshold != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 超出厘米数按步长向上取整。刚超过不足一个步长也收一档。 */
|
||||
private static PayCostLine stepBySum(PayProduct product, PaySurcharge fee, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String currency)
|
||||
{
|
||||
if (fee.getAmount() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal sum = length.add(width).add(height);
|
||||
for (Map<String, Object> detail : ruleDetails(product, PaySurchargeRules.SIZE))
|
||||
{
|
||||
BigDecimal step = decimal(detail.get("exceedStepCm"));
|
||||
BigDecimal threshold = decimal(detail.get("sumMin"));
|
||||
if (step == null || step.compareTo(BigDecimal.ZERO) <= 0 || threshold == null || sum.compareTo(threshold) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String feeCurrency = normalize(fee.getCurrency());
|
||||
if (!feeCurrency.isEmpty() && !feeCurrency.equals(currency))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal excess = sum.subtract(threshold);
|
||||
BigDecimal steps = excess.divide(step, 0, RoundingMode.CEILING);
|
||||
if (steps.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal amount = fee.getAmount().multiply(steps);
|
||||
String remark = "三边之和 " + plain(sum) + "cm,超出 " + plain(excess) + "cm,每 " + plain(step) + "cm "
|
||||
+ plain(fee.getAmount()) + "," + plain(steps) + " 档";
|
||||
long scId = fee.getSurchargeId() == null ? 0L : fee.getSurchargeId();
|
||||
return line("SURCHARGE", blank(fee.getFeeName()), scId, amount, currency, remark);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BigDecimal decimal(Object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (value instanceof BigDecimal decimal)
|
||||
{
|
||||
return decimal;
|
||||
}
|
||||
String text = String.valueOf(value).trim();
|
||||
if (text.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigDecimal(text);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static PayCostLine matchedFee(PaySurcharge fee, BigDecimal freight, String currency, String remark)
|
||||
{
|
||||
if (fee.getAmount() == null)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user