Compare commits
76 Commits
f03aa7be6c
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ec7f97f831 | |||
| 8d45439931 | |||
| e2deccc65a | |||
| 32cea1c348 | |||
| 2aec7fdd5c | |||
| 5c8e905a37 | |||
| ad2d8c8b50 | |||
| 8fb042f171 | |||
| 4ad799719a | |||
| d8f6ceda59 | |||
| e104c5a3e9 | |||
| fcaf0dc9be | |||
| c86cad30ec | |||
| 33e8a5890a | |||
| 8ede0bb5ec | |||
| 366ddff0b3 | |||
| e2d123de85 | |||
| e22f4bc9d7 | |||
| 7500728c1d | |||
| 9483bb4899 | |||
| 69d9971a79 | |||
| f6012f96e3 | |||
| 111176e767 | |||
| cce123890e | |||
| b76b26b2b1 | |||
| 6e01167f41 | |||
| e0b8eec98d | |||
| 54ac6428e7 | |||
| ee5c79ba29 | |||
| ea62697b98 | |||
| f00f8c619a | |||
| f9038c62ac | |||
| 49f24a6b1b | |||
| 9273fcec56 | |||
| 5b8d4de262 | |||
| 215effe036 | |||
| 4503424cf0 | |||
| 3cf7fa30bd | |||
| e34e4f117c | |||
| 03043104bc | |||
| a5cd752005 | |||
| 5d44cc4edf | |||
| 0400f55838 | |||
| 1b43bcca4c | |||
| a38e2c7f57 | |||
| 63ded27fd5 | |||
| 2f25a99396 | |||
| 206e4e786b | |||
| 48b7fbc7cf | |||
| 15a72e3503 | |||
| 0179a35942 | |||
| 99651b6758 | |||
| 2342d34194 | |||
| 4de755ca60 | |||
| bcd9c789cb | |||
| bf7b46a231 | |||
| 358e5a46b9 | |||
| 6f78b813f3 | |||
| a71f0a164f | |||
| ee36c8c902 | |||
| f7c7d9fe8b | |||
| 7e699fb80e | |||
| 80d639d887 | |||
| 87ae3e6674 | |||
| 359c3c18e4 | |||
| 4f2f2db20f | |||
| 0094e4aaff | |||
| 8b7c346ec4 | |||
| bde1d7d86e | |||
| 87eab12d51 | |||
| 880b4751c5 | |||
| 3a104d2d8c | |||
| a024b45940 | |||
| 6675808dfc | |||
| 2d5ffc4e06 | |||
| 1ba431540d |
+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));
|
||||
}
|
||||
|
||||
+59
-27
@@ -8,6 +8,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -24,16 +25,19 @@ import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PaySaveCommand;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblSurcharge;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
import com.bms.price.domain.LblSaveCommand;
|
||||
|
||||
import com.bms.price.domain.PrcCustomerPriceSet;
|
||||
import com.bms.price.domain.PrcCustomerPriceSetBatch;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
import com.bms.price.service.ILblProductService;
|
||||
import com.bms.price.service.IPrcPriceSetService;
|
||||
|
||||
/**
|
||||
* 打单套餐:套餐壳 + 应收价卡(pay_*)。
|
||||
* 打单套餐:套餐壳 + 独立打单价卡(prc_label_*)。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/label")
|
||||
@@ -43,7 +47,7 @@ public class LabelPackageController extends BaseController
|
||||
private IPrcPriceSetService priceSetService;
|
||||
|
||||
@Autowired
|
||||
private IPayProductService payProductService;
|
||||
private ILblProductService lblProductService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:list')")
|
||||
@GetMapping("/list")
|
||||
@@ -127,30 +131,37 @@ public class LabelPackageController extends BaseController
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
}
|
||||
// 打单独立预览:已存在按本套餐判断,不与应付公共模板互挡
|
||||
return success(payProductService.previewLabel(file.getBytes(), name, dictValue, progressId, priceSetId));
|
||||
return success(lblProductService.preview(file.getBytes(), name, dictValue, progressId, priceSetId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:import')")
|
||||
@GetMapping("/preview/progress")
|
||||
public AjaxResult parseProgress(@RequestParam("progressId") String progressId)
|
||||
{
|
||||
return success(payProductService.parseProgress(progressId));
|
||||
return success(lblProductService.parseProgress(progressId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:import')")
|
||||
@Log(title = "打单套餐导入", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importSave")
|
||||
public AjaxResult importSave(@RequestBody PaySaveCommand command)
|
||||
public AjaxResult importSave(@RequestBody LblSaveCommand command)
|
||||
{
|
||||
if (command == null)
|
||||
{
|
||||
throw new ServiceException("保存参数不能为空");
|
||||
}
|
||||
String message = payProductService.saveLabel(command);
|
||||
String taskId = lblProductService.submitSave(command);
|
||||
Map<String, Object> payload = new HashMap<String, Object>();
|
||||
payload.put("message", message);
|
||||
payload.put("priceSetId", command.getPriceSetId());
|
||||
return success(payload);
|
||||
payload.put("taskId", taskId);
|
||||
// data.taskId + 顶层 taskId,兼容前端不同取值方式
|
||||
return success(payload).put("taskId", taskId);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:import')")
|
||||
@GetMapping("/importSave/task/{taskId}")
|
||||
public AjaxResult importSaveTask(@PathVariable String taskId)
|
||||
{
|
||||
return success(lblProductService.getSaveTask(taskId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:list')")
|
||||
@@ -158,7 +169,7 @@ public class LabelPackageController extends BaseController
|
||||
public AjaxResult versions(@PathVariable Long priceSetId)
|
||||
{
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
return success(payProductService.selectLabelVersions(priceSetId));
|
||||
return success(lblProductService.selectVersions(priceSetId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
||||
@@ -169,7 +180,7 @@ public class LabelPackageController extends BaseController
|
||||
{
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
Date effectiveTime = parseEffectiveTime(body == null ? null : body.get("effectiveTime"));
|
||||
String message = payProductService.activateLabelVersion(priceSetId, versionNo, effectiveTime);
|
||||
String message = lblProductService.activateVersion(priceSetId, versionNo, effectiveTime);
|
||||
Map<String, Object> payload = new HashMap<String, Object>();
|
||||
payload.put("message", message);
|
||||
return success(payload);
|
||||
@@ -181,7 +192,7 @@ public class LabelPackageController extends BaseController
|
||||
public AjaxResult deleteVersion(@PathVariable Long priceSetId, @PathVariable Integer versionNo)
|
||||
{
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
return toAjax(payProductService.deleteLabelVersion(priceSetId, versionNo));
|
||||
return toAjax(lblProductService.deleteVersion(priceSetId, versionNo));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:list')")
|
||||
@@ -192,32 +203,53 @@ public class LabelPackageController extends BaseController
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
if (versionNo != null)
|
||||
{
|
||||
return success(payProductService.selectLabelProductsByVersion(priceSetId, versionNo));
|
||||
return success(lblProductService.selectProductsByVersion(priceSetId, versionNo));
|
||||
}
|
||||
return success(payProductService.selectLabelProducts(priceSetId));
|
||||
return success(lblProductService.selectProducts(priceSetId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:label:query')")
|
||||
@GetMapping("/product/{productId}")
|
||||
public AjaxResult productDetail(@PathVariable Long productId,
|
||||
@RequestParam(value = "termId", required = false) Long termId)
|
||||
@RequestParam(value = "termId", required = false) Long termId,
|
||||
@RequestParam(value = "versionId", required = false) Long versionId)
|
||||
{
|
||||
if (termId != null)
|
||||
Long vid = versionId != null ? versionId : termId;
|
||||
if (vid != null)
|
||||
{
|
||||
return success(payProductService.selectPayProductDetailByTerm(termId));
|
||||
return success(lblProductService.selectDetailByVersionId(vid));
|
||||
}
|
||||
return success(payProductService.selectPayProductDetail(productId));
|
||||
throw new ServiceException("请传入 versionId");
|
||||
}
|
||||
|
||||
/** 保存打单产品明细(重量段/附加费等),按当前 term 覆盖子表 */
|
||||
/** 保存打单产品明细(重量段/附加费等),按当前 version 覆盖子表 */
|
||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
||||
@Log(title = "打单产品明细", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/product")
|
||||
public AjaxResult updateProduct(@RequestBody PayProduct product)
|
||||
public AjaxResult updateProduct(@RequestBody LblProduct product)
|
||||
{
|
||||
return toAjax(payProductService.updateDetail(product));
|
||||
return toAjax(lblProductService.updateDetail(product));
|
||||
}
|
||||
|
||||
/** 仅保存当前重量段行 */
|
||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
||||
@Log(title = "打单重量段", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/product/band")
|
||||
public AjaxResult updateWeightBand(@RequestBody LblWeightBand band)
|
||||
{
|
||||
return toAjax(lblProductService.updateWeightBand(band));
|
||||
}
|
||||
|
||||
/** 仅保存当前附加费行 */
|
||||
@PreAuthorize("@ss.hasPermi('price:label:edit')")
|
||||
@Log(title = "打单附加费", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/product/surcharge")
|
||||
public AjaxResult updateSurcharge(@RequestBody LblSurcharge surcharge)
|
||||
{
|
||||
return toAjax(lblProductService.updateSurcharge(surcharge));
|
||||
}
|
||||
|
||||
|
||||
/** 查询打单产品已绑定渠道(默认应收 AR) */
|
||||
@PreAuthorize("@ss.hasPermi('price:label:query')")
|
||||
@GetMapping("/product/{productId}/channels")
|
||||
@@ -225,7 +257,7 @@ public class LabelPackageController extends BaseController
|
||||
@RequestParam(value = "payType", required = false) String payType)
|
||||
{
|
||||
String type = (payType == null || payType.trim().isEmpty()) ? "AR" : payType.trim();
|
||||
return success(payProductService.listProductChannelBinds(productId, type));
|
||||
return success(lblProductService.listProductChannelBinds(productId, type));
|
||||
}
|
||||
|
||||
/** 覆盖保存打单产品渠道绑定,写入 srv_channel_product_map */
|
||||
@@ -247,7 +279,7 @@ public class LabelPackageController extends BaseController
|
||||
}
|
||||
}
|
||||
}
|
||||
String msg = payProductService.replaceProductChannelBinds(productId, payType, channelIds);
|
||||
String msg = lblProductService.replaceProductChannelBinds(productId, payType, channelIds);
|
||||
return AjaxResult.success(msg);
|
||||
}
|
||||
|
||||
@@ -257,7 +289,7 @@ public class LabelPackageController extends BaseController
|
||||
public AjaxResult removeProducts(@PathVariable Long priceSetId, @PathVariable Long[] productIds)
|
||||
{
|
||||
priceSetService.assertSetCategory(priceSetId, PrcPriceSet.CATEGORY_LABEL);
|
||||
return toAjax(payProductService.removeLabelProducts(priceSetId, productIds));
|
||||
return toAjax(lblProductService.removeProducts(priceSetId, productIds));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.bms.web.controller.price;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
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;
|
||||
@@ -15,6 +21,7 @@ import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.price.domain.PayBill;
|
||||
import com.bms.price.domain.PayBillCommand;
|
||||
import com.bms.price.domain.PayBillFile;
|
||||
import com.bms.price.service.IPayBillService;
|
||||
|
||||
/**
|
||||
@@ -119,4 +126,176 @@ public class PayBillController extends BaseController
|
||||
payBillService.voidBill(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿提交审核。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:submit,price:payBill:confirm')")
|
||||
@PutMapping("/submit/{billId}")
|
||||
public AjaxResult submit(@PathVariable Long billId)
|
||||
{
|
||||
payBillService.submit(billId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核通过。蓝字账单需要先有凭证。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:approve,price:payBill:confirm')")
|
||||
@PutMapping("/approve/{billId}")
|
||||
public AjaxResult approve(@PathVariable Long billId)
|
||||
{
|
||||
payBillService.approve(billId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核驳回。
|
||||
*
|
||||
* @param command 账单ID和驳回意见
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:approve,price:payBill:confirm')")
|
||||
@PutMapping("/reject")
|
||||
public AjaxResult reject(@RequestBody PayBillCommand command)
|
||||
{
|
||||
payBillService.reject(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿登记对方金额。
|
||||
*
|
||||
* @param command 账单和费用行
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:add,price:payBill:submit')")
|
||||
@PutMapping("/diff")
|
||||
public AjaxResult diff(@RequestBody PayBillCommand command)
|
||||
{
|
||||
payBillService.saveSupplierAmounts(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 接受我方或接受对方金额。
|
||||
*
|
||||
* @param command 费用行和处理方式
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:add,price:payBill:submit')")
|
||||
@PutMapping("/diff/accept")
|
||||
public AjaxResult accept(@RequestBody PayBillCommand command)
|
||||
{
|
||||
payBillService.acceptDiff(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从草稿剔除一条费用。
|
||||
*
|
||||
* @param command 账单ID和行ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:add,price:payBill:submit')")
|
||||
@PutMapping("/line/remove")
|
||||
public AjaxResult removeLine(@RequestBody PayBillCommand command)
|
||||
{
|
||||
payBillService.removeLine(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传应付凭证。
|
||||
*
|
||||
* @param file 凭证
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payVoucher:add,price:payBill:add')")
|
||||
@PostMapping("/file")
|
||||
public AjaxResult saveFile(@RequestBody PayBillFile file)
|
||||
{
|
||||
payBillService.saveFile(file);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除应付凭证。
|
||||
*
|
||||
* @param fileId 凭证ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payVoucher:remove,price:payBill:void')")
|
||||
@DeleteMapping("/file/{fileId}")
|
||||
public AjaxResult deleteFile(@PathVariable Long fileId)
|
||||
{
|
||||
payBillService.deleteFile(fileId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询应付凭证。
|
||||
*
|
||||
* @param query 账单号、供应商、发票号、类型
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payVoucher:list,price:payBill:query')")
|
||||
@GetMapping("/file/list")
|
||||
public TableDataInfo fileList(PayBillFile query)
|
||||
{
|
||||
startPage();
|
||||
return getDataTable(payBillService.listFiles(query));
|
||||
}
|
||||
|
||||
/**
|
||||
* 对未付款的已确认账单开红字。
|
||||
*
|
||||
* @param command 原账单和原因
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:approve,price:payBill:confirm')")
|
||||
@PostMapping("/red")
|
||||
public AjaxResult red(@RequestBody PayBillCommand command)
|
||||
{
|
||||
return success(payBillService.redBill(command));
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿保存税率和汇率。
|
||||
*
|
||||
* @param command 账单、税率、汇率和汇率日期
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:add,price:payBill:submit')")
|
||||
@PutMapping("/finance")
|
||||
public AjaxResult finance(@RequestBody PayBillCommand command)
|
||||
{
|
||||
payBillService.saveFinance(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出对账单。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
* @param response 文件流
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payBill:query')")
|
||||
@GetMapping("/statement/{billId}")
|
||||
public void statement(@PathVariable Long billId, HttpServletResponse response) throws Exception
|
||||
{
|
||||
String name = URLEncoder.encode("应付对账单.xlsx", StandardCharsets.UTF_8).replace("+", "%20");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + name);
|
||||
payBillService.exportStatement(billId, response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入对方金额。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
* @param file 导出的对账单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:payBill:add,price:payBill:submit')")
|
||||
@PostMapping("/diff/import")
|
||||
public AjaxResult importDiff(@RequestParam Long billId, @RequestParam("file") MultipartFile file)
|
||||
{
|
||||
payBillService.importSupplierAmounts(billId, file);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
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;
|
||||
|
||||
/** 提单管理下的应付列表。 */
|
||||
@RestController
|
||||
@RequestMapping("/price/payOrder")
|
||||
public class PayOrderController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPayOrderListService payOrderListService;
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看一票订单的应付费用,按 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));
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
package com.bms.web.controller.price;
|
||||
|
||||
import java.util.List;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
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.PayPayment;
|
||||
import com.bms.price.domain.PayPaymentAlloc;
|
||||
import com.bms.price.service.IPayPaymentService;
|
||||
|
||||
/**
|
||||
* 账单管理下的应付付款。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/payPayment")
|
||||
public class PayPaymentController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IPayPaymentService payPaymentService;
|
||||
|
||||
/**
|
||||
* 分页查询应付付款。
|
||||
*
|
||||
* @param query 付款单号、供应商、状态、币种
|
||||
* @return 付款单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PayPayment query)
|
||||
{
|
||||
startPage();
|
||||
List<PayPayment> list = payPaymentService.selectPayPaymentList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 付款单详情,含核销明细。
|
||||
*
|
||||
* @param paymentId 付款单ID
|
||||
* @return 付款单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:query')")
|
||||
@GetMapping("/{paymentId}")
|
||||
public AjaxResult detail(@PathVariable Long paymentId)
|
||||
{
|
||||
return success(payPaymentService.selectPayPaymentDetail(paymentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询这个供应商、这个币种下还能核销的账单。
|
||||
*
|
||||
* @param supplierId 供应商ID
|
||||
* @param currency 币种
|
||||
* @return 未付账单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:query')")
|
||||
@GetMapping("/open")
|
||||
public AjaxResult open(Long supplierId, String currency)
|
||||
{
|
||||
List<PayPaymentAlloc> list = payPaymentService.selectOpenBills(supplierId, currency);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登记草稿付款。确认后才核销账单。
|
||||
*
|
||||
* @param payment 付款单和核销明细
|
||||
* @return 付款单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:add')")
|
||||
@PostMapping
|
||||
public AjaxResult create(@RequestBody PayPayment payment)
|
||||
{
|
||||
return success(payPaymentService.create(payment));
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认付款并核销。
|
||||
*
|
||||
* @param paymentId 付款单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:confirm')")
|
||||
@PutMapping("/confirm/{paymentId}")
|
||||
public AjaxResult confirm(@PathVariable Long paymentId)
|
||||
{
|
||||
payPaymentService.confirm(paymentId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废草稿付款。已确认的付款不在这里作废。
|
||||
*
|
||||
* @param paymentId 付款单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:void')")
|
||||
@PutMapping("/void/{paymentId}")
|
||||
public AjaxResult voidPayment(@PathVariable Long paymentId)
|
||||
{
|
||||
payPaymentService.voidPayment(paymentId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 反核销。账单未付金额恢复。
|
||||
*
|
||||
* @param paymentId 付款单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:confirm')")
|
||||
@PutMapping("/reverse/{paymentId}")
|
||||
public AjaxResult reverse(@PathVariable Long paymentId)
|
||||
{
|
||||
payPaymentService.reverse(paymentId);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款。冲回核销,付款单改为已退款。
|
||||
*
|
||||
* @param paymentId 付款单ID
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payPayment:confirm')")
|
||||
@PutMapping("/refund/{paymentId}")
|
||||
public AjaxResult refund(@PathVariable Long paymentId)
|
||||
{
|
||||
payPaymentService.refund(paymentId);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
+33
-3
@@ -30,12 +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.service.IPayOrderCostService;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
import com.bms.price.service.IPaySurchargeRuleService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 价格基础下的应付配置。导入先预览,确认后才入库。
|
||||
* 应付管理下的应付配置。导入先预览,确认后才入库。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/pay")
|
||||
@@ -47,6 +49,9 @@ 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)
|
||||
@@ -84,7 +89,7 @@ public class PayProductController extends BaseController
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:billing:bill,price:pay:edit')")
|
||||
@Log(title = "应付账单", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/order/{billId}")
|
||||
public AjaxResult generateOrderCost(@PathVariable String billId)
|
||||
public AjaxResult generateOrderCost(@PathVariable Long billId)
|
||||
{
|
||||
payOrderCostService.generate(billId);
|
||||
return success("操作成功");
|
||||
@@ -102,6 +107,31 @@ 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(required = false) Long termId)
|
||||
{
|
||||
return success(paySurchargeRuleService.list(productId, termId));
|
||||
}
|
||||
|
||||
/** 这个产品上的附加费配置操作记录。 */
|
||||
@PreAuthorize("@ss.hasAnyPermi('price:pay:query,price:pay:edit')")
|
||||
@GetMapping("/surchargeRule/log")
|
||||
public AjaxResult surchargeRuleLog(@RequestParam Long productId, @RequestParam(required = false) Long termId)
|
||||
{
|
||||
return success(paySurchargeRuleService.logs(productId, termId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:edit')")
|
||||
@Log(title = "应付附加费计费条件", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/surchargeRule")
|
||||
public AjaxResult saveSurchargeRule(@RequestBody PaySurchargeRuleSave command)
|
||||
{
|
||||
paySurchargeRuleService.save(command);
|
||||
return success();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:pay:query')")
|
||||
@GetMapping("/{productId}")
|
||||
public AjaxResult getInfo(@PathVariable Long productId)
|
||||
@@ -143,7 +173,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)
|
||||
|
||||
+14
-3
@@ -34,7 +34,9 @@ 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;
|
||||
import com.bms.receivable.task.ArBillGeneratePreviewExportRunner;
|
||||
import com.bms.common.annotation.Log;
|
||||
@@ -61,6 +63,9 @@ public class ArBillController extends BaseController {
|
||||
@Autowired
|
||||
private IArBillService billService;
|
||||
|
||||
@Autowired
|
||||
private ArBillVoidTaskService voidTaskService;
|
||||
|
||||
@Autowired
|
||||
private ArBillScopeResolver billScope;
|
||||
|
||||
@@ -171,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;
|
||||
}
|
||||
@@ -215,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;
|
||||
@@ -297,7 +302,13 @@ public class ArBillController extends BaseController {
|
||||
public AjaxResult voidBill(@PathVariable Long arBillId, @RequestBody ArBillActionRequest request,
|
||||
@RequestHeader(value = "X-Request-Id", required = false) String headerRequestId) {
|
||||
String requestId = requestId(request == null ? null : request.getRequestId(), headerRequestId);
|
||||
return success(billService.voidBill(arBillId, request, getUsername(), requestId)).put("request_id", requestId);
|
||||
return success(voidTaskService.submit(arBillId, request == null ? null : request.getRemark(), getUsername(), requestId)).put("request_id", requestId);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('ar:bill:list')")
|
||||
@GetMapping("/void/task/{taskId}")
|
||||
public AjaxResult voidTask(@PathVariable Long taskId) {
|
||||
return success(voidTaskService.get(taskId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+25
-12
@@ -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());
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
failExport(export, e);
|
||||
throw e;
|
||||
}
|
||||
return success(Map.of("taskId", exportRunner.submit(query, getUserId())));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('report:profit:export')")
|
||||
@GetMapping("/orders/export/task/{taskId}")
|
||||
public AjaxResult orderExportTask(@PathVariable String taskId)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.bms.price.pay;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PaySurcharge;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
import com.bms.price.domain.PayWeightBand;
|
||||
|
||||
/** 用 DE-iMile 价卡和附加费配置,按测试订单的重量、尺寸、日期测算。 */
|
||||
class PaySurchargeConfigCalcTest
|
||||
{
|
||||
@Test
|
||||
void lightOctoberOrderChargesFreightAndCarbonOnly()
|
||||
{
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(imile(), new BigDecimal("0.451"),
|
||||
new BigDecimal("35.70"), new BigDecimal("32.80"), new BigDecimal("4.00"),
|
||||
null, null, day(2026, 10, 17), 8);
|
||||
assertTrue(hasFee(result, "基础运费", "2.99"));
|
||||
assertTrue(hasFee(result, "CO₂附加费", "0.03"));
|
||||
assertTrue(result.getFees().stream().noneMatch(fee -> fee.getFeeName().contains("超尺寸")));
|
||||
assertTrue(result.getFees().stream().noneMatch(fee -> fee.getFeeName().contains("旺季")));
|
||||
assertEquals(new BigDecimal("3.02"), result.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void heavierOctoberOrderUsesTheNextWeightBand()
|
||||
{
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(imile(), new BigDecimal("1.246"),
|
||||
new BigDecimal("41.10"), new BigDecimal("34.20"), new BigDecimal("6.10"),
|
||||
null, null, day(2026, 10, 17), 5);
|
||||
assertTrue(hasFee(result, "基础运费", "3.12"));
|
||||
assertTrue(hasFee(result, "CO₂附加费", "0.03"));
|
||||
assertEquals(new BigDecimal("3.15"), result.getPayTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
void oversizeAndPeakSeasonUseTheConfiguredRules()
|
||||
{
|
||||
PayOrderCostResult oversize = PayCostCalculator.calculate(imile(), new BigDecimal("1.246"),
|
||||
new BigDecimal("130"), new BigDecimal("70"), new BigDecimal("40"),
|
||||
null, null, day(2026, 11, 12), 5);
|
||||
assertTrue(hasFee(oversize, "基础运费", "3.12"));
|
||||
assertTrue(hasFee(oversize, "CO₂附加费", "0.03"));
|
||||
assertTrue(hasFee(oversize, "异形件/超尺寸处理费", "3.60"));
|
||||
assertTrue(hasFee(oversize, "旺季附加费", "0.19"));
|
||||
assertEquals(new BigDecimal("6.94"), oversize.getPayTotal());
|
||||
|
||||
PayOrderCostResult peak = PayCostCalculator.calculate(dhl(), new BigDecimal("0.664"),
|
||||
new BigDecimal("25.50"), new BigDecimal("18.90"), new BigDecimal("7.80"),
|
||||
null, null, day(2026, 11, 4), 11);
|
||||
assertTrue(hasFee(peak, "基础运费", "3.13"));
|
||||
assertTrue(hasFee(peak, "燃油附加费", "0.15"));
|
||||
assertTrue(hasFee(peak, "旺季附加费", "0.19"));
|
||||
assertTrue(peak.getFees().stream().noneMatch(fee -> "高峰旺季附加费".equals(fee.getFeeName())));
|
||||
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())
|
||||
&& fee.getAmount().compareTo(new BigDecimal(amount)) == 0);
|
||||
}
|
||||
|
||||
private static Date day(int year, int month, int day)
|
||||
{
|
||||
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();
|
||||
product.setProductName("DE-iMile");
|
||||
product.setCurrency("EUR");
|
||||
product.setWeightBands(List.of(
|
||||
band("0", "1", "2.99"),
|
||||
band("1", "2", "3.12")));
|
||||
product.setSurcharges(List.of(
|
||||
fee("CO₂附加费", "0.03", "ALWAYS"),
|
||||
fee("异形件/超尺寸处理费", "3.60", "SIZE"),
|
||||
fee("旺季附加费", "0.19", "ALWAYS")));
|
||||
product.setBillingRules(List.of(
|
||||
always(null, null, null),
|
||||
always("旺季附加费", "11-01", "12-31"),
|
||||
sizeBox()));
|
||||
return product;
|
||||
}
|
||||
|
||||
private static PayProduct dhl()
|
||||
{
|
||||
PayProduct product = new PayProduct();
|
||||
product.setProductName("德国DHL");
|
||||
product.setCurrency("EUR");
|
||||
product.setWeightBands(List.of(band("0", "1", "3.13")));
|
||||
product.setSurcharges(List.of(
|
||||
fee("燃油附加费", "0.15", "ALWAYS"),
|
||||
fee("超尺寸超重费", "14.00", "SIZE"),
|
||||
fee("旺季附加费", "0.19", "ALWAYS"),
|
||||
fee("高峰旺季附加费", "0.50", "ALWAYS")));
|
||||
product.setBillingRules(List.of(
|
||||
always(null, null, null),
|
||||
always("旺季附加费", "11-01", "12-31"),
|
||||
always("高峰旺季附加费", "11-24", "12-07"),
|
||||
sizeBox()));
|
||||
return product;
|
||||
}
|
||||
|
||||
private static PaySurchargeRule always(String feeName, String start, String end)
|
||||
{
|
||||
PaySurchargeRule rule = new PaySurchargeRule();
|
||||
rule.setCalcRule("ALWAYS");
|
||||
rule.setEnabled("1");
|
||||
Map<String, Object> detail = new LinkedHashMap<>();
|
||||
if (feeName != null)
|
||||
{
|
||||
detail.put("feeName", feeName);
|
||||
detail.put("periodStart", start);
|
||||
detail.put("periodEnd", end);
|
||||
}
|
||||
rule.setDetail(detail);
|
||||
return rule;
|
||||
}
|
||||
|
||||
private static PaySurchargeRule sizeBox()
|
||||
{
|
||||
PaySurchargeRule rule = new PaySurchargeRule();
|
||||
rule.setCalcRule("SIZE");
|
||||
rule.setEnabled("1");
|
||||
Map<String, Object> detail = new LinkedHashMap<>();
|
||||
detail.put("matchMode", "ANY");
|
||||
detail.put("boxMode", "OVER");
|
||||
detail.put("boxLength", new BigDecimal("120"));
|
||||
detail.put("boxWidth", new BigDecimal("60"));
|
||||
detail.put("boxHeight", new BigDecimal("60"));
|
||||
rule.setDetail(detail);
|
||||
return rule;
|
||||
}
|
||||
|
||||
private static PayWeightBand band(String min, String max, String price)
|
||||
{
|
||||
PayWeightBand band = new PayWeightBand();
|
||||
band.setWeightMin(new BigDecimal(min));
|
||||
band.setWeightMax(new BigDecimal(max));
|
||||
band.setWeightLabel(min + "-" + max);
|
||||
band.setPrice(new BigDecimal(price));
|
||||
band.setPriceUnit("EUR/ITEM");
|
||||
return band;
|
||||
}
|
||||
|
||||
private static PaySurcharge fee(String name, String amount, String rule)
|
||||
{
|
||||
PaySurcharge fee = new PaySurcharge();
|
||||
fee.setFeeName(name);
|
||||
fee.setAmount(new BigDecimal(amount));
|
||||
fee.setCurrency("EUR");
|
||||
fee.setCalcRule(rule);
|
||||
fee.setChargeText(amount + " EUR/ITEM");
|
||||
return fee;
|
||||
}
|
||||
}
|
||||
@@ -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); }
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,49 @@ public enum PaymentMesEnum
|
||||
BMS_PAY_CUR_DICT("BMS_PAY_CUR_DICT", "提单费用校验币种", "收费币种不在币种字典中"),
|
||||
BMS_PAY_REMARK("BMS_PAY_REMARK", "提单费用校验备注", "备注不能超过500字"),
|
||||
BMS_PAY_LAD_BLANK("BMS_PAY_LAD_BLANK", "提单费用校验提单", "提单号不能为空"),
|
||||
BMS_PAY_LAD_MISS("BMS_PAY_LAD_MISS", "提单费用校验提单", "提单不存在");
|
||||
BMS_PAY_LAD_MISS("BMS_PAY_LAD_MISS", "提单费用校验提单", "提单不存在"),
|
||||
|
||||
BMS_PAY_USE_AUDIT("BMS_PAY_USE_AUDIT", "应付账单确认", "请先提交审核,审核通过后账单才确认"),
|
||||
BMS_PAY_USE_PAY("BMS_PAY_USE_PAY", "应付账单付款", "请到应付付款登记付款并核销"),
|
||||
BMS_PAY_SUBMIT("BMS_PAY_SUBMIT", "应付账单提交", "只有草稿可以提交审核"),
|
||||
BMS_PAY_DIFF_OPEN("BMS_PAY_DIFF_OPEN", "应付账单提交", "还有未处理的对账差异"),
|
||||
BMS_PAY_NO_LINE("BMS_PAY_NO_LINE", "应付账单提交", "账单没有费用行"),
|
||||
BMS_PAY_PENDING("BMS_PAY_PENDING", "应付账单审核", "只有待审核的账单可以审核"),
|
||||
BMS_PAY_NO_FILE("BMS_PAY_NO_FILE", "应付账单审核", "请先上传发票或对账凭证"),
|
||||
BMS_PAY_REJECT_WHY("BMS_PAY_REJECT_WHY", "应付账单审核", "请填写驳回意见"),
|
||||
BMS_PAY_LINE_MISS("BMS_PAY_LINE_MISS", "应付账单差异", "费用行不存在"),
|
||||
BMS_PAY_LINE_LOCK("BMS_PAY_LINE_LOCK", "应付账单差异", "只有草稿可以调整费用行"),
|
||||
BMS_PAY_NO_DIFF("BMS_PAY_NO_DIFF", "应付账单差异", "这行没有待处理的差异"),
|
||||
BMS_PAY_NO_VOID("BMS_PAY_NO_VOID", "应付账单作废", "已确认的账单不能直接作废,请做红字"),
|
||||
BMS_PAY_FEE_TAKEN("BMS_PAY_FEE_TAKEN", "应付账单生成", "费用已经进入其他账单"),
|
||||
BMS_PAY_RED_STAT("BMS_PAY_RED_STAT", "应付账单红字", "只有已确认或部分付款的账单可以红冲"),
|
||||
BMS_PAY_RED_PAID("BMS_PAY_RED_PAID", "应付账单红字", "账单已有付款,请先处理付款后再红冲"),
|
||||
BMS_PAY_RED_KIND("BMS_PAY_RED_KIND", "应付账单红字", "红字账单不能再红冲"),
|
||||
BMS_PAY_FILE_NEED("BMS_PAY_FILE_NEED", "应付凭证", "请先上传文件"),
|
||||
BMS_PAY_FILE_MISS("BMS_PAY_FILE_MISS", "应付凭证", "凭证不存在"),
|
||||
BMS_PAY_FILE_LOCK("BMS_PAY_FILE_LOCK", "应付凭证", "已确认的账单不能删除凭证"),
|
||||
BMS_PAY_PAY_MISS("BMS_PAY_PAY_MISS", "应付付款", "付款单不存在"),
|
||||
BMS_PAY_PAY_DRAFT("BMS_PAY_PAY_DRAFT", "应付付款", "只有草稿付款单可以确认或作废"),
|
||||
BMS_PAY_PAY_DATE("BMS_PAY_PAY_DATE", "应付付款", "请填写付款日期"),
|
||||
BMS_PAY_PAY_AMT("BMS_PAY_PAY_AMT", "应付付款", "请填写付款金额"),
|
||||
BMS_PAY_ALLOC_NEED("BMS_PAY_ALLOC_NEED", "应付付款", "请填写本次核销金额"),
|
||||
BMS_PAY_ALLOC_AMT("BMS_PAY_ALLOC_AMT", "应付付款", "核销金额超过账单未付金额"),
|
||||
BMS_PAY_ALLOC_DUP("BMS_PAY_ALLOC_DUP", "应付付款", "同一张账单不能重复核销"),
|
||||
BMS_PAY_ALLOC_OVER("BMS_PAY_ALLOC_OVER", "应付付款", "核销合计不能超过付款金额"),
|
||||
BMS_PAY_PAY_BILL("BMS_PAY_PAY_BILL", "应付付款", "只能核销已确认或部分付款的账单"),
|
||||
BMS_PAY_PAY_SAME("BMS_PAY_PAY_SAME", "应付付款", "付款单和账单的供应商、币种需要一致"),
|
||||
BMS_PAY_SAME_USER("BMS_PAY_SAME_USER", "应付审核", "提交人和审核人不能是同一人"),
|
||||
BMS_PAY_SAME_PAY("BMS_PAY_SAME_PAY", "应付付款", "登记人和确认人不能是同一人"),
|
||||
BMS_PAY_INV_NEED("BMS_PAY_INV_NEED", "应付发票", "审核通过前请上传发票,并填写发票号和价税合计"),
|
||||
BMS_PAY_INV_AMT("BMS_PAY_INV_AMT", "应付发票", "发票价税合计与账单金额不一致"),
|
||||
BMS_PAY_INV_TAX("BMS_PAY_INV_TAX", "应付发票", "发票税额与账单税额不一致"),
|
||||
BMS_PAY_INV_DUP("BMS_PAY_INV_DUP", "应付发票", "这张发票号已经在该供应商下勾稽过"),
|
||||
BMS_PAY_INV_NO("BMS_PAY_INV_NO", "应付发票", "请填写发票号"),
|
||||
BMS_PAY_TAX_RATE("BMS_PAY_TAX_RATE", "应付价税", "税率要在 0 到 1 之间,例如 0.06"),
|
||||
BMS_PAY_RATE("BMS_PAY_RATE", "应付汇率", "请填写大于 0 的汇率"),
|
||||
BMS_PAY_NO_REVERSE("BMS_PAY_NO_REVERSE", "应付付款", "只有已付款的单据可以反核销或退款"),
|
||||
BMS_PAY_NO_BACK("BMS_PAY_NO_BACK", "应付付款", "没有可冲回的核销"),
|
||||
BMS_PAY_XLS_LINE("BMS_PAY_XLS_LINE", "应付对账单", "对账单里没有可导入的行号");
|
||||
|
||||
private static final Map<String, PaymentMesEnum> BY_CODE = new HashMap<>();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
+4
-1
@@ -11,7 +11,7 @@ public class SrvBillAirAllocFee
|
||||
|
||||
private String billCode;
|
||||
|
||||
/** 提单主键 srv_bill_air.guid,写入订单费用的 source_id */
|
||||
/** 提单主键 srv_bill_air.guid */
|
||||
private String ladingId;
|
||||
|
||||
/** 费用阶段,字典 bms_fee_level */
|
||||
@@ -20,6 +20,9 @@ public class SrvBillAirAllocFee
|
||||
/** 费用状态,字典 bill_fee_status */
|
||||
private String billFeeStatus;
|
||||
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
private String feeName;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
+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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
/**
|
||||
* 打单重量段计费条件(字典 lbl_charge_mode)。
|
||||
*/
|
||||
public final class LblChargeMode
|
||||
{
|
||||
private LblChargeMode()
|
||||
{
|
||||
}
|
||||
|
||||
/** 按票 */
|
||||
public static final String ITEM = "ITEM";
|
||||
|
||||
/** 单价*公斤数 */
|
||||
public static final String PER_KG = "PER_KG";
|
||||
|
||||
/** 首重+续重 */
|
||||
public static final String EXTRA_KG = "EXTRA_KG";
|
||||
|
||||
/** 邮编 */
|
||||
public static final String POSTCODE = "POSTCODE";
|
||||
|
||||
/** @deprecated 映射为 ITEM */
|
||||
@Deprecated
|
||||
public static final String ALWAYS = "ALWAYS";
|
||||
|
||||
/** @deprecated 映射为 ITEM(分区用 zone 列过滤) */
|
||||
@Deprecated
|
||||
public static final String ZONE = "ZONE";
|
||||
|
||||
/** @deprecated 映射为 ITEM */
|
||||
@Deprecated
|
||||
public static final String FLAT = "FLAT";
|
||||
|
||||
/** @deprecated 映射为 PER_KG */
|
||||
@Deprecated
|
||||
public static final String UNIT_PLUS_HANDLE = "UNIT_PLUS_HANDLE";
|
||||
|
||||
/** @deprecated 映射为 EXTRA_KG */
|
||||
@Deprecated
|
||||
public static final String FIRST_EXTRA = "FIRST_EXTRA";
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public static final String WEIGHT = "WEIGHT";
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public static final String SIZE = "SIZE";
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public static final String RETURN = "RETURN";
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
public static final String MANUAL = "MANUAL";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 打单解析过程中的邮编/配置原文行(二期落库;当前仅预览内存态)。
|
||||
*/
|
||||
@Data
|
||||
public class LblExtraLine
|
||||
{
|
||||
private Long lineId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private Long versionId;
|
||||
|
||||
private String lineType;
|
||||
|
||||
private String lineText;
|
||||
|
||||
private Integer sortNo;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
/**
|
||||
* 打单重量段费用类型(字典 bms_fee_type)。
|
||||
*/
|
||||
public final class LblFeeType
|
||||
{
|
||||
private LblFeeType()
|
||||
{
|
||||
}
|
||||
|
||||
/** 运费 */
|
||||
public static final String FREIGHT = "FREIGHT";
|
||||
|
||||
/** 处理费/挂号 */
|
||||
public static final String REGISTRATION = "REGISTRATION";
|
||||
|
||||
/** 偏远费 */
|
||||
public static final String REMOTE = "REMOTE";
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 打单价卡导入预览。
|
||||
*/
|
||||
@Data
|
||||
public class LblPreview
|
||||
{
|
||||
private String sourceFile;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private String fileMd5;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveDate;
|
||||
|
||||
private List<LblProduct> products = new ArrayList<>();
|
||||
|
||||
private List<String> skippedSheets = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.bms.common.annotation.Excel;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 打单价卡产品主数据。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class LblProduct extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long productId;
|
||||
|
||||
@Excel(name = "产品名称", width = 24)
|
||||
private String productName;
|
||||
|
||||
private String dictValue;
|
||||
|
||||
private Long versionId;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
private String versionStatus;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date versionStart;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date versionEnd;
|
||||
|
||||
private String countryScope;
|
||||
|
||||
private String chargeType;
|
||||
|
||||
private String extraPerKg;
|
||||
|
||||
private String serviceType;
|
||||
|
||||
private String classification;
|
||||
|
||||
private String catalogRemark;
|
||||
|
||||
private String updateContent;
|
||||
|
||||
private String weightLimit;
|
||||
|
||||
private String sheetName;
|
||||
|
||||
private String relatedSheet;
|
||||
|
||||
private String sourceFile;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private String fileMd5;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveDate;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String serviceNote;
|
||||
|
||||
private String parseStatus;
|
||||
|
||||
private Integer weightCount;
|
||||
|
||||
private Integer surchargeCount;
|
||||
|
||||
private Integer extraCount;
|
||||
|
||||
private String boundChannelText;
|
||||
|
||||
private Integer boundChannelCount;
|
||||
|
||||
private Boolean duplicated;
|
||||
|
||||
private Long existsId;
|
||||
|
||||
private List<LblWeightBand> weightBands;
|
||||
|
||||
private List<LblSurcharge> surcharges;
|
||||
|
||||
/** 兼容旧前端 termId,等同 versionId */
|
||||
public Long getTermId()
|
||||
{
|
||||
return versionId;
|
||||
}
|
||||
|
||||
public void setTermId(Long termId)
|
||||
{
|
||||
this.versionId = termId;
|
||||
}
|
||||
|
||||
private List<LblExtraLine> extraLines;
|
||||
|
||||
/** 邮编→分区(保存时同步到 prc_zone,不落产品子表) */
|
||||
private Map<String, List<String>> zonePostcodes;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.bms.common.core.domain.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 打单价卡产品版本周期。
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class LblProductVersion extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long versionId;
|
||||
|
||||
private Long priceSetId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private String dictValue;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveStart;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveEnd;
|
||||
|
||||
private String filePath;
|
||||
|
||||
/** 0待生效 1生效 2已失效 */
|
||||
private String status;
|
||||
|
||||
private String productName;
|
||||
|
||||
private String sourceFile;
|
||||
|
||||
private Integer weightCount;
|
||||
|
||||
private Integer surchargeCount;
|
||||
|
||||
private String currency;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 打单价卡预览确认后的保存请求。
|
||||
*/
|
||||
@Data
|
||||
public class LblSaveCommand
|
||||
{
|
||||
private boolean overwrite;
|
||||
|
||||
private Long priceSetId;
|
||||
|
||||
private String priceSetName;
|
||||
|
||||
private String priceSetNote;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
private List<LblProduct> products = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 打单价卡异步保存进度(Redis)。
|
||||
*/
|
||||
public class LblSaveTask implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String STATUS_PENDING = "PENDING";
|
||||
public static final String STATUS_RUNNING = "RUNNING";
|
||||
public static final String STATUS_SUCCESS = "SUCCESS";
|
||||
public static final String STATUS_FAIL = "FAIL";
|
||||
|
||||
private String taskId;
|
||||
private String status;
|
||||
private int percent;
|
||||
private String message;
|
||||
private Long priceSetId;
|
||||
private String error;
|
||||
|
||||
public String getTaskId()
|
||||
{
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId)
|
||||
{
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getPercent()
|
||||
{
|
||||
return percent;
|
||||
}
|
||||
|
||||
public void setPercent(int percent)
|
||||
{
|
||||
this.percent = percent;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Long getPriceSetId()
|
||||
{
|
||||
return priceSetId;
|
||||
}
|
||||
|
||||
public void setPriceSetId(Long priceSetId)
|
||||
{
|
||||
this.priceSetId = priceSetId;
|
||||
}
|
||||
|
||||
public String getError()
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error)
|
||||
{
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
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 LblSurcharge
|
||||
{
|
||||
private Long surchargeId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private Long versionId;
|
||||
|
||||
/** 解析中间态区块名,不落库 */
|
||||
private String sectionName;
|
||||
|
||||
private String feeName;
|
||||
|
||||
private Long scId;
|
||||
|
||||
private String zoneCode;
|
||||
|
||||
private String zoneName;
|
||||
|
||||
private String chargeText;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String priceUnit;
|
||||
|
||||
private String feeDesc;
|
||||
|
||||
private String periodText;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveStart;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date effectiveEnd;
|
||||
|
||||
private String chargeTiming;
|
||||
|
||||
private String calcRule;
|
||||
|
||||
private String calcParam;
|
||||
|
||||
private String postcodeParam;
|
||||
|
||||
private BigDecimal weightMin;
|
||||
|
||||
private BigDecimal weightMax;
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 打单价卡重量段明细。
|
||||
* 维度:产品+国家+分区+重量段+fee_type;无 handle 字段。
|
||||
*/
|
||||
@Data
|
||||
public class LblWeightBand
|
||||
{
|
||||
private Long bandId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private Long versionId;
|
||||
|
||||
/** 解析中间态区块名,不落库 */
|
||||
private String sectionName;
|
||||
|
||||
/** FREIGHT / REGISTRATION / REMOTE */
|
||||
private String feeType;
|
||||
|
||||
private String countryName;
|
||||
|
||||
private String countryCode;
|
||||
|
||||
private String zoneCode;
|
||||
|
||||
private String zoneName;
|
||||
|
||||
private String postcodeParam;
|
||||
|
||||
private String weightLabel;
|
||||
|
||||
private BigDecimal weightMin;
|
||||
|
||||
private BigDecimal weightMax;
|
||||
|
||||
private String volumeText;
|
||||
|
||||
private String chargeName;
|
||||
|
||||
/** 字典 lbl_charge_mode:ITEM/PER_KG/EXTRA_KG/POSTCODE */
|
||||
private String chargeMode;
|
||||
|
||||
/** 条件参数(如首重KG、尺寸表达) */
|
||||
private String calcParam;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
private String priceUnit;
|
||||
|
||||
private BigDecimal extraPrice;
|
||||
|
||||
private String extraPriceUnit;
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
/** 编辑保存删除标记(不落库) */
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -33,9 +33,23 @@ public class PayBill
|
||||
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/** DRAFT CONFIRMED PAID VOID */
|
||||
private BigDecimal supplierAmount;
|
||||
|
||||
private BigDecimal diffAmount;
|
||||
|
||||
private BigDecimal paidAmount;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date dueDate;
|
||||
|
||||
/** DRAFT PENDING CONFIRMED PARTIAL PAID RED VOID */
|
||||
private String status;
|
||||
|
||||
/** BLUE 蓝字,RED 红字 */
|
||||
private String billKind;
|
||||
|
||||
private Long originalBillId;
|
||||
|
||||
private String voidReason;
|
||||
|
||||
private String voidBy;
|
||||
@@ -43,6 +57,29 @@ public class PayBill
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date voidTime;
|
||||
|
||||
private String confirmBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date confirmTime;
|
||||
|
||||
/** 0.06 表示 6% */
|
||||
private BigDecimal taxRate;
|
||||
|
||||
private BigDecimal amountNet;
|
||||
|
||||
private BigDecimal taxAmount;
|
||||
|
||||
private BigDecimal exchangeRate;
|
||||
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date rateDate;
|
||||
|
||||
private Integer termDays;
|
||||
|
||||
private String submitBy;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@@ -58,4 +95,10 @@ public class PayBill
|
||||
private List<PayBillLine> lines;
|
||||
|
||||
private List<PayBillLog> logs;
|
||||
|
||||
private List<PayBillDiff> diffs;
|
||||
|
||||
private List<PayBillFile> files;
|
||||
|
||||
private List<PayBillApproval> approvals;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付账单审核记录。 */
|
||||
@Data
|
||||
public class PayBillApproval
|
||||
{
|
||||
private Long approvalId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
/** SUBMIT APPROVE REJECT */
|
||||
private String action;
|
||||
|
||||
private String opinion;
|
||||
|
||||
private String operatorName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -32,4 +32,34 @@ public class PayBillCommand
|
||||
|
||||
/** 要作废的应付账单ID */
|
||||
private Long billId;
|
||||
|
||||
/** 到期日,yyyy-MM-dd */
|
||||
private String dueDate;
|
||||
|
||||
/** 账单费用行。登记对方金额时使用 */
|
||||
private java.util.List<PayBillLine> lines;
|
||||
|
||||
/** 要处理的账单行 */
|
||||
private Long lineId;
|
||||
|
||||
/** 对方金额 */
|
||||
private java.math.BigDecimal supplierAmount;
|
||||
|
||||
/** OURS 接受我方,THEIRS 接受对方 */
|
||||
private String handleType;
|
||||
|
||||
/** 差异原因或红字原因 */
|
||||
private String reason;
|
||||
|
||||
/** 驳回意见 */
|
||||
private String opinion;
|
||||
|
||||
/** 税率,0.06 表示 6% */
|
||||
private java.math.BigDecimal taxRate;
|
||||
|
||||
/** 折人民币汇率 */
|
||||
private java.math.BigDecimal exchangeRate;
|
||||
|
||||
/** 汇率日期,yyyy-MM-dd */
|
||||
private String rateDate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
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 PayBillDiff
|
||||
{
|
||||
private Long diffId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
private Long lineId;
|
||||
|
||||
private String feeId;
|
||||
|
||||
private BigDecimal ourAmount;
|
||||
|
||||
private BigDecimal supplierAmount;
|
||||
|
||||
private BigDecimal diffAmount;
|
||||
|
||||
private String reason;
|
||||
|
||||
/** OPEN ACCEPT_OURS ACCEPT_THEIRS */
|
||||
private String handleType;
|
||||
|
||||
private String adjustFeeId;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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 PayBillFile
|
||||
{
|
||||
private Long fileId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
private String billNo;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
/** INVOICE STATEMENT DEBIT OTHER */
|
||||
private String fileType;
|
||||
|
||||
private String invoiceNo;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date invoiceDate;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal taxAmount;
|
||||
|
||||
private BigDecimal amountNet;
|
||||
|
||||
private String sellerName;
|
||||
|
||||
private BigDecimal matchedAmount;
|
||||
|
||||
private String currency;
|
||||
|
||||
private String fileName;
|
||||
|
||||
private String fileUrl;
|
||||
|
||||
private String deleted;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -13,7 +13,10 @@ public class PayBillLine
|
||||
|
||||
private Long billId;
|
||||
|
||||
private String orderBillId;
|
||||
private String feeId;
|
||||
|
||||
/** 计费订单ID,对应 prc_order_bill.bill_id */
|
||||
private Long orderBillId;
|
||||
|
||||
private String orderNo;
|
||||
|
||||
@@ -23,8 +26,27 @@ public class PayBillLine
|
||||
|
||||
private String feeName;
|
||||
|
||||
private String feeSource;
|
||||
|
||||
private String feeLevel;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal supplierAmount;
|
||||
|
||||
private BigDecimal diffAmount;
|
||||
|
||||
/** NONE OPEN ACCEPT_OURS ACCEPT_THEIRS */
|
||||
private String diffStatus;
|
||||
|
||||
private BigDecimal taxRate;
|
||||
|
||||
private BigDecimal amountNet;
|
||||
|
||||
private BigDecimal taxAmount;
|
||||
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
private String currency;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
@@ -12,6 +13,14 @@ public class PayBillLog
|
||||
|
||||
private Long billId;
|
||||
|
||||
private String bizType;
|
||||
|
||||
private Long bizId;
|
||||
|
||||
private Long lineId;
|
||||
|
||||
private String feeId;
|
||||
|
||||
private String operationType;
|
||||
|
||||
private String fromStatus;
|
||||
@@ -20,6 +29,10 @@ public class PayBillLog
|
||||
|
||||
private String operationDesc;
|
||||
|
||||
private BigDecimal amountBefore;
|
||||
|
||||
private BigDecimal amountAfter;
|
||||
|
||||
private String operatorName;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -45,4 +46,10 @@ public class PayBillOrder
|
||||
|
||||
/** 已挂在未作废账单上时的账单号 */
|
||||
private String occupiedBillNo;
|
||||
|
||||
/** 未删除费用行数 */
|
||||
private Integer feeCount;
|
||||
|
||||
/** 还没进入未作废账单的费用行数 */
|
||||
private Integer unbilledCount;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付付款单。一张付款可以核销多张已确认账单。 */
|
||||
@Data
|
||||
public class PayPayment
|
||||
{
|
||||
private Long paymentId;
|
||||
|
||||
private String paymentNo;
|
||||
|
||||
private Long supplierId;
|
||||
|
||||
private String supplierName;
|
||||
|
||||
private String currency;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date payDate;
|
||||
|
||||
/** BANK CASH OTHER */
|
||||
private String payMethod;
|
||||
|
||||
private String bankAccount;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal bankFee;
|
||||
|
||||
private BigDecimal exchangeRate;
|
||||
|
||||
private BigDecimal baseAmount;
|
||||
|
||||
private BigDecimal allocAmount;
|
||||
|
||||
/** DRAFT PAID VOID REFUNDED */
|
||||
private String status;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
private String confirmBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date confirmTime;
|
||||
|
||||
private List<PayPaymentAlloc> allocs;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付付款核销到一张账单的金额。 */
|
||||
@Data
|
||||
public class PayPaymentAlloc
|
||||
{
|
||||
private Long allocId;
|
||||
|
||||
private Long paymentId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
private String billNo;
|
||||
|
||||
private BigDecimal allocAmount;
|
||||
|
||||
/** ACTIVE REVERSED */
|
||||
private String allocStatus;
|
||||
|
||||
/** 账单未核销金额,只在查询未付账单时带出 */
|
||||
private BigDecimal openAmount;
|
||||
|
||||
private String currency;
|
||||
|
||||
private Long supplierId;
|
||||
|
||||
private String supplierName;
|
||||
}
|
||||
@@ -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<>();
|
||||
}
|
||||
|
||||
@@ -151,5 +151,8 @@ public class PayProduct extends BaseEntity
|
||||
|
||||
private List<PaySurcharge> surcharges;
|
||||
|
||||
/** 这一版附加费配置。只在计费时带上,不入库 */
|
||||
private List<PaySurchargeRule> billingRules;
|
||||
|
||||
private List<PayExtraLine> extraLines;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 应付附加费计费条件。同一产品版本的全部条件都在这张表,用 calcRule 区分列表。
|
||||
*/
|
||||
@Data
|
||||
public class PaySurchargeRule
|
||||
{
|
||||
private Long ruleId;
|
||||
|
||||
/** 这一版应付产品 */
|
||||
private Long productId;
|
||||
|
||||
/** 价卡版本周期 */
|
||||
private Long termId;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
/** ALWAYS、POSTCODE、ZONE、EXTRA_KG、WEIGHT、SIZE、RETURN */
|
||||
private String calcRule;
|
||||
|
||||
/** 1开 0关 */
|
||||
private String enabled;
|
||||
|
||||
/** 条件摘要,由明细生成 */
|
||||
private String calcParam;
|
||||
|
||||
/** 条件明细 JSON。接口不直接收发这一列,用 detail */
|
||||
@JsonIgnore
|
||||
private String ruleDetail;
|
||||
|
||||
/** 这一条规则的结构化参数。超尺寸含长宽高、围长、体积、加收比例和命中方式 */
|
||||
private Map<String, Object> detail;
|
||||
|
||||
/** 续重行的邮编 */
|
||||
private String postcodeParam;
|
||||
|
||||
private String zoneName;
|
||||
|
||||
private BigDecimal weightMin;
|
||||
|
||||
private BigDecimal weightMax;
|
||||
|
||||
private Integer sortNo;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private String updateBy;
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/** 应付附加费配置在某一产品版本上的操作记录。 */
|
||||
public class PaySurchargeRuleLog
|
||||
{
|
||||
private Long logId;
|
||||
|
||||
private Long productId;
|
||||
|
||||
private Long termId;
|
||||
|
||||
private Integer versionNo;
|
||||
|
||||
/** 1新增 2修改 3删除 */
|
||||
private String operationType;
|
||||
|
||||
private String ruleKey;
|
||||
|
||||
private String changeContent;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
public Long getLogId()
|
||||
{
|
||||
return logId;
|
||||
}
|
||||
|
||||
public void setLogId(Long logId)
|
||||
{
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public Long getProductId()
|
||||
{
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Long productId)
|
||||
{
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Long getTermId()
|
||||
{
|
||||
return termId;
|
||||
}
|
||||
|
||||
public void setTermId(Long termId)
|
||||
{
|
||||
this.termId = termId;
|
||||
}
|
||||
|
||||
public Integer getVersionNo()
|
||||
{
|
||||
return versionNo;
|
||||
}
|
||||
|
||||
public void setVersionNo(Integer versionNo)
|
||||
{
|
||||
this.versionNo = versionNo;
|
||||
}
|
||||
|
||||
public String getOperationType()
|
||||
{
|
||||
return operationType;
|
||||
}
|
||||
|
||||
public void setOperationType(String operationType)
|
||||
{
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public String getRuleKey()
|
||||
{
|
||||
return ruleKey;
|
||||
}
|
||||
|
||||
public void setRuleKey(String ruleKey)
|
||||
{
|
||||
this.ruleKey = ruleKey;
|
||||
}
|
||||
|
||||
public String getChangeContent()
|
||||
{
|
||||
return changeContent;
|
||||
}
|
||||
|
||||
public void setChangeContent(String changeContent)
|
||||
{
|
||||
this.changeContent = changeContent;
|
||||
}
|
||||
|
||||
public String getCreateBy()
|
||||
{
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy)
|
||||
{
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime()
|
||||
{
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime)
|
||||
{
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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,11 +37,45 @@ public class PrcPayBillFee implements Serializable
|
||||
/** CALC 计算,LADING 提单分摊,MANUAL 人工 */
|
||||
private String feeSource;
|
||||
|
||||
/** 来源数据id */
|
||||
/** 来源数据id。提单分摊时为 srv_bill_air_fee.id */
|
||||
private String sourceId;
|
||||
|
||||
/** 是否删除:0未删除 1已删除 */
|
||||
private String isDeleted;
|
||||
|
||||
/** 已进入的应付账单行。空表示还没出账 */
|
||||
private Long statementLineId;
|
||||
|
||||
/** 结算供应商。空表示还没标明付款对象 */
|
||||
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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import com.bms.price.domain.LblChargeMode;
|
||||
import com.bms.price.domain.LblFeeType;
|
||||
import com.bms.price.domain.LblPreview;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
|
||||
/**
|
||||
* 归并解析重量段:按 fee_type 分行;首重+续重合 EXTRA_KG;补 chargeMode/zoneCode。
|
||||
* 不再把处理费合并进运费行。
|
||||
*/
|
||||
public final class LblBandNormalizer
|
||||
{
|
||||
private LblBandNormalizer()
|
||||
{
|
||||
}
|
||||
|
||||
public static void normalize(LblPreview preview)
|
||||
{
|
||||
if (preview == null || preview.getProducts() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (LblProduct product : preview.getProducts())
|
||||
{
|
||||
normalizeProduct(product);
|
||||
}
|
||||
}
|
||||
|
||||
public static void normalizeProduct(LblProduct product)
|
||||
{
|
||||
if (product == null || product.getWeightBands() == null || product.getWeightBands().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<LblWeightBand> rows = splitByFeeType(product.getWeightBands());
|
||||
rows = mergeFirstExtra(rows);
|
||||
int sort = 0;
|
||||
for (LblWeightBand band : rows)
|
||||
{
|
||||
if (band.getFeeType() == null || band.getFeeType().isEmpty())
|
||||
{
|
||||
band.setFeeType(inferFeeType(band));
|
||||
}
|
||||
if (band.getChargeMode() == null || band.getChargeMode().isEmpty())
|
||||
{
|
||||
band.setChargeMode(inferMode(band));
|
||||
}
|
||||
band.setChargeMode(migrateMode(band.getChargeMode()));
|
||||
if (band.getZoneCode() == null || band.getZoneCode().isEmpty())
|
||||
{
|
||||
band.setZoneCode(toZoneCode(band.getZoneName()));
|
||||
}
|
||||
if (band.getPostcodeParam() == null || band.getPostcodeParam().isEmpty())
|
||||
{
|
||||
String prefixes = LblSurchargeRules.remotePrefixes(band.getZoneName());
|
||||
band.setPostcodeParam(prefixes == null ? "" : prefixes);
|
||||
}
|
||||
if (band.getCountryCode() == null)
|
||||
{
|
||||
band.setCountryCode("");
|
||||
}
|
||||
if (band.getZoneCode() == null)
|
||||
{
|
||||
band.setZoneCode("");
|
||||
}
|
||||
if (band.getCalcParam() == null)
|
||||
{
|
||||
band.setCalcParam("");
|
||||
}
|
||||
band.setSortNo(sort++);
|
||||
}
|
||||
product.setWeightBands(rows);
|
||||
product.setWeightCount(rows.size());
|
||||
product.setChargeType(summarizeChargeType(rows));
|
||||
}
|
||||
|
||||
/** 处理费/挂号落 REGISTRATION;偏远落 REMOTE;其余落 FREIGHT。 */
|
||||
private static List<LblWeightBand> splitByFeeType(List<LblWeightBand> source)
|
||||
{
|
||||
List<LblWeightBand> out = new ArrayList<LblWeightBand>();
|
||||
for (LblWeightBand band : source)
|
||||
{
|
||||
if (band == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = nz(band.getChargeName());
|
||||
String fee = nz(band.getFeeType());
|
||||
if (!fee.isEmpty())
|
||||
{
|
||||
LblWeightBand kept = copyBand(band);
|
||||
// 解析器若误标 FREIGHT,按费用名回正为 REGISTRATION
|
||||
if (name.contains("处理费") || name.contains("挂号"))
|
||||
{
|
||||
kept.setFeeType(LblFeeType.REGISTRATION);
|
||||
if (kept.getChargeMode() == null || kept.getChargeMode().isEmpty())
|
||||
{
|
||||
kept.setChargeMode(LblChargeMode.ITEM);
|
||||
}
|
||||
}
|
||||
out.add(kept);
|
||||
continue;
|
||||
}
|
||||
if (nameContainsRemote(name))
|
||||
{
|
||||
LblWeightBand row = copyBand(band);
|
||||
row.setFeeType(LblFeeType.REMOTE);
|
||||
if (row.getChargeMode() == null || row.getChargeMode().isEmpty())
|
||||
{
|
||||
row.setChargeMode(nz(row.getPostcodeParam()).isEmpty() ? LblChargeMode.ITEM : LblChargeMode.POSTCODE);
|
||||
}
|
||||
out.add(row);
|
||||
continue;
|
||||
}
|
||||
if (name.contains("处理费") || name.contains("挂号"))
|
||||
{
|
||||
// 处理费/挂号固定 REGISTRATION,不再改写为 FREIGHT(避免与运费同维度唯一键冲突)
|
||||
LblWeightBand row = copyBand(band);
|
||||
row.setFeeType(LblFeeType.REGISTRATION);
|
||||
row.setChargeMode(LblChargeMode.ITEM);
|
||||
out.add(row);
|
||||
continue;
|
||||
}
|
||||
LblWeightBand row = copyBand(band);
|
||||
row.setFeeType(LblFeeType.FREIGHT);
|
||||
out.add(row);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static boolean nameContainsRemote(String name)
|
||||
{
|
||||
String n = name.toLowerCase(Locale.ROOT);
|
||||
return name.contains("偏远") || n.contains("remote") || name.contains("岛屿") || n.contains("island");
|
||||
}
|
||||
|
||||
private static List<LblWeightBand> mergeFirstExtra(List<LblWeightBand> source)
|
||||
{
|
||||
Map<String, LblWeightBand> firsts = new LinkedHashMap<String, LblWeightBand>();
|
||||
List<LblWeightBand> extras = new ArrayList<LblWeightBand>();
|
||||
List<LblWeightBand> rest = new ArrayList<LblWeightBand>();
|
||||
for (LblWeightBand band : source)
|
||||
{
|
||||
String label = nz(band.getWeightLabel()).toLowerCase(Locale.ROOT);
|
||||
boolean first = label.contains("首重") || label.contains("first");
|
||||
boolean extra = label.contains("每增加") || label.contains("续重") || label.contains("additional");
|
||||
if (first)
|
||||
{
|
||||
String key = zoneFeeKey(band);
|
||||
LblWeightBand row = copyBand(band);
|
||||
row.setChargeMode(LblChargeMode.EXTRA_KG);
|
||||
if (row.getWeightMax() != null && (row.getCalcParam() == null || row.getCalcParam().isEmpty()))
|
||||
{
|
||||
row.setCalcParam(row.getWeightMax().stripTrailingZeros().toPlainString());
|
||||
}
|
||||
firsts.put(key, row);
|
||||
}
|
||||
else if (extra)
|
||||
{
|
||||
extras.add(band);
|
||||
}
|
||||
else
|
||||
{
|
||||
rest.add(band);
|
||||
}
|
||||
}
|
||||
for (LblWeightBand extra : extras)
|
||||
{
|
||||
String key = zoneFeeKey(extra);
|
||||
LblWeightBand row = firsts.get(key);
|
||||
if (row == null)
|
||||
{
|
||||
row = copyBand(extra);
|
||||
row.setExtraPrice(extra.getPrice());
|
||||
row.setExtraPriceUnit(extra.getPriceUnit());
|
||||
row.setPrice(null);
|
||||
row.setChargeMode(LblChargeMode.EXTRA_KG);
|
||||
firsts.put(key, row);
|
||||
}
|
||||
else
|
||||
{
|
||||
row.setExtraPrice(extra.getPrice());
|
||||
row.setExtraPriceUnit(extra.getPriceUnit());
|
||||
row.setChargeMode(LblChargeMode.EXTRA_KG);
|
||||
}
|
||||
}
|
||||
List<LblWeightBand> out = new ArrayList<LblWeightBand>();
|
||||
out.addAll(rest);
|
||||
out.addAll(firsts.values());
|
||||
return out;
|
||||
}
|
||||
|
||||
private static String inferFeeType(LblWeightBand band)
|
||||
{
|
||||
String name = nz(band.getChargeName());
|
||||
if (nameContainsRemote(name))
|
||||
{
|
||||
return LblFeeType.REMOTE;
|
||||
}
|
||||
if (name.contains("处理费") || name.contains("挂号"))
|
||||
{
|
||||
return LblFeeType.REGISTRATION;
|
||||
}
|
||||
return LblFeeType.FREIGHT;
|
||||
}
|
||||
|
||||
private static String inferMode(LblWeightBand band)
|
||||
{
|
||||
if (band.getExtraPrice() != null)
|
||||
{
|
||||
return LblChargeMode.EXTRA_KG;
|
||||
}
|
||||
if (!nz(band.getPostcodeParam()).isEmpty())
|
||||
{
|
||||
return LblChargeMode.POSTCODE;
|
||||
}
|
||||
String unit = nz(band.getPriceUnit()).toUpperCase(Locale.ROOT);
|
||||
if (unit.contains("KG") || unit.contains("公斤") || unit.contains("千克"))
|
||||
{
|
||||
return LblChargeMode.PER_KG;
|
||||
}
|
||||
return LblChargeMode.ITEM;
|
||||
}
|
||||
|
||||
private static String migrateMode(String mode)
|
||||
{
|
||||
if (mode == null || mode.isEmpty())
|
||||
{
|
||||
return LblChargeMode.ITEM;
|
||||
}
|
||||
if (LblChargeMode.FIRST_EXTRA.equals(mode) || "EXTRA_KG".equals(mode))
|
||||
{
|
||||
return LblChargeMode.EXTRA_KG;
|
||||
}
|
||||
if (LblChargeMode.POSTCODE.equals(mode))
|
||||
{
|
||||
return LblChargeMode.POSTCODE;
|
||||
}
|
||||
if (LblChargeMode.PER_KG.equals(mode) || LblChargeMode.UNIT_PLUS_HANDLE.equals(mode))
|
||||
{
|
||||
return LblChargeMode.PER_KG;
|
||||
}
|
||||
if (LblChargeMode.ITEM.equals(mode) || LblChargeMode.FLAT.equals(mode) || LblChargeMode.ALWAYS.equals(mode)
|
||||
|| LblChargeMode.ZONE.equals(mode) || LblChargeMode.WEIGHT.equals(mode) || LblChargeMode.SIZE.equals(mode)
|
||||
|| LblChargeMode.RETURN.equals(mode) || LblChargeMode.MANUAL.equals(mode))
|
||||
{
|
||||
return LblChargeMode.ITEM;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
private static String summarizeChargeType(List<LblWeightBand> bands)
|
||||
{
|
||||
boolean firstExtra = false;
|
||||
boolean unitKg = false;
|
||||
for (LblWeightBand band : bands)
|
||||
{
|
||||
if (LblChargeMode.EXTRA_KG.equals(band.getChargeMode()) || LblChargeMode.FIRST_EXTRA.equals(band.getChargeMode()))
|
||||
{
|
||||
firstExtra = true;
|
||||
}
|
||||
String unit = nz(band.getPriceUnit()).toUpperCase(Locale.ROOT);
|
||||
if (unit.contains("KG") || unit.contains("公斤"))
|
||||
{
|
||||
unitKg = true;
|
||||
}
|
||||
if (LblFeeType.REGISTRATION.equals(band.getFeeType()))
|
||||
{
|
||||
unitKg = true;
|
||||
}
|
||||
}
|
||||
if (firstExtra)
|
||||
{
|
||||
return "续重计费";
|
||||
}
|
||||
if (unitKg)
|
||||
{
|
||||
return "常规计重价";
|
||||
}
|
||||
return "单票价";
|
||||
}
|
||||
|
||||
private static String zoneFeeKey(LblWeightBand band)
|
||||
{
|
||||
return nz(band.getCountryCode()) + "|" + nz(band.getZoneName()) + "|" + nz(band.getPostcodeParam()) + "|"
|
||||
+ nz(band.getSectionName()) + "|" + nz(band.getFeeType());
|
||||
}
|
||||
|
||||
private static String toZoneCode(String zoneName)
|
||||
{
|
||||
if (zoneName == null || zoneName.trim().isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String s = zoneName.trim().toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]+", "_");
|
||||
if (s.length() > 64)
|
||||
{
|
||||
s = s.substring(0, 64);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
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());
|
||||
b.setFeeType(src.getFeeType());
|
||||
b.setCountryName(src.getCountryName());
|
||||
b.setCountryCode(src.getCountryCode());
|
||||
b.setZoneCode(src.getZoneCode());
|
||||
b.setZoneName(src.getZoneName());
|
||||
b.setPostcodeParam(src.getPostcodeParam());
|
||||
b.setWeightLabel(src.getWeightLabel());
|
||||
b.setWeightMin(src.getWeightMin());
|
||||
b.setWeightMax(src.getWeightMax());
|
||||
b.setVolumeText(src.getVolumeText());
|
||||
b.setChargeName(src.getChargeName());
|
||||
b.setChargeMode(src.getChargeMode());
|
||||
b.setCalcParam(src.getCalcParam());
|
||||
b.setPrice(src.getPrice());
|
||||
b.setPriceUnit(src.getPriceUnit());
|
||||
b.setExtraPrice(src.getExtraPrice());
|
||||
b.setExtraPriceUnit(src.getExtraPriceUnit());
|
||||
b.setSortNo(src.getSortNo());
|
||||
return b;
|
||||
}
|
||||
|
||||
private static String nz(String v)
|
||||
{
|
||||
return v == null ? "" : v.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import com.bms.common.enums.PaymentMesEnum;
|
||||
import com.bms.price.domain.LblChargeMode;
|
||||
import com.bms.price.domain.LblFeeType;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
import com.bms.price.domain.PayCostLine;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.pay.LabelArCostCalculator;
|
||||
import com.bms.price.pay.PaySurchargeRules;
|
||||
import com.bms.price.pay.PayZoneMatcher;
|
||||
|
||||
/**
|
||||
* 打单新计费:直读 {@link LblWeightBand},按 fee_type 分行 + charge_mode(=calc_rule)。
|
||||
* 附加费仍复用 {@link LabelArCostCalculator#appendSurcharges}。
|
||||
*/
|
||||
public final class LblCostCalculator
|
||||
{
|
||||
private static final Set<Integer> REFUND_STATUS_SET = Set.of(9, 10);
|
||||
|
||||
private LblCostCalculator()
|
||||
{
|
||||
}
|
||||
|
||||
public static PayOrderCostResult calculate(LblProduct product, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Date bizDate, Integer orderStatus)
|
||||
{
|
||||
PayOrderCostResult result = new PayOrderCostResult();
|
||||
result.setFees(new ArrayList<PayCostLine>());
|
||||
result.setSkipped(new ArrayList<String>());
|
||||
if (product == null)
|
||||
{
|
||||
result.setMessage(PaymentMesEnum.BMS_PAY_NO_PRODUCT.getCnMes());
|
||||
return result;
|
||||
}
|
||||
result.setProductId(product.getProductId());
|
||||
result.setProductName(product.getProductName());
|
||||
if (weight == null || weight.compareTo(BigDecimal.ZERO) <= 0)
|
||||
{
|
||||
result.setMessage(PaymentMesEnum.BMS_PAY_NO_WEIGHT.getCnMes());
|
||||
return result;
|
||||
}
|
||||
|
||||
List<LblWeightBand> all = product.getWeightBands() == null ? List.of() : product.getWeightBands();
|
||||
Set<String> zones = zoneNames(all);
|
||||
if (zones.size() > 1 && (zoneName == null || zoneName.isBlank()))
|
||||
{
|
||||
result.setMessage("产品「" + nz(product.getProductName()) + "」有多个地区("
|
||||
+ String.join("、", zones) + "),邮编没有对上其中的地区,无法确定运费");
|
||||
return result;
|
||||
}
|
||||
|
||||
String currency = nz(product.getCurrency());
|
||||
if (currency.isEmpty())
|
||||
{
|
||||
currency = "EUR";
|
||||
}
|
||||
|
||||
BigDecimal freight = BigDecimal.ZERO;
|
||||
String freightSection = "";
|
||||
freight = addFeeGroup(result, all, LblFeeType.FREIGHT, weight, length, width, height, postcode, zoneName,
|
||||
orderStatus, currency, true);
|
||||
if (result.getMessage() != null && !result.getMessage().isEmpty() && freight.compareTo(BigDecimal.ZERO) == 0
|
||||
&& result.getFees().isEmpty())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
if ("BASIC_FREIGHT".equals(fee.getFeeType()))
|
||||
{
|
||||
freightSection = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
addFeeGroup(result, all, LblFeeType.REGISTRATION, weight, length, width, height, postcode, zoneName,
|
||||
orderStatus, currency, false);
|
||||
addFeeGroup(result, all, LblFeeType.REMOTE, weight, length, width, height, postcode, zoneName,
|
||||
orderStatus, currency, false);
|
||||
|
||||
if (freight.compareTo(BigDecimal.ZERO) == 0)
|
||||
{
|
||||
boolean hasFreightLine = false;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
if ("BASIC_FREIGHT".equals(fee.getFeeType()))
|
||||
{
|
||||
hasFreightLine = true;
|
||||
freight = freight.add(fee.getAmount() == null ? BigDecimal.ZERO : fee.getAmount());
|
||||
}
|
||||
}
|
||||
if (!hasFreightLine)
|
||||
{
|
||||
result.setMessage(outOfRange(product, all, weight, zoneName));
|
||||
result.getFees().clear();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result.setCurrency(currency);
|
||||
PayProduct pay = LblProductPayAdapter.toPayProductForSurcharge(product);
|
||||
LabelArCostCalculator.appendSurcharges(pay, weight, length, width, height, postcode, zoneName, bizDate,
|
||||
orderStatus, freight, currency, freightSection, null, result);
|
||||
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (PayCostLine fee : result.getFees())
|
||||
{
|
||||
if (fee != null && fee.getAmount() != null)
|
||||
{
|
||||
total = total.add(fee.getAmount());
|
||||
}
|
||||
}
|
||||
result.setPayTotal(total.setScale(2, RoundingMode.HALF_UP));
|
||||
result.setMessage(summary(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FREIGHT 组金额汇总;其它组返回 ZERO
|
||||
*/
|
||||
private static BigDecimal addFeeGroup(PayOrderCostResult result, List<LblWeightBand> all, String feeType,
|
||||
BigDecimal weight, BigDecimal length, BigDecimal width, BigDecimal height, String postcode, String zoneName,
|
||||
Integer orderStatus, String currency, boolean required)
|
||||
{
|
||||
List<LblWeightBand> candidates = filterCandidates(all, feeType, weight, zoneName);
|
||||
LblWeightBand best = pickBest(candidates, weight, postcode, zoneName, length, width, height, orderStatus);
|
||||
if (best == null)
|
||||
{
|
||||
if (required)
|
||||
{
|
||||
// message set by caller
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
if (!modeApplies(best, weight, length, width, height, postcode, zoneName, orderStatus))
|
||||
{
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
BigDecimal amount = amountOf(best, weight);
|
||||
if (amount == null)
|
||||
{
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
amount = amount.setScale(2, RoundingMode.HALF_UP);
|
||||
String quoteType = quoteFeeType(feeType);
|
||||
String feeName = blank(best.getChargeName(), defaultFeeName(feeType));
|
||||
String remark = nz(best.getWeightLabel()) + " " + plain(best.getPrice()) + " " + nz(best.getPriceUnit());
|
||||
if (zoneName != null && !zoneName.isBlank())
|
||||
{
|
||||
remark = remark + ",地区 " + zoneName.replace('\n', ' ');
|
||||
}
|
||||
result.getFees().add(line(quoteType, feeName, 0L, amount, currency, remark.trim()));
|
||||
return LblFeeType.FREIGHT.equals(feeType) ? amount : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private static List<LblWeightBand> filterCandidates(List<LblWeightBand> all, String feeType, BigDecimal weight,
|
||||
String zoneName)
|
||||
{
|
||||
List<LblWeightBand> out = new ArrayList<LblWeightBand>();
|
||||
for (LblWeightBand band : all)
|
||||
{
|
||||
if (band == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String ft = nz(band.getFeeType());
|
||||
if (ft.isEmpty())
|
||||
{
|
||||
ft = LblFeeType.FREIGHT;
|
||||
}
|
||||
if (!feeType.equals(ft))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String mode = migrateMode(band.getChargeMode());
|
||||
boolean zoned = !nz(band.getZoneName()).isEmpty() || !nz(band.getZoneCode()).isEmpty();
|
||||
boolean postcodeDriven = LblChargeMode.POSTCODE.equals(mode)
|
||||
|| ((LblChargeMode.EXTRA_KG.equals(mode) || LblFeeType.REMOTE.equals(ft))
|
||||
&& !nz(band.getPostcodeParam()).isEmpty());
|
||||
if (zoned && zoneName != null && !zoneName.isBlank() && !postcodeDriven)
|
||||
{
|
||||
if (!PayZoneMatcher.sameZone(band.getZoneName(), zoneName)
|
||||
&& !PayZoneMatcher.sameZone(band.getZoneCode(), zoneName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (LblChargeMode.EXTRA_KG.equals(mode))
|
||||
{
|
||||
out.add(band);
|
||||
continue;
|
||||
}
|
||||
if (band.getWeightMin() != null && weight.compareTo(band.getWeightMin()) < 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (band.getWeightMax() != null && weight.compareTo(band.getWeightMax()) > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
out.add(band);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private static LblWeightBand pickBest(List<LblWeightBand> candidates, BigDecimal weight, String postcode,
|
||||
String zoneName, BigDecimal length, BigDecimal width, BigDecimal height, Integer orderStatus)
|
||||
{
|
||||
List<LblWeightBand> ok = new ArrayList<LblWeightBand>();
|
||||
for (LblWeightBand band : candidates)
|
||||
{
|
||||
if (modeApplies(band, weight, length, width, height, postcode, zoneName, orderStatus))
|
||||
{
|
||||
ok.add(band);
|
||||
}
|
||||
}
|
||||
if (ok.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ok.sort(Comparator.comparingInt(LblCostCalculator::specificity).reversed());
|
||||
return ok.get(0);
|
||||
}
|
||||
|
||||
private static int specificity(LblWeightBand band)
|
||||
{
|
||||
int score = 0;
|
||||
if (!nz(band.getZoneName()).isEmpty() || !nz(band.getZoneCode()).isEmpty())
|
||||
{
|
||||
score += 4;
|
||||
}
|
||||
if (!nz(band.getPostcodeParam()).isEmpty())
|
||||
{
|
||||
score += 2;
|
||||
}
|
||||
if (band.getWeightMin() != null || band.getWeightMax() != null)
|
||||
{
|
||||
score += 1;
|
||||
}
|
||||
return score;
|
||||
}
|
||||
|
||||
private static boolean modeApplies(LblWeightBand band, BigDecimal weight, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, String postcode, String zoneName, Integer orderStatus)
|
||||
{
|
||||
String mode = migrateMode(band.getChargeMode());
|
||||
if (LblChargeMode.POSTCODE.equals(mode))
|
||||
{
|
||||
return LblSurchargeRules.matchesPostcode(band.getPostcodeParam(), postcode)
|
||||
|| PaySurchargeRules.matchesPostcode(band.getPostcodeParam(), postcode);
|
||||
}
|
||||
if (LblChargeMode.EXTRA_KG.equals(mode))
|
||||
{
|
||||
if (!nz(band.getPostcodeParam()).isEmpty()
|
||||
&& !PaySurchargeRules.matchesPostcode(band.getPostcodeParam(), postcode)
|
||||
&& !LblSurchargeRules.matchesPostcode(band.getPostcodeParam(), postcode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// ITEM / PER_KG:维度筛选后即适用
|
||||
return true;
|
||||
}
|
||||
|
||||
private static BigDecimal amountOf(LblWeightBand band, BigDecimal weight)
|
||||
{
|
||||
String mode = migrateMode(band.getChargeMode());
|
||||
if (LblChargeMode.EXTRA_KG.equals(mode))
|
||||
{
|
||||
BigDecimal first = firstKg(band);
|
||||
BigDecimal base = band.getPrice() == null ? BigDecimal.ZERO : band.getPrice();
|
||||
BigDecimal extra = band.getExtraPrice() == null ? BigDecimal.ZERO : band.getExtraPrice();
|
||||
if (weight == null)
|
||||
{
|
||||
return base;
|
||||
}
|
||||
BigDecimal over = weight.subtract(first);
|
||||
if (over.compareTo(BigDecimal.ZERO) < 0)
|
||||
{
|
||||
over = BigDecimal.ZERO;
|
||||
}
|
||||
return base.add(extra.multiply(over));
|
||||
}
|
||||
if (band.getPrice() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (LblChargeMode.PER_KG.equals(mode))
|
||||
{
|
||||
return band.getPrice().multiply(weight);
|
||||
}
|
||||
// ITEM / POSTCODE:按票
|
||||
return band.getPrice();
|
||||
}
|
||||
|
||||
private static BigDecimal firstKg(LblWeightBand band)
|
||||
{
|
||||
if (band.getCalcParam() != null && !band.getCalcParam().isBlank())
|
||||
{
|
||||
try
|
||||
{
|
||||
return new BigDecimal(band.getCalcParam().trim());
|
||||
}
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (band.getWeightMax() != null)
|
||||
{
|
||||
return band.getWeightMax();
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
private static boolean perKilogram(LblWeightBand band)
|
||||
{
|
||||
String unit = nz(band.getPriceUnit()).toUpperCase(Locale.ROOT);
|
||||
return unit.contains("KG") || unit.contains("公斤") || unit.contains("千克");
|
||||
}
|
||||
|
||||
private static String migrateMode(String mode)
|
||||
{
|
||||
if (mode == null || mode.isEmpty())
|
||||
{
|
||||
return LblChargeMode.ITEM;
|
||||
}
|
||||
if (LblChargeMode.FIRST_EXTRA.equals(mode))
|
||||
{
|
||||
return LblChargeMode.EXTRA_KG;
|
||||
}
|
||||
if (LblChargeMode.UNIT_PLUS_HANDLE.equals(mode))
|
||||
{
|
||||
return LblChargeMode.PER_KG;
|
||||
}
|
||||
if (LblChargeMode.FLAT.equals(mode) || LblChargeMode.ALWAYS.equals(mode) || LblChargeMode.ZONE.equals(mode)
|
||||
|| LblChargeMode.WEIGHT.equals(mode) || LblChargeMode.SIZE.equals(mode) || LblChargeMode.RETURN.equals(mode)
|
||||
|| LblChargeMode.MANUAL.equals(mode))
|
||||
{
|
||||
return LblChargeMode.ITEM;
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
private static String quoteFeeType(String feeType)
|
||||
{
|
||||
if (LblFeeType.REGISTRATION.equals(feeType))
|
||||
{
|
||||
return "REGISTRATION_FEE";
|
||||
}
|
||||
if (LblFeeType.REMOTE.equals(feeType))
|
||||
{
|
||||
return "SURCHARGE";
|
||||
}
|
||||
return "BASIC_FREIGHT";
|
||||
}
|
||||
|
||||
private static String defaultFeeName(String feeType)
|
||||
{
|
||||
if (LblFeeType.REGISTRATION.equals(feeType))
|
||||
{
|
||||
return "处理费";
|
||||
}
|
||||
if (LblFeeType.REMOTE.equals(feeType))
|
||||
{
|
||||
return "偏远费";
|
||||
}
|
||||
return "基础运费";
|
||||
}
|
||||
|
||||
private static Set<String> zoneNames(List<LblWeightBand> bands)
|
||||
{
|
||||
Set<String> zones = new LinkedHashSet<String>();
|
||||
for (LblWeightBand band : bands)
|
||||
{
|
||||
if (band != null && band.getZoneName() != null && !band.getZoneName().isBlank())
|
||||
{
|
||||
zones.add(band.getZoneName().trim());
|
||||
}
|
||||
}
|
||||
return zones;
|
||||
}
|
||||
|
||||
private static String outOfRange(LblProduct product, List<LblWeightBand> bands, BigDecimal weight, String zoneName)
|
||||
{
|
||||
String name = nz(product.getProductName());
|
||||
List<LblWeightBand> freight = filterCandidates(bands, LblFeeType.FREIGHT, weight, zoneName);
|
||||
if (freight.isEmpty())
|
||||
{
|
||||
// try without weight filter for message
|
||||
int n = 0;
|
||||
BigDecimal max = null;
|
||||
for (LblWeightBand band : bands)
|
||||
{
|
||||
if (band == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String ft = nz(band.getFeeType());
|
||||
if (!ft.isEmpty() && !LblFeeType.FREIGHT.equals(ft))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
n++;
|
||||
if (band.getWeightMax() != null && (max == null || band.getWeightMax().compareTo(max) > 0))
|
||||
{
|
||||
max = band.getWeightMax();
|
||||
}
|
||||
}
|
||||
if (n == 0)
|
||||
{
|
||||
return "产品「" + name + "」没有可匹配的重量段";
|
||||
}
|
||||
if (max != null && weight.compareTo(max) > 0)
|
||||
{
|
||||
return "计费重 " + plain(weight) + "kg 超出「" + name + "」的重量段,最大 " + plain(max) + "kg";
|
||||
}
|
||||
}
|
||||
return "计费重 " + plain(weight) + "kg 没有落在「" + name + "」的重量段里";
|
||||
}
|
||||
|
||||
private static String summary(PayOrderCostResult result)
|
||||
{
|
||||
if (result.getFees() == null || result.getFees().isEmpty())
|
||||
{
|
||||
return nz(result.getMessage());
|
||||
}
|
||||
return "计费成功,共 " + result.getFees().size() + " 项";
|
||||
}
|
||||
|
||||
private static PayCostLine line(String feeType, String feeName, long scId, BigDecimal amount, String currency,
|
||||
String remark)
|
||||
{
|
||||
PayCostLine line = new PayCostLine();
|
||||
line.setFeeType(feeType);
|
||||
line.setFeeName(feeName);
|
||||
line.setScId(scId);
|
||||
line.setAmount(amount);
|
||||
line.setCurrency(currency);
|
||||
line.setRemark(remark);
|
||||
return line;
|
||||
}
|
||||
|
||||
private static String blank(String v, String fallback)
|
||||
{
|
||||
return v == null || v.trim().isEmpty() ? fallback : v.trim();
|
||||
}
|
||||
|
||||
private static String nz(String v)
|
||||
{
|
||||
return v == null ? "" : v.trim();
|
||||
}
|
||||
|
||||
private static String plain(BigDecimal v)
|
||||
{
|
||||
return v == null ? "" : v.stripTrailingZeros().toPlainString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblSurcharge;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PaySurcharge;
|
||||
import com.bms.price.domain.PayWeightBand;
|
||||
|
||||
/**
|
||||
* 兼容适配:打单产品转 PayProduct(附加费/旧对照)。
|
||||
* 计费主路请用 {@link LblCostCalculator}。
|
||||
*/
|
||||
public final class LblProductPayAdapter
|
||||
{
|
||||
private LblProductPayAdapter()
|
||||
{
|
||||
}
|
||||
|
||||
public static PayProduct toPayProduct(LblProduct src)
|
||||
{
|
||||
if (src == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
PayProduct p = new PayProduct();
|
||||
p.setProductId(src.getProductId());
|
||||
p.setProductName(src.getProductName());
|
||||
p.setDictValue(src.getDictValue());
|
||||
p.setChargeType(src.getChargeType());
|
||||
p.setExtraPerKg(src.getExtraPerKg());
|
||||
p.setCurrency(src.getCurrency());
|
||||
p.setCountryScope(src.getCountryScope());
|
||||
p.setTermId(src.getVersionId());
|
||||
p.setVersionNo(src.getVersionNo());
|
||||
p.setEffectiveDate(src.getEffectiveDate());
|
||||
p.setTermStart(src.getVersionStart());
|
||||
p.setTermEnd(src.getVersionEnd());
|
||||
List<PayWeightBand> bands = new ArrayList<PayWeightBand>();
|
||||
if (src.getWeightBands() != null)
|
||||
{
|
||||
for (LblWeightBand band : src.getWeightBands())
|
||||
{
|
||||
if (band == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bands.add(toBand(band, blank(band.getChargeName(), "派送费"), band.getPrice(), band.getPriceUnit()));
|
||||
}
|
||||
}
|
||||
p.setWeightBands(bands);
|
||||
p.setSurcharges(toSurcharges(src));
|
||||
return p;
|
||||
}
|
||||
|
||||
/** 仅转附加费,供新计费追加附加费。 */
|
||||
public static PayProduct toPayProductForSurcharge(LblProduct src)
|
||||
{
|
||||
PayProduct p = toPayProduct(src);
|
||||
if (p != null)
|
||||
{
|
||||
p.setWeightBands(new ArrayList<PayWeightBand>());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private static List<PaySurcharge> toSurcharges(LblProduct src)
|
||||
{
|
||||
List<PaySurcharge> fees = new ArrayList<PaySurcharge>();
|
||||
if (src.getSurcharges() == null)
|
||||
{
|
||||
return fees;
|
||||
}
|
||||
for (LblSurcharge fee : src.getSurcharges())
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PaySurcharge s = new PaySurcharge();
|
||||
s.setSurchargeId(fee.getSurchargeId());
|
||||
s.setProductId(fee.getProductId());
|
||||
s.setTermId(fee.getVersionId());
|
||||
s.setFeeName(fee.getFeeName());
|
||||
s.setScId(fee.getScId());
|
||||
s.setZoneName(fee.getZoneName());
|
||||
s.setChargeText(fee.getChargeText());
|
||||
s.setAmount(fee.getAmount());
|
||||
s.setCurrency(fee.getCurrency());
|
||||
s.setPriceUnit(fee.getPriceUnit());
|
||||
s.setFeeDesc(fee.getFeeDesc());
|
||||
s.setPeriodText(fee.getPeriodText());
|
||||
s.setEffectiveStart(fee.getEffectiveStart());
|
||||
s.setEffectiveEnd(fee.getEffectiveEnd());
|
||||
s.setChargeTiming(fee.getChargeTiming());
|
||||
s.setCalcRule(fee.getCalcRule());
|
||||
s.setCalcParam(fee.getCalcParam());
|
||||
s.setPostcodeParam(fee.getPostcodeParam());
|
||||
s.setWeightMin(fee.getWeightMin());
|
||||
s.setWeightMax(fee.getWeightMax());
|
||||
s.setSortNo(fee.getSortNo());
|
||||
fees.add(s);
|
||||
}
|
||||
return fees;
|
||||
}
|
||||
|
||||
private static PayWeightBand toBand(LblWeightBand src, String chargeName, java.math.BigDecimal price, String unit)
|
||||
{
|
||||
PayWeightBand b = new PayWeightBand();
|
||||
b.setProductId(src.getProductId());
|
||||
b.setTermId(src.getVersionId());
|
||||
b.setSectionName(src.getSectionName());
|
||||
b.setCountryName(src.getCountryName());
|
||||
b.setCountryCode(src.getCountryCode());
|
||||
b.setZoneName(blank(src.getZoneName(), src.getZoneCode()));
|
||||
b.setWeightLabel(src.getWeightLabel());
|
||||
b.setWeightMin(src.getWeightMin());
|
||||
b.setWeightMax(src.getWeightMax());
|
||||
b.setVolumeText(src.getVolumeText());
|
||||
b.setChargeName(chargeName);
|
||||
b.setPrice(price);
|
||||
b.setPriceUnit(unit);
|
||||
b.setSortNo(src.getSortNo());
|
||||
return b;
|
||||
}
|
||||
|
||||
private static String blank(String v, String fallback)
|
||||
{
|
||||
return v == null || v.trim().isEmpty() ? fallback : v.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,617 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.bms.price.domain.LblSurcharge;
|
||||
|
||||
/**
|
||||
* 把附加费说明收成可计算的条件。认不出的标为暂不计费,避免把签名、重复单号当成每票必收。
|
||||
*/
|
||||
public final class LblSurchargeRules
|
||||
{
|
||||
public static final String ALWAYS = "ALWAYS";
|
||||
|
||||
public static final String POSTCODE = "POSTCODE";
|
||||
|
||||
public static final String WEIGHT = "WEIGHT";
|
||||
|
||||
public static final String SIZE = "SIZE";
|
||||
|
||||
public static final String RETURN = "RETURN";
|
||||
|
||||
public static final String MANUAL = "MANUAL";
|
||||
|
||||
/** 超过重量段上限后,按超出的公斤数乘单价 */
|
||||
public static final String EXTRA_KG = "EXTRA_KG";
|
||||
|
||||
/** 邮编已经落到这个分区,再按重量区间收取,例如英国高地 */
|
||||
public static final String ZONE = "ZONE";
|
||||
|
||||
private static final Pattern REMOTE_PREFIX = Pattern.compile("(\\d{1,5}(?:\\s*[、,,]\\s*\\d{1,5})*)\\s*邮编");
|
||||
|
||||
private static final Pattern RANGE = Pattern.compile("([A-Z]{1,2})(\\d{1,2})\\s*-\\s*(\\d{1,2})");
|
||||
|
||||
private static final Pattern DISTRICT = Pattern.compile("([A-Z]{1,2})(\\d{1,2})");
|
||||
|
||||
private static final Pattern AREA = Pattern.compile("^[A-Z]{1,2}$");
|
||||
|
||||
private static final Pattern UK_FULL = Pattern.compile("^([A-Z]{1,2})(\\d{1,2})[A-Z]?\\d[A-Z]{2}$");
|
||||
|
||||
private static final Pattern UK_OUTWARD = Pattern.compile("^([A-Z]{1,2})(\\d{1,2})$");
|
||||
|
||||
private static final Pattern BOX = Pattern.compile("(\\d+(?:\\.\\d+)?)\\s*\\*\\s*(\\d+(?:\\.\\d+)?)\\s*\\*\\s*(\\d+(?:\\.\\d+)?)");
|
||||
|
||||
private static final Pattern VOLUME = Pattern.compile("(?i)(\\d+(?:\\.\\d+)?)\\s*(?:m3|m³|立方米)");
|
||||
|
||||
private static final Pattern CM = Pattern.compile("(\\d+(?:\\.\\d+)?)\\s*(?:cm|厘米)");
|
||||
|
||||
private static final Pattern KG = Pattern.compile("(?i)(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤|千克)");
|
||||
|
||||
private LblSurchargeRules()
|
||||
{
|
||||
}
|
||||
|
||||
public static void apply(LblSurcharge fee)
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String name = fee.getFeeName() == null ? "" : fee.getFeeName();
|
||||
String desc = fee.getFeeDesc() == null ? "" : fee.getFeeDesc();
|
||||
String charge = fee.getChargeText() == null ? "" : fee.getChargeText();
|
||||
String blob = name + " " + desc + " " + charge;
|
||||
if (name.contains("报价说明"))
|
||||
{
|
||||
fee.setCalcRule(MANUAL);
|
||||
return;
|
||||
}
|
||||
if (name.contains("退件"))
|
||||
{
|
||||
fee.setCalcRule(RETURN);
|
||||
return;
|
||||
}
|
||||
if (name.contains("签名") || name.contains("重复") || name.contains("未预报") || name.contains("重新贴"))
|
||||
{
|
||||
fee.setCalcRule("ITEM");
|
||||
return;
|
||||
}
|
||||
String postcodes = postcodeParam(desc);
|
||||
if (name.contains("偏远") && !postcodes.isEmpty())
|
||||
{
|
||||
fee.setCalcRule(POSTCODE);
|
||||
fee.setCalcParam(postcodes);
|
||||
return;
|
||||
}
|
||||
Matcher kg = KG.matcher(blob);
|
||||
if ((name.contains("超重") || blob.contains("重量>") || blob.toLowerCase(Locale.ROOT).contains("weight")) && kg.find())
|
||||
{
|
||||
fee.setCalcRule(WEIGHT);
|
||||
fee.setCalcParam(kg.group(1));
|
||||
return;
|
||||
}
|
||||
String size = sizeParam(blob);
|
||||
if (!size.isEmpty() && (name.contains("超大") || name.contains("超尺寸") || name.contains("特大") || blob.contains("厘米") || blob.toLowerCase(Locale.ROOT).contains("cm")))
|
||||
{
|
||||
fee.setCalcRule(SIZE);
|
||||
fee.setCalcParam(size);
|
||||
return;
|
||||
}
|
||||
if (blob.contains("固定收取") || "固定收取".equals(fee.getChargeTiming()))
|
||||
{
|
||||
fee.setCalcRule("ITEM");
|
||||
return;
|
||||
}
|
||||
fee.setCalcRule("ITEM");
|
||||
}
|
||||
|
||||
public static boolean matchesPostcode(String param, String postcode)
|
||||
{
|
||||
if (param == null || param.isBlank() || postcode == null || postcode.isBlank())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
UkPostcode parsed = parseUk(postcode);
|
||||
String digits = postcode.replaceAll("\\D", "");
|
||||
for (String token : param.split(","))
|
||||
{
|
||||
String value = token.trim().toUpperCase(Locale.ROOT);
|
||||
if (value.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String compact = value.replaceAll("[^A-Z0-9]", "");
|
||||
String whole = postcode.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
if (!compact.isEmpty() && compact.equals(whole))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (parsed != null && tokenMatches(value, parsed))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (parsed == null && value.matches("\\d{1,5}") && !digits.isEmpty())
|
||||
{
|
||||
boolean full = value.length() >= 4 ? digits.equals(value) : digits.startsWith(value);
|
||||
if (full)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 从“07邮编开头”“35、38邮编开头”取出数字前缀。没有邮编字样时不猜。 */
|
||||
public static String remotePrefixes(String text)
|
||||
{
|
||||
if (text == null || !text.contains("邮编"))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
List<String> tokens = new ArrayList<>();
|
||||
Matcher matcher = REMOTE_PREFIX.matcher(text);
|
||||
while (matcher.find())
|
||||
{
|
||||
for (String part : matcher.group(1).split("[、,,\\s]+"))
|
||||
{
|
||||
if (part.matches("\\d{1,5}") && !tokens.contains(part))
|
||||
{
|
||||
tokens.add(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.join(",", tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按附加费配置里的超尺寸明细判断。上限表示超过这个值才命中。箱规按从大到小比,任一边超过对应边即命中。
|
||||
*/
|
||||
public static boolean matchesConfiguredSize(java.util.Map<String, Object> detail, BigDecimal length, BigDecimal width,
|
||||
BigDecimal height, BigDecimal weight)
|
||||
{
|
||||
if (detail == null || detail.isEmpty() || length == null || width == null || height == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BigDecimal weightMin = number(detail.get("weightMin"));
|
||||
BigDecimal weightMax = number(detail.get("weightMax"));
|
||||
if (weightMin != null || weightMax != null)
|
||||
{
|
||||
if (weight == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (weightMin != null && weight.compareTo(weightMin) <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (weightMax != null && weight.compareTo(weightMax) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
BigDecimal[] sides = desc(length, width, height);
|
||||
List<Boolean> checks = new ArrayList<>();
|
||||
addBound(checks, sides[0], detail.get("longestMin"), detail.get("longestMax"));
|
||||
addBound(checks, sides[1], detail.get("secondMin"), detail.get("secondMax"));
|
||||
addBound(checks, length.add(width).add(height), detail.get("sumMin"), detail.get("sumMax"));
|
||||
addBound(checks, sides[0].add(sides[1].add(sides[2]).multiply(new BigDecimal("2"))), detail.get("girthMin"), detail.get("girthMax"));
|
||||
BigDecimal volumeMin = number(detail.get("volumeMin"));
|
||||
BigDecimal volumeMax = number(detail.get("volumeMax"));
|
||||
if (volumeMin != null || volumeMax != null)
|
||||
{
|
||||
BigDecimal cubic = length.multiply(width).multiply(height).divide(new BigDecimal("1000000"), 6, RoundingMode.HALF_UP);
|
||||
addBound(checks, cubic, volumeMin, volumeMax);
|
||||
}
|
||||
BigDecimal cubicMax = number(detail.get("cubicMax"));
|
||||
if (cubicMax != null)
|
||||
{
|
||||
checks.add(length.multiply(width).multiply(height).compareTo(cubicMax) > 0);
|
||||
}
|
||||
BigDecimal boxLength = number(detail.get("boxLength"));
|
||||
BigDecimal boxWidth = number(detail.get("boxWidth"));
|
||||
BigDecimal boxHeight = number(detail.get("boxHeight"));
|
||||
if (boxLength != null && boxWidth != null && boxHeight != null)
|
||||
{
|
||||
boolean under = "UNDER".equals(String.valueOf(detail.get("boxMode")));
|
||||
checks.add(under ? withinBox(sides, boxLength, boxWidth, boxHeight) : exceedsBox(sides, boxLength, boxWidth, boxHeight));
|
||||
}
|
||||
if (checks.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ("ALL".equals(String.valueOf(detail.get("matchMode"))))
|
||||
{
|
||||
return !checks.contains(Boolean.FALSE);
|
||||
}
|
||||
return checks.contains(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/** 每票都收。写了费用名的规则只约束这一项;带生效月日的规则只在这段日期内收取。 */
|
||||
public static boolean allowsAlways(List<java.util.Map<String, Object>> details, String feeName, java.util.Date bizDate)
|
||||
{
|
||||
if (details == null || details.isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
String name = feeName == null ? "" : feeName.trim();
|
||||
List<java.util.Map<String, Object>> named = new ArrayList<>();
|
||||
List<java.util.Map<String, Object>> shared = new ArrayList<>();
|
||||
for (java.util.Map<String, Object> detail : details)
|
||||
{
|
||||
if (detail == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String ruleName = detail.get("feeName") == null ? "" : String.valueOf(detail.get("feeName")).trim();
|
||||
if (ruleName.isEmpty())
|
||||
{
|
||||
shared.add(detail);
|
||||
}
|
||||
else if (ruleName.equals(name))
|
||||
{
|
||||
named.add(detail);
|
||||
}
|
||||
}
|
||||
List<java.util.Map<String, Object>> mine = named.isEmpty() ? shared : named;
|
||||
if (mine.isEmpty())
|
||||
{
|
||||
return shared.isEmpty();
|
||||
}
|
||||
java.time.LocalDate day = bizDate == null ? null : bizDate.toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDate();
|
||||
for (java.util.Map<String, Object> detail : mine)
|
||||
{
|
||||
if (!hasPeriod(detail))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (day != null && inPeriod(day, detail))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void addBound(List<Boolean> checks, BigDecimal actual, Object min, Object max)
|
||||
{
|
||||
BigDecimal lower = min instanceof BigDecimal ? (BigDecimal) min : number(min);
|
||||
BigDecimal upper = max instanceof BigDecimal ? (BigDecimal) max : number(max);
|
||||
if (lower == null && upper == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (lower != null && upper != null)
|
||||
{
|
||||
checks.add(actual.compareTo(lower) > 0 && actual.compareTo(upper) <= 0);
|
||||
}
|
||||
else if (upper != null)
|
||||
{
|
||||
checks.add(actual.compareTo(upper) > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
checks.add(actual.compareTo(lower) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean withinBox(BigDecimal[] parcel, BigDecimal a, BigDecimal b, BigDecimal c)
|
||||
{
|
||||
BigDecimal[] limit = desc(a, b, c);
|
||||
return parcel[0].compareTo(limit[0]) < 0 && parcel[1].compareTo(limit[1]) < 0 && parcel[2].compareTo(limit[2]) < 0;
|
||||
}
|
||||
|
||||
private static boolean hasPeriod(java.util.Map<String, Object> detail)
|
||||
{
|
||||
return text(detail.get("periodStart")) != null || text(detail.get("periodEnd")) != null;
|
||||
}
|
||||
|
||||
private static boolean inPeriod(java.time.LocalDate day, java.util.Map<String, Object> detail)
|
||||
{
|
||||
int[] start = monthDay(text(detail.get("periodStart")));
|
||||
int[] end = monthDay(text(detail.get("periodEnd")));
|
||||
int current = day.getMonthValue() * 100 + day.getDayOfMonth();
|
||||
int from = start == null ? 101 : start[0] * 100 + start[1];
|
||||
int to = end == null ? 1231 : end[0] * 100 + end[1];
|
||||
if (from <= to)
|
||||
{
|
||||
return current >= from && current <= to;
|
||||
}
|
||||
return current >= from || current <= to;
|
||||
}
|
||||
|
||||
private static int[] monthDay(String text)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String[] parts = text.split("-");
|
||||
try
|
||||
{
|
||||
if (parts.length == 2)
|
||||
{
|
||||
return new int[] { Integer.parseInt(parts[0]), Integer.parseInt(parts[1]) };
|
||||
}
|
||||
if (parts.length == 3)
|
||||
{
|
||||
return new int[] { Integer.parseInt(parts[1]), Integer.parseInt(parts[2]) };
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String text(Object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = String.valueOf(value).trim();
|
||||
return text.isEmpty() ? null : text;
|
||||
}
|
||||
|
||||
private static BigDecimal number(Object value)
|
||||
{
|
||||
if (value == null || (value instanceof String text && text.isBlank()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (value instanceof BigDecimal decimal)
|
||||
{
|
||||
return decimal;
|
||||
}
|
||||
try
|
||||
{
|
||||
return new BigDecimal(String.valueOf(value).trim());
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean matchesWeight(String param, BigDecimal weight)
|
||||
{
|
||||
if (param == null || param.isBlank() || weight == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
return weight.compareTo(new BigDecimal(param.trim())) > 0;
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 长宽高单位厘米。箱规按从大到小比较,体积用立方米,总和是三边相加。 */
|
||||
public static boolean matchesSize(String param, BigDecimal length, BigDecimal width, BigDecimal height)
|
||||
{
|
||||
if (param == null || param.isBlank() || length == null || width == null || height == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
BigDecimal[] sides = desc(length, width, height);
|
||||
boolean sideHit = false;
|
||||
boolean sumHit = false;
|
||||
boolean sideSeen = false;
|
||||
boolean sumSeen = false;
|
||||
String join = "or";
|
||||
for (String part : param.split(";"))
|
||||
{
|
||||
String[] pair = part.split(":", 2);
|
||||
if (pair.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String key = pair[0].trim();
|
||||
String value = pair[1].trim();
|
||||
if ("join".equals(key))
|
||||
{
|
||||
join = value;
|
||||
continue;
|
||||
}
|
||||
if ("box".equals(key))
|
||||
{
|
||||
String[] dims = value.split("\\*");
|
||||
if (dims.length == 3 && exceedsBox(sides, decimal(dims[0]), decimal(dims[1]), decimal(dims[2])))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ("volume".equals(key))
|
||||
{
|
||||
BigDecimal cubic = length.multiply(width).multiply(height)
|
||||
.divide(new BigDecimal("1000000"), 6, RoundingMode.HALF_UP);
|
||||
if (cubic.compareTo(decimal(value)) >= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ("side".equals(key))
|
||||
{
|
||||
sideSeen = true;
|
||||
sideHit = sides[0].compareTo(decimal(value)) > 0;
|
||||
}
|
||||
else if ("sum".equals(key))
|
||||
{
|
||||
sumSeen = true;
|
||||
sumHit = length.add(width).add(height).compareTo(decimal(value)) > 0;
|
||||
}
|
||||
}
|
||||
if (sideSeen || sumSeen)
|
||||
{
|
||||
if ("and".equals(join))
|
||||
{
|
||||
return (!sideSeen || sideHit) && (!sumSeen || sumHit);
|
||||
}
|
||||
return sideHit || sumHit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String postcodeParam(String desc)
|
||||
{
|
||||
if (desc == null || desc.isBlank())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
int cut = Math.max(desc.lastIndexOf(';'), desc.lastIndexOf(';'));
|
||||
String source = cut >= 0 ? desc.substring(cut + 1) : desc;
|
||||
String upper = source.replace("邮编开头", " ").toUpperCase(Locale.ROOT).replace(',', ',').replace('、', ',').replace('.', ',');
|
||||
List<String> tokens = new ArrayList<>();
|
||||
for (String raw : upper.split("[,\\s]+"))
|
||||
{
|
||||
String token = raw.trim();
|
||||
if (token.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (RANGE.matcher(token).matches() || DISTRICT.matcher(token).matches() || AREA.matcher(token).matches())
|
||||
{
|
||||
tokens.add(token);
|
||||
}
|
||||
}
|
||||
return String.join(",", tokens);
|
||||
}
|
||||
|
||||
private static String sizeParam(String blob)
|
||||
{
|
||||
StringBuilder param = new StringBuilder();
|
||||
Matcher box = BOX.matcher(blob);
|
||||
if (box.find())
|
||||
{
|
||||
param.append("box:").append(box.group(1)).append('*').append(box.group(2)).append('*').append(box.group(3));
|
||||
}
|
||||
Matcher volume = VOLUME.matcher(blob);
|
||||
if (volume.find())
|
||||
{
|
||||
if (param.length() > 0)
|
||||
{
|
||||
param.append(';');
|
||||
}
|
||||
param.append("volume:").append(volume.group(1));
|
||||
}
|
||||
List<String> cms = new ArrayList<>();
|
||||
Matcher cm = CM.matcher(blob);
|
||||
while (cm.find())
|
||||
{
|
||||
cms.add(cm.group(1));
|
||||
}
|
||||
if (cms.size() >= 1 && (blob.contains("一边") || blob.toLowerCase(Locale.ROOT).contains("length") || blob.contains("最长")))
|
||||
{
|
||||
if (param.length() > 0)
|
||||
{
|
||||
param.append(';');
|
||||
}
|
||||
param.append("side:").append(cms.get(0));
|
||||
if (cms.size() >= 2 && (blob.contains("总和") || blob.toLowerCase(Locale.ROOT).contains("sum")))
|
||||
{
|
||||
param.append(";sum:").append(cms.get(1));
|
||||
param.append(";join:").append(join(blob));
|
||||
}
|
||||
}
|
||||
return param.toString();
|
||||
}
|
||||
|
||||
private static String join(String blob)
|
||||
{
|
||||
if (blob.contains("或") || Pattern.compile("(?i)\\bor\\b").matcher(blob).find())
|
||||
{
|
||||
return "or";
|
||||
}
|
||||
return "and";
|
||||
}
|
||||
|
||||
private static boolean tokenMatches(String token, UkPostcode postcode)
|
||||
{
|
||||
Matcher range = RANGE.matcher(token);
|
||||
if (range.matches())
|
||||
{
|
||||
int low = Integer.parseInt(range.group(2));
|
||||
int high = Integer.parseInt(range.group(3));
|
||||
return postcode.area.equals(range.group(1)) && postcode.district >= low && postcode.district <= high;
|
||||
}
|
||||
Matcher district = DISTRICT.matcher(token);
|
||||
if (district.matches())
|
||||
{
|
||||
return postcode.area.equals(district.group(1)) && postcode.district == Integer.parseInt(district.group(2));
|
||||
}
|
||||
return AREA.matcher(token).matches() && postcode.area.equals(token);
|
||||
}
|
||||
|
||||
private static UkPostcode parseUk(String postcode)
|
||||
{
|
||||
if (postcode == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String compact = postcode.toUpperCase(Locale.ROOT).replaceAll("[^A-Z0-9]", "");
|
||||
Matcher full = UK_FULL.matcher(compact);
|
||||
if (full.matches())
|
||||
{
|
||||
return new UkPostcode(full.group(1), Integer.parseInt(full.group(2)));
|
||||
}
|
||||
Matcher outward = UK_OUTWARD.matcher(compact);
|
||||
if (outward.matches())
|
||||
{
|
||||
return new UkPostcode(outward.group(1), Integer.parseInt(outward.group(2)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean exceedsBox(BigDecimal[] parcel, BigDecimal a, BigDecimal b, BigDecimal c)
|
||||
{
|
||||
BigDecimal[] limit = desc(a, b, c);
|
||||
return parcel[0].compareTo(limit[0]) > 0 || parcel[1].compareTo(limit[1]) > 0 || parcel[2].compareTo(limit[2]) > 0;
|
||||
}
|
||||
|
||||
private static BigDecimal[] desc(BigDecimal a, BigDecimal b, BigDecimal c)
|
||||
{
|
||||
BigDecimal[] values = new BigDecimal[] { a, b, c };
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
for (int j = i + 1; j < values.length; j++)
|
||||
{
|
||||
if (values[j].compareTo(values[i]) > 0)
|
||||
{
|
||||
BigDecimal swap = values[i];
|
||||
values[i] = values[j];
|
||||
values[j] = swap;
|
||||
}
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private static BigDecimal decimal(String text)
|
||||
{
|
||||
return new BigDecimal(text.trim());
|
||||
}
|
||||
|
||||
private static final class UkPostcode
|
||||
{
|
||||
private final String area;
|
||||
|
||||
private final int district;
|
||||
|
||||
private UkPostcode(String area, int district)
|
||||
{
|
||||
this.area = area;
|
||||
this.district = district;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 价卡单元格里的重量段、金额和时效原文解析。供导入预览和保存共用。
|
||||
*/
|
||||
public final class LblTexts
|
||||
{
|
||||
private static final Pattern WEIGHT_RANGE = Pattern.compile(
|
||||
"(?i)(\\d+(?:\\.\\d+)?)\\s*[<<]\\s*[wW]\\s*[≤<=<]\\s*(\\d+(?:\\.\\d+)?)");
|
||||
|
||||
private static final Pattern WEIGHT_DASH = Pattern.compile(
|
||||
"(?i)(\\d+(?:\\.\\d+)?)\\s*[-~~]\\s*(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤)?");
|
||||
|
||||
private static final Pattern FIRST_WEIGHT = Pattern.compile("(?i)首重\\s*(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤)?");
|
||||
|
||||
private static final Pattern STEP_WEIGHT = Pattern.compile("(?i)每增加\\s*(\\d+(?:\\.\\d+)?)");
|
||||
|
||||
private static final Pattern ONLY_KG = Pattern.compile("(?i)^\\s*(\\d+(?:\\.\\d+)?)\\s*(?:kg|公斤)\\s*$");
|
||||
|
||||
private static final Pattern CN_PERIOD = Pattern.compile(
|
||||
"(20\\d{2})\\s*年\\s*(\\d{1,2})\\s*月\\s*(\\d{1,2})\\s*[日号]?\\s*[至到\\-~~]+\\s*(?:(20\\d{2})\\s*年\\s*)?(\\d{1,2})\\s*月\\s*(\\d{1,2})\\s*[日号]?");
|
||||
|
||||
private static final Pattern CN_MONTH = Pattern.compile(
|
||||
"(20\\d{2})\\s*年\\s*(\\d{1,2})\\s*月\\s*[至到\\-~~]+\\s*(\\d{1,2})\\s*月");
|
||||
|
||||
private static final Pattern ISO_DATE = Pattern.compile("(20\\d{2})[./-](\\d{1,2})[./-](\\d{1,2})");
|
||||
|
||||
/** 20260928-20270117 这种连在一起的日期窗口 */
|
||||
private static final Pattern COMPACT_PERIOD = Pattern.compile("(20\\d{2})(\\d{2})(\\d{2})\\s*-\\s*(20\\d{2})(\\d{2})(\\d{2})");
|
||||
|
||||
private static final Pattern EN_PERIOD = Pattern.compile(
|
||||
"(?i)(January|February|March|April|May|June|July|August|September|October|November|December)"
|
||||
+ "\\s+(\\d{1,2})\\w*\\s+to\\s+"
|
||||
+ "(January|February|March|April|May|June|July|August|September|October|November|December)"
|
||||
+ "\\s+(\\d{1,2})\\w*[,\\s]+(20\\d{2})");
|
||||
|
||||
private static final Pattern MONEY = Pattern.compile(
|
||||
"(?i)(\\d+(?:\\.\\d+)?)\\s*(EUR|GBP|USD|RMB|CNY|欧元|英镑|人民币)?");
|
||||
|
||||
private static final Pattern PERCENT = Pattern.compile("(\\d+(?:\\.\\d+)?)\\s*%");
|
||||
|
||||
private LblTexts()
|
||||
{
|
||||
}
|
||||
|
||||
/** 从重量段原文取出上下限。每增加一公斤只保留原文,不编造上下限。 */
|
||||
public static BigDecimal[] weightBounds(String label)
|
||||
{
|
||||
BigDecimal[] bounds = new BigDecimal[] { null, null };
|
||||
if (label == null || label.isBlank())
|
||||
{
|
||||
return bounds;
|
||||
}
|
||||
Matcher range = WEIGHT_RANGE.matcher(label);
|
||||
if (range.find())
|
||||
{
|
||||
bounds[0] = decimal(range.group(1));
|
||||
bounds[1] = decimal(range.group(2));
|
||||
return bounds;
|
||||
}
|
||||
Matcher dash = WEIGHT_DASH.matcher(label);
|
||||
if (dash.find())
|
||||
{
|
||||
bounds[0] = decimal(dash.group(1));
|
||||
bounds[1] = decimal(dash.group(2));
|
||||
return bounds;
|
||||
}
|
||||
Matcher first = FIRST_WEIGHT.matcher(label);
|
||||
if (first.find())
|
||||
{
|
||||
bounds[0] = BigDecimal.ZERO;
|
||||
bounds[1] = decimal(first.group(1));
|
||||
return bounds;
|
||||
}
|
||||
if (STEP_WEIGHT.matcher(label).find())
|
||||
{
|
||||
return bounds;
|
||||
}
|
||||
Matcher only = ONLY_KG.matcher(label.trim());
|
||||
if (only.find())
|
||||
{
|
||||
bounds[0] = BigDecimal.ZERO;
|
||||
bounds[1] = decimal(only.group(1));
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public static boolean looksLikeWeight(String text)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return WEIGHT_RANGE.matcher(text).find()
|
||||
|| WEIGHT_DASH.matcher(text).find()
|
||||
|| FIRST_WEIGHT.matcher(text).find()
|
||||
|| STEP_WEIGHT.matcher(text).find()
|
||||
|| ONLY_KG.matcher(text.trim()).find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从说明里取第一段时效。defaultYear 用于只有月日、没有年份的句子。
|
||||
*/
|
||||
public static Period period(String text, int defaultYear)
|
||||
{
|
||||
if (text == null || text.isBlank())
|
||||
{
|
||||
return Period.NONE;
|
||||
}
|
||||
Matcher full = CN_PERIOD.matcher(text);
|
||||
if (full.find())
|
||||
{
|
||||
int y1 = Integer.parseInt(full.group(1));
|
||||
int y2 = full.group(4) == null ? y1 : Integer.parseInt(full.group(4));
|
||||
LocalDate start = date(y1, full.group(2), full.group(3));
|
||||
LocalDate end = date(y2, full.group(5), full.group(6));
|
||||
return new Period(start, end, full.group());
|
||||
}
|
||||
Matcher month = CN_MONTH.matcher(text);
|
||||
if (month.find())
|
||||
{
|
||||
int year = Integer.parseInt(month.group(1));
|
||||
int m1 = Integer.parseInt(month.group(2));
|
||||
int m2 = Integer.parseInt(month.group(3));
|
||||
LocalDate start = LocalDate.of(year, m1, 1);
|
||||
LocalDate end = YearMonth.of(year, m2).atEndOfMonth();
|
||||
return new Period(start, end, month.group());
|
||||
}
|
||||
Matcher english = EN_PERIOD.matcher(text);
|
||||
if (english.find())
|
||||
{
|
||||
int year = Integer.parseInt(english.group(5));
|
||||
LocalDate start = date(year, monthNumber(english.group(1)), english.group(2));
|
||||
LocalDate end = date(year, monthNumber(english.group(3)), english.group(4));
|
||||
return new Period(start, end, english.group());
|
||||
}
|
||||
Matcher compact = COMPACT_PERIOD.matcher(text);
|
||||
if (compact.find())
|
||||
{
|
||||
LocalDate start = date(compact.group(1), compact.group(2), compact.group(3));
|
||||
LocalDate end = date(compact.group(4), compact.group(5), compact.group(6));
|
||||
return new Period(start, end, compact.group());
|
||||
}
|
||||
Matcher iso = ISO_DATE.matcher(text);
|
||||
if (iso.find())
|
||||
{
|
||||
LocalDate day = date(iso.group(1), iso.group(2), iso.group(3));
|
||||
return new Period(day, day, iso.group());
|
||||
}
|
||||
return Period.NONE;
|
||||
}
|
||||
|
||||
/** 去掉时效句子后再取金额,避免把 2026 当成费用。 */
|
||||
public static Money money(String text, Period period)
|
||||
{
|
||||
if (text == null || text.isBlank())
|
||||
{
|
||||
return Money.NONE;
|
||||
}
|
||||
String source = text;
|
||||
if (period != null && period.text != null)
|
||||
{
|
||||
source = source.replace(period.text, " ");
|
||||
}
|
||||
Matcher percent = PERCENT.matcher(source);
|
||||
if (percent.find() && !source.matches(".*(?i)(EUR|GBP|USD|RMB|CNY|欧元|英镑).*"))
|
||||
{
|
||||
return new Money(decimal(percent.group(1)), "", "%");
|
||||
}
|
||||
Matcher matcher = MONEY.matcher(source);
|
||||
Money found = Money.NONE;
|
||||
while (matcher.find())
|
||||
{
|
||||
String raw = matcher.group(1);
|
||||
if (raw.startsWith("20") && raw.length() == 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String currency = currency(matcher.group(2));
|
||||
String unit = unit(source);
|
||||
found = new Money(decimal(raw), currency, unit);
|
||||
if (!currency.isEmpty())
|
||||
{
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
public static String timing(String text, Period period)
|
||||
{
|
||||
String value = text == null ? "" : text;
|
||||
if (value.contains("产生时") || value.contains("实报") || value.contains("实付"))
|
||||
{
|
||||
return "产生时收取";
|
||||
}
|
||||
if (value.contains("旺季") || (period != null && period.start != null && value.contains("期间")))
|
||||
{
|
||||
return "旺季期间";
|
||||
}
|
||||
if (value.contains("固定收取") || value.contains("每票固定"))
|
||||
{
|
||||
return "固定收取";
|
||||
}
|
||||
if (period != null && period.start != null)
|
||||
{
|
||||
return "旺季期间";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String currencies(String text)
|
||||
{
|
||||
String source = text == null ? "" : text.toUpperCase(Locale.ROOT);
|
||||
StringBuilder joined = new StringBuilder();
|
||||
appendCurrency(joined, source, "GBP", "英镑");
|
||||
appendCurrency(joined, source, "EUR", "欧元");
|
||||
appendCurrency(joined, source, "USD", "美元");
|
||||
if (source.contains("RMB") || source.contains("CNY") || source.contains("人民币"))
|
||||
{
|
||||
appendCurrency(joined, "CNY", "CNY", "");
|
||||
}
|
||||
return joined.toString();
|
||||
}
|
||||
|
||||
public static Date toDate(LocalDate day)
|
||||
{
|
||||
if (day == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// 用普通日期,避免 java.sql.Date 在接口序列化时抛出不支持的时间类型
|
||||
return Date.from(day.atStartOfDay(ZoneId.of("GMT+8")).toInstant());
|
||||
}
|
||||
|
||||
private static void appendCurrency(StringBuilder joined, String source, String code, String alias)
|
||||
{
|
||||
if (source.contains(code) || (!alias.isEmpty() && source.contains(alias)))
|
||||
{
|
||||
if (joined.length() > 0)
|
||||
{
|
||||
joined.append(',');
|
||||
}
|
||||
joined.append(code);
|
||||
}
|
||||
}
|
||||
|
||||
private static String currency(String token)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String value = token.toUpperCase(Locale.ROOT);
|
||||
if (value.contains("GBP") || token.contains("英镑"))
|
||||
{
|
||||
return "GBP";
|
||||
}
|
||||
if (value.contains("EUR") || token.contains("欧元"))
|
||||
{
|
||||
return "EUR";
|
||||
}
|
||||
if (value.contains("USD") || token.contains("美元"))
|
||||
{
|
||||
return "USD";
|
||||
}
|
||||
if (value.contains("RMB") || value.contains("CNY") || token.contains("人民币"))
|
||||
{
|
||||
return "CNY";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static String unit(String text)
|
||||
{
|
||||
String value = text.toUpperCase(Locale.ROOT);
|
||||
if (value.contains("/ITEM") || value.contains("每票") || text.contains("/票") || value.contains("/PARCEL"))
|
||||
{
|
||||
return "ITEM";
|
||||
}
|
||||
if (value.contains("/KG") || text.contains("/公斤") || text.contains("每公斤"))
|
||||
{
|
||||
return "KG";
|
||||
}
|
||||
if (text.contains("/次"))
|
||||
{
|
||||
return "次";
|
||||
}
|
||||
if (text.contains("%"))
|
||||
{
|
||||
return "%";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static int monthNumber(String name)
|
||||
{
|
||||
String[] months = { "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST",
|
||||
"SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER" };
|
||||
String key = name.toUpperCase(Locale.ROOT);
|
||||
for (int i = 0; i < months.length; i++)
|
||||
{
|
||||
if (months[i].equals(key))
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static LocalDate date(String year, String month, String day)
|
||||
{
|
||||
return date(Integer.parseInt(year), month, day);
|
||||
}
|
||||
|
||||
private static LocalDate date(int year, String month, String day)
|
||||
{
|
||||
return date(year, Integer.parseInt(month), day);
|
||||
}
|
||||
|
||||
private static LocalDate date(int year, int month, String day)
|
||||
{
|
||||
return LocalDate.of(year, month, Integer.parseInt(day));
|
||||
}
|
||||
|
||||
private static BigDecimal decimal(String raw)
|
||||
{
|
||||
return new BigDecimal(raw);
|
||||
}
|
||||
|
||||
/** 一段可以落库的生效窗口。text 是原文片段。 */
|
||||
public static final class Period
|
||||
{
|
||||
public static final Period NONE = new Period(null, null, null);
|
||||
|
||||
public final LocalDate start;
|
||||
|
||||
public final LocalDate end;
|
||||
|
||||
public final String text;
|
||||
|
||||
public Period(LocalDate start, LocalDate end, String text)
|
||||
{
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
/** 收费标准里的金额。unit 为 % 时 amount 是百分数本身。 */
|
||||
public static final class Money
|
||||
{
|
||||
public static final Money NONE = new Money(null, "", "");
|
||||
|
||||
public final BigDecimal amount;
|
||||
|
||||
public final String currency;
|
||||
|
||||
public final String unit;
|
||||
|
||||
public Money(BigDecimal amount, String currency, String unit)
|
||||
{
|
||||
this.amount = amount;
|
||||
this.currency = currency == null ? "" : currency;
|
||||
this.unit = unit == null ? "" : unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,703 @@
|
||||
package com.bms.price.label;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
|
||||
/**
|
||||
* 打单价卡「邮编分区」表抽取为 zone→postcodes,保存时同步到分区管理 prc_zone。
|
||||
* 支持 Corres/双列、Colissimo Densite、CTT Density、PosteItaliane 三列、iMile IT/DE。
|
||||
*/
|
||||
public final class LblZonePostcodeAttach
|
||||
{
|
||||
private static final DataFormatter FMT = new DataFormatter(Locale.ROOT);
|
||||
private static final Pattern COUNTRY_CODE = Pattern.compile("\\(([A-Z]{2})\\)");
|
||||
private static final int MAX_ROWS = 30000;
|
||||
|
||||
private LblZonePostcodeAttach()
|
||||
{
|
||||
}
|
||||
|
||||
public static void attach(Workbook workbook, List<LblProduct> products)
|
||||
{
|
||||
if (workbook == null || products == null || products.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < workbook.getNumberOfSheets(); i++)
|
||||
{
|
||||
Sheet sheet = workbook.getSheetAt(i);
|
||||
if (sheet == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String sheetName = sheet.getSheetName() == null ? "" : sheet.getSheetName().trim();
|
||||
if (!isZonePostcodeSheet(sheetName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (sheetName.contains("iMile"))
|
||||
{
|
||||
attachImile(sheet, sheetName, products);
|
||||
continue;
|
||||
}
|
||||
Map<String, List<String>> zoneMap = parseSheet(sheet);
|
||||
if (zoneMap.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
LblProduct target = matchProduct(products, sheetName);
|
||||
if (target == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
mergeZonePostcodes(target, zoneMap);
|
||||
linkSheet(target, sheetName);
|
||||
}
|
||||
}
|
||||
|
||||
/** 从产品国家/重量段推导 ISO2,供同步 prc_zone 使用。 */
|
||||
public static String countryCodeOf(LblProduct product)
|
||||
{
|
||||
if (product == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (product.getWeightBands() != null)
|
||||
{
|
||||
for (LblWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band == null || band.getCountryCode() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String code = band.getCountryCode().trim().toUpperCase(Locale.ROOT);
|
||||
if (code.matches("[A-Z]{2}"))
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
String scope = product.getCountryScope() == null ? "" : product.getCountryScope();
|
||||
Matcher m = COUNTRY_CODE.matcher(scope.toUpperCase(Locale.ROOT));
|
||||
if (m.find())
|
||||
{
|
||||
return m.group(1);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static boolean isZonePostcodeSheet(String sheetName)
|
||||
{
|
||||
if (sheetName == null || sheetName.isBlank())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return sheetName.contains("邮编") && sheetName.contains("分区");
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> parseSheet(Sheet sheet)
|
||||
{
|
||||
Map<String, List<String>> poste = parsePosteItaliane(sheet);
|
||||
if (!poste.isEmpty())
|
||||
{
|
||||
return poste;
|
||||
}
|
||||
Map<String, List<String>> ctt = parseCtt(sheet);
|
||||
if (!ctt.isEmpty())
|
||||
{
|
||||
return ctt;
|
||||
}
|
||||
Map<String, List<String>> coli = parseColissimo(sheet);
|
||||
if (!coli.isEmpty())
|
||||
{
|
||||
return coli;
|
||||
}
|
||||
return parseTwoCol(sheet);
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> parsePosteItaliane(Sheet sheet)
|
||||
{
|
||||
Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
|
||||
int cityCol = -1;
|
||||
int provinceCol = -1;
|
||||
int ruralCol = -1;
|
||||
int headerRow = -1;
|
||||
int lastRow = Math.min(sheet.getLastRowNum(), MAX_ROWS);
|
||||
for (int r = 0; r <= Math.min(lastRow, 10); r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < row.getLastCellNum(); c++)
|
||||
{
|
||||
String val = cellText(row.getCell(c)).toLowerCase(Locale.ROOT);
|
||||
if (val.contains("city") && cityCol < 0)
|
||||
{
|
||||
cityCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
else if (val.contains("province") && provinceCol < 0)
|
||||
{
|
||||
provinceCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
else if (val.contains("rural") && ruralCol < 0)
|
||||
{
|
||||
ruralCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
}
|
||||
if (cityCol >= 0 && provinceCol >= 0 && ruralCol >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cityCol < 0 || provinceCol < 0 || ruralCol < 0 || headerRow < 0)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
int dataStart = headerRow + 1;
|
||||
Row sub = sheet.getRow(headerRow + 1);
|
||||
if (sub != null)
|
||||
{
|
||||
String subLine = cellText(sub.getCell(cityCol)) + cellText(sub.getCell(provinceCol))
|
||||
+ cellText(sub.getCell(ruralCol));
|
||||
if (subLine.contains("邮编"))
|
||||
{
|
||||
dataStart = headerRow + 2;
|
||||
}
|
||||
}
|
||||
for (int r = dataStart; r <= lastRow; r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
addPrefix(map, "City", cellText(row.getCell(cityCol)), 3);
|
||||
addPrefix(map, "Province", cellText(row.getCell(provinceCol)), 3);
|
||||
addPrefix(map, "Rural", cellText(row.getCell(ruralCol)), 5);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void addPrefix(Map<String, List<String>> map, String zone, String raw, int pad)
|
||||
{
|
||||
String postcode = normalizePostcode(raw, pad);
|
||||
if (postcode.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<String> list = map.computeIfAbsent(zone, k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> parseCtt(Sheet sheet)
|
||||
{
|
||||
Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
|
||||
int postcodeCol = -1;
|
||||
int zoneCol = -1;
|
||||
int headerRow = -1;
|
||||
int lastRow = Math.min(sheet.getLastRowNum(), MAX_ROWS);
|
||||
for (int r = 0; r <= Math.min(lastRow, 10); r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < row.getLastCellNum(); c++)
|
||||
{
|
||||
String val = cellText(row.getCell(c));
|
||||
String low = val.toLowerCase(Locale.ROOT);
|
||||
if ((low.contains("codigo postal") || low.contains("código postal") || low.equals("postcode")
|
||||
|| low.equals("postal code")) && postcodeCol < 0)
|
||||
{
|
||||
postcodeCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
if ((low.contains("ctt density") || (low.contains("density") && !low.contains("densité")))
|
||||
&& zoneCol < 0)
|
||||
{
|
||||
zoneCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
}
|
||||
if (postcodeCol >= 0 && zoneCol >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (postcodeCol < 0 || zoneCol < 0 || headerRow < 0)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String postcode = normalizePostcode(cellText(row.getCell(postcodeCol)), 5);
|
||||
String zone = mapCttZone(cellText(row.getCell(zoneCol)));
|
||||
if (postcode.isEmpty() || zone.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<String> list = map.computeIfAbsent(zone, k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/** 价表密度分区名与邮编表 CTT Density 对齐。 */
|
||||
public static String normalizeDensityZone(String raw)
|
||||
{
|
||||
return mapCttZone(raw);
|
||||
}
|
||||
|
||||
private static String mapCttZone(String raw)
|
||||
{
|
||||
String zone = normalizeZone(raw);
|
||||
if (zone.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String low = zone.toLowerCase(Locale.ROOT);
|
||||
if ((low.contains("madrid") || low.contains("mad ")) && low.contains("high"))
|
||||
{
|
||||
return "Mad High Density";
|
||||
}
|
||||
if (low.equals("high") || low.startsWith("high "))
|
||||
{
|
||||
return "High";
|
||||
}
|
||||
if (low.equals("medium") || low.startsWith("medium "))
|
||||
{
|
||||
return "Medium";
|
||||
}
|
||||
if (low.equals("low") || low.startsWith("low "))
|
||||
{
|
||||
return "Low";
|
||||
}
|
||||
if (low.contains("mainland") || low.contains("主岛"))
|
||||
{
|
||||
return "Mainland";
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> parseColissimo(Sheet sheet)
|
||||
{
|
||||
Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
|
||||
int postcodeCol = -1;
|
||||
int zoneCol = -1;
|
||||
int headerRow = -1;
|
||||
int lastRow = Math.min(sheet.getLastRowNum(), MAX_ROWS);
|
||||
for (int r = 0; r <= Math.min(lastRow, 10); r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < row.getLastCellNum(); c++)
|
||||
{
|
||||
String val = cellText(row.getCell(c));
|
||||
String low = val.toLowerCase(Locale.ROOT);
|
||||
if ((val.contains("邮编") || low.contains("postal")) && postcodeCol < 0)
|
||||
{
|
||||
postcodeCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
if ((low.contains("densit") || val.contains("中文名称")) && zoneCol < 0)
|
||||
{
|
||||
zoneCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
}
|
||||
if (postcodeCol >= 0 && zoneCol >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (postcodeCol < 0 || zoneCol < 0 || headerRow < 0)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String postcode = normalizePostcode(cellText(row.getCell(postcodeCol)), 5);
|
||||
String zone = normalizeZone(cellText(row.getCell(zoneCol)));
|
||||
if (postcode.isEmpty() || zone.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<String> list = map.computeIfAbsent(zone, k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String, List<String>> parseTwoCol(Sheet sheet)
|
||||
{
|
||||
Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
|
||||
int postcodeCol = -1;
|
||||
int zoneCol = -1;
|
||||
int headerRow = -1;
|
||||
int lastRow = Math.min(sheet.getLastRowNum(), MAX_ROWS);
|
||||
for (int r = 0; r <= Math.min(lastRow, 20); r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int c = 0; c < row.getLastCellNum(); c++)
|
||||
{
|
||||
String val = cellText(row.getCell(c));
|
||||
if (val.contains("邮编") && postcodeCol < 0)
|
||||
{
|
||||
postcodeCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
if (val.contains("分区") && !val.contains("附加") && zoneCol < 0)
|
||||
{
|
||||
zoneCol = c;
|
||||
headerRow = r;
|
||||
}
|
||||
}
|
||||
if (postcodeCol >= 0 && zoneCol >= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (postcodeCol < 0 || zoneCol < 0 || headerRow < 0)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
for (int r = headerRow + 1; r <= lastRow; r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String postcode = normalizePostcode(cellText(row.getCell(postcodeCol)), 5);
|
||||
String zone = normalizeZone(cellText(row.getCell(zoneCol)));
|
||||
if (postcode.isEmpty() || zone.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<String> list = map.computeIfAbsent(zone, k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void attachImile(Sheet sheet, String sheetName, List<LblProduct> products)
|
||||
{
|
||||
LblProduct italy = productOf(products, "IT-iMile");
|
||||
LblProduct germany = productOf(products, "DE-iMile");
|
||||
int lastRow = Math.min(sheet.getLastRowNum(), MAX_ROWS);
|
||||
int header = -1;
|
||||
for (int r = 0; r <= Math.min(lastRow, 6); r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
StringBuilder line = new StringBuilder();
|
||||
for (int c = 0; c < row.getLastCellNum(); c++)
|
||||
{
|
||||
line.append(cellText(row.getCell(c)));
|
||||
}
|
||||
String text = line.toString();
|
||||
if (text.contains("邮编") || text.toLowerCase(Locale.ROOT).contains("zip"))
|
||||
{
|
||||
header = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (header < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Row head = sheet.getRow(header);
|
||||
int postcodeCol = -1;
|
||||
int zoneCol = -1;
|
||||
int zipCol = -1;
|
||||
int statusCol = -1;
|
||||
for (int c = 0; c < head.getLastCellNum(); c++)
|
||||
{
|
||||
String val = cellText(head.getCell(c));
|
||||
String low = val.toLowerCase(Locale.ROOT);
|
||||
if (val.contains("邮编") && postcodeCol < 0)
|
||||
{
|
||||
postcodeCol = c;
|
||||
}
|
||||
if (("分区".equals(val) || val.startsWith("分区")) && zoneCol < 0)
|
||||
{
|
||||
zoneCol = c;
|
||||
}
|
||||
if (low.contains("zip") && zipCol < 0)
|
||||
{
|
||||
zipCol = c;
|
||||
}
|
||||
if (low.contains("status") && statusCol < 0)
|
||||
{
|
||||
statusCol = c;
|
||||
}
|
||||
}
|
||||
Map<String, List<String>> itMap = new LinkedHashMap<String, List<String>>();
|
||||
Map<String, List<String>> deMap = new LinkedHashMap<String, List<String>>();
|
||||
for (int r = header + 1; r <= lastRow; r++)
|
||||
{
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (italy != null && postcodeCol >= 0 && zoneCol >= 0)
|
||||
{
|
||||
String postcode = normalizePostcode(cellText(row.getCell(postcodeCol)), 5);
|
||||
String zone = imileZone(cellText(row.getCell(zoneCol)));
|
||||
if (!postcode.isEmpty() && !zone.isEmpty())
|
||||
{
|
||||
List<String> list = itMap.computeIfAbsent(zone, k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (germany != null && zipCol >= 0)
|
||||
{
|
||||
String postcode = normalizePostcode(cellText(row.getCell(zipCol)), 5);
|
||||
String status = statusCol >= 0 ? cellText(row.getCell(statusCol)) : "Active";
|
||||
if (!postcode.isEmpty() && (statusCol < 0 || "Active".equalsIgnoreCase(status)))
|
||||
{
|
||||
List<String> list = deMap.computeIfAbsent("Phase 1", k -> new ArrayList<String>());
|
||||
if (!list.contains(postcode))
|
||||
{
|
||||
list.add(postcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (italy != null && !itMap.isEmpty())
|
||||
{
|
||||
mergeZonePostcodes(italy, itMap);
|
||||
linkSheet(italy, sheetName);
|
||||
}
|
||||
if (germany != null && !deMap.isEmpty())
|
||||
{
|
||||
mergeZonePostcodes(germany, deMap);
|
||||
linkSheet(germany, sheetName);
|
||||
}
|
||||
}
|
||||
|
||||
private static String imileZone(String text)
|
||||
{
|
||||
String value = text == null ? "" : text.trim().toLowerCase(Locale.ROOT);
|
||||
if (value.startsWith("city"))
|
||||
{
|
||||
return "City";
|
||||
}
|
||||
if (value.startsWith("province"))
|
||||
{
|
||||
return "Province";
|
||||
}
|
||||
if (value.startsWith("rural"))
|
||||
{
|
||||
return "Rural";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static LblProduct productOf(List<LblProduct> products, String name)
|
||||
{
|
||||
for (LblProduct product : products)
|
||||
{
|
||||
if (name.equals(product.getSheetName()) || name.equals(product.getProductName())
|
||||
|| name.equals(product.getDictValue()))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static LblProduct matchProduct(List<LblProduct> products, String sheetName)
|
||||
{
|
||||
for (LblProduct product : products)
|
||||
{
|
||||
String related = product.getRelatedSheet();
|
||||
if (related != null && related.contains(sheetName))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
}
|
||||
String token = sheetName.replace("邮编分区", "").replace("分区", "").trim();
|
||||
String tokenNorm = compact(token);
|
||||
LblProduct fuzzy = null;
|
||||
int hits = 0;
|
||||
for (LblProduct product : products)
|
||||
{
|
||||
String blob = compact(nz(product.getProductName()) + nz(product.getSheetName()) + nz(product.getDictValue()));
|
||||
if (!tokenNorm.isEmpty() && blob.contains(tokenNorm))
|
||||
{
|
||||
fuzzy = product;
|
||||
hits++;
|
||||
}
|
||||
}
|
||||
if (hits == 1)
|
||||
{
|
||||
return fuzzy;
|
||||
}
|
||||
for (LblProduct product : products)
|
||||
{
|
||||
String blob = compact(nz(product.getProductName()) + nz(product.getSheetName()) + nz(product.getDictValue()));
|
||||
if (tokenNorm.startsWith("ctt") && blob.contains("ctt"))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
if (tokenNorm.startsWith("colissimo") && blob.contains("colissimo"))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
if (tokenNorm.startsWith("corres") && blob.contains("corres"))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
if (tokenNorm.startsWith("posteitaliane") && blob.contains("posteitaliane"))
|
||||
{
|
||||
return product;
|
||||
}
|
||||
}
|
||||
if (products.size() == 1)
|
||||
{
|
||||
return products.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void mergeZonePostcodes(LblProduct product, Map<String, List<String>> incoming)
|
||||
{
|
||||
Map<String, List<String>> current = product.getZonePostcodes();
|
||||
if (current == null)
|
||||
{
|
||||
current = new LinkedHashMap<String, List<String>>();
|
||||
product.setZonePostcodes(current);
|
||||
}
|
||||
for (Map.Entry<String, List<String>> e : incoming.entrySet())
|
||||
{
|
||||
List<String> list = current.computeIfAbsent(e.getKey(), k -> new ArrayList<String>());
|
||||
for (String pc : e.getValue())
|
||||
{
|
||||
if (!list.contains(pc))
|
||||
{
|
||||
list.add(pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void linkSheet(LblProduct product, String sheetName)
|
||||
{
|
||||
String current = product.getRelatedSheet();
|
||||
if (current == null || current.isBlank())
|
||||
{
|
||||
product.setRelatedSheet(sheetName);
|
||||
return;
|
||||
}
|
||||
if (!current.contains(sheetName))
|
||||
{
|
||||
product.setRelatedSheet(current + "、" + sheetName);
|
||||
}
|
||||
}
|
||||
|
||||
private static String cellText(Cell cell)
|
||||
{
|
||||
if (cell == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return FMT.formatCellValue(cell).replace('\r', ' ').replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
}
|
||||
|
||||
private static String normalizePostcode(String raw, int pad)
|
||||
{
|
||||
if (raw == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String text = raw.trim().replace(" ", "");
|
||||
if (text.isEmpty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (text.matches("\\d+"))
|
||||
{
|
||||
if (pad > 0)
|
||||
{
|
||||
long value = Long.parseLong(text);
|
||||
return String.format("%0" + pad + "d", value);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String normalizeZone(String raw)
|
||||
{
|
||||
if (raw == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return raw.replace('\r', ' ').replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
}
|
||||
|
||||
private static String compact(String text)
|
||||
{
|
||||
return text == null ? "" : text.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9\\u4e00-\\u9fa5]", "");
|
||||
}
|
||||
|
||||
private static String nz(String text)
|
||||
{
|
||||
return text == null ? "" : text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.LblProduct;
|
||||
import com.bms.price.domain.LblProductVersion;
|
||||
import com.bms.price.domain.LblSurcharge;
|
||||
import com.bms.price.domain.LblWeightBand;
|
||||
import com.bms.price.domain.LabelPackageVersion;
|
||||
|
||||
/**
|
||||
* 打单价卡四表 Mapper。
|
||||
*/
|
||||
public interface LblProductMapper
|
||||
{
|
||||
int insertProduct(LblProduct product);
|
||||
|
||||
int updateProduct(LblProduct product);
|
||||
|
||||
LblProduct selectProductById(@Param("productId") Long productId);
|
||||
|
||||
LblProduct selectProductByDict(@Param("dictValue") String dictValue);
|
||||
|
||||
Long selectProductIdBySetAndDict(@Param("priceSetId") Long priceSetId, @Param("dictValue") String dictValue);
|
||||
|
||||
int insertVersion(LblProductVersion version);
|
||||
|
||||
int updateVersion(LblProductVersion version);
|
||||
|
||||
int closePendingBySetProduct(@Param("priceSetId") Long priceSetId, @Param("productId") Long productId,
|
||||
@Param("endDate") java.util.Date endDate, @Param("operator") String operator);
|
||||
|
||||
List<Long> selectVersionIdsBySetAndNo(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo);
|
||||
|
||||
int deletePendingVersionsBySetAndNo(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo);
|
||||
|
||||
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,
|
||||
@Param("versionNo") Integer versionNo);
|
||||
|
||||
LblProductVersion selectVersionById(@Param("versionId") Long versionId);
|
||||
|
||||
Integer selectMaxVersionNo(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
List<LabelPackageVersion> selectLabelVersionGroups(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
int insertWeightBand(LblWeightBand band);
|
||||
|
||||
/** 按 band_id 更新可编辑字段(不动维度/单位) */
|
||||
int updateWeightBand(LblWeightBand band);
|
||||
|
||||
LblWeightBand selectWeightBandById(@Param("bandId") Long bandId);
|
||||
|
||||
int deleteWeightBandsByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
int deleteWeightBandById(@Param("bandId") Long bandId);
|
||||
|
||||
List<LblWeightBand> selectWeightBandsByVersion(@Param("versionId") Long versionId);
|
||||
|
||||
int insertSurcharge(LblSurcharge surcharge);
|
||||
|
||||
int updateSurcharge(LblSurcharge surcharge);
|
||||
|
||||
LblSurcharge selectSurchargeById(@Param("surchargeId") Long surchargeId);
|
||||
|
||||
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);
|
||||
|
||||
int deleteVersionsBySetAndProducts(@Param("priceSetId") Long priceSetId, @Param("productIds") Long[] productIds);
|
||||
|
||||
List<LblProduct> selectProductsBySet(@Param("priceSetId") Long priceSetId);
|
||||
|
||||
List<LblProduct> selectProductsBySetAndVersion(@Param("priceSetId") Long priceSetId,
|
||||
@Param("versionNo") Integer versionNo);
|
||||
|
||||
int activateVersionRows(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo,
|
||||
@Param("effectiveStart") java.util.Date effectiveStart, @Param("operator") String operator);
|
||||
|
||||
int expireOtherActive(@Param("priceSetId") Long priceSetId, @Param("versionNo") Integer versionNo,
|
||||
@Param("endDate") java.util.Date endDate, @Param("operator") String operator);
|
||||
}
|
||||
@@ -3,9 +3,13 @@ package com.bms.price.mapper;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PayBill;
|
||||
import com.bms.price.domain.PayBillApproval;
|
||||
import com.bms.price.domain.PayBillDiff;
|
||||
import com.bms.price.domain.PayBillFile;
|
||||
import com.bms.price.domain.PayBillLine;
|
||||
import com.bms.price.domain.PayBillLog;
|
||||
import com.bms.price.domain.PayBillOrder;
|
||||
import com.bms.price.domain.PayPaymentAlloc;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
|
||||
/** 供应商应付账单 pay_bill 及其明细、日志。 */
|
||||
@@ -61,7 +65,23 @@ public interface PayBillMapper
|
||||
* @param billIds 计费订单ID
|
||||
* @return 订单应付费用
|
||||
*/
|
||||
List<PrcPayBillFee> selectOrderFees(@Param("billIds") List<String> billIds);
|
||||
List<PrcPayBillFee> selectOrderFees(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 读取还没被未作废账单占用的费用。旧账单没有费用行号时,整票视为已占用。
|
||||
*
|
||||
* @param billIds 计费订单ID
|
||||
* @return 可抄进本次账单的费用
|
||||
*/
|
||||
List<PrcPayBillFee> selectFreeFees(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/**
|
||||
* 这票订单还有没有未删除的计算费用。
|
||||
*
|
||||
* @param billId 计费订单ID
|
||||
* @return 计算费用条数
|
||||
*/
|
||||
int countCalcFees(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 插入一张草稿应付账单。
|
||||
@@ -87,6 +107,103 @@ public interface PayBillMapper
|
||||
*/
|
||||
int insertLines(@Param("list") List<PayBillLine> list);
|
||||
|
||||
/**
|
||||
* 写入一条账单费用快照,并回填行号。
|
||||
*
|
||||
* @param line 费用行
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertLine(PayBillLine line);
|
||||
|
||||
/**
|
||||
* 把费用明细占用到刚写入的账单行。已被占用时影响行数为 0。
|
||||
*
|
||||
* @param feeId 费用明细ID
|
||||
* @param lineId 账单行ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int bindFeeLine(@Param("feeId") String feeId, @Param("lineId") Long lineId);
|
||||
|
||||
/**
|
||||
* 释放一张账单占用的费用明细。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int clearFeeLines(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 释放某一条账单行占用的费用明细。
|
||||
*
|
||||
* @param lineId 账单行ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int clearFeeLine(@Param("lineId") Long lineId);
|
||||
|
||||
/**
|
||||
* 按费用行重算账单金额、订单数,并写回状态。
|
||||
*
|
||||
* @param bill 账单ID、金额、状态和更新人
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updatePayBillMoney(PayBill bill);
|
||||
|
||||
/**
|
||||
* 删除草稿中的一条费用快照。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
* @param lineId 账单行ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteLine(@Param("billId") Long billId, @Param("lineId") Long lineId);
|
||||
|
||||
int updateLineAmount(PayBillLine line);
|
||||
|
||||
int deleteOpenDiff(@Param("lineId") Long lineId);
|
||||
|
||||
/**
|
||||
* 读取一张账单的差异、凭证和审核。
|
||||
*
|
||||
* @param billId 应付账单ID
|
||||
* @return 对应记录
|
||||
*/
|
||||
List<PayBillDiff> selectDiffs(@Param("billId") Long billId);
|
||||
|
||||
List<PayBillFile> selectFiles(@Param("billId") Long billId);
|
||||
|
||||
List<PayBillApproval> selectApprovals(@Param("billId") Long billId);
|
||||
|
||||
PayBillLine selectLine(@Param("lineId") Long lineId);
|
||||
|
||||
PayBillDiff selectOpenDiff(@Param("lineId") Long lineId);
|
||||
|
||||
int insertDiff(PayBillDiff diff);
|
||||
|
||||
int updateDiff(PayBillDiff diff);
|
||||
|
||||
int deleteDiffsByLine(@Param("lineId") Long lineId);
|
||||
|
||||
int insertFile(PayBillFile file);
|
||||
|
||||
PayBillFile selectFile(@Param("fileId") Long fileId);
|
||||
|
||||
int markFileDeleted(@Param("fileId") Long fileId);
|
||||
|
||||
int insertApproval(PayBillApproval approval);
|
||||
|
||||
List<PayBillFile> selectFileList(PayBillFile query);
|
||||
|
||||
int countActiveFiles(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 查询可以核销的账单。已确认或部分付款,且还有未付金额。
|
||||
*
|
||||
* @param supplierId 供应商
|
||||
* @param currency 币种
|
||||
* @return 未付账单
|
||||
*/
|
||||
List<PayPaymentAlloc> selectOpenBills(@Param("supplierId") Long supplierId, @Param("currency") String currency);
|
||||
|
||||
/**
|
||||
* 写入一条账单操作日志。
|
||||
*
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/** 应付价税、发票勾稽和费用付款对象。 */
|
||||
public interface PayFinanceMapper
|
||||
{
|
||||
int updateFinanceHead(@Param("billId") Long billId, @Param("taxRate") BigDecimal taxRate,
|
||||
@Param("exchangeRate") BigDecimal exchangeRate, @Param("rateDate") Date rateDate);
|
||||
|
||||
int updateSubmitBy(@Param("billId") Long billId, @Param("submitBy") String submitBy);
|
||||
|
||||
int updateLineTax(@Param("billId") Long billId, @Param("taxRate") BigDecimal taxRate,
|
||||
@Param("exchangeRate") BigDecimal exchangeRate);
|
||||
|
||||
int countDuplicateInvoice(@Param("supplierId") Long supplierId, @Param("invoiceNo") String invoiceNo,
|
||||
@Param("fileId") Long fileId);
|
||||
|
||||
int markInvoiceMatched(@Param("billId") Long billId);
|
||||
|
||||
Long selectLadingSupplier(@Param("ladingNo") String ladingNo);
|
||||
|
||||
int stampFee(@Param("feeId") String feeId, @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);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PayPayment;
|
||||
import com.bms.price.domain.PayPaymentAlloc;
|
||||
|
||||
/** 应付付款单和核销。 */
|
||||
public interface PayPaymentMapper
|
||||
{
|
||||
List<PayPayment> selectPayPaymentList(PayPayment query);
|
||||
|
||||
PayPayment selectPayPaymentById(@Param("paymentId") Long paymentId);
|
||||
|
||||
List<PayPaymentAlloc> selectAllocs(@Param("paymentId") Long paymentId);
|
||||
|
||||
int insertPayPayment(PayPayment payment);
|
||||
|
||||
int insertAlloc(PayPaymentAlloc alloc);
|
||||
|
||||
int updatePayPaymentStatus(PayPayment payment);
|
||||
|
||||
int reverseAlloc(@Param("allocId") Long allocId, @Param("reverseBy") String reverseBy);
|
||||
}
|
||||
@@ -10,6 +10,38 @@ public interface PayPostcodeMapper
|
||||
{
|
||||
List<PayPostcodeGroup> selectGroupList(PayPostcodeGroup query);
|
||||
|
||||
List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query);
|
||||
|
||||
List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query);
|
||||
|
||||
PayPostcodeGroup selectSampleGroup(PayPostcodeGroup query);
|
||||
|
||||
int countZoneName(PayPostcodeGroup query);
|
||||
|
||||
int updateCountryProfile(PayPostcodeGroup country);
|
||||
|
||||
List<Long> selectGroupIdsByCountry(PayPostcodeGroup query);
|
||||
|
||||
int renameZoneLines(PayPostcodeGroup zone);
|
||||
|
||||
int updateExclusiveZone(PayPostcodeGroup zone);
|
||||
|
||||
int insertLine(PayPostcodeLine line);
|
||||
|
||||
int updateLine(PayPostcodeLine line);
|
||||
|
||||
PayPostcodeLine selectLineById(Long lineId);
|
||||
|
||||
List<Long> selectGroupIdsByLineIds(@Param("lineIds") List<Long> lineIds);
|
||||
|
||||
int deleteLineByIds(@Param("lineIds") List<Long> lineIds);
|
||||
|
||||
int deleteLinesByZone(PayPostcodeGroup zone);
|
||||
|
||||
int refreshLineCount(Long groupId);
|
||||
|
||||
Long selectZoneGroupId(PayPostcodeGroup query);
|
||||
|
||||
/** 按国家去重区块标题 */
|
||||
List<String> selectBlockTitlesByCountry(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName);
|
||||
@@ -31,6 +63,10 @@ public interface PayPostcodeMapper
|
||||
/** 报价表、销售产品或工作表与产品名称完全一致的邮编配置 */
|
||||
List<PayPostcodeGroup> selectGroupsForProduct(@Param("names") List<String> names);
|
||||
|
||||
/** 目的国家下标记为偏远的邮编组。产品自己没有偏远名单时,用这一份做偏远附加费。 */
|
||||
List<PayPostcodeGroup> selectRemoteGroupsByCountry(@Param("countryCode") String countryCode,
|
||||
@Param("countryName") String countryName);
|
||||
|
||||
List<PayPostcodeLine> selectRegionKeys(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
List<PayPostcodeLine> selectLinesByGroups(@Param("groupIds") List<Long> groupIds);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PaySurchargeRuleLog;
|
||||
|
||||
public interface PaySurchargeRuleLogMapper
|
||||
{
|
||||
List<PaySurchargeRuleLog> selectByTerm(@Param("productId") Long productId, @Param("termId") Long termId);
|
||||
|
||||
List<PaySurchargeRuleLog> selectByProductIds(@Param("productIds") List<Long> productIds);
|
||||
|
||||
int insertBatch(@Param("list") List<PaySurchargeRuleLog> list);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user