108 Commits

Author SHA1 Message Date
caojia ec7f97f831 Merge branch 'test' 2026-11-17 16:55:46 +08:00
caojia 8d45439931 ✨ 限制应收账单毛利查询日期并调整筛选布局 2026-11-17 16:51:53 +08:00
caojia e2deccc65a ✨ 限制毛利分析查询日期为一个月 2026-11-17 16:46:54 +08:00
caojia 32cea1c348 Merge branch 'test' 2026-11-17 16:20:11 +08:00
caojia 2aec7fdd5c ✨ 毛利分析筛选支持编码名称搜索 2026-11-17 16:16:14 +08:00
caojia 5c8e905a37 ✨ 毛利分析订单导出合并为单个工作表 2026-11-17 15:48:57 +08:00
caojia ad2d8c8b50 Merge branch 'test' 2026-11-17 15:26:23 +08:00
caojia 8fb042f171 ✨ 应收账单导出预留明细空行 2026-11-17 15:25:29 +08:00
caojia 4ad799719a Merge branch 'test' 2026-11-17 15:01:33 +08:00
caojia d8f6ceda59 ✨ 毛利分析订单支持异步导出 2026-11-17 14:55:54 +08:00
caojia e104c5a3e9 修改文案 2026-11-17 14:42:53 +08:00
caojia fcaf0dc9be ⚡ 毛利分析分页复用汇总订单数并禁用重复统计 2026-11-17 14:34:31 +08:00
caojia c86cad30ec Merge branch 'test' 2026-11-17 11:28:28 +08:00
caojia 33e8a5890a ✨ 应收账单计费重优先取 charge_weight,空值回退 weight 2026-11-17 11:27:19 +08:00
wuweihua 8ede0bb5ec 移除原计费重显示 2026-11-17 11:27:18 +08:00
caojia 366ddff0b3 去掉导出日志功能 2026-11-17 11:27:17 +08:00
caojia e2d123de85 去掉导出日志功能 2026-11-17 11:27:16 +08:00
caojia e22f4bc9d7 ⚡ 优化毛利分析订单查询 2026-11-17 11:27:15 +08:00
wuweihua 7500728c1d 优化计费任务列表状态过滤逻辑,更新计费重和客户确认重字段名称 2026-11-17 11:27:14 +08:00
caojia 9483bb4899 ✨ 应收账单计费重优先取 charge_weight,空值回退 weight 2026-11-17 11:24:39 +08:00
wuweihua 69d9971a79 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-17 10:52:16 +08:00
wuweihua f6012f96e3 移除原计费重显示 2026-11-17 10:52:12 +08:00
caojia 111176e767 去掉导出日志功能 2026-11-17 10:37:35 +08:00
caojia cce123890e 去掉导出日志功能 2026-11-17 10:37:24 +08:00
wuweihua b76b26b2b1 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-17 10:26:24 +08:00
caojia 6e01167f41 ⚡ 优化毛利分析订单查询 2026-11-17 10:23:03 +08:00
wuweihua e0b8eec98d Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-17 10:16:42 +08:00
liuminghui 54ac6428e7 应付费用重算优化以及样式调整 2026-11-17 10:16:00 +08:00
wuweihua ee5c79ba29 优化计费任务列表状态过滤逻辑,更新计费重和客户确认重字段名称 2026-11-17 10:13:09 +08:00
caojia ea62697b98 ✨ 毛利分析合并订单明细及产品筛选 2026-11-16 20:29:56 +08:00
caojia f00f8c619a ✨ 毛利分析合并订单明细及产品筛选 2026-11-16 20:24:27 +08:00
liuminghui f9038c62ac 费用重算优化、日志记录、费用调整为逻辑删除 2026-11-16 16:52:33 +08:00
liuminghui 49f24a6b1b 应付模块菜单调整,新增应付费用编辑等 2026-11-16 15:50:51 +08:00
caojia 9273fcec56 Merge branch 'test' 2026-11-16 15:00:09 +08:00
caojia 5b8d4de262 ✨ 毛利分析支持不选择客户查询 2026-11-16 14:59:00 +08:00
wuweihua 215effe036 新增产品和附加费删除标记,优化版本编辑逻辑 2026-11-16 14:54:19 +08:00
caojia 4503424cf0 ♻️ 调整应收账单来源 ID 为 bigint 2026-11-16 14:21:36 +08:00
wuweihua 3cf7fa30bd 重命名应付关联列,删除旧UUID列并重建索引 2026-11-16 13:44:09 +08:00
wuweihua e34e4f117c 更新UUID到新同步Mapper,删除旧UUID列并优化相关SQL逻辑 2026-11-16 12:44:10 +08:00
wuweihua 03043104bc 修改账单ID类型为Long,更新相关服务和Mapper逻辑 2026-11-16 12:40:05 +08:00
wuweihua a5cd752005 移除计费结果中的应付费用查询 2026-11-16 11:01:20 +08:00
wuweihua 5d44cc4edf 修改账单ID类型为Long,优化相关服务和Mapper逻辑 2026-11-16 10:30:46 +08:00
wuweihua 0400f55838 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-15 20:47:28 +08:00
wuweihua 1b43bcca4c Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-15 16:38:52 +08:00
caojia a38e2c7f57 🐛 修复应收账单毛利分析分页失效 2026-11-15 16:29:58 +08:00
wuweihua 63ded27fd5 新增游标抓取逻辑,优化UUID到新同步服务的查询和Redis配置 2026-11-15 12:26:12 +08:00
wuweihua 2f25a99396 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-15 09:41:04 +08:00
wuweihua 206e4e786b 新增ar_bill_detail_fee表的income_fee_id字段,更新UUID到新同步逻辑 2026-11-15 09:39:57 +08:00
wuweihua 48b7fbc7cf Merge branch 'master' of D:\wuweihua\BMS with conflicts. 2026-11-15 09:03:49 +08:00
wuweihua 15a72e3503 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-15 09:02:44 +08:00
wuweihua 0179a35942 更新UUID到新费用行和阴影同步Mapper的注释,新增关联表回写逻辑 2026-11-15 09:01:19 +08:00
wuweihua 99651b6758 Merge branch 'master' of D:\wuweihua\BMS with conflicts. 2026-11-15 00:23:04 +08:00
wuweihua 2342d34194 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-15 00:22:34 +08:00
wuweihua 4de755ca60 移除UUID阴影同步中的应付相关表与同步逻辑
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 00:15:58 +08:00
wuweihua bcd9c789cb Merge branch 'master' of D:\wuweihua\BMS with conflicts. 2026-11-14 19:57:30 +08:00
wuweihua bf7b46a231 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-14 19:55:06 +08:00
wuweihua 358e5a46b9 新增UUID到新同步服务的失败处理逻辑和批次结果返回 2026-11-14 19:52:38 +08:00
wuweihua 6f78b813f3 Merge branch 'master' of D:\wuweihua\BMS with conflicts. 2026-11-14 19:29:38 +08:00
wuweihua a71f0a164f Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-14 19:28:58 +08:00
wuweihua ee36c8c902 新增UUID到新同步运行器的Redis配置持久化功能 2026-11-14 19:27:49 +08:00
wuweihua f7c7d9fe8b Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-14 19:03:19 +08:00
wuweihua 7e699fb80e 调整UUID到新配置的线程数范围和注释说明 2026-11-14 19:00:26 +08:00
wuweihua 80d639d887 更新支付账单服务逻辑,调整源ID赋值方式;修改SQL映射中的源ID字段为费用ID;新增UUID到BIGINT迁移配置 2026-11-14 18:53:03 +08:00
wuweihua 87ae3e6674 回退 UUID 转 bigint 相关改动(已迁至 feature/uuid-to-bigint)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-14 08:08:49 +08:00
wuweihua 359c3c18e4 修改费用ID类型为Long,更新相关逻辑和SQL映射 2026-11-14 01:22:12 +08:00
wuweihua 4f2f2db20f 更新UUID到BIGINT的迁移脚本,优化备份和回滚说明 2026-11-14 00:40:16 +08:00
wuweihua 0094e4aaff Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test
# Conflicts:
#	bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPayBillFee.java
#	bms-back/bms-system/src/main/resources/mapper/price/PrcPayBillFeeMapper.xml
2026-11-14 00:32:55 +08:00
wuweihua 8b7c346ec4 修改计费订单ID类型为Long,优化相关逻辑 2026-11-14 00:23:47 +08:00
liuminghui bde1d7d86e 应付计费邮编改造 2026-11-13 18:26:21 +08:00
wuweihua 87eab12d51 优化附加费计算规则,调整相关逻辑和注释 2026-11-13 15:25:10 +08:00
liuminghui 880b4751c5 Merge remote-tracking branch 'origin/test' into test 2026-11-13 11:57:40 +08:00
liuminghui 3a104d2d8c 应付配置的附加费配置完善 2026-11-13 11:57:19 +08:00
wuweihua a024b45940 重构打单套餐相关逻辑,更新服务接口,优化保存和查询功能 2026-11-13 11:27:58 +08:00
liuminghui 6675808dfc 应付配置增加附加费配置,应付账单新增核销、对账、凭证、审核功能 2026-11-12 18:20:32 +08:00
caojia 2d5ffc4e06 Merge branch 'test' 2026-11-12 18:10:16 +08:00
caojia 1ba431540d ✨ 支持应收账单异步作废 2026-11-12 17:33:21 +08:00
wuweihua f03aa7be6c Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2026-11-12 17:12:21 +08:00
caojia 0d0613e810 ⚡ 移除应收账单确认时的明细校验 2026-11-12 17:08:56 +08:00
caojia 47b95b6bfd 💄 调整应收合计查询按钮显示 2026-11-12 17:08:56 +08:00
wuweihua e7fd7f9059 优化计费规则注释,新增三边规则处理逻辑 2026-11-12 17:00:04 +08:00
wuweihua 1ffaf424b1 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-12 16:53:45 +08:00
wuweihua 8ca5af1ff0 新增打单产品明细保存接口,优化附加费管理逻辑 2026-11-12 16:53:40 +08:00
caojia 621128530a ⚡ 优化应收合计查询并补充导出汇总 2026-11-12 15:58:25 +08:00
caojia 73ce7f4eae Merge branch 'test' 2026-11-12 15:05:39 +08:00
caojia fb9a4e1b29 ⚡ 优化应收账单预览排序 2026-11-12 15:00:58 +08:00
caojia 89aadf97db ✨ 扩展应收账单销售经理部门数据范围 2026-11-12 15:00:58 +08:00
wuweihua 90147ed4e3 新增附加费计费标识,优化附加费管理逻辑 2026-11-12 14:43:42 +08:00
wuweihua cf336f7a67 新增按国家去重区块标题接口,优化计费列表请求方式 2026-11-12 13:45:09 +08:00
wuweihua d2c75e0c51 修改计费逻辑 2026-11-12 11:07:13 +08:00
wuweihua 17ee9731e8 更新应用配置,新增工具迁移链接排除项 2026-11-12 09:56:37 +08:00
caojia 146d3469b6 ✨ 支持应收账单导出通过 OSS 签名链接下载 2026-11-12 09:27:10 +08:00
caojia b49600ab9f Merge branch 'test'
# Conflicts:
#	bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java
2026-11-11 17:57:33 +08:00
caojia 27715b3e13 ✨ 将应收账单预览导出改为异步处理 2026-11-11 17:56:14 +08:00
wuweihua b5299e4490 移除价卡导入按钮和相关组件 2026-11-11 17:48:02 +08:00
wuweihua 82164cb00c 修改计费重按钮为注释,更新重新计费按钮样式 2026-11-11 17:12:20 +08:00
caojia 34fa8e23c1 🐛 毛利分析增加查询条件校验 2026-11-11 17:00:49 +08:00
liuminghui efd92b5663 新增提单管理和提单计费页面 2026-11-11 16:36:40 +08:00
wuweihua 7869205afc 新增数据迁移任务到定时任务白名单;优化默认收货时间范围逻辑 2026-11-11 15:34:11 +08:00
wuweihua f82d9c667f Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-11 14:50:58 +08:00
wuweihua 7e1041391a 新增打单产品渠道查询与替换功能 2026-11-11 14:50:34 +08:00
caojia 99cdfd86d3 ✨ 展示TMS同步新增用户明细 2026-11-11 14:44:41 +08:00
caojia 41a80f9794 ✨ 设置应收账单默认日期范围 2026-11-11 14:31:08 +08:00
caojia 8cb2d03062 🐛 修复应收账单二维码位置 2026-11-11 14:23:25 +08:00
wuweihua 4ceb0bc830 Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test 2026-11-11 13:52:35 +08:00
wuweihua f7384c88f6 优化代码注释为简体中文 2026-11-11 13:52:28 +08:00
caojia beba9e9caa 🐛 校验账单价格后确认提成比例 2026-11-11 13:45:34 +08:00
wuweihua b7d0674fda 优化代码注释为简体中文 2026-11-11 13:35:53 +08:00
wuweihua 0545de88b4 新增订单计费失败原因的价格周期字段,并优化前端展示,支持查看价格周期详情。 2026-11-11 13:12:32 +08:00
469 changed files with 39002 additions and 3662 deletions
@@ -59,9 +59,9 @@ public class TmsPriceController extends BaseController
private IBillSearchStore billSearchStore;
/**
* Quote by customer + product + country + weight (+ destPostcode when country has zones).
* Zone resolve: destPostcode -> prc_zone_detail/prc_zone -> product_country.zone_code.
* Match: customer package FIXED &gt; DISCOUNT &gt; product default.
* 按客户 + 产品 + 国家 + 重量试算(国家配置了分区时需传 destPostcode)。
* 分区解析:destPostcode -> prc_zone_detail/prc_zone -> product_country.zone_code。
* 匹配顺序:客户套餐 FIXED &gt; DISCOUNT &gt; 产品默认价。
*/
@PostMapping("/quote")
public AjaxResult quote(
@@ -83,9 +83,9 @@ public class TmsPriceController extends BaseController
}
/**
* Sync order and persist prc_order_bill / prc_income_bill_fee.
* Same price match as quote (bound set + active version by bizDate, else default).
* Same orderNo upserts.
* 同步订单并落库 prc_order_bill / prc_income_bill_fee。
* 价格匹配与试算一致(绑定套餐 + 按 bizDate 取生效版本,否则取默认价)。
* 相同 orderNo 执行 upsert。
*/
@PostMapping("/bill")
public AjaxResult bill(
@@ -106,8 +106,8 @@ public class TmsPriceController extends BaseController
}
/**
* Warehouse inbound: create billing task (PENDING/REBILL/REFUND) and publish MQ.
* Consumer queries Oracle by transferNo/orderNo then inserts prc_order_bill.
* 仓库入库:创建计费任务(PENDING/REBILL/REFUND)并发送 MQ。
* 消费端按 transferNo/orderNo 查询 Oracle,然后插入 prc_order_bill。
* POST /api/tms/price/billing-task
*/
@PostMapping("/billing-task")
@@ -121,7 +121,7 @@ public class TmsPriceController extends BaseController
}
/**
* Query billing task writeback status.
* 查询计费任务回写状态。
* GET /api/tms/price/billing-task/{taskId}
*/
@GetMapping("/billing-task/{taskId}")
@@ -135,7 +135,7 @@ public class TmsPriceController extends BaseController
}
/**
* Query order bill by orderNo after sync.
* 同步完成后按 orderNo 查询订单账单。
*/
@GetMapping("/bill/by-order/{orderNo}")
public AjaxResult getBillByOrder(
@@ -188,7 +188,7 @@ public class CommonController
}
/**
* Common resource download: local profile path or oss://bucket/key (AR bill style).
* 通用资源下载:本地 profile 路径或 oss://bucket/key(AR 账单风格)。
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
@@ -207,7 +207,7 @@ public class CommonController
}
if (ossFile)
{
// Extension check still applies to the object key suffix.
// 扩展名校验仍适用于对象 key 后缀。
if (!FileUtils.checkAllowDownload(resource))
{
throw new Exception(StringUtils.format("resource ({}) not allowed", resource));
@@ -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)
@@ -12,6 +12,7 @@ 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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.bms.common.annotation.Log;
@@ -19,7 +20,7 @@ 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.common.exception.ServiceException;
import com.bms.common.enums.PaymentMesEnum;
import com.bms.price.domain.PayPostcodeGroup;
import com.bms.price.domain.PayPostcodeLine;
import com.bms.price.service.IPayPostcodeService;
@@ -39,10 +40,90 @@ 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")
public AjaxResult blockOptions(@RequestParam(required = false) String countryCode,
@RequestParam(required = false) String countryName)
{
return success(payPostcodeService.selectBlockTitlesByCountry(countryCode, countryName));
}
@PreAuthorize("@ss.hasPermi('data:payPostcode:query')")
@GetMapping("/{groupId}")
public AjaxResult getInfo(@PathVariable Long groupId)
@@ -74,12 +155,12 @@ public class PayPostcodeController extends BaseController
{
if (file == null || file.isEmpty())
{
throw new ServiceException("请选择 Excel 文件");
throw PaymentMesEnum.BMS_PAY_PICK_XLS.exception();
}
String name = file.getOriginalFilename() == null ? "" : file.getOriginalFilename().toLowerCase(Locale.ROOT);
if (!name.endsWith(".xlsx"))
{
throw new ServiceException("只支持 xlsx 文件");
throw PaymentMesEnum.BMS_PAY_XLSX_ONLY.exception();
}
return success(payPostcodeService.importExcel(file.getBytes(), file.getOriginalFilename(), getUsername()));
}
@@ -33,16 +33,15 @@ public class BillingTaskMonitorController extends BaseController
@Autowired
private IPrcBillingTaskService billingTaskService;
/** Default list = FAILED abnormal tasks. */
/** 列表默认不过滤状态(全部);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);
}
@@ -58,7 +57,7 @@ public class BillingTaskMonitorController extends BaseController
return success(billingTaskService.getById(taskId));
}
/** Manual resync one task (reset WAITING then process). */
/** 手工重同步单个任务(先重置为 WAITING 再处理)。 */
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
@Log(title = "billing task retry", businessType = BusinessType.UPDATE)
@PostMapping("/retry/{taskId}")
@@ -67,7 +66,7 @@ public class BillingTaskMonitorController extends BaseController
return success(billingTaskService.retryTask(taskId));
}
/** Manual resync selected tasks. */
/** 手工重同步选中的任务。 */
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
@Log(title = "billing task batch retry", businessType = BusinessType.UPDATE)
@PostMapping("/retry")
@@ -116,8 +115,8 @@ public class BillingTaskMonitorController extends BaseController
}
/**
* Async resync by customer + bill_time (batched ID pages to avoid OOM).
* Returns asyncTaskId; poll {@code GET /retryTask/{asyncTaskId}}.
* 按客户 + 计费时间异步重同步(ID 分页批处理,避免 OOM)。
* 返回 asyncTaskId,通过 {@code GET /retryTask/{asyncTaskId}} 轮询进度。
*/
@PreAuthorize("@ss.hasPermi('monitor:billingTask:retry')")
@Log(title = "billing task filter retry", businessType = BusinessType.UPDATE)
@@ -53,7 +53,7 @@ public class PriceLogController extends BaseController
return rsp;
}
/** Group by productCode + write time for package-version drill-down. */
/** 按 productCode + 写入时间分组,用于套餐版本下钻。 */
@PreAuthorize("@ss.hasPermi('monitor:priceLog:list')")
@GetMapping("/groups")
public TableDataInfo groups(
@@ -119,7 +119,7 @@ public class TabOrderMonitorController extends BaseController
rsp.setTotal(0L);
return rsp;
}
// clear time so shared resolvers cannot accidentally reuse month window
// 清空时间,避免共用解析器误复用按月时间窗口
query.setBeginTime(null);
query.setEndTime(null);
customerKeywordResolver.resolve(query);
@@ -224,7 +224,7 @@ public class TabOrderMonitorController extends BaseController
@PostMapping("/syncByFilter")
public AjaxResult syncByFilter(@RequestBody TabOrderMonitorQuery query)
{
// Upstream field overwrite only (no billing). Same filters as list query.
// 仅覆盖上游字段(不触发计费)。筛选条件与列表查询一致。
if (!hasListFilters(query))
{
return error("orderIdentifiers or (customer and pickup time) required");
@@ -257,7 +257,7 @@ public class TabOrderMonitorController extends BaseController
return success(task);
}
/** Selected rows: overwrite local bill fields from Oracle; does not quote/rebill. */
/** 选中行:用 Oracle 数据覆盖本地账单字段;不做报价/重算。 */
@PreAuthorize("@ss.hasPermi('monitor:orderSource:sync') or @ss.hasPermi('price:orderBill:rebill')")
@Log(title = "order source sync selected", businessType = BusinessType.UPDATE)
@PostMapping("/sync")
@@ -318,7 +318,7 @@ public class TabOrderMonitorController extends BaseController
{
continue;
}
// Prefer transferNo as bizId (same as BILL / upstream sync ES).
// 优先使用转单号作为 bizId(与 BILL / 上游同步 ES 一致)。
if (StringUtils.isNotEmpty(row.getTransferOrderId()))
{
return prefix + "_" + row.getTransferOrderId().trim();
@@ -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;
}
}
}
@@ -0,0 +1,126 @@
package com.bms.web.controller.price;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedHashSet;
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.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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.bms.common.annotation.Log;
import com.bms.common.core.controller.BaseController;
import com.bms.common.core.domain.AjaxResult;
import com.bms.common.enums.BusinessType;
import com.bms.common.utils.poi.ExcelUtil;
import com.bms.price.airbill.domain.SrvBillAirFeeImportRow;
import com.bms.price.airbill.domain.SrvBillAirRoleFeeCommand;
import com.bms.price.airbill.domain.SrvBillAirRoleFeeQuery;
import com.bms.price.domain.vo.SrvBillAirQuery;
import com.bms.price.service.ISrvBillAirFeeService;
import com.bms.price.service.ISrvBillAirService;
/**
* 空运、报关、清关三个角色往提单上添加费用。
*/
@RestController
@RequestMapping("/price/airFee")
public class AirFeeRoleController extends BaseController
{
private static final int MAX_BILLS = 50;
@Autowired
private ISrvBillAirFeeService srvBillAirFeeService;
@Autowired
private ISrvBillAirService srvBillAirService;
/** 按提单号查出可绑定的提单,支持一次多选。 */
@PreAuthorize("@ss.hasAnyPermi('price:airFee:air,price:airFee:declare,price:airFee:clear')")
@GetMapping("/bills")
public AjaxResult bills(@RequestParam(value = "billCodes", required = false) String billCodes)
{
List<String> codes = splitCodes(billCodes);
if (codes.isEmpty())
{
return success(List.of());
}
if (codes.size() > MAX_BILLS)
{
return error("单次最多选择" + MAX_BILLS + "个提单");
}
SrvBillAirQuery query = new SrvBillAirQuery();
query.setBillCodes(codes);
return success(srvBillAirService.selectSrvBillAirList(query));
}
/** 查询已绑定到这些提单、且属于当前入口的费用。 */
@PreAuthorize("@ss.hasAnyPermi('price:airFee:air,price:airFee:declare,price:airFee:clear')")
@GetMapping("/list")
public AjaxResult list(@RequestParam("scene") String scene, @RequestParam(value = "billCodes", required = false) String billCodes)
{
SrvBillAirRoleFeeQuery query = new SrvBillAirRoleFeeQuery();
query.setScene(scene);
query.setBillCodes(splitCodes(billCodes));
return success(srvBillAirFeeService.listRoleFees(query));
}
/** 保存当前入口的费用。空运写入 b 段,报关和清关写入 c 段。 */
@PreAuthorize("@ss.hasAnyPermi('price:airFee:air,price:airFee:declare,price:airFee:clear')")
@Log(title = "提单角色费用", businessType = BusinessType.UPDATE)
@PostMapping("/save")
public AjaxResult save(@RequestBody SrvBillAirRoleFeeCommand command)
{
return success(srvBillAirFeeService.saveRole(command));
}
/** 下载导入模板,模板中带一行示例。 */
@PreAuthorize("@ss.hasAnyPermi('price:airFee:air,price:airFee:declare,price:airFee:clear')")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
SrvBillAirFeeImportRow example = new SrvBillAirFeeImportRow();
example.setFeeName("燃油附加费");
example.setPrice(new BigDecimal("1000"));
example.setCurrency("EUR");
example.setRemark("导入时需清空这行示例数据");
List<SrvBillAirFeeImportRow> rows = new ArrayList<>();
rows.add(example);
new ExcelUtil<>(SrvBillAirFeeImportRow.class).exportExcel(response, rows, "提单费用导入模板");
}
/** 解析导入文件,不直接落库。示例行会被跳过。 */
@PreAuthorize("@ss.hasAnyPermi('price:airFee:air,price:airFee:declare,price:airFee:clear')")
@Log(title = "提单角色费用导入", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importFee(MultipartFile file, @RequestParam("scene") String scene) throws Exception
{
if (file == null || file.isEmpty())
{
return error("请选择导入文件");
}
return success(srvBillAirFeeService.parseImport(scene, file.getInputStream()));
}
private static List<String> splitCodes(String billCodes)
{
LinkedHashSet<String> codes = new LinkedHashSet<>();
if (billCodes != null)
{
for (String part : billCodes.split("[,,\\s]+"))
{
if (part != null && !part.isBlank())
{
codes.add(part.trim());
}
}
}
return new ArrayList<>(codes);
}
}
@@ -96,7 +96,7 @@ public class BillingController extends BaseController
private IBillSearchStore billSearchStore;
/**
* Historical quote list.
* 历史报价列表。
*/
@PreAuthorize("@ss.hasPermi('price:billing:quote')")
@GetMapping("/quote/list")
@@ -108,7 +108,7 @@ public class BillingController extends BaseController
}
/**
* Products of the customer's bound effective package version (trial product dropdown).
* 客户已绑定生效套餐版本下的产品(试算产品下拉)。
*/
@PreAuthorize("@ss.hasPermi('price:billing:quote')")
@GetMapping("/quote/products")
@@ -124,7 +124,7 @@ public class BillingController extends BaseController
}
/**
* Historical quote detail with fee lines.
* 历史报价详情,含费用明细行。
*/
@PreAuthorize("@ss.hasPermi('price:billing:quote')")
@GetMapping("/quote/{quoteId}")
@@ -134,7 +134,7 @@ public class BillingController extends BaseController
}
/**
* Same matching logic as TMS open API, for BMS console trial.
* 与 TMS 开放接口使用相同匹配逻辑,供 BMS 后台试算使用。
*/
@PreAuthorize("@ss.hasPermi('price:billing:quote')")
@PostMapping("/quote")
@@ -147,12 +147,28 @@ public class BillingController extends BaseController
@PreAuthorize("@ss.hasPermi('price:billing:bill')")
@GetMapping("/bill/list")
public TableDataInfo billList(PrcOrderBill query)
{
return doBillList(query);
}
/**
* POST 计费列表:大批单号等筛选放请求体,避免 GET URL 过长触发 HTTP 431。
* pageNum/pageSize 仍走 URL 查询参数,供 PageHelper 读取。
*/
@PreAuthorize("@ss.hasPermi('price:billing:bill')")
@PostMapping("/bill/list")
public TableDataInfo billListPost(@RequestBody(required = false) PrcOrderBill query)
{
return doBillList(query);
}
private TableDataInfo doBillList(PrcOrderBill query)
{
if (query == null)
{
query = new PrcOrderBill();
}
// Billing list only shows successfully billed orders.
// 计费列表只展示计费成功的订单。
query.setBillingFailStatuses(limitBillingListFailStatus());
query.setBillingFailStatus(null);
startPage();
@@ -161,8 +177,8 @@ public class BillingController extends BaseController
}
/**
* Async export billing list by current filters (status limited to success=0).
* Requires at least one meaningful filter. Poll task then download.
* 按当前筛选条件异步导出计费列表(状态限定为成功 success=0)。
* 需至少一个有效筛选条件。轮询任务完成后再下载。
*/
@PreAuthorize("@ss.hasPermi('price:billing:export')")
@Log(title = "计费列表", businessType = BusinessType.EXPORT)
@@ -173,7 +189,7 @@ public class BillingController extends BaseController
{
query = new PrcOrderBill();
}
// Filter gate uses the request as-is; defaults applied only for query scope.
// 筛选条件校验使用原始请求;默认值仅用于查询范围。
if (!OrderBillExportSupport.hasExportFilter(query))
{
return error(MessageUtils.message("price.bill.export.filterRequired"));
@@ -206,11 +222,11 @@ public class BillingController extends BaseController
private static List<Integer> limitBillingListFailStatus()
{
// Billing list is success-only (billing_fail_status = 0).
// 计费列表仅包含成功数据(billing_fail_status = 0)。
return new ArrayList<Integer>(Arrays.asList(Integer.valueOf(0)));
}
/** All prc_order_bill rows. Billing list stays limited to status 0. */
/** 全部 prc_order_bill 记录。计费列表仍限定为状态 0。 */
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
@GetMapping("/orderBill/list")
public TableDataInfo orderBillList(PrcOrderBill query)
@@ -220,18 +236,31 @@ public class BillingController extends BaseController
return getDataTable(list);
}
/**
* POST 列表:筛选(尤其是大批量单号)放请求体,避免 GET URL 过长触发 HTTP 431。
* pageNum/pageSize 仍走 URL 查询参数,供 TableSupport/PageHelper 读取。
*/
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
@PostMapping("/orderBill/list")
public TableDataInfo orderBillListPost(@RequestBody(required = false) PrcOrderBill query)
{
startPage();
List<PrcOrderBill> list = prcOrderBillService.selectBillList(query == null ? new PrcOrderBill() : query);
return getDataTable(list);
}
/** Order-list popup: billing fail reason by billId (data-scoped). */
/** 订单列表弹窗:按 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));
}
/**
* Async export order list by current filters.
* Requires at least one meaningful filter (default orderStatuses alone is not enough).
* 按当前筛选条件异步导出订单列表。
* 需至少一个有效筛选条件(仅默认 orderStatuses 不够)。
*/
@PreAuthorize("@ss.hasPermi('price:orderBill:export')")
@Log(title = "订单列表", businessType = BusinessType.EXPORT)
@@ -263,8 +292,8 @@ public class BillingController extends BaseController
}
/**
* Compare local order-bill products vs customer bound package SALES products
* (includes product_code_mapping).
* 对比本地订单账单产品与客户绑定套餐的 SALES 产品
* (包含 product_code_mapping)。
*/
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
@PostMapping("/orderBill/checkProducts")
@@ -274,7 +303,7 @@ public class BillingController extends BaseController
return success(data);
}
/** Drill-down order bills for one product under the same check filters. */
/** 在同一校验筛选条件下,下钻查看单个产品的订单账单。 */
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
@PostMapping("/orderBill/checkProducts/orders")
public AjaxResult listOrderBillsByProduct(@RequestBody PrcOrderBill query)
@@ -283,8 +312,8 @@ public class BillingController extends BaseController
}
/**
* Order-list rebill from local prc_order_bill only (no Oracle TAB_ORDER).
* Poll {@code GET /orderBill/rebill/task/{taskId}}.
* 订单列表重算,仅基于本地 prc_order_bill(不查询 Oracle TAB_ORDER)。
* 轮询 {@code GET /orderBill/rebill/task/{taskId}}。
*/
@PreAuthorize("@ss.hasPermi('price:orderBill:rebill')")
@Log(title = "Order bill local rebill", businessType = BusinessType.UPDATE)
@@ -315,7 +344,7 @@ public class BillingController extends BaseController
}
/**
* Order no options for remote-search dropdown (bill list multi search).
* 远程搜索下拉的订单号选项(计费列表多选搜索)。
*/
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
@GetMapping("/bill/orderNos")
@@ -349,26 +378,26 @@ 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));
}
/**
* ES BILL logs for this order (billing / upstream sync / fail snapshots).
* bizId prefers transferNo then orderNo (same as write path).
* 该订单的 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();
@@ -383,7 +412,7 @@ public class BillingController extends BaseController
int pageSize = pageDomain.getPageSize() == null ? 10 : pageDomain.getPageSize().intValue();
String primary = EsBizLogSupport.billBizId(bill.getTransferNo(), bill.getOrderNo());
BillSearchPage page = billSearchStore.search(EsLogType.BILL, primary, null, pageNum, pageSize);
// Also pull by orderNo when transferNo was used as bizId, so older orderNo-keyed rows appear.
// 当 bizId 使用 transferNo 时,再按 orderNo 拉取一次,以便出现更早的以 orderNo 为 key 的记录。
if (StringUtils.isNotEmpty(bill.getTransferNo()) && StringUtils.isNotEmpty(bill.getOrderNo())
&& !bill.getTransferNo().trim().equalsIgnoreCase(bill.getOrderNo().trim())
&& pageNum == 1)
@@ -448,18 +477,18 @@ public class BillingController extends BaseController
}
/**
* Refund one receivable bill via billing task billType=REFUND.
* 通过计费任务 billType=REFUND 退费单笔应收账单。
*/
@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");
@@ -485,12 +514,12 @@ public class BillingController extends BaseController
}
/**
* Batch update order credit arrears status (ARREARS -> NORMAL) with available-credit check.
* 批量更新订单信用欠款状态(ARREARS -> NORMAL),并校验可用额度。
*/
@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())
{
@@ -498,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
{
@@ -512,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())
@@ -545,7 +574,7 @@ public class BillingController extends BaseController
return success(prcOrderBillService.addIncomeFee(request));
}
/** Preview matched bills for batch add fee (filter: customer / transferNo / country). */
/** 批量加费前预览匹配的账单(筛选:客户 / transferNo / 国家)。 */
@PreAuthorize("@ss.hasPermi('price:billing:feeAdd')")
@PostMapping("/bill/fee/batch/preview")
public AjaxResult previewBatchAddIncomeFee(@RequestBody BatchAddIncomeBillFeeRequest request)
@@ -553,7 +582,7 @@ public class BillingController extends BaseController
return success(prcOrderBillService.previewBatchAddIncomeFee(request));
}
/** Submit async batch add fee; poll /bill/fee/batch/task/{taskId}. */
/** 提交异步批量加费;轮询 /bill/fee/batch/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:billing:feeAdd')")
@Log(title = "Billing batch income fee", businessType = BusinessType.INSERT)
@PostMapping("/bill/fee/batch")
@@ -577,7 +606,7 @@ public class BillingController extends BaseController
return success(task);
}
/** Async recalc product_amount only. Poll /bill/recalcPrice/task/{taskId}. */
/** 仅异步重算 product_amount。轮询 /bill/recalcPrice/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:billing:recalc')")
@Log(title = "Billing recalc product amount", businessType = BusinessType.UPDATE)
@PostMapping("/bill/recalcProduct")
@@ -591,7 +620,7 @@ public class BillingController extends BaseController
return successTask(prcOrderBillService.submitRecalcBillPrice(request));
}
/** Async recalc redline_amount only. Poll /bill/recalcPrice/task/{taskId}. */
/** 仅异步重算 redline_amount。轮询 /bill/recalcPrice/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:billing:recalc')")
@Log(title = "Billing recalc redline amount", businessType = BusinessType.UPDATE)
@PostMapping("/bill/recalcRedline")
@@ -635,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));
}
@@ -648,7 +677,7 @@ public class BillingController extends BaseController
return success(result);
}
/** Update charge_weight (keep weight), then rebill. */
/** 更新 charge_weight(保留 weight),随后重新计费。 */
@PreAuthorize("@ss.hasPermi('price:billing:chargeWeightEdit')")
@Log(title = "Billing charge weight", businessType = BusinessType.UPDATE)
@PutMapping("/bill/chargeWeight")
@@ -658,7 +687,7 @@ public class BillingController extends BaseController
}
/**
* Download import template. fillByFilter=true fills orderNo/customer from list filters.
* 下载导入模板。fillByFilter=true 时按列表筛选条件填充 orderNo/customer。
*/
@PreAuthorize("@ss.hasPermi('price:billing:chargeWeightEdit')")
@PostMapping("/bill/chargeWeight/importTemplate")
@@ -680,8 +709,8 @@ public class BillingController extends BaseController
}
/**
* Async import charge_weight updates and rebill.
* Returns taskId; poll /bill/chargeWeight/import/task/{taskId}.
* 异步导入 charge_weight 更新并重新计费。
* 返回 taskId;轮询 /bill/chargeWeight/import/task/{taskId}。
*/
@PreAuthorize("@ss.hasPermi('price:billing:chargeWeightEdit')")
@Log(title = "Billing charge weight import", businessType = BusinessType.IMPORT)
@@ -712,7 +741,7 @@ public class BillingController extends BaseController
}
catch (Exception e)
{
// Import task already queued; attachment failure should not block rebill
// 导入任务已入队;附件保存失败不应阻塞后续重新计费
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("taskId", taskId);
payload.put("attachmentWarn", e.getMessage());
@@ -733,7 +762,7 @@ public class BillingController extends BaseController
}
/**
* List charge-weight import Excel attachment records.
* 查询收费重导入的 Excel 附件记录。
*/
@PreAuthorize("@ss.hasPermi('price:billing:chargeWeightEdit')")
@GetMapping("/bill/chargeWeight/import/attachments")
@@ -37,7 +37,7 @@ import com.bms.price.service.IPrcPriceExcelFileService;
import com.bms.price.service.IPrcPriceSetService;
/**
* Exclusive quote (shares prc_price_set with PACKAGE)
* 独家报价(与 PACKAGE 共用 prc_price_set 表)
*
* @author bms
*/
@@ -82,7 +82,7 @@ public class ExclusiveQuoteController extends BaseController
set.setCreateBy(getUsername());
set.setUpdateBy(getUsername());
String taskId = priceSetService.submitSaveAsync(set);
// Do not pass bare String to success(): overload puts it into msg, not data.
// 不要向 success() 直接传字符串:该重载会把字符串放进 msg 而不是 data。
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("taskId", taskId);
return success(payload);
@@ -111,7 +111,7 @@ public class ExclusiveQuoteController extends BaseController
return toAjax(priceSetService.updatePrcPriceSet(set));
}
/** Update package name and note only. */
/** 仅更新套餐名称与备注。 */
@PreAuthorize("@ss.hasPermi('price:exclusive:edit')")
@Log(title = "Exclusive quote basic", businessType = BusinessType.UPDATE)
@PutMapping("/basic")
@@ -200,7 +200,7 @@ public class ExclusiveQuoteController extends BaseController
return toAjax(priceSetService.deleteVersion(psvId, getUsername()));
}
/** Import excel attachments for a version (prc_price_excel_file.psv_id). */
/** 版本的 Excel 附件导入(prc_price_excel_file.psv_id)。 */
@PreAuthorize("@ss.hasPermi('price:exclusive:list')")
@GetMapping("/version/{psvId}/excelFiles")
public AjaxResult versionExcelFiles(@PathVariable Long psvId)
@@ -253,7 +253,7 @@ public class ExclusiveQuoteController extends BaseController
return getDataTable(list);
}
/** All detail rows for one product (no page); used by edit-price drawer. */
/** 单个产品的全部明细行(不分页),供改价抽屉使用。 */
@PreAuthorize("@ss.hasPermi('price:exclusive:list')")
@GetMapping("/detail/byProduct")
public AjaxResult detailByProduct(@RequestParam("psvId") Long psvId,
@@ -262,7 +262,7 @@ public class ExclusiveQuoteController extends BaseController
return success(priceSetService.selectDetailListByProduct(psvId, productCode));
}
/** All detail rows for a version (no page); batch prefetch instead of N byProduct calls. */
/** 某个版本的全部明细行(不分页);用批量预取替代 N 次 byProduct 调用。 */
@PreAuthorize("@ss.hasPermi('price:exclusive:list')")
@GetMapping("/detail/byVersion")
public AjaxResult detailByVersion(@RequestParam("psvId") Long psvId)
@@ -318,7 +318,7 @@ public class ExclusiveQuoteController extends BaseController
}
/**
* Preview pull product library (no DB write). For create wizard before finish.
* 预览拉取产品库(不写库),用于新建向导提交前的预览。
*/
@PreAuthorize("@ss.hasPermi('price:exclusive:edit') or @ss.hasPermi('price:exclusive:forceEdit') or @ss.hasPermi('price:exclusive:add')")
@PostMapping("/detail/previewPullFromLibrary")
@@ -328,8 +328,8 @@ public class ExclusiveQuoteController extends BaseController
}
/**
* Preview Excel import (no DB write). Optional detailsJson for updateOnly / build-price merge.
* Optional countryCode = single-country dedicated-line Excel (same as product country import).
* 预览 Excel 导入(不写库)。可选 detailsJson,用于 updateOnly / 构建价格合并。
* 可选 countryCode = 单国家专线 Excel(与按产品国家导入一致)。
*/
@PreAuthorize("@ss.hasPermi('price:exclusive:edit') or @ss.hasPermi('price:exclusive:forceEdit') or @ss.hasPermi('price:exclusive:add')")
@PostMapping("/detail/previewImportPrices")
@@ -359,7 +359,7 @@ public class ExclusiveQuoteController extends BaseController
}
/**
* Async pull product library into version details. Returns taskId; poll /save/task/{taskId}.
* 异步拉取产品库到版本明细。返回 taskId,通过 /save/task/{taskId} 轮询进度。
*/
@PreAuthorize("@ss.hasPermi('price:exclusive:edit') or @ss.hasPermi('price:exclusive:forceEdit')")
@Log(title = "Exclusive quote拉取产品", businessType = BusinessType.IMPORT)
@@ -376,7 +376,7 @@ public class ExclusiveQuoteController extends BaseController
}
/**
* Async batch write of detail surcharge snapshots. Returns taskId; poll /save/task/{taskId}.
* 异步批量写入明细附加费快照。返回 taskId,通过 /save/task/{taskId} 轮询进度。
*/
@PreAuthorize("@ss.hasPermi('price:exclusive:edit') or @ss.hasPermi('price:exclusive:forceEdit')")
@Log(title = "Exclusive quote附加费", businessType = BusinessType.UPDATE)
@@ -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,15 +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.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")
@@ -42,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")
@@ -126,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')")
@@ -157,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')")
@@ -168,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);
@@ -180,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')")
@@ -191,21 +203,84 @@ 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");
}
/** 保存打单产品明细(重量段/附加费等),按当前 version 覆盖子表 */
@PreAuthorize("@ss.hasPermi('price:label:edit')")
@Log(title = "打单产品明细", businessType = BusinessType.UPDATE)
@PutMapping("/product")
public AjaxResult updateProduct(@RequestBody LblProduct 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")
public AjaxResult productChannels(@PathVariable Long productId,
@RequestParam(value = "payType", required = false) String payType)
{
String type = (payType == null || payType.trim().isEmpty()) ? "AR" : payType.trim();
return success(lblProductService.listProductChannelBinds(productId, type));
}
/** 覆盖保存打单产品渠道绑定,写入 srv_channel_product_map */
@PreAuthorize("@ss.hasPermi('price:label:edit')")
@Log(title = "打单产品绑定渠道", businessType = BusinessType.UPDATE)
@PutMapping("/product/{productId}/channels")
public AjaxResult replaceProductChannels(@PathVariable Long productId, @RequestBody Map<String, Object> body)
{
String payType = body == null || body.get("payType") == null ? "AR" : String.valueOf(body.get("payType")).trim();
List<String> channelIds = new ArrayList<String>();
Object rawIds = body == null ? null : body.get("channelIds");
if (rawIds instanceof List<?>)
{
for (Object item : (List<?>) rawIds)
{
if (item != null && !String.valueOf(item).trim().isEmpty())
{
channelIds.add(String.valueOf(item).trim());
}
}
}
String msg = lblProductService.replaceProductChannelBinds(productId, payType, channelIds);
return AjaxResult.success(msg);
}
@PreAuthorize("@ss.hasPermi('price:label:remove')")
@@ -214,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();
}
}
@@ -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));
}
}
@@ -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();
}
}
@@ -22,7 +22,7 @@ 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.common.exception.ServiceException;
import com.bms.common.enums.PaymentMesEnum;
import com.bms.common.utils.file.FileUtils;
import com.bms.common.utils.poi.ExcelUtil;
import com.bms.price.domain.ChannelProductMap;
@@ -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,9 +89,10 @@ 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)
{
return success(payOrderCostService.generate(billId));
payOrderCostService.generate(billId);
return success("操作成功");
}
/** 下载某一版导入时上传的源文件 */
@@ -101,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)
@@ -142,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)
@@ -260,16 +291,16 @@ public class PayProductController extends BaseController
{
if (file == null || file.isEmpty())
{
throw new ServiceException("请选择价卡文件");
throw PaymentMesEnum.BMS_PAY_PICK_FILE.exception();
}
String filename = file.getOriginalFilename();
if (filename == null || !filename.toLowerCase(Locale.ROOT).endsWith(".xlsx"))
{
throw new ServiceException("请上传xlsx价卡");
throw PaymentMesEnum.BMS_PAY_XLSX.exception();
}
if (file.getSize() > 30L * 1024 * 1024)
{
throw new ServiceException("价卡文件不能超过30MB");
throw PaymentMesEnum.BMS_PAY_FILE_30M.exception();
}
}
@@ -55,7 +55,7 @@ public class PriceSetController extends BaseController
@GetMapping("/list")
public TableDataInfo list(PrcPriceSet set)
{
// Ordinary package module: never mix exclusive quotes into this list.
// 普通套餐模块:该列表不混入专属报价。
set.setSetCategory(PrcPriceSet.CATEGORY_PACKAGE);
startPage();
List<PrcPriceSet> list = priceSetService.selectPrcPriceSetList(set);
@@ -83,7 +83,7 @@ public class PriceSetController extends BaseController
set.setCreateBy(getUsername());
set.setUpdateBy(getUsername());
String taskId = priceSetService.submitSaveAsync(set);
// Do not pass bare String to success(): overload puts it into msg, not data.
// 不要向 success() 直接传裸 String:重载会把它放入 msg 而不是 data。
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("taskId", taskId);
return success(payload);
@@ -112,7 +112,7 @@ public class PriceSetController extends BaseController
return toAjax(priceSetService.updatePrcPriceSet(set));
}
/** Update package name and note only. */
/** 仅更新套餐名称和备注。 */
@PreAuthorize("@ss.hasPermi('price:set:edit')")
@Log(title = "价格套餐基本信息", businessType = BusinessType.UPDATE)
@PutMapping("/basic")
@@ -190,7 +190,7 @@ public class PriceSetController extends BaseController
return toAjax(priceSetService.deleteVersion(psvId, getUsername()));
}
/** Import excel attachments for a version (prc_price_excel_file.psv_id). */
/** 某个版本的导入 Excel 附件(prc_price_excel_file.psv_id)。 */
@PreAuthorize("@ss.hasPermi('price:set:list')")
@GetMapping("/version/{psvId}/excelFiles")
public AjaxResult versionExcelFiles(@PathVariable Long psvId)
@@ -240,7 +240,7 @@ public class PriceSetController extends BaseController
return getDataTable(list);
}
/** All detail rows for one product (no page); used by edit-price drawer. */
/** 某个产品的全部明细行(不分页);供改价抽屉使用。 */
@PreAuthorize("@ss.hasPermi('price:set:list')")
@GetMapping("/detail/byProduct")
public AjaxResult detailByProduct(@RequestParam("psvId") Long psvId,
@@ -249,7 +249,7 @@ public class PriceSetController extends BaseController
return success(priceSetService.selectDetailListByProduct(psvId, productCode));
}
/** All detail rows for a version (no page); batch prefetch instead of N byProduct calls. */
/** 某个版本的全部明细行(不分页);批量预取,避免 N 次 byProduct 调用。 */
@PreAuthorize("@ss.hasPermi('price:set:list')")
@GetMapping("/detail/byVersion")
public AjaxResult detailByVersion(@RequestParam("psvId") Long psvId)
@@ -304,7 +304,7 @@ public class PriceSetController extends BaseController
}
/**
* Preview pull product library (no DB write). For create wizard before finish.
* 预览从产品库拉取(不写库)。用于新建向导完成前的预览。
*/
@PreAuthorize("@ss.hasPermi('price:set:edit') or @ss.hasPermi('price:set:forceEdit') or @ss.hasPermi('price:set:add')")
@PostMapping("/detail/previewPullFromLibrary")
@@ -314,8 +314,8 @@ public class PriceSetController extends BaseController
}
/**
* Preview Excel import (no DB write). Optional detailsJson for updateOnly / build-price merge.
* Optional countryCode = single-country dedicated-line Excel (same as product country import).
* 预览 Excel 导入(不写库)。可选 detailsJson 用于 updateOnly / 构建价格时的合并。
* 可选 countryCode = 单国家专线 Excel(与产品国家导入一致)。
*/
@PreAuthorize("@ss.hasPermi('price:set:edit') or @ss.hasPermi('price:set:forceEdit') or @ss.hasPermi('price:set:add')")
@PostMapping("/detail/previewImportPrices")
@@ -345,7 +345,7 @@ public class PriceSetController extends BaseController
}
/**
* Async pull product library into version details. Returns taskId; poll /save/task/{taskId}.
* 异步从产品库拉取到版本明细。返回 taskId;轮询 /save/task/{taskId}。
*/
@PreAuthorize("@ss.hasPermi('price:set:edit') or @ss.hasPermi('price:set:forceEdit')")
@Log(title = "套餐拉取产品", businessType = BusinessType.IMPORT)
@@ -361,7 +361,7 @@ public class PriceSetController extends BaseController
}
/**
* Async batch write of detail surcharge snapshots. Returns taskId; poll /save/task/{taskId}.
* 异步批量写入明细附加费快照。返回 taskId;轮询 /save/task/{taskId}。
*/
@PreAuthorize("@ss.hasPermi('price:set:edit') or @ss.hasPermi('price:set:forceEdit')")
@Log(title = "套餐附加费", businessType = BusinessType.UPDATE)
@@ -63,8 +63,8 @@ public class ProductController extends BaseController
}
/**
* Product dropdown (non-paged). Slim query, no list-page status refresh.
* Used by price-set / billing / customer bind; login required, no extra perm.
* 产品下拉(非分页)。精简查询,不做列表页状态刷新。
* 供价格套餐 / 计费 / 客户绑定使用;需登录,无额外权限要求。
*/
@GetMapping("/optionselect")
public AjaxResult optionselect(BmsProduct product)
@@ -139,7 +139,7 @@ public class ProductController extends BaseController
return success();
}
/** Persist create-page preview details into draft/pending/effect version. */
/** 将新建页预览明细保存到草稿/待生效/生效版本。 */
@PreAuthorize("@ss.hasPermi('price:product:add') or @ss.hasPermi('price:product:edit')")
@Log(title = "product preview apply", businessType = BusinessType.UPDATE)
@PostMapping("/version/applyPreview")
@@ -148,7 +148,7 @@ public class ProductController extends BaseController
return success(productService.applyCatalogPreview(body));
}
/** Async parallel save of create-page preview. Returns taskId; poll /import/task/{taskId}. */
/** 异步并行保存新建页预览。返回 taskId;轮询 /import/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:product:add') or @ss.hasPermi('price:product:edit')")
@Log(title = "product preview apply", businessType = BusinessType.UPDATE)
@PostMapping("/version/applyPreviewAsync")
@@ -160,7 +160,7 @@ public class ProductController extends BaseController
return success(payload);
}
/** Save import Excel attachment onto a draft/pending/effect version (prc_price_excel_file). */
/** 将导入 Excel 附件保存到草稿/待生效/生效版本(prc_price_excel_file)。 */
@PreAuthorize("@ss.hasPermi('price:product:import')")
@Log(title = "product version excel", businessType = BusinessType.IMPORT)
@PostMapping("/version/{psvId}/excel")
@@ -176,7 +176,7 @@ public class ProductController extends BaseController
return success(row);
}
/** List Excel attachments of a version. */
/** 查询某个版本的 Excel 附件列表。 */
@PreAuthorize("@ss.hasPermi('price:product:query')")
@GetMapping("/version/{psvId}/excelFiles")
public AjaxResult listVersionExcelFiles(@PathVariable Long psvId)
@@ -201,8 +201,8 @@ public class ProductController extends BaseController
}
/**
* Async import Weishi B2C workbook. Returns taskId; poll /import/task/{taskId}.
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
* 异步导入 Weishi B2C 工作簿。返回 taskId;轮询 /import/task/{taskId}。
* effectiveDate 必填:写入 product / product_country;原有未失效记录在该日期失效。
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:product:import')")
@@ -217,8 +217,8 @@ public class ProductController extends BaseController
}
/**
* Async single-country cost-sheet import. Returns taskId; poll /import/task/{taskId}.
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
* 异步导入单国家成本表。返回 taskId;轮询 /import/task/{taskId}。
* effectiveDate 必填:写入 product / product_country;原有未失效记录在该日期失效。
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:product:import')")
@@ -233,7 +233,7 @@ public class ProductController extends BaseController
return success(payload);
}
/** Async parse-only preview; returns taskId, poll /import/task/{taskId} for result. */
/** 仅解析的异步预览;返回 taskId,轮询 /import/task/{taskId} 获取结果。 */
@PreAuthorize("@ss.hasPermi('price:product:import')")
@PostMapping("/previewImport")
public AjaxResult previewImport(
@@ -246,7 +246,7 @@ public class ProductController extends BaseController
return success(payload);
}
/** Async single-country parse-only preview; returns taskId, poll /import/task/{taskId}. */
/** 单国家仅解析的异步预览;返回 taskId,轮询 /import/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:product:import')")
@PostMapping("/previewImportCountry")
public AjaxResult previewImportCountry(
@@ -139,7 +139,7 @@ public class RedlineProductController extends BaseController
return success();
}
/** Persist create-page preview details into draft/pending/effect version. */
/** 将新建页预览明细保存到草稿/待生效/生效版本。 */
@PreAuthorize("@ss.hasPermi('price:redline:add') or @ss.hasPermi('price:redline:edit')")
@Log(title = "redline preview apply", businessType = BusinessType.UPDATE)
@PostMapping("/version/applyPreview")
@@ -148,7 +148,7 @@ public class RedlineProductController extends BaseController
return success(productService.applyCatalogPreview(body));
}
/** Async parallel save of create-page preview. Returns taskId; poll /import/task/{taskId}. */
/** 异步并行保存新建页预览。返回 taskId;轮询 /import/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:redline:add') or @ss.hasPermi('price:redline:edit')")
@Log(title = "redline preview apply", businessType = BusinessType.UPDATE)
@PostMapping("/version/applyPreviewAsync")
@@ -160,7 +160,7 @@ public class RedlineProductController extends BaseController
return success(payload);
}
/** Save import Excel attachment onto a draft/pending/effect version (prc_price_excel_file). */
/** 将导入 Excel 附件保存到草稿/待生效/生效版本(prc_price_excel_file)。 */
@PreAuthorize("@ss.hasPermi('price:redline:import')")
@Log(title = "redline version excel", businessType = BusinessType.IMPORT)
@PostMapping("/version/{psvId}/excel")
@@ -176,7 +176,7 @@ public class RedlineProductController extends BaseController
return success(row);
}
/** List Excel attachments of a version. */
/** 查询某个版本的 Excel 附件列表。 */
@PreAuthorize("@ss.hasPermi('price:redline:query')")
@GetMapping("/version/{psvId}/excelFiles")
public AjaxResult listVersionExcelFiles(@PathVariable Long psvId)
@@ -201,8 +201,8 @@ public class RedlineProductController extends BaseController
}
/**
* Async import Weishi B2C workbook. Returns taskId; poll /import/task/{taskId}.
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
* 异步导入 Weishi B2C 工作簿。返回 taskId;轮询 /import/task/{taskId}。
* effectiveDate 必填:写入 product / product_country;原有未失效记录在该日期失效。
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:redline:import')")
@@ -217,8 +217,8 @@ public class RedlineProductController extends BaseController
}
/**
* Async single-country cost-sheet import. Returns taskId; poll /import/task/{taskId}.
* effectiveDate is required: written to product / product_country; previous open rows expire at this date.
* 异步导入单国家成本表。返回 taskId;轮询 /import/task/{taskId}。
* effectiveDate 必填:写入 product / product_country;原有未失效记录在该日期失效。
*/
@Log(title = "产品列表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('price:redline:import')")
@@ -233,7 +233,7 @@ public class RedlineProductController extends BaseController
return success(payload);
}
/** Async parse-only preview; returns taskId, poll /import/task/{taskId} for result. */
/** 仅解析的异步预览;返回 taskId,轮询 /import/task/{taskId} 获取结果。 */
@PreAuthorize("@ss.hasPermi('price:redline:import')")
@PostMapping("/previewImport")
public AjaxResult previewImport(
@@ -246,7 +246,7 @@ public class RedlineProductController extends BaseController
return success(payload);
}
/** Async single-country parse-only preview; returns taskId, poll /import/task/{taskId}. */
/** 单国家仅解析的异步预览;返回 taskId,轮询 /import/task/{taskId}。 */
@PreAuthorize("@ss.hasPermi('price:redline:import')")
@PostMapping("/previewImportCountry")
public AjaxResult previewImportCountry(
@@ -20,6 +20,7 @@ import com.bms.common.core.page.TableDataInfo;
import com.bms.common.enums.BusinessType;
import com.bms.price.domain.PrcSurcharge;
import com.bms.price.domain.PrcSurchargeRel;
import com.bms.price.service.IPayPostcodeService;
import com.bms.price.service.IPrcSurchargeRelService;
import com.bms.price.service.IPrcSurchargeService;
@@ -38,6 +39,9 @@ public class SurchargeController extends BaseController
@Autowired
private IPrcSurchargeRelService surchargeRelService;
@Autowired
private IPayPostcodeService payPostcodeService;
@PreAuthorize("@ss.hasPermi('price:surcharge:list')")
@GetMapping("/list")
public TableDataInfo list(PrcSurcharge surcharge)
@@ -47,6 +51,15 @@ public class SurchargeController extends BaseController
return getDataTable(list);
}
/** 按国家从应付邮编配置拉取区块/分区选项 */
@PreAuthorize("@ss.hasPermi('price:surcharge:list') or @ss.hasPermi('price:surcharge:query') or @ss.hasPermi('price:surcharge:add') or @ss.hasPermi('price:surcharge:edit')")
@GetMapping("/blockOptions")
public AjaxResult blockOptions(@RequestParam(required = false) String countryCode,
@RequestParam(required = false) String countryName)
{
return success(payPostcodeService.selectBlockTitlesByCountry(countryCode, countryName));
}
@PreAuthorize("@ss.hasPermi('price:surcharge:query')")
@GetMapping("/{scId}")
public AjaxResult getInfo(@PathVariable Long scId)
@@ -3,6 +3,7 @@ package com.bms.web.controller.receivable;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;
import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -30,13 +31,14 @@ import com.bms.receivable.domain.ArBillGenerateTask;
import com.bms.receivable.domain.ArBillLog;
import com.bms.receivable.domain.vo.ArBillActionRequest;
import com.bms.receivable.domain.vo.ArBillGenerateQuery;
import com.bms.receivable.domain.vo.ArBillGeneratePreviewExportRow;
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.enums.ArBillDateType;
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;
import com.bms.common.core.controller.BaseController;
import com.bms.common.core.domain.AjaxResult;
@@ -61,9 +63,15 @@ public class ArBillController extends BaseController {
@Autowired
private IArBillService billService;
@Autowired
private ArBillVoidTaskService voidTaskService;
@Autowired
private ArBillScopeResolver billScope;
@Autowired
private ArBillGeneratePreviewExportRunner previewExportRunner;
/** 应收筛选专用客户选项,与账单使用同一角色规则。 */
@PreAuthorize("@ss.hasPermi('ar:bill:list')")
@GetMapping("/customer-options")
@@ -168,32 +176,37 @@ 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());
result.put("totalAmount", billService.sumPreviewBill(query));
return result;
}
/** 按生成预览使用的相同筛选条件导出全部匹配订单,不受分页参数影响。 */
/** 按需汇总生成预览范围内的应收金额。 */
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
@PostMapping("/generate/preview/amount")
public AjaxResult previewAmount(@RequestBody ArBillGenerateQuery query) {
return success(billService.sumPreviewBill(query));
}
/** 按生成预览使用的相同筛选条件提交异步导出任务。 */
@Log(title = "应收账单生成订单", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
@PostMapping("/generate/preview/export")
public void exportGeneratePreview(HttpServletResponse response, ArBillGenerateQuery query,
HttpServletRequest request) {
rejectMultiValueParameter(request, "customerId");
ArBillGenerateQuery exportQuery = query == null ? new ArBillGenerateQuery() : query;
List<PrcOrderBill> bills = billService.previewBill(exportQuery);
List<ArBillGeneratePreviewExportRow> rows = new ArrayList<>(bills.size());
for (PrcOrderBill bill : bills) {
rows.add(ArBillGeneratePreviewExportRow.from(bill));
}
ExcelUtil<ArBillGeneratePreviewExportRow> util = new ExcelUtil<>(ArBillGeneratePreviewExportRow.class);
if (ArBillDateType.PICKUP_DATE == ArBillDateType.of(exportQuery.getDateType())) {
util.hideColumn("bizDate");
} else {
util.hideColumn("pickupDate");
}
util.exportExcel(response, rows, "应收账单待生成订单");
public AjaxResult exportGeneratePreview(@RequestBody ArBillGenerateQuery query) {
return success(Map.of("taskId", previewExportRunner.submit(query, getUserId())));
}
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
@GetMapping("/generate/preview/export/task/{taskId}")
public AjaxResult generatePreviewExportTask(@PathVariable String taskId) {
return success(previewExportRunner.getTask(taskId, getUserId()));
}
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
@GetMapping("/generate/preview/export/download/{taskId}")
public void downloadGeneratePreviewExport(@PathVariable String taskId, HttpServletResponse response)
throws Exception {
previewExportRunner.download(taskId, getUserId(), response);
}
/** 查询需要从全选结果中排除的订单;空条件不执行查询,避免返回全部订单。 */
@@ -207,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;
@@ -289,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));
}
/**
@@ -323,9 +342,16 @@ public class ArBillController extends BaseController {
}
/**
* 下载已成功生成的导出文件;文件内容由服务层从临时文件或配置存储读取。
* 获取已成功生成导出文件的下载方式;OSS 文件返回短时签名链接,本地历史文件走原下载接口。
*/
@PreAuthorize("@ss.hasPermi('ar:bill:download')")
@GetMapping("/export/{exportId}/download-url")
public AjaxResult exportDownloadInfo(@PathVariable Long exportId) {
return success(billService.getExportDownloadInfo(exportId));
}
/** 下载本地历史导出文件;OSS 文件由前端通过签名链接直接下载。 */
@PreAuthorize("@ss.hasPermi('ar:bill:download')")
@GetMapping("/export/{exportId}/download")
public void download(@PathVariable Long exportId, HttpServletResponse response) throws Exception {
billService.downloadExport(exportId, response);
@@ -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)
@@ -47,7 +47,7 @@ public class SysFileTemplateController extends BaseController
return success(fileTemplateService.selectSysFileTemplateById(templateId));
}
/** Meta by file code (authenticated; used by import dialogs). */
/** 按文件编码获取元信息(需登录,供导入弹窗使用)。 */
@GetMapping("/code/{fileCode}")
public AjaxResult getByCode(@PathVariable String fileCode)
{
@@ -91,7 +91,7 @@ public class SysFileTemplateController extends BaseController
}
/**
* Download by file_code. Login required; no admin perm so import pages can use it.
* 按 file_code 下载。需要登录,但不校验管理员权限,便于导入页面调用。
*/
@GetMapping("/download/{fileCode}")
public void download(@PathVariable String fileCode, HttpServletResponse response) throws Exception
@@ -0,0 +1,204 @@
package com.bms.web.controller.tool;
import java.util.List;
import java.util.Map;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
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.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.annotation.Log;
import com.bms.common.constant.ScheduleConstants;
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.common.exception.ServiceException;
import com.bms.common.exception.job.TaskException;
import com.bms.common.utils.StringUtils;
import com.bms.quartz.domain.SysJob;
import com.bms.quartz.service.ISysJobService;
import com.bms.quartz.util.CronUtils;
import com.bms.system.domain.SysDataMigration;
import com.bms.system.domain.SysDataMigrationLog;
import com.bms.system.service.ISysDataMigrationService;
/** 系统工具 - 数据迁移:保存 SQL、手动/定时执行(Quartz) */
@RestController
@RequestMapping("/tool/migration")
public class DataMigrationController extends BaseController
{
private static final String JOB_GROUP = "DATA_MIGRATION";
@Autowired
private ISysDataMigrationService migrationService;
@Autowired
private ISysJobService jobService;
@PreAuthorize("@ss.hasPermi('tool:migration:list')")
@GetMapping("/list")
public TableDataInfo list(SysDataMigration query)
{
startPage();
List<SysDataMigration> list = migrationService.selectSysDataMigrationList(query);
return getDataTable(list);
}
@PreAuthorize("@ss.hasPermi('tool:migration:query')")
@GetMapping("/{migrationId}")
public AjaxResult getInfo(@PathVariable Long migrationId)
{
return success(migrationService.selectSysDataMigrationById(migrationId));
}
@PreAuthorize("@ss.hasPermi('tool:migration:add')")
@Log(title = "数据迁移", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDataMigration row) throws SchedulerException, TaskException
{
row.setCreateBy(getUsername());
migrationService.insertSysDataMigration(row);
syncJob(row);
return success(row);
}
@PreAuthorize("@ss.hasPermi('tool:migration:edit')")
@Log(title = "数据迁移", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDataMigration row) throws SchedulerException, TaskException
{
row.setUpdateBy(getUsername());
migrationService.updateSysDataMigration(row);
SysDataMigration fresh = migrationService.selectSysDataMigrationById(row.getMigrationId());
syncJob(fresh);
return success(fresh);
}
@PreAuthorize("@ss.hasPermi('tool:migration:remove')")
@Log(title = "数据迁移", businessType = BusinessType.DELETE)
@DeleteMapping("/{migrationIds}")
public AjaxResult remove(@PathVariable Long[] migrationIds) throws SchedulerException
{
if (migrationIds != null)
{
for (Long id : migrationIds)
{
SysDataMigration row = migrationService.selectSysDataMigrationById(id);
if (row != null)
{
removeJob(row);
}
}
}
return toAjax(migrationService.deleteSysDataMigrationByIds(migrationIds));
}
@PreAuthorize("@ss.hasPermi('tool:migration:run')")
@Log(title = "数据迁移执行", businessType = BusinessType.OTHER)
@PostMapping("/run/{migrationId}")
public AjaxResult run(@PathVariable Long migrationId)
{
Map<String, Object> result = migrationService.executeMigration(migrationId, "MANUAL", getUsername());
return success(result);
}
@PreAuthorize("@ss.hasPermi('tool:migration:log')")
@GetMapping("/log/list")
public TableDataInfo logList(SysDataMigrationLog query)
{
startPage();
List<SysDataMigrationLog> list = migrationService.selectSysDataMigrationLogList(query);
return getDataTable(list);
}
private void syncJob(SysDataMigration row) throws SchedulerException, TaskException
{
if (row == null || row.getMigrationId() == null)
{
return;
}
boolean enable = "0".equals(row.getStatus()) && StringUtils.isNotEmpty(row.getCronExpression());
if (enable && !CronUtils.isValid(row.getCronExpression()))
{
throw new ServiceException("Cron 表达式不正确");
}
if (!enable)
{
removeJob(row);
return;
}
String invokeTarget = "dataMigrationTask.executeById(" + row.getMigrationId() + "L)";
String jobName = "data-migration-" + row.getMigrationId();
if (row.getJobId() != null)
{
SysJob existed = jobService.selectJobById(row.getJobId());
if (existed != null)
{
existed.setJobName(jobName);
existed.setJobGroup(JOB_GROUP);
existed.setInvokeTarget(invokeTarget);
existed.setCronExpression(row.getCronExpression());
existed.setMisfirePolicy("3");
existed.setConcurrent("1");
existed.setUpdateBy(getUsername());
existed.setRemark(row.getMigrationName());
jobService.updateJob(existed);
existed.setStatus(ScheduleConstants.Status.NORMAL.getValue());
jobService.changeStatus(existed);
return;
}
}
SysJob job = new SysJob();
job.setJobName(jobName);
job.setJobGroup(JOB_GROUP);
job.setInvokeTarget(invokeTarget);
job.setCronExpression(row.getCronExpression());
job.setMisfirePolicy("3");
job.setConcurrent("1");
job.setCreateBy(getUsername());
job.setRemark(row.getMigrationName());
jobService.insertJob(job);
job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
jobService.changeStatus(job);
SysDataMigration patch = new SysDataMigration();
patch.setMigrationId(row.getMigrationId());
patch.setJobId(job.getJobId());
patch.setUpdateBy(getUsername());
migrationService.updateSysDataMigration(patch);
row.setJobId(job.getJobId());
}
private void removeJob(SysDataMigration row) throws SchedulerException
{
if (row == null || row.getJobId() == null)
{
return;
}
SysJob job = jobService.selectJobById(row.getJobId());
if (job != null)
{
jobService.deleteJob(job);
}
SysDataMigration patch = new SysDataMigration();
patch.setMigrationId(row.getMigrationId());
patch.setJobId(null);
// keep job_id clear: update XML only sets jobId when non-null; force via dedicated clear
clearJobId(row.getMigrationId());
}
private void clearJobId(Long migrationId)
{
migrationService.clearJobId(migrationId);
}
}
@@ -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
@@ -191,7 +206,7 @@ xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice
excludes: /system/notice,/tool/migration
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
@@ -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,122 @@
package com.bms.receivable;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.util.ReflectionTestUtils;
import com.bms.common.core.domain.entity.SysUser;
import com.bms.common.core.domain.model.LoginUser;
import com.bms.common.exception.ServiceException;
import com.bms.receivable.domain.ArBill;
import com.bms.receivable.domain.ArBillLog;
import com.bms.receivable.mapper.ArBillDetailMapper;
import com.bms.receivable.mapper.ArBillExportMapper;
import com.bms.receivable.mapper.ArBillMapper;
import com.bms.receivable.security.ArBillScopeResolver;
import com.bms.receivable.service.IArBillLogService;
import com.bms.receivable.service.impl.ArBillServiceImpl;
class ArBillConfirmTest {
private final ArBillMapper billMapper = mock(ArBillMapper.class);
private final ArBillDetailMapper detailMapper = mock(ArBillDetailMapper.class);
private final ArBillExportMapper exportMapper = mock(ArBillExportMapper.class);
private final ArBillScopeResolver scope = mock(ArBillScopeResolver.class);
private final IArBillLogService logService = mock(IArBillLogService.class);
private final ArBillServiceImpl service = new ArBillServiceImpl();
@BeforeEach
void setUp() {
ReflectionTestUtils.setField(service, "billMapper", billMapper);
ReflectionTestUtils.setField(service, "detailMapper", detailMapper);
ReflectionTestUtils.setField(service, "exportMapper", exportMapper);
ReflectionTestUtils.setField(service, "billScope", scope);
ReflectionTestUtils.setField(service, "logService", logService);
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(
new LoginUser(7L, 1L, new SysUser(), Set.of()), null));
}
@AfterEach
void clearSecurity() {
SecurityContextHolder.clearContext();
}
@Test
void readyDraftCanBeConfirmedWithoutReadingDetails() {
ArBill draft = bill("DRAFT", "READY");
draft.setTotalAmount(new BigDecimal("123.45"));
ArBill confirmed = bill("CONFIRMED", "READY");
when(billMapper.selectArBillByIdForUpdate(11L)).thenReturn(draft);
when(billMapper.updateArBillStatus(11L, "CONFIRMED", null, "finance", "DRAFT")).thenReturn(1);
when(billMapper.selectArBillByIdScoped(11L, null)).thenReturn(confirmed);
when(exportMapper.selectByBillId(11L)).thenReturn(List.of());
assertSame(confirmed, service.confirmBill(11L, null, "finance", "request-1"));
verify(scope).requireBillAccessible(11L);
verifyNoInteractions(detailMapper);
verify(logService).record(any(ArBillLog.class));
}
@Test
void unfinishedOrNonDraftBillStillCannotBeConfirmed() {
when(billMapper.selectArBillByIdForUpdate(11L)).thenReturn(
bill("DRAFT", "GENERATING"), bill("CONFIRMED", "READY"));
ServiceException unfinished = assertThrows(ServiceException.class,
() -> service.confirmBill(11L, null, "finance", "request-1"));
assertEquals("账单尚未生成完成,暂不能确认", unfinished.getMessage());
ServiceException notDraft = assertThrows(ServiceException.class,
() -> service.confirmBill(11L, null, "finance", "request-2"));
assertEquals("只有草稿账单可以确认,当前状态为 CONFIRMED", notDraft.getMessage());
verify(billMapper, never()).updateArBillStatus(eq(11L), any(), nullable(String.class), any(), any());
verifyNoInteractions(detailMapper);
}
@Test
void inaccessibleBillStillCannotBeConfirmed() {
when(billMapper.selectArBillByIdForUpdate(11L)).thenReturn(bill("DRAFT", "READY"));
doThrow(new ServiceException("账单不存在或无权访问")).when(scope).requireBillAccessible(11L);
assertThrows(ServiceException.class, () -> service.confirmBill(11L, null, "finance", "request-1"));
verify(billMapper, never()).updateArBillStatus(eq(11L), any(), nullable(String.class), any(), any());
verifyNoInteractions(detailMapper);
}
@Test
void concurrentStatusChangeStillPreventsConfirmation() {
when(billMapper.selectArBillByIdForUpdate(11L)).thenReturn(bill("DRAFT", "READY"));
ServiceException error = assertThrows(ServiceException.class,
() -> service.confirmBill(11L, null, "finance", "request-1"));
assertEquals("账单状态已发生变化,请刷新后重试", error.getMessage());
verify(logService, never()).record(any(ArBillLog.class));
verifyNoInteractions(detailMapper);
}
private static ArBill bill(String status, String generationStatus) {
ArBill bill = new ArBill();
bill.setArBillId(11L);
bill.setStatus(status);
bill.setGenerationStatus(generationStatus);
return bill;
}
}
@@ -0,0 +1,112 @@
package com.bms.receivable;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.InputStream;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.test.util.ReflectionTestUtils;
import com.github.pagehelper.PageHelper;
import com.bms.common.config.BmsConfig;
import com.bms.common.core.domain.AjaxResult;
import com.bms.common.core.redis.RedisCache;
import com.bms.price.domain.PrcOrderBill;
import com.bms.receivable.domain.vo.ArBillGenerateQuery;
import com.bms.receivable.security.ArBillScopeResolver;
import com.bms.receivable.service.IArBillService;
import com.bms.receivable.task.ArBillGeneratePreviewExportRunner;
import com.bms.web.controller.receivable.ArBillController;
class ArBillGeneratePreviewTest {
@TempDir
Path tempDir;
@Test
void previewDoesNotCalculateAmountUntilAmountEndpointIsCalled() {
IArBillService service = mock(IArBillService.class);
ArBillController controller = new ArBillController();
ReflectionTestUtils.setField(controller, "billService", service);
ArBillGenerateQuery query = new ArBillGenerateQuery();
when(service.previewBill(query)).thenReturn(List.of(new PrcOrderBill()));
when(service.sumPreviewBill(query)).thenReturn(new BigDecimal("12.34"));
try {
AjaxResult preview = controller.preview(query);
assertFalse(preview.containsKey("totalAmount"));
verify(service, never()).sumPreviewBill(query);
} finally {
PageHelper.clearPage();
}
assertEquals(new BigDecimal("12.34"), controller.previewAmount(query).get("data"));
verify(service).sumPreviewBill(query);
}
@Test
void exportEndsWithTheSumOfTheExportedAmounts() throws Exception {
String previousProfile = BmsConfig.getProfile();
try {
new BmsConfig().setProfile(tempDir.toString());
IArBillService service = mock(IArBillService.class);
ArBillGenerateQuery query = new ArBillGenerateQuery();
when(service.previewBill(same(query), isNull())).thenReturn(List.of(
bill("A", "0.10"), bill("B", "0.20"), bill("C", "-0.05"), bill("D", null)));
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor() {
@Override
public void execute(Runnable task) {
task.run();
}
};
ArBillGeneratePreviewExportRunner runner = new ArBillGeneratePreviewExportRunner(
service, mock(RedisCache.class), mock(ArBillScopeResolver.class), executor);
for (String dateType : List.of("BIZ_DATE", "PICKUP_DATE")) {
query.setDateType(dateType);
String taskId = runner.submit(query, 1L);
Path file = tempDir.resolve("download/arBillGeneratePreviewExport/" + taskId + ".xlsx");
try (InputStream in = Files.newInputStream(file); Workbook workbook = WorkbookFactory.create(in)) {
Sheet sheet = workbook.getSheetAt(0);
Row header = sheet.getRow(0);
Row lastRow = sheet.getRow(sheet.getLastRowNum());
assertEquals("合计", lastRow.getCell(column(header, "订单号")).getStringCellValue());
assertEquals(0.25, lastRow.getCell(column(header, "应收金额")).getNumericCellValue(), 0.000001);
assertEquals(5, sheet.getLastRowNum());
}
}
} finally {
new BmsConfig().setProfile(previousProfile);
}
}
private static PrcOrderBill bill(String orderNo, String amount) {
PrcOrderBill bill = new PrcOrderBill();
bill.setOrderNo(orderNo);
bill.setIncomeTotal(amount == null ? null : new BigDecimal(amount));
return bill;
}
private static int column(Row header, String name) {
for (int i = 0; i < header.getLastCellNum(); i++) {
if (name.equals(header.getCell(i).getStringCellValue())) return i;
}
throw new AssertionError("缺少导出列: " + name);
}
}
@@ -1,9 +1,11 @@
package com.bms.report;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Proxy;
import java.math.BigDecimal;
@@ -11,18 +13,93 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import com.bms.common.core.domain.entity.SysUser;
import com.bms.common.core.domain.model.LoginUser;
import com.bms.receivable.domain.ArBalanceWriteoff;
import com.bms.receivable.domain.ArBill;
import com.bms.receivable.mapper.ArBillMapper;
import com.bms.receivable.mapper.ArCommissionMapper;
import com.bms.receivable.profit.ArCommissionRate;
import com.bms.receivable.profit.ArCommissionResult;
import com.bms.receivable.profit.ArCommissionService;
import com.bms.receivable.profit.ArProfitScope;
import com.bms.receivable.profit.ArProfitScopeResolver;
import com.bms.receivable.profit.ArWriteoffRate;
import com.bms.common.exception.ServiceException;
class ArCommissionServiceTest
{
@Test
void rateConfirmationRequiresCompleteProfitDataBeforeAnyWrite()
{
List<String> calls = new ArrayList<>();
AtomicReference<Integer> complete = new AtomicReference<>(0);
ArCommissionMapper mapper = (ArCommissionMapper) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] { ArCommissionMapper.class }, (proxy, method, args) -> {
calls.add(method.getName());
return switch (method.getName()) {
case "selectBillIdByWriteoffId" -> 25L;
case "isBillProfitDataComplete" -> complete.get();
case "confirmMissingRate", "reverseResults" -> 1;
case "countMissingRates" -> 0;
case "selectSettlementInputs" -> List.of();
default -> throw new AssertionError(method.getName());
};
});
ArBill bill = new ArBill();
bill.setProfitSalesUserId(7L);
bill.setGenerationStatus("READY");
ArBillMapper billMapper = (ArBillMapper) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class<?>[] { ArBillMapper.class }, (proxy, method, args) -> {
if ("selectArBillByIdForUpdate".equals(method.getName())) return bill;
throw new AssertionError(method.getName());
});
ArProfitScopeResolver resolver = new ArProfitScopeResolver() {
@Override public ArProfitScope resolve() { return new ArProfitScope(true, false, false, 1L, 1L); }
};
ArCommissionService service = new ArCommissionService(mapper, resolver, null, billMapper);
ArWriteoffRate input = new ArWriteoffRate();
input.setWriteoffId(18L);
input.setRate(new BigDecimal("5"));
input.setRemark("已核对");
for (String status : List.of("CONFIRMED", "PARTIAL_WRITTEN_OFF", "WRITTEN_OFF"))
{
bill.setStatus(status);
calls.clear();
ServiceException error = assertThrows(ServiceException.class, () -> service.confirmMissingRate(input));
assertTrue(error.getMessage().contains("请先处理后再确认比例"));
assertFalse(calls.contains("confirmMissingRate"));
assertFalse(calls.contains("reverseResults"));
}
complete.set(null);
assertThrows(ServiceException.class, () -> service.confirmMissingRate(input));
complete.set(1);
SysUser user = new SysUser();
user.setUserName("finance");
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken(new LoginUser(user, java.util.Set.of()), null));
try
{
bill.setStatus("PARTIAL_WRITTEN_OFF");
calls.clear();
service.confirmMissingRate(input);
assertTrue(calls.contains("confirmMissingRate"));
assertFalse(calls.contains("reverseResults"));
bill.setStatus("WRITTEN_OFF");
calls.clear();
service.confirmMissingRate(input);
assertTrue(calls.indexOf("isBillProfitDataComplete") < calls.indexOf("confirmMissingRate"));
assertTrue(calls.contains("reverseResults"));
assertTrue(calls.contains("selectSettlementInputs"));
}
finally
{
SecurityContextHolder.clearContext();
}
}
@Test
void commissionReadsUseServerResolvedScopeAndManagementRemainsRestricted()
{
@@ -158,6 +158,17 @@ class ArProfitMapperSqlTest
.getBoundSql(Map.of("billId", 1L)).getSql();
assertTrue(settlement.contains("w.status = 'EFFECTIVE'"));
assertTrue(settlement.contains("b.status = 'WRITTEN_OFF'"));
String validation = configuration.getMappedStatement("com.bms.receivable.mapper.ArCommissionMapper.isBillProfitDataComplete")
.getBoundSql(Map.of("billId", 1L)).getSql();
assertTrue(validation.contains("detail.ar_bill_id = ?"));
assertTrue(validation.contains("d.ar_bill_id = ?"));
assertTrue(validation.contains("a.detail_total = b.total_amount"));
assertTrue(validation.contains("f.sales_amount = d.total_amount"));
assertTrue(validation.contains("f.fee_currency = d.currency"));
assertTrue(validation.contains("f.product_complete = 1"));
assertTrue(validation.contains("f.redline_complete = 1"));
assertFalse(validation.contains("b.status = 'WRITTEN_OFF'"));
assertFalse(validation.contains("profit_calc_status"));
var insert = configuration.getMappedStatement("com.bms.receivable.mapper.ArCommissionMapper.insertResults")
.getBoundSql(Map.of("items", java.util.List.of(new ArCommissionResult(), new ArCommissionResult()), "operator", "test"));
assertTrue(insert.getSql().contains("ar_profit_commission_result"));
@@ -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); }
}
}
@@ -164,10 +164,11 @@ public class Constants
* 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
* com.bms.customer 覆盖客户/供应商资料同步、客户授信到期等业务任务包;
* com.bms.masterdata.task 为渠道产品主数据同步任务;com.bms.notify.task 为客户超额通知;
* com.bms.price.task 为价格/产品状态刷新任务
* com.bms.price.task 为价格/产品状态刷新任务;com.bms.system.migration 为数据迁移任务
*/
public static final String[] JOB_WHITELIST_STR = { "com.bms.quartz.task", "com.bms.customer",
"com.bms.masterdata.task", "com.bms.notify.task", "com.bms.price.task" };
"com.bms.masterdata.task", "com.bms.notify.task", "com.bms.price.task",
"com.bms.system.migration" };
/**
* 定时任务违规的字符
@@ -0,0 +1,236 @@
package com.bms.common.enums;
import java.util.HashMap;
import java.util.Map;
import com.bms.common.exception.ServiceException;
/**
* 应付报错。只收没有拼接变量的固定提示。
* code 以 BMS_PAY 开头,name 是这条提示用在哪一步,cnMes 是弹出的中文,enMes 先留空。
*/
public enum PaymentMesEnum
{
BMS_PAY_PICK_ORDER("BMS_PAY_PICK_ORDER", "生成应付校验订单", "请选择订单"),
BMS_PAY_ORDER_MISS("BMS_PAY_ORDER_MISS", "生成应付校验订单", "订单不存在"),
BMS_PAY_NO_COST("BMS_PAY_NO_COST", "生成应付计算结果", "没有算出应付费用"),
BMS_PAY_NO_ZONE("BMS_PAY_NO_ZONE", "生成应付匹配邮编", "邮编没有对上价卡地区"),
BMS_PAY_NO_CHANNEL("BMS_PAY_NO_CHANNEL", "生成应付匹配渠道", "订单没有渠道服务商"),
BMS_PAY_CH_SYNC("BMS_PAY_CH_SYNC", "生成应付匹配渠道", "订单没有渠道服务商,或渠道尚未同步"),
BMS_PAY_NO_PRODUCT("BMS_PAY_NO_PRODUCT", "应付计费匹配产品", "没有应付产品"),
BMS_PAY_NO_WEIGHT("BMS_PAY_NO_WEIGHT", "订单判断重量", "订单没有计费重"),
BMS_PAY_PICK_PROD("BMS_PAY_PICK_PROD", "应付产品保存", "请先勾选要保存的产品"),
BMS_PAY_PROD_LIMIT("BMS_PAY_PROD_LIMIT", "应付产品保存", "一次最多保存80个产品"),
BMS_PAY_PROD_FIELD("BMS_PAY_PROD_FIELD", "应付产品保存", "产品名称、工作表和文件摘要不能为空"),
BMS_PAY_PICK_EDIT("BMS_PAY_PICK_EDIT", "应付产品修改", "请选择要修改的产品"),
BMS_PAY_PROD_MISS("BMS_PAY_PROD_MISS", "应付产品修改", "产品不存在或已删除"),
BMS_PAY_TPL_ONLY("BMS_PAY_TPL_ONLY", "应付产品修改", "渠道价格请在渠道页面保存,这里只改公共模板"),
BMS_PAY_SAVE_CH("BMS_PAY_SAVE_CH", "渠道应付价格", "请先保存渠道,再维护价格"),
BMS_PAY_NO_PRICE("BMS_PAY_NO_PRICE", "渠道应付价格", "没有可保存的价格"),
BMS_PAY_REIMPORT("BMS_PAY_REIMPORT", "应付价卡导入", "重新导入时请使用单个产品文件,或先选定渠道上的应付产品"),
BMS_PAY_PICK_IMP("BMS_PAY_PICK_IMP", "应付价卡导入", "请先选择一个已导入的应付产品"),
BMS_PAY_DICT_EMPTY("BMS_PAY_DICT_EMPTY", "应付产品字典", "应付产品字典还没有数据"),
BMS_PAY_TERM_START("BMS_PAY_TERM_START", "应付有效期", "请填写生效开始"),
BMS_PAY_TERM_END("BMS_PAY_TERM_END", "应付有效期", "生效结束不能早于生效开始"),
BMS_PAY_PICK_VER("BMS_PAY_PICK_VER", "应付有效期", "请选择要修改的版本"),
BMS_PAY_TERM_MISS("BMS_PAY_TERM_MISS", "应付有效期", "有效期不存在"),
BMS_PAY_TERM_STAT("BMS_PAY_TERM_STAT", "应付有效期", "状态只能是待生效、生效或已失效"),
BMS_PAY_FILE_DOWN("BMS_PAY_FILE_DOWN", "应付价卡源文件", "源文件下载失败"),
BMS_PAY_NO_SOURCE("BMS_PAY_NO_SOURCE", "应付价卡源文件", "这一版没有可下载的源文件"),
BMS_PAY_FILE_UP("BMS_PAY_FILE_UP", "应付价卡源文件", "价卡文件上传失败"),
BMS_PAY_FILE_WAIT("BMS_PAY_FILE_WAIT", "应付价卡源文件", "源文件还没有上传成功,请重新选择价卡后再保存"),
BMS_PAY_CH_FIRST("BMS_PAY_CH_FIRST", "渠道绑定产品", "请先保存渠道,再选择产品"),
BMS_PAY_CH_MISS("BMS_PAY_CH_MISS", "渠道绑定产品", "渠道不存在或渠道编码为空"),
BMS_PAY_PICK_CH("BMS_PAY_PICK_CH", "渠道绑定产品", "请先勾选渠道"),
BMS_PAY_PICK_SIDE("BMS_PAY_PICK_SIDE", "渠道绑定产品", "请至少选择应付或应收产品"),
BMS_PAY_BIND_NONE("BMS_PAY_BIND_NONE", "渠道绑定产品", "没有可绑定的渠道"),
BMS_PAY_CH_PROD("BMS_PAY_CH_PROD", "渠道应付产品", "渠道还没有选择应付产品"),
BMS_PAY_OUT_TERM("BMS_PAY_OUT_TERM", "应付价格有效期", "订单时间没有落在价格有效期内"),
BMS_PAY_TWO_VER("BMS_PAY_TWO_VER", "应付价格对比", "请选择两个价格版本"),
BMS_PAY_AR_AP("BMS_PAY_AR_AP", "收付类型", "收付类型只能是应收AR或应付AP"),
BMS_PAY_AP_MISS("BMS_PAY_AP_MISS", "应付产品查询", "应付产品不存在或已删除"),
BMS_PAY_PICK_FILE("BMS_PAY_PICK_FILE", "应付价卡文件", "请选择价卡文件"),
BMS_PAY_XLSX("BMS_PAY_XLSX", "应付价卡文件", "请上传xlsx价卡"),
BMS_PAY_FILE_30M("BMS_PAY_FILE_30M", "应付价卡文件", "价卡文件不能超过30MB"),
BMS_PAY_NO_SHEET("BMS_PAY_NO_SHEET", "应付价卡解析", "文件里没有工作表"),
BMS_PAY_NO_QUOTE("BMS_PAY_NO_QUOTE", "应付价卡解析", "目录里没有找到产品报价表"),
BMS_PAY_BAD_XLS("BMS_PAY_BAD_XLS", "应付价卡解析", "价卡无法读取,请确认是 Excel 报价文件"),
BMS_PAY_PICK_XLS("BMS_PAY_PICK_XLS", "应付邮编导入", "请选择 Excel 文件"),
BMS_PAY_XLS_30M("BMS_PAY_XLS_30M", "应付邮编导入", "文件不能超过30MB"),
BMS_PAY_ZIP_READ("BMS_PAY_ZIP_READ", "应付邮编导入", "邮编表无法读取,请确认是 Excel 文件"),
BMS_PAY_XLSX_ONLY("BMS_PAY_XLSX_ONLY", "应付邮编导入", "只支持 xlsx 文件"),
BMS_PAY_ZIP_EDIT("BMS_PAY_ZIP_EDIT", "应付邮编配置", "请选择要修改的邮编配置"),
BMS_PAY_ZIP_MISS("BMS_PAY_ZIP_MISS", "应付邮编配置", "邮编配置不存在或已删除"),
BMS_PAY_ZIP_TYPE("BMS_PAY_ZIP_TYPE", "应付邮编配置", "类型只能是附加费或邮编分区"),
BMS_PAY_ZIP_HEAD("BMS_PAY_ZIP_HEAD", "应付邮编导入", "没有识别到邮编或附加费邮编,请确认表头里有邮编、ZIP 或附加费"),
BMS_PAY_ZIP_ATTR("BMS_PAY_ZIP_ATTR", "应付邮编配置", "邮编属性只能是可达、不可达或偏远"),
BMS_PAY_BILL_MISS("BMS_PAY_BILL_MISS", "应付账单查询", "应付账单不存在"),
BMS_PAY_PICK_SUP("BMS_PAY_PICK_SUP", "应付账单生成", "请选择供应商"),
BMS_PAY_SUP_MISS("BMS_PAY_SUP_MISS", "应付账单生成", "供应商不存在"),
BMS_PAY_NO_GEN("BMS_PAY_NO_GEN", "应付账单生成", "没有可生成的订单"),
BMS_PAY_BILL_FEE("BMS_PAY_BILL_FEE", "应付账单生成", "订单没有应付费用"),
BMS_PAY_CURRENCY("BMS_PAY_CURRENCY", "应付账单生成", "所选订单币种不一致,请按币种分开生成"),
BMS_PAY_DRAFT("BMS_PAY_DRAFT", "应付账单确认", "只有草稿可以确认"),
BMS_PAY_CONFIRM("BMS_PAY_CONFIRM", "应付账单付款", "请先确认账单,再登记付款"),
BMS_PAY_PICK_BILL("BMS_PAY_PICK_BILL", "应付账单作废", "请选择应付账单"),
BMS_PAY_VOID_WHY("BMS_PAY_VOID_WHY", "应付账单作废", "请填写作废原因"),
BMS_PAY_VOIDED("BMS_PAY_VOIDED", "应付账单作废", "账单已经作废"),
BMS_PAY_PAID("BMS_PAY_PAID", "应付账单作废", "已付款的账单不能直接作废,请先冲回付款"),
BMS_PAY_ORDER_NO("BMS_PAY_ORDER_NO", "应付账单查询", "请填写订单号"),
BMS_PAY_BIZ_DATE("BMS_PAY_BIZ_DATE", "应付账单查询", "请选择计费日起止"),
BMS_PAY_LADING_NO("BMS_PAY_LADING_NO", "应付账单查询", "请填写提单号"),
BMS_PAY_QUERY("BMS_PAY_QUERY", "应付账单查询", "请选择查询方式"),
BMS_PAY_NO_ALLOC("BMS_PAY_NO_ALLOC", "提单费用分摊", "所选提单没有需要分摊的费用"),
BMS_PAY_ALLOC_ST("BMS_PAY_ALLOC_ST", "提单费用分摊", "费用状态已变化,请重新打开后再分摊"),
BMS_PAY_PICK_LAD("BMS_PAY_PICK_LAD", "提单费用分摊", "请勾选提单"),
BMS_PAY_LAD_LIMIT("BMS_PAY_LAD_LIMIT", "提单费用分摊", "单次最多处理5条提单"),
BMS_PAY_NO_CHANGE("BMS_PAY_NO_CHANGE", "提单费用保存", "没有需要保存的变更"),
BMS_PAY_IMP_EMPTY("BMS_PAY_IMP_EMPTY", "提单费用导入", "导入文件没有费用数据"),
BMS_PAY_IMP_DEMO("BMS_PAY_IMP_DEMO", "提单费用导入", "请删除示例行后再导入有效费用"),
BMS_PAY_FEE_BODY("BMS_PAY_FEE_BODY", "提单费用保存", "请提交要保存的费用"),
BMS_PAY_DEL_ID("BMS_PAY_DEL_ID", "提单费用删除", "要删除的费用缺少编号"),
BMS_PAY_FEE_DUP("BMS_PAY_FEE_DUP", "提单费用保存", "同一条费用不能重复提交"),
BMS_PAY_FEE_GONE("BMS_PAY_FEE_GONE", "提单费用保存", "费用已删除或不属于该提单"),
BMS_PAY_FEE_LOCK("BMS_PAY_FEE_LOCK", "提单费用删除", "已分摊或已确定的费用不能删除,请使用作废"),
BMS_PAY_EDIT_ID("BMS_PAY_EDIT_ID", "提单费用修改", "要修改的费用缺少编号"),
BMS_PAY_FEE_EDIT("BMS_PAY_FEE_EDIT", "提单费用修改", "已分摊或已确定的费用不能修改"),
BMS_PAY_PICK_OK("BMS_PAY_PICK_OK", "提单费用确定", "请选择要确定的费用"),
BMS_PAY_OK_STAT("BMS_PAY_OK_STAT", "提单费用确定", "只有已分摊的费用可以确定"),
BMS_PAY_OK_CHG("BMS_PAY_OK_CHG", "提单费用确定", "费用状态已变化,请刷新后再确定"),
BMS_PAY_PICK_VOID("BMS_PAY_PICK_VOID", "提单费用作废", "请选择要作废的费用"),
BMS_PAY_VOID_STAT("BMS_PAY_VOID_STAT", "提单费用作废", "只有已分摊或已确定的费用可以作废"),
BMS_PAY_VOID_CHG("BMS_PAY_VOID_CHG", "提单费用作废", "费用状态已变化,请刷新后再作废"),
BMS_PAY_NO_PERM("BMS_PAY_NO_PERM", "提单费用权限", "没有权限修改该费用"),
BMS_PAY_FEE_ENTRY("BMS_PAY_FEE_ENTRY", "提单费用保存", "费用入口不正确"),
BMS_PAY_FORBIDDEN("BMS_PAY_FORBIDDEN", "提单费用权限", "没有权限"),
BMS_PAY_PICK_ITEM("BMS_PAY_PICK_ITEM", "提单费用校验", "请选择费用项"),
BMS_PAY_ITEM_MISS("BMS_PAY_ITEM_MISS", "提单费用校验", "费用项不存在"),
BMS_PAY_LEVEL("BMS_PAY_LEVEL", "提单费用校验", "费用阶段不在字典中"),
BMS_PAY_PRICE("BMS_PAY_PRICE", "提单费用校验价格", "请填写价格"),
BMS_PAY_PRICE_NEG("BMS_PAY_PRICE_NEG", "提单费用校验价格", "价格不能小于0"),
BMS_PAY_PRICE_LEN("BMS_PAY_PRICE_LEN", "提单费用校验价格", "价格整数部分不能超过16位"),
BMS_PAY_CUR_PICK("BMS_PAY_CUR_PICK", "提单费用校验币种", "请选择收费币种"),
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_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<>();
static
{
for (PaymentMesEnum item : values())
{
BY_CODE.put(item.code, item);
}
}
private final String code;
private final String name;
private final String cnMes;
private final String enMes;
PaymentMesEnum(String code, String name, String cnMes)
{
this(code, name, cnMes, "");
}
PaymentMesEnum(String code, String name, String cnMes, String enMes)
{
this.code = code;
this.name = name;
this.cnMes = cnMes;
this.enMes = enMes == null ? "" : enMes;
}
public String getCode()
{
return code;
}
public String getName()
{
return name;
}
public String getCnMes()
{
return cnMes;
}
public String getEnMes()
{
return enMes;
}
/** 按编码取出提示。没有对应编码时返回 null。 */
public static PaymentMesEnum of(String code)
{
if (code == null || code.isBlank())
{
return null;
}
return BY_CODE.get(code.trim());
}
/** 弹出给用户的中文提示。英文未配置时仍返回中文。 */
public String text()
{
return cnMes == null || cnMes.isBlank() ? enMes : cnMes;
}
/** 转成业务异常,页面只看到中文提示。 */
public ServiceException exception()
{
return new ServiceException(text()).setDetailMessage(code);
}
}
@@ -169,9 +169,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
/**
* Normalize destination postcode for zone match / persist.
* Removes all Unicode whitespace (incl. NBSP / U+2005) and ASCII spaces;
* strips Excel-style trailing ".0" on pure digits.
* 规范化目的地邮编,用于分区匹配/持久化。
* 移除所有 Unicode 空白字符(包括 NBSP / U+2005)和 ASCII 空格;
* 去除纯数字末尾 Excel 风格的 ".0"。
*/
public static String normalizePostcode(String postcode)
{
@@ -681,12 +681,12 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
/**
* Compares given {@code string} to a CharSequences vararg of {@code searchStrings},
* returning {@code true} if the {@code string} is equal to any of the {@code searchStrings}, ignoring case.
* 将给定的 {@code string} 与 {@code searchStrings} 可变参数中的字符序列进行比较,
* 如果 {@code string} 与其中任意一个 {@code searchStrings} 相等(忽略大小写),则返回 {@code true}。
*
* @param string to compare, may be {@code null}.
* @param searchStrings a vararg of strings, may be {@code null}.
* @return {@code true} if the string is equal (case-insensitive) to any other element of {@code searchStrings};
* @param string 要比较的字符串,可能为 {@code null}。
* @param searchStrings 字符串可变参数,可能为 {@code null}。
* @return 如果字符串与 {@code searchStrings} 中的任意其他元素相等(不区分大小写),则返回 {@code true};
*/
public static boolean equalsAnyIgnoreCase(final CharSequence string, final CharSequence... searchStrings)
{
@@ -29,13 +29,13 @@ public class MimeTypeUtils
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
// 图片
"bmp", "gif", "jpg", "jpeg", "png",
// word excel powerpoint
// Word、Excel、PowerPoint 文档
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt",
// 压缩文件
"rar", "zip", "gz", "bz2",
// 视频格式
"mp4", "avi", "rmvb",
// pdf
// pdf 文档
"pdf" };
public static String getExtension(String prefix)
@@ -1,18 +1,25 @@
package com.bms.common.utils.file;
import java.net.URL;
import java.net.URLEncoder;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Date;
import com.aliyun.oss.ClientBuilderConfiguration;
import com.aliyun.oss.HttpMethod;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.GeneratePresignedUrlRequest;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.ResponseHeaderOverrides;
import com.bms.common.config.OssProperties;
import com.bms.common.exception.ServiceException;
import org.springframework.stereotype.Component;
@@ -67,6 +74,28 @@ public class OssStorage {
}
}
/** 为私有 OSS 对象生成带附件文件名的限时下载链接。 */
public String generatePresignedDownloadUrl(String storageKey, String fileName, Date expiresAt) {
String objectKey = resolveObjectKey(storageKey);
OSS client = createClient();
try {
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(
properties.getBucket(), objectKey, HttpMethod.GET);
request.setExpiration(expiresAt);
String downloadName = StringUtils.hasText(fileName) ? fileName : "账单导出.xlsx";
String encodedFileName = URLEncoder.encode(downloadName, StandardCharsets.UTF_8).replace("+", "%20");
ResponseHeaderOverrides responseHeaders = new ResponseHeaderOverrides();
responseHeaders.setContentDisposition("attachment; filename=" + encodedFileName
+ ";filename*=utf-8''" + encodedFileName);
request.setResponseHeaders(responseHeaders);
URL signedUrl = client.generatePresignedUrl(request);
return signedUrl.toExternalForm();
} finally {
client.shutdown();
}
}
public void delete(String storageKey) {
String objectKey = resolveObjectKey(storageKey);
OSS client = createClient();
@@ -20,7 +20,7 @@ public class EscapeUtil
TEXT[i] = new char[] { (char) i };
}
// special HTML characters
// 特殊的 HTML 字符
TEXT['\''] = "&#039;".toCharArray(); // 单引号
TEXT['"'] = "&#34;".toCharArray(); // 双引号
TEXT['&'] = "&#38;".toCharArray(); // &符
@@ -18,7 +18,7 @@ import java.util.regex.Pattern;
public final class HTMLFilter
{
/**
* regex flag union representing /si modifiers in php
* 表示 php 中 /si 修饰符的正则表达式标志组合
**/
private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL;
private static final Pattern P_COMMENTS = Pattern.compile("<!--(.*?)-->", Pattern.DOTALL);
@@ -45,60 +45,60 @@ public final class HTMLFilter
private static final Pattern P_RIGHT_ARROW = Pattern.compile(">");
private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>");
// @xxx could grow large... maybe use sesat's ReferenceMap
// @xxx 可能会变得很大……也许可以使用 sesat 的 ReferenceMap
private static final ConcurrentMap<String, Pattern> P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>();
private static final ConcurrentMap<String, Pattern> P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>();
/**
* set of allowed html elements, along with allowed attributes for each element
* 允许的 html 元素集合,以及每个元素允许的属性
**/
private final Map<String, List<String>> vAllowed;
/**
* counts of open tags for each (allowable) html element
* 每个(允许的)html 元素当前打开的标签计数
**/
private final Map<String, Integer> vTagCounts = new HashMap<>();
/**
* html elements which must always be self-closing (e.g. "<img />")
* 必须始终自闭合的 html 元素(例如 "<img />")
**/
private final String[] vSelfClosingTags;
/**
* html elements which must always have separate opening and closing tags (e.g. "<b></b>")
* 必须始终具有独立开始和结束标签的 html 元素(例如 "<b></b>")
**/
private final String[] vNeedClosingTags;
/**
* set of disallowed html elements
* 不允许的 html 元素集合
**/
private final String[] vDisallowed;
/**
* attributes which should be checked for valid protocols
* 需要校验协议是否有效的属性
**/
private final String[] vProtocolAtts;
/**
* allowed protocols
* 允许的协议
**/
private final String[] vAllowedProtocols;
/**
* tags which should be removed if they contain no content (e.g. "<b></b>" or "<b />")
* 内容为空时应移除的标签(例如 "<b></b>" 或 "<b />")
**/
private final String[] vRemoveBlanks;
/**
* entities allowed within html markup
* html 标记中允许的实体
**/
private final String[] vAllowedEntities;
/**
* flag determining whether comments are allowed in input String.
* 用于标识输入字符串中是否允许注释的标志。
*/
private final boolean stripComment;
private final boolean encodeQuotes;
/**
* flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "<b text </b>"
* becomes "<b> text </b>"). If set to false, unbalanced angle brackets will be html escaped.
* 用于标识在遇到“不配对”的尖括号时是否尝试构造标签的标志(例如 "<b text </b>"
* 会变成 "<b> text </b>")。如果设置为 false,不配对的尖括号将被 html 转义。
*/
private final boolean alwaysMakeTags;
/**
* Default constructor.
* 默认构造方法。
*/
public HTMLFilter()
{
@@ -125,7 +125,7 @@ public final class HTMLFilter
vSelfClosingTags = new String[] { "img" };
vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
vDisallowed = new String[] {};
vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
vAllowedProtocols = new String[] { "http", "mailto", "https" }; // 不支持 ftp。
vProtocolAtts = new String[] { "src", "href" };
vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
@@ -135,9 +135,9 @@ public final class HTMLFilter
}
/**
* Map-parameter configurable constructor.
* 可通过 Map 参数配置的构造方法。
*
* @param conf map containing configuration. keys match field names.
* @param conf 包含配置的 map。键与字段名一致。
*/
@SuppressWarnings("unchecked")
public HTMLFilter(final Map<String, Object> conf)
@@ -171,7 +171,7 @@ public final class HTMLFilter
}
// ---------------------------------------------------------------
// my versions of some PHP library functions
// 我实现的某些 PHP 库函数版本
public static String chr(final int decimal)
{
return String.valueOf((char) decimal);
@@ -190,10 +190,10 @@ public final class HTMLFilter
// ---------------------------------------------------------------
/**
* given a user submitted input String, filter out any invalid or restricted html.
* 对用户提交的输入字符串,过滤掉任何无效或受限的 html。
*
* @param input text (i.e. submitted by a user) than may contain html
* @return "clean" version of input, with only valid, whitelisted html elements allowed
* @param input 可能包含 html 的文本(即用户提交的内容)
* @return 输入的“干净”版本,仅允许有效且在 html 白名单中的元素
*/
public String filter(final String input)
{
@@ -242,7 +242,7 @@ public final class HTMLFilter
if (alwaysMakeTags)
{
//
// try and form html
// 尝试构造 html
//
s = regexReplace(P_END_ARROW, "", s);
// 不追加结束标签
@@ -253,15 +253,15 @@ public final class HTMLFilter
else
{
//
// escape stray brackets
// 转义多余的括号
//
s = regexReplace(P_STRAY_LEFT_ARROW, "&lt;$1", s);
s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2&gt;<", s);
//
// the last regexp causes '<>' entities to appear
// (we need to do a lookahead assertion so that the last bracket can
// be used in the next pass of the regexp)
// 上一个正则表达式会导致出现 "<>" 实体
// (我们需要使用先行断言,以便最后一个括号
// 可以在正则表达式的下一次匹配中使用)
//
s = regexReplace(P_BOTH_ARROWS, "", s);
}
@@ -282,8 +282,8 @@ public final class HTMLFilter
}
m.appendTail(buf);
// these get tallied in processTag
// (remember to reset before subsequent calls to filter method)
// 这些计数在 processTag 中进行累加
// (记住在后续调用 filter 方法之前重置计数)
final StringBuilder sBuilder = new StringBuilder(buf.toString());
for (String key : vTagCounts.keySet())
{
@@ -325,7 +325,7 @@ public final class HTMLFilter
private String processTag(final String s)
{
// ending tags
// 结束标签
Matcher m = P_END_TAG.matcher(s);
if (m.find())
{
@@ -343,7 +343,7 @@ public final class HTMLFilter
}
}
// starting tags
// 开始标签
m = P_START_TAG.matcher(s);
if (m.find())
{
@@ -424,7 +424,7 @@ public final class HTMLFilter
}
}
// comments
// 注释
m = P_COMMENT.matcher(s);
if (!stripComment && m.find())
{
@@ -443,7 +443,7 @@ public final class HTMLFilter
final String protocol = m.group(1);
if (!inArray(protocol, vAllowedProtocols))
{
// bad protocol, turn into local anchor link instead
// 协议不合法,改为本地锚点链接
s = "#" + s.substring(protocol.length() + 1);
if (s.startsWith("#//"))
{
@@ -499,7 +499,7 @@ public final class HTMLFilter
{
StringBuffer buf = new StringBuffer();
// validate entities throughout the string
// 校验整个字符串中的实体
Matcher m = P_VALID_ENTITIES.matcher(s);
while (m.find())
{
@@ -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;
/**
* 工作表名称
*/
@@ -569,12 +570,12 @@ public class ExcelUtil<T>
}
/**
* Common one-liner export for controllers.
* 供控制器使用的通用一行式导出方法。
*
* @param response HTTP response
* @param list export rows
* @param clazz row class with @Excel fields
* @param sheetName sheet / file title
* @param response HTTP 响应
* @param list 导出的数据行
* @param clazz 带有 @Excel 注解字段的数据行类
* @param sheetName sheet / 文件标题
*/
public static <E> void export(HttpServletResponse response, List<E> list, Class<E> clazz, String sheetName)
{
@@ -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;
}
/**
* 获取子列表最大数
*/
@@ -75,10 +75,10 @@ public final class Base64
}
/**
* Encodes hex octects into Base64
* 将十六进制字节编码为 Base64
*
* @param binaryData Array containing binaryData
* @return Encoded Base64 array
* @param binaryData 包含二进制数据的数组
* @return 编码后的 Base64 数组
*/
public static String encode(byte[] binaryData)
{
@@ -124,7 +124,7 @@ public final class Base64
encodedData[encodedIndex++] = lookUpBase64Alphabet[b3 & 0x3f];
}
// form integral number of 6-bit groups
// 组成完整的 6 位组
if (fewerThan24bits == EIGHTBIT)
{
b1 = binaryData[dataIndex];
@@ -154,10 +154,10 @@ public final class Base64
}
/**
* Decodes Base64 data into octects
* 将 Base64 数据解码为字节
*
* @param encoded string containing Base64 data
* @return Array containind decoded data.
* @param encoded 包含 Base64 数据的字符串
* @return 包含解码后数据的数组。
*/
public static byte[] decode(String encoded)
{
@@ -167,12 +167,12 @@ public final class Base64
}
char[] base64Data = encoded.toCharArray();
// remove white spaces
// 去除空白字符
int len = removeWhiteSpace(base64Data);
if (len % FOURBYTE != 0)
{
return null;// should be divisible by four
return null;// 应为 4 的倍数
}
int numberQuadruple = (len / FOURBYTE);
@@ -198,7 +198,7 @@ public final class Base64
|| !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++])))
{
return null;
} // if found "no data" just return null
} // 如果未找到数据,直接返回 null
b1 = base64Alphabet[d1];
b2 = base64Alphabet[d2];
@@ -212,7 +212,7 @@ public final class Base64
if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])))
{
return null;// if found "no data" just return null
return null;// 如果未找到数据,直接返回 null
}
b1 = base64Alphabet[d1];
@@ -221,10 +221,10 @@ public final class Base64
d3 = base64Data[dataIndex++];
d4 = base64Data[dataIndex++];
if (!isData((d3)) || !isData((d4)))
{// Check if they are PAD characters
{// 检查它们是否为 PAD 字符
if (isPad(d3) && isPad(d4))
{
if ((b2 & 0xf) != 0)// last 4 bits should be zero
if ((b2 & 0xf) != 0)// 最后 4 位应为零
{
return null;
}
@@ -236,7 +236,7 @@ public final class Base64
else if (!isPad(d3) && isPad(d4))
{
b3 = base64Alphabet[d3];
if ((b3 & 0x3) != 0)// last 2 bits should be zero
if ((b3 & 0x3) != 0)// 最后 2 位应为零
{
return null;
}
@@ -252,7 +252,7 @@ public final class Base64
}
}
else
{ // No PAD e.g 3cQl
{ // 没有 PAD,例如 3cQl
b3 = base64Alphabet[d3];
b4 = base64Alphabet[d4];
decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
@@ -264,10 +264,10 @@ public final class Base64
}
/**
* remove WhiteSpace from MIME containing encoded Base64 data.
* 从包含已编码 Base64 数据的 MIME 中移除空白字符。
*
* @param data the byte array of base64 data (with WS)
* @return the new length
* @param data Base64 数据的字节数组(含空白字符)
* @return 新的长度
*/
private static int removeWhiteSpace(char[] data)
{
@@ -276,7 +276,7 @@ public final class Base64
return 0;
}
// count characters that's not whitespace
// 统计非空白字符的数量
int newSize = 0;
int len = data.length;
for (int i = 0; i < len; i++)
@@ -97,10 +97,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
randomBytes[6] &= 0x0f; /* 清除版本位 */
randomBytes[6] |= 0x40; /* 设置为版本 4 */
randomBytes[8] &= 0x3f; /* 清除变体位 */
randomBytes[8] |= 0x80; /* 设置为 IETF 变体 */
return new UUID(randomBytes);
}
@@ -123,10 +123,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
throw new InternalError("MD5 not supported");
}
byte[] md5Bytes = md.digest(name);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
md5Bytes[6] &= 0x0f; /* 清除版本位 */
md5Bytes[6] |= 0x30; /* 设置为版本 3 */
md5Bytes[8] &= 0x3f; /* 清除变体位 */
md5Bytes[8] |= 0x80; /* 设置为 IETF 变体 */
return new UUID(md5Bytes);
}
@@ -198,7 +198,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
*/
public int version()
{
// Version is bits masked by 0x000000000000F000 in MS long
// 版本号是最高有效长整型中被 0x000000000000F000 掩码的位
return (int) ((mostSigBits >> 12) & 0x0f);
}
@@ -217,11 +217,11 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
*/
public int variant()
{
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
// 该字段由数量可变的位组成。
// 0 - - 为 NCS 向后兼容保留
// 1 0 - IETF 即 Leach-Salz 变体(本类使用)
// 1 1 0 保留,微软向后兼容
// 1 1 1 保留供以后定义使用。
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62))) & (leastSigBits >> 63));
}
@@ -403,7 +403,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits);
}
// Comparison Operations
// 比较操作
/**
* 将此 UUID 与指定的 UUID 比较。
@@ -419,8 +419,8 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
@Override
public int compareTo(UUID val)
{
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
// 此处有意这样设置比较顺序,使得 UUID
// 可以简单地作为两个数字进行数值比较
return (this.mostSigBits < val.mostSigBits ? -1 : //
(this.mostSigBits > val.mostSigBits ? 1 : //
(this.leastSigBits < val.leastSigBits ? -1 : //
@@ -429,7 +429,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
}
// -------------------------------------------------------------------------------------------------------------------
// Private method start
// 私有方法开始
/**
* 返回指定数字对应的hex值
*
@@ -106,7 +106,7 @@ public class MyBatisConfig
}
catch (IOException e)
{
// ignore
// 忽略
}
}
}
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Component;
public class TmsApiProperties
{
/**
* Agreed API identification code (header X-Api-Code or body apiCode).
* 约定的 API 标识码(请求头 X-Api-Code 或请求体 apiCode)。
*/
private String apiCode = "BMS.TMS.ZYaOvlQzpcfau8TUaCFfO3Hp8ieHIqGw";
@@ -59,7 +59,7 @@ public class BmsCustomerPriceSet extends BaseEntity
/** 计价类型 FIXED=固定价 DISCOUNT=折扣 */
private String setType;
/** Package status D=pending-enable A=audit E=effective R=reject S=stopped */
/** 套餐状态 D=待启用 A=审核 E=生效 R=拒绝 S=停用 */
private String priceSetStatus;
/** 套餐生效日期 */
@@ -26,7 +26,7 @@ public class BmsPriceSetOption
/** 计价类型 FIXED=固定价 DISCOUNT=折扣 */
private String setType;
/** Package status D=pending-enable A=audit E=effective R=reject S=stopped */
/** 套餐状态 D=待启用 A=审核 E=生效 R=拒绝 S=停用 */
private String status;
/** 生效日期 */
@@ -94,7 +94,7 @@ public class BmsCustomerPriceSetServiceImpl implements IBmsCustomerPriceSetServi
if (existing != null)
{
bind.setCustomerPricesetId(existing.getCustomerPricesetId());
// UI no longer collects bind dates: keep existing when not passed.
// UI 不再收集绑定日期:未传时保留原值。
if (bind.getPrBegindate() == null)
{
bind.setPrBegindate(existing.getPrBegindate());
@@ -107,7 +107,7 @@ public class BmsCustomerPriceSetServiceImpl implements IBmsCustomerPriceSetServi
}
else
{
// pr_begindate NOT NULL; UI omits it — default to now (same as price-set bind).
// pr_begindate NOT NULL,UI 未传时默认取当前时间(与价格套餐绑定一致)。
if (bind.getPrBegindate() == null)
{
bind.setPrBegindate(DateUtils.getNowDate());
@@ -525,7 +525,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
}
catch (RuntimeException e)
{
// Concurrent first-create: peer may have inserted; re-lock existing row.
// 并发首次创建:其他节点可能已插入;重新锁定已存在的行。
if (isAccountInitRace(e))
{
account = customerMoneyMapper.selectAccountForUpdate(customerId, BASE_CURRENCY);
@@ -539,7 +539,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
}
}
/** Deadlock / duplicate key while inserting ctr_customer_account. */
/** 插入 ctr_customer_account 时出现死锁 / 唯一键冲突。 */
private static boolean isAccountInitRace(Throwable e)
{
Throwable t = e;
@@ -607,7 +607,7 @@ public class CustomerAccountApiImpl implements ICustomerAccountApi
flow.setEffectiveDate(effectiveDate);
flow.setExpireDate(expireDate);
flow.setReason("账户初始化");
// No login (open API / MQ / job): operatorId null, same as occupyCredit
// 无登录态(开放 API / MQ / 定时任务):operatorId 为 null,与 occupyCredit 一致
flow.setOperatorId(currentUserId());
flow.setCreateBy(username);
flow.setRemark(remark);
@@ -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;
@@ -26,6 +26,9 @@ public interface BmsSupplierMapper
/** 修改供应商 */
public int updateBmsSupplier(BmsSupplier bmsSupplier);
/** 只更新供应商绑定的渠道编码。 */
public int updateSupplierChannels(BmsSupplier bmsSupplier);
/** 删除供应商 */
public int deleteBmsSupplierBySupplierId(Long supplierId);
@@ -26,6 +26,9 @@ public interface IBmsSupplierService
/** 修改供应商 */
public int updateBmsSupplier(BmsSupplier bmsSupplier);
/** 只改这一家供应商绑定的渠道,其它资料不动。 */
public int bindChannels(Long supplierId, String channelIds);
/** 批量删除供应商 */
public int deleteBmsSupplierBySupplierIds(Long[] supplierIds);
@@ -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)
@@ -1,7 +1,6 @@
package com.bms.price.airbill.domain;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
/** 待分摊的一条提单费用,供费用处理弹框展示。 */
@@ -12,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 */
@@ -21,6 +20,9 @@ public class SrvBillAirAllocFee
/** 费用状态,字典 bill_fee_status */
private String billFeeStatus;
/** 费用类型,字典 bms_fee_type 的英文编码 */
private String feeType;
private String feeName;
private BigDecimal price;
@@ -30,14 +32,6 @@ public class SrvBillAirAllocFee
/** 分摊维度:1订单 2重量 */
private String allocDim;
/** 提单实际重量。只在按重量分摊时按提单号填入,不返回页面 */
@JsonIgnore
private BigDecimal actualWeight;
/** 干线打板重量。只在按重量分摊时按提单号填入,不返回页面 */
@JsonIgnore
private BigDecimal bandBoxWeight;
private Integer orderCount;
/** 不能分摊时的原因。空表示可以分摊 */
@@ -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,15 +15,21 @@ 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;
/** 费用阶段,字典 bms_fee_level */
/** 费用阶段,字典 bms_fee_level。空运为 2(b段),报关和清关为 3(c段) */
private String feeLevel;
/** 费用入口:AIR 空运,DECLARE 报关,CLEAR 清关。页面不展示 */
private String feeScene;
/** 提单费用状态,字典 bill_fee_status。只随分摊、作废操作变化 */
private String billFeeStatus;
@@ -0,0 +1,22 @@
package com.bms.price.airbill.domain;
import java.math.BigDecimal;
import com.bms.common.annotation.Excel;
import lombok.Data;
/** 空运、报关、清关费用导入行。 */
@Data
public class SrvBillAirFeeImportRow
{
@Excel(name = "费用名称")
private String feeName;
@Excel(name = "价格")
private BigDecimal price;
@Excel(name = "币种")
private String currency;
@Excel(name = "备注")
private String remark;
}
@@ -0,0 +1,27 @@
package com.bms.price.airbill.domain;
import java.util.ArrayList;
import java.util.List;
import com.bms.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 空运、报关、清关页面保存费用。
* scene:air 空运,declare 报关,clear 清关。数据权限写在 params.dataScope。
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SrvBillAirRoleFeeCommand extends BaseEntity
{
private static final long serialVersionUID = 1L;
private String scene;
/** 入库入口,仅服务端填写 */
@JsonIgnore
private String feeScene;
private List<SrvBillAirFeeSave> bills = new ArrayList<>();
}
@@ -0,0 +1,25 @@
package com.bms.price.airbill.domain;
import java.util.ArrayList;
import java.util.List;
import com.bms.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 空运、报关、清关费用查询。数据权限写在 params.dataScope。
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SrvBillAirRoleFeeQuery extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** air 空运,declare 报关,clear 清关 */
private String scene;
/** 入库入口:AIR、DECLARE、CLEAR */
private String feeScene;
private List<String> billCodes = new ArrayList<>();
}
@@ -10,22 +10,22 @@ import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "bms.billing")
public class BillingProperties
{
/** local = Spring event; redis = Redis list queue */
/** local = Spring 事件;redis = Redis 列表队列 */
private String mqMode = "redis";
private String mqQueueKey = "bms:billing:task";
private boolean consumerEnabled = true;
/** Messages popped per scheduled tick (redis mode) */
/** 每个调度周期取出的消息数量(redis 模式) */
private int consumerBatchSize = 32;
/** Concurrent processTask threads (redis mode) */
/** 并发执行 processTask 的线程数(redis 模式) */
private int consumerThreads = 8;
/** Concurrent threads for monitor order-source sync */
/** 监控订单数源同步的并发线程数 */
private int orderSourceSyncThreads = 8;
/**
* Concurrent threads for order-list local rebill (2~24).
* Keep below Druid maxActive with headroom for other traffic.
* 订单列表本地重计费的并发线程数(2~24)。
* 需低于 Druid maxActive,并给其他流量留出余量。
*/
private int localRebillThreads = 16;
/** Hourly auto-retry of prc_billing_task (all statuses) */
/** 每小时自动重试 prc_billing_task(所有状态) */
private NightRetry nightRetry = new NightRetry();
private Oracle oracle = new Oracle();
@@ -120,18 +120,18 @@ public class BillingProperties
}
/**
* Auto rebill window: pull prc_billing_task (all success_status) and retryTask.
* Default hours [0, 24) local time (all day); empty result skips billing.
* 自动重计费时间窗:拉取 prc_billing_task(所有 success_status)并执行 retryTask。
* 默认本地时间 [0, 24) 点(全天);结果为空则跳过计费。
*/
public static class NightRetry
{
/** Master switch */
/** 总开关 */
private boolean enabled = true;
/** Inclusive start hour (0 = 00:00) */
/** 起始小时,含(0 = 00:00) */
private int startHour = 0;
/** Exclusive end hour (24 = all day) */
/** 结束小时,不含(24 = 全天) */
private int endHour = 24;
/** Page size: bill this many then pull next page (default 500) */
/** 分页大小:计费这么多条后再拉下一页(默认 500) */
private int batchSize = 500;
public boolean isEnabled()
@@ -177,9 +177,9 @@ public class BillingProperties
public static class Oracle
{
/** Upstream main-order table name on SLAVE/Oracle DS */
/** SLAVE/Oracle 数据源上的上游主订单表名 */
private String orderTable = "WEISHI_USER.TAB_ORDER";
/** Optional default product when Oracle row has no PRODUCT_CODE */
/** Oracle 行中没有 PRODUCT_CODE 时使用的可选默认产品 */
private String defaultProductCode = "";
public String getOrderTable()
@@ -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;
}
}
@@ -14,7 +14,7 @@ public class BmsProduct extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** maps to prc_price_set_product.psp_id */
/** 对应 prc_price_set_product.psp_id */
private Long productId;
private Long psvId;
private String priceType;
@@ -30,7 +30,7 @@ public class BmsProduct extends BaseEntity
private Date effectiveDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expireDate;
/** 0 pending, 1 active, 2 expired */
/** 0 待生效,1 生效,2 已失效 */
public static final String STATUS_PENDING = "0";
public static final String STATUS_ACTIVE = "1";
public static final String STATUS_EXPIRED = "2";
@@ -45,8 +45,8 @@ public class BmsProduct extends BaseEntity
private Integer countryCount;
private Integer surchargeCount;
private List<BmsProductCountry> countries;
/** query alias of status (0/1/2) */
/** status 的查询别名(0/1/2) */
private String effectStatus;
/** query: active = status in (0,1); expired = status 2 */
/** 查询:active = status in (0,1);expired = status 2 */
private String statusGroup;
}
@@ -12,23 +12,23 @@ public class BmsProductCountry implements Serializable
{
private static final long serialVersionUID = 1L;
/** maps to prc_price_set_detail.psd_id */
/** 对应 prc_price_set_detail.psd_id */
private Long detailId;
private Long psvId;
private Long pspId;
private String priceType;
/** FK to product.product_id */
/** 外键,指向 product.product_id */
private Long productId;
private String productCode;
/** Parse/import helper only (not a DB column). */
/** 仅用于解析/导入辅助(非数据库字段)。 */
private String productName;
private String countryName;
private String countryCode;
/** prc_zone.zone_id; null when product country has no zone */
/** prc_zone.zone_id;产品国家无分区时为 null */
private Long zoneId;
/** e.g. Z1; null when no zone */
/** 例如 Z1;无分区时为 null */
private String zoneCode;
/** e.g. Australia(Z1); null when no zone */
/** 例如 Australia(Z1);无分区时为 null */
private String zoneName;
private BigDecimal weightMin;
private BigDecimal weightMax;
@@ -39,10 +39,10 @@ public class BmsProductCountry implements Serializable
private String leadTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date effectiveDate;
/** null=open; closed to next import effective_date */
/** null=未关闭;关闭到下次导入的 effective_date */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expireDate;
/** 0 pending, 1 active, 2 expired */
/** 0 待生效,1 生效,2 已失效 */
private String status;
/** 0未删除 1已删除 */
public static final String IS_DEL_NO = "0";
@@ -52,8 +52,8 @@ public class BmsProductCountry implements Serializable
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** query only: true = expire_date is null */
/** 仅查询用:true = expire_date 为 null */
private Boolean openOnly;
/** query alias of status (0/1/2) */
/** status 的查询别名(0/1/2) */
private String effectStatus;
}
@@ -19,7 +19,7 @@ public class BmsProductImportTask implements Serializable
private int percent;
private String message;
private String error;
/** Preview parse payload (products / details); not persisted to DB. */
/** 预览解析结果(products / details);不落库。 */
private Object result;
public String getTaskId()
@@ -29,7 +29,7 @@ public class BmsRedlineProduct extends BaseEntity
private Date effectiveDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expireDate;
/** 0 pending, 1 active, 2 expired */
/** 0 待生效,1 生效,2 已失效 */
public static final String STATUS_PENDING = "0";
public static final String STATUS_ACTIVE = "1";
public static final String STATUS_EXPIRED = "2";
@@ -44,8 +44,8 @@ public class BmsRedlineProduct extends BaseEntity
private Integer countryCount;
private Integer surchargeCount;
private List<BmsRedlineProductCountry> countries;
/** query alias of status (0/1/2) */
/** status 的查询别名(0/1/2) */
private String effectStatus;
/** query: active = status in (0,1); expired = status 2 */
/** 查询:active = status in (0,1);expired = status 2 */
private String statusGroup;
}
@@ -12,23 +12,23 @@ public class BmsRedlineProductCountry implements Serializable
{
private static final long serialVersionUID = 1L;
/** maps to prc_price_set_detail.psd_id */
/** 对应 prc_price_set_detail.psd_id */
private Long detailId;
private Long psvId;
private Long pspId;
private String priceType;
/** FK to product.product_id / psp_id */
/** 外键,指向 product.product_id / psp_id */
private Long productId;
private String productCode;
/** Parse/import helper only (not a DB column). */
/** 仅用于解析/导入辅助(非数据库字段)。 */
private String productName;
private String countryName;
private String countryCode;
/** prc_zone.zone_id; null when product country has no zone */
/** prc_zone.zone_id;产品国家无分区时为 null */
private Long zoneId;
/** e.g. Z1; null when no zone */
/** 例如 Z1;无分区时为 null */
private String zoneCode;
/** e.g. Australia(Z1); null when no zone */
/** 例如 Australia(Z1);无分区时为 null */
private String zoneName;
private BigDecimal weightMin;
private BigDecimal weightMax;
@@ -39,10 +39,10 @@ public class BmsRedlineProductCountry implements Serializable
private String leadTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date effectiveDate;
/** null=open; closed to next import effective_date */
/** null=未关闭;关闭到下次导入的 effective_date */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expireDate;
/** 0 pending, 1 active, 2 expired */
/** 0 待生效,1 生效,2 已失效 */
private String status;
/** 0未删除 1已删除 */
public static final String IS_DEL_NO = "0";
@@ -52,8 +52,8 @@ public class BmsRedlineProductCountry implements Serializable
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** query only: true = expire_date is null */
/** 仅查询用:true = expire_date 为 null */
private Boolean openOnly;
/** query alias of status (0/1/2) */
/** status 的查询别名(0/1/2) */
private String effectStatus;
}
@@ -19,7 +19,7 @@ public class BmsRedlineProductImportTask implements Serializable
private int percent;
private String message;
private String error;
/** Preview parse payload (products / details); not persisted to DB. */
/** 预览解析结果(products / details);不落库。 */
private Object result;
public String getTaskId()
@@ -13,7 +13,7 @@ public class CatalogPreviewApplyRequest implements Serializable
private Long psvId;
private List<BmsProduct> products;
/** key = upper-case productCode */
/** key = 大写后的 productCode */
private Map<String, List<BmsProductCountry>> detailsByProductCode;
public Long getPsvId()
@@ -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<>();
}

Some files were not shown because too many files have changed in this diff Show More