应付模块菜单调整,新增应付费用编辑等
This commit is contained in:
+10
@@ -90,6 +90,16 @@ public class BmsSupplierController extends BaseController
|
||||
return toAjax(bmsSupplierService.updateBmsSupplier(bmsSupplier));
|
||||
}
|
||||
|
||||
/** 只绑定这一家供应商的渠道 */
|
||||
@PreAuthorize("@ss.hasPermi('customersupplier:supplierinfo:bindChannel')")
|
||||
@Log(title = "供应商绑定渠道", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{supplierId}/channels")
|
||||
public AjaxResult bindChannels(@PathVariable("supplierId") Long supplierId, @RequestBody BmsSupplier bmsSupplier)
|
||||
{
|
||||
String channelIds = bmsSupplier == null ? "" : bmsSupplier.getChannelIds();
|
||||
return toAjax(bmsSupplierService.bindChannels(supplierId, channelIds));
|
||||
}
|
||||
|
||||
/** 删除供应商 */
|
||||
@PreAuthorize("@ss.hasPermi('customersupplier:supplierinfo:remove')")
|
||||
@Log(title = "供应商信息", businessType = BusinessType.DELETE)
|
||||
|
||||
+2
-2
@@ -378,7 +378,7 @@ 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 Long billId)
|
||||
{
|
||||
@@ -389,7 +389,7 @@ public class BillingController extends BaseController
|
||||
* 该订单的 ES BILL 日志(计费 / 上游同步 / 失败快照)。
|
||||
* bizId 优先取 transferNo,其次取 orderNo(与写入路径一致)。
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list')")
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill') or @ss.hasPermi('price:orderBill:list') or @ss.hasPermi('price:payOrder:query')")
|
||||
@GetMapping("/bill/{billId}/history")
|
||||
public TableDataInfo billHistory(@PathVariable("billId") Long billId)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.bms.web.controller.price;
|
||||
|
||||
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.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)
|
||||
{
|
||||
return success(payOrderListService.recalc(command));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看一票订单的应付费用,按 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();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -37,7 +37,7 @@ import com.bms.price.service.IPaySurchargeRuleService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 价格基础下的应付配置。导入先预览,确认后才入库。
|
||||
* 应付管理下的应付配置。导入先预览,确认后才入库。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/price/pay")
|
||||
@@ -173,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)
|
||||
|
||||
+4
@@ -136,6 +136,10 @@ public class BmsSupplier extends BaseEntity
|
||||
@Excel(name = "合作状态", readConverterExp = "0=正常,1=暂停,2=终止")
|
||||
private String cooperationStatus;
|
||||
|
||||
/** 数据来源,字典 bms_supplier_data_source。空表示未填写 */
|
||||
@Excel(name = "数据来源", dictType = "bms_supplier_data_source")
|
||||
private String dataSource;
|
||||
|
||||
/** 绑定的渠道/服务ID */
|
||||
private String channelIds;
|
||||
|
||||
|
||||
+3
@@ -26,6 +26,9 @@ public interface BmsSupplierMapper
|
||||
/** 修改供应商 */
|
||||
public int updateBmsSupplier(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 只更新供应商绑定的渠道编码。 */
|
||||
public int updateSupplierChannels(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 删除供应商 */
|
||||
public int deleteBmsSupplierBySupplierId(Long supplierId);
|
||||
|
||||
|
||||
+3
@@ -26,6 +26,9 @@ public interface IBmsSupplierService
|
||||
/** 修改供应商 */
|
||||
public int updateBmsSupplier(BmsSupplier bmsSupplier);
|
||||
|
||||
/** 只改这一家供应商绑定的渠道,其它资料不动。 */
|
||||
public int bindChannels(Long supplierId, String channelIds);
|
||||
|
||||
/** 批量删除供应商 */
|
||||
public int deleteBmsSupplierBySupplierIds(Long[] supplierIds);
|
||||
|
||||
|
||||
+56
@@ -1,6 +1,7 @@
|
||||
package com.bms.customer.supplierinfo.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.bms.common.annotation.DataScope;
|
||||
@@ -302,6 +303,61 @@ public class BmsSupplierServiceImpl implements IBmsSupplierService
|
||||
return bmsSupplierMapper.updateBmsSupplier(bmsSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* 只改绑定渠道。不走整单修改,避免把附件、采购员和合同日期清掉。
|
||||
*/
|
||||
@Override
|
||||
public int bindChannels(Long supplierId, String channelIds)
|
||||
{
|
||||
if (supplierId == null)
|
||||
{
|
||||
throw new ServiceException("请选择供应商");
|
||||
}
|
||||
if (bmsSupplierMapper.selectBmsSupplierBySupplierId(supplierId) == null)
|
||||
{
|
||||
throw new ServiceException("供应商不存在");
|
||||
}
|
||||
String value = joinChannels(channelIds);
|
||||
if (value.length() > 1000)
|
||||
{
|
||||
throw new ServiceException("绑定的渠道过多,请减少后再保存");
|
||||
}
|
||||
BmsSupplier row = new BmsSupplier();
|
||||
row.setSupplierId(supplierId);
|
||||
row.setChannelIds(value);
|
||||
row.setUpdateBy(SecurityUtils.getUsername());
|
||||
row.setUpdateTime(DateUtils.getNowDate());
|
||||
int rows = bmsSupplierMapper.updateSupplierChannels(row);
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new ServiceException("供应商不存在");
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** 渠道编码去空白、去重,仍按选择顺序用逗号拼起来。 */
|
||||
private static String joinChannels(String channelIds)
|
||||
{
|
||||
if (StringUtils.isEmpty(channelIds))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
LinkedHashSet<String> codes = new LinkedHashSet<>();
|
||||
for (String part : channelIds.split(","))
|
||||
{
|
||||
if (part == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String code = part.trim();
|
||||
if (!code.isEmpty())
|
||||
{
|
||||
codes.add(code);
|
||||
}
|
||||
}
|
||||
return String.join(",", codes);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int deleteBmsSupplierBySupplierIds(Long[] supplierIds)
|
||||
|
||||
@@ -20,6 +20,9 @@ public class SrvBillAirAllocFee
|
||||
/** 费用状态,字典 bill_fee_status */
|
||||
private String billFeeStatus;
|
||||
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
private String feeName;
|
||||
|
||||
private BigDecimal price;
|
||||
|
||||
@@ -15,9 +15,12 @@ public class SrvBillAirFee
|
||||
|
||||
private String billCode;
|
||||
|
||||
/** 附加费编号 prc_surcharge.sc_id */
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
/** 附加费配置ID,对应 prc_surcharge.sc_id */
|
||||
private Long scId;
|
||||
|
||||
/** 附加费名称,仅展示,不入库 */
|
||||
private String feeName;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
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<>();
|
||||
|
||||
/** 这票订单的应付费用日志,新的在前 */
|
||||
private List<PrcPayBillFeeLog> logs = 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,18 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/** 费用重算里的一票结果。 */
|
||||
@Data
|
||||
public class PayOrderRecalcLine
|
||||
{
|
||||
private String orderNo;
|
||||
|
||||
private String ladingNo;
|
||||
|
||||
/** 这一票是否已经生成应付费用 */
|
||||
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,42 @@
|
||||
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;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date bizDate;
|
||||
}
|
||||
@@ -24,8 +24,15 @@ public class PrcPayBill implements Serializable
|
||||
private BigDecimal redlineAmount;
|
||||
/** 成本价合计(当前计费结果) */
|
||||
private BigDecimal costAmount;
|
||||
/** 应付合计(当前等于成本价) */
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细重算) */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** 应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败 */
|
||||
private Integer payCalcStatus;
|
||||
|
||||
/** 计费失败原因,最长 100 字 */
|
||||
private String payCalcMsg;
|
||||
|
||||
/** 业务员/销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
|
||||
@@ -17,8 +17,13 @@ public class PrcPayBillFee implements Serializable
|
||||
private Long billId;
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
/** 费用类型,字典 bms_fee_type 的英文编码 */
|
||||
private String feeType;
|
||||
|
||||
/** 展示用的费用项名称,不入库。附加费取配置名称,其余取字典标签 */
|
||||
private String feeName;
|
||||
|
||||
/** 尾程计算时是附加费配置ID。提单分摊时是 srv_bill_air_fee.id */
|
||||
private Long scId;
|
||||
|
||||
/** 费用所属阶段:1 a段,2 b段,3 c段,4 d段 */
|
||||
@@ -31,7 +36,7 @@ public class PrcPayBillFee implements Serializable
|
||||
/** CALC 计算,LADING 提单分摊,MANUAL 人工 */
|
||||
private String feeSource;
|
||||
|
||||
/** 来源数据id */
|
||||
/** 来源数据id。提单分摊时为 srv_bill_air_fee.id */
|
||||
private String sourceId;
|
||||
|
||||
/** 是否删除:0未删除 1已删除 */
|
||||
@@ -44,6 +49,16 @@ public class PrcPayBillFee implements Serializable
|
||||
private Long settleSupplierId;
|
||||
|
||||
private String settleSupplierName;
|
||||
|
||||
/** 创建人 */
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付费用日志 prc_pay_bill_fee_log */
|
||||
@Data
|
||||
public class PrcPayBillFeeLog implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long logId;
|
||||
|
||||
private String feeId;
|
||||
|
||||
private Long billId;
|
||||
|
||||
/** 费用项 */
|
||||
private String feeName;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private String currency;
|
||||
|
||||
/** 操作类型,字典 bms_pay_fee_log_type */
|
||||
private String operationType;
|
||||
|
||||
/** 操作人 */
|
||||
private String createBy;
|
||||
|
||||
/** 操作时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRow;
|
||||
|
||||
/** 应付列表。 */
|
||||
public interface PayOrderListMapper
|
||||
{
|
||||
List<PayOrderRow> selectList(PayOrderQuery query);
|
||||
|
||||
PayOrderRow selectRow(@Param("billId") String billId);
|
||||
|
||||
/**
|
||||
* 按订单号精确找出要重算的订单。
|
||||
*
|
||||
* @param orderNos 订单号,已去重
|
||||
* @return 订单号和提单号
|
||||
*/
|
||||
List<PayOrderRow> selectByOrderNos(@Param("orderNos") List<String> orderNos);
|
||||
|
||||
/**
|
||||
* 按提单号找出下面的全部订单。提单号对应订单扩展上的空运单号。
|
||||
*
|
||||
* @param ladingNos 提单号,已去重
|
||||
* @return 这些提单下的订单
|
||||
*/
|
||||
List<PayOrderRow> selectByLadingNos(@Param("ladingNos") List<String> ladingNos);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPayBillFeeLog;
|
||||
|
||||
/** 应付费用日志 prc_pay_bill_fee_log。 */
|
||||
public interface PrcPayBillFeeLogMapper
|
||||
{
|
||||
/**
|
||||
* 批量写入应付费用日志。
|
||||
*
|
||||
* @param logs 本次操作的费用快照
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("list") List<PrcPayBillFeeLog> logs);
|
||||
|
||||
/**
|
||||
* 按订单读取费用日志,新的在前。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 日志
|
||||
*/
|
||||
List<PrcPayBillFeeLog> selectByBillId(@Param("billId") Long billId);
|
||||
}
|
||||
@@ -15,6 +15,39 @@ public interface PrcPayBillFeeMapper
|
||||
*/
|
||||
public List<PrcPayBillFee> selectByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 按费用明细 ID 读取一行。已逻辑删除的也返回,调用方自己判断。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
* @return 费用行,没有时为 null
|
||||
*/
|
||||
public PrcPayBillFee selectByFeeId(@Param("feeId") String feeId);
|
||||
|
||||
/**
|
||||
* 写入一条手工费用。来源固定为 MANUAL,并记下创建人、更新人。
|
||||
*
|
||||
* @param fee 费用项、金额、币种、说明和所属阶段
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int insertManual(PrcPayBillFee fee);
|
||||
|
||||
/**
|
||||
* 逻辑删除一条费用。已经进入应付账单的行不删。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
* @param operator 当前登录人
|
||||
* @return 影响行数
|
||||
*/
|
||||
public int markFeeDeleted(@Param("feeId") String feeId, @Param("operator") String operator);
|
||||
|
||||
/**
|
||||
* 这票订单里已经进入应付账单的计算费用条数。有则不能重算覆盖。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 已出账的计算费用条数
|
||||
*/
|
||||
public int countSettledCalc(@Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 插入一条订单应付费用。
|
||||
*
|
||||
@@ -53,6 +86,9 @@ public interface PrcPayBillFeeMapper
|
||||
/** 这条提单费用已经分摊到的订单。作废前取出,用来重算应付总额。 */
|
||||
public List<Long> selectBillIdsByLadingFee(@Param("feeId") Long feeId);
|
||||
|
||||
/** 这条提单费用已经分摊、且还没删除的订单费用。作废前取出,用来记日志。 */
|
||||
public List<PrcPayBillFee> selectAliveByLadingFee(@Param("feeId") Long feeId);
|
||||
|
||||
/** 明细还没挂上应付主表时,按订单补上主表 ID。单次不超过 1000 个订单。 */
|
||||
public int bindPayBillId(@Param("billIds") List<Long> billIds);
|
||||
|
||||
|
||||
@@ -65,4 +65,16 @@ public interface PrcPayBillMapper
|
||||
|
||||
/** 订单还没有应付主表时补一行,总额随后按明细重算。单次不超过 1000 个订单。 */
|
||||
int insertMissingPayBills(@Param("billIds") List<Long> billIds, @Param("operator") String operator);
|
||||
|
||||
/**
|
||||
* 写下这票应付的计费状态和失败原因。成功时原因传空。
|
||||
*
|
||||
* @param billId 计费订单 ID,对应 prc_pay_bill.bill_id
|
||||
* @param status 1计费成功,2计费失败
|
||||
* @param message 失败原因,最长 100 字;成功时为 null
|
||||
* @param operator 操作人账号
|
||||
* @return 影响行数
|
||||
*/
|
||||
int markCalcStatus(@Param("billId") Long billId, @Param("status") Integer status,
|
||||
@Param("message") String message, @Param("operator") String operator);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
package com.bms.price.pay;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.bms.common.enums.PaymentMesEnum;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayPostcodeGroup;
|
||||
import com.bms.price.domain.PayPostcodeLine;
|
||||
import com.bms.price.domain.PayProduct;
|
||||
import com.bms.price.domain.PaySurcharge;
|
||||
import com.bms.price.domain.PaySurchargeRule;
|
||||
import com.bms.price.domain.PayWeightBand;
|
||||
import com.bms.price.domain.PrcOrderBill;
|
||||
import com.bms.price.domain.PrcOrderBillExt;
|
||||
import com.bms.price.mapper.PayPostcodeMapper;
|
||||
import com.bms.price.mapper.PrcOrderBillExtMapper;
|
||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
import com.bms.price.service.IPaySurchargeRuleService;
|
||||
|
||||
/**
|
||||
* 按一票已经落库的订单,算出应付尾程运费和订单附加费。
|
||||
* 这里只计算,不写费用。账单生成、Oracle 订单同步和其他入口都调用这一处。
|
||||
*/
|
||||
@Component
|
||||
public class PayOrderFeeCalculator
|
||||
{
|
||||
private static final ZoneId SHANGHAI = ZoneId.of("GMT+8");
|
||||
|
||||
@Autowired
|
||||
private PrcOrderBillMapper orderBillMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcOrderBillExtMapper orderBillExtMapper;
|
||||
|
||||
@Autowired
|
||||
private ServiceChannelMapper serviceChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private IPayProductService payProductService;
|
||||
|
||||
@Autowired
|
||||
private PayPostcodeMapper payPostcodeMapper;
|
||||
|
||||
@Autowired
|
||||
private IPaySurchargeRuleService paySurchargeRuleService;
|
||||
|
||||
/**
|
||||
* 计算一票订单的尾程运费和附加费。渠道、价卡、分区或重量不齐时抛出业务异常,调用方决定是否落库。
|
||||
*
|
||||
* @param billId 计费订单 ID,对应 prc_order_bill.bill_id
|
||||
* @return 渠道、价卡版本、币种、尾程运费和订单附加费
|
||||
*/
|
||||
public PayOrderCostResult calculate(Long billId)
|
||||
{
|
||||
PrcOrderBill bill = requireOrder(billId);
|
||||
PrcOrderBillExt ext = orderBillExtMapper.selectByBillId(bill.getBillId());
|
||||
ServiceChannel channel = resolveChannel(ext);
|
||||
Date priceDate = bizDate(bill);
|
||||
PayProduct product = payProductService.selectPriceForDate(channel.getId(), priceDate);
|
||||
BigDecimal weight = chargeWeight(bill);
|
||||
Integer orderStatus = orderStatus(bill, ext);
|
||||
List<PayPostcodeGroup> linked = linkedGroups(product);
|
||||
String zoneName = resolveZone(channel, product, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName(), linked);
|
||||
applyCurrentSurcharge(channel.getId(), product);
|
||||
List<PaySurchargeRule> billingRules = product.getBillingRules();
|
||||
boolean postcodeOn = ruleOn(billingRules, PaySurchargeRules.POSTCODE);
|
||||
boolean zoneOn = ruleOn(billingRules, PaySurchargeRules.ZONE);
|
||||
List<PayRemoteBook.Hit> remoteHits = prefixRules(billingRules, PaySurchargeRules.POSTCODE)
|
||||
? null : remoteHits(linked, bill.getDestPostcode(), bill.getCountryCode(), bill.getCountryName());
|
||||
PayOrderCostResult result = PayCostCalculator.calculate(product, weight, bill.getPkgLength(), bill.getPkgWidth(),
|
||||
bill.getPkgHeight(), bill.getDestPostcode(), zoneName, priceDate, orderStatus, remoteHits, postcodeOn, zoneOn,
|
||||
bill.getCountryCode(), bill.getCountryName());
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setChannelId(channel.getId());
|
||||
result.setChannelName(channel.getChannelName());
|
||||
result.setVersionNo(product.getVersionNo());
|
||||
result.setMessage(explain(channel, product, result.getMessage()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取这票订单当前尾程价卡上的归属供应商。渠道或价卡不齐时返回空字符串,不抛异常。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 价卡归属供应商名称,没有时为空字符串
|
||||
*/
|
||||
public String supplierName(Long billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
try
|
||||
{
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
ServiceChannel channel = resolveChannel(orderBillExtMapper.selectByBillId(bill.getBillId()));
|
||||
PayProduct product = payProductService.selectPriceForDate(channel.getId(), bizDate(bill));
|
||||
return product.getSupplierName() == null ? "" : product.getSupplierName().trim();
|
||||
}
|
||||
catch (ServiceException ex)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取计费订单。单号为空或库里没有这票时抛出业务异常。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 订单主表
|
||||
*/
|
||||
private PrcOrderBill requireOrder(Long billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PICK_ORDER.exception();
|
||||
}
|
||||
PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_ORDER_MISS.exception();
|
||||
}
|
||||
return bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取价日。优先用订单业务日,没有时用下单时间。
|
||||
*
|
||||
* @param bill 计费订单
|
||||
* @return 用来命中价卡版本的日期,两边都空时为 null
|
||||
*/
|
||||
private static Date bizDate(PrcOrderBill bill)
|
||||
{
|
||||
return bill.getBizDate() != null ? bill.getBizDate() : bill.getOrderTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计费重。按计费重、重量、实重、收货重的顺序,取第一个大于 0 的值。
|
||||
*
|
||||
* @param bill 计费订单
|
||||
* @return 公斤数,都没有时为 null
|
||||
*/
|
||||
private static BigDecimal chargeWeight(PrcOrderBill bill)
|
||||
{
|
||||
return firstPositive(bill.getChargeWeight(), bill.getWeight(), bill.getActualWeight(), bill.getReceiveWeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单状态。主表没有时用扩展表,用来判断退件类附加费是否收取。
|
||||
*
|
||||
* @param bill 计费订单
|
||||
* @param ext 订单扩展,可以没有
|
||||
* @return 订单状态,两边都没有时为 null
|
||||
*/
|
||||
private static Integer orderStatus(PrcOrderBill bill, PrcOrderBillExt ext)
|
||||
{
|
||||
return bill.getOrderStatus() != null ? bill.getOrderStatus() : (ext == null ? null : ext.getOrderStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼出这次计算用了哪条渠道、哪个产品和哪一版价卡。
|
||||
*
|
||||
* @param channel 订单渠道
|
||||
* @param product 订单日期命中的价卡版本
|
||||
* @param detail 计算器给出的费用说明
|
||||
* @return 带渠道和版本的说明
|
||||
*/
|
||||
private static String explain(ServiceChannel channel, PayProduct product, String detail)
|
||||
{
|
||||
String channelName = channel.getChannelName() == null ? channel.getChannelCode() : channel.getChannelName();
|
||||
String end = product.getTermEnd() == null ? "不限" : day(product.getTermEnd());
|
||||
return "渠道「" + channelName + "」" + product.getProductName() + " 第 " + product.getVersionNo()
|
||||
+ " 版(" + day(product.getTermStart()) + " 至 " + end + ")," + detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* 运费仍按订单日期取版本。附加费明细和计费条件改用这个产品今天生效的版本。
|
||||
*
|
||||
* @param channelId 渠道 ID
|
||||
* @param priced 订单日期已经命中的价卡,方法会改写它的附加费和计费条件
|
||||
*/
|
||||
private void applyCurrentSurcharge(String channelId, PayProduct priced)
|
||||
{
|
||||
try
|
||||
{
|
||||
PayProduct current = payProductService.selectPriceForDate(channelId, new Date());
|
||||
if (current != null && current.getSurcharges() != null)
|
||||
{
|
||||
priced.setSurcharges(current.getSurcharges());
|
||||
}
|
||||
}
|
||||
catch (ServiceException ignored)
|
||||
{
|
||||
// 今天没有生效版本时,附加费明细仍用订单日期命中的那一版
|
||||
}
|
||||
List<PaySurchargeRule> rules = paySurchargeRuleService.listForCalc(priced);
|
||||
priced.setBillingRules(rules == null ? new ArrayList<>() : rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* 这条计费条件是否启用。没有配置行时视为关闭。
|
||||
*
|
||||
* @param rules 当前产品的计费条件
|
||||
* @param calcRule 条件编码,如 POSTCODE、ZONE
|
||||
* @return 有启用行时为 true
|
||||
*/
|
||||
private static boolean ruleOn(List<PaySurchargeRule> rules, String calcRule)
|
||||
{
|
||||
if (rules == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (PaySurchargeRule rule : rules)
|
||||
{
|
||||
if (rule != null && calcRule.equals(rule.getCalcRule()) && !"0".equals(rule.getEnabled()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计费条件里是否已经写了邮编前缀。写了就不再去应付邮编配置里查偏远。
|
||||
*
|
||||
* @param rules 当前产品的计费条件
|
||||
* @param calcRule 条件编码,目前用于 POSTCODE
|
||||
* @return 有非空邮编前缀时为 true
|
||||
*/
|
||||
private static boolean prefixRules(List<PaySurchargeRule> rules, String calcRule)
|
||||
{
|
||||
if (rules == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (PaySurchargeRule rule : rules)
|
||||
{
|
||||
if (rule == null || !calcRule.equals(rule.getCalcRule()) || "0".equals(rule.getEnabled()) || rule.getDetail() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Object postcodes = rule.getDetail().get("postcodes");
|
||||
if (postcodes != null && !String.valueOf(postcodes).isBlank())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用产品名称、报价工作表、字典值和关联分区表,对上这份产品的邮编配置。
|
||||
*
|
||||
* @param product 当前价卡版本
|
||||
* @return 名称能对上的邮编组,没有时为空列表
|
||||
*/
|
||||
private List<PayPostcodeGroup> linkedGroups(PayProduct product)
|
||||
{
|
||||
List<String> names = new ArrayList<>();
|
||||
addName(names, product.getProductName());
|
||||
addName(names, product.getSheetName());
|
||||
addName(names, product.getDictValue());
|
||||
addName(names, product.getRelatedSheet());
|
||||
if (names.isEmpty())
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<PayPostcodeGroup> found = payPostcodeMapper.selectGroupsForProduct(names);
|
||||
return found == null ? new ArrayList<>() : found;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把非空名称放进匹配列表,已有的不重复加入。
|
||||
*
|
||||
* @param names 已经收集的名称
|
||||
* @param value 产品名、工作表名或字典值
|
||||
*/
|
||||
private static void addName(List<String> names, String value)
|
||||
{
|
||||
if (value == null || value.isBlank())
|
||||
{
|
||||
return;
|
||||
}
|
||||
String name = value.trim();
|
||||
if (!names.contains(name))
|
||||
{
|
||||
names.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断这票是否偏远。产品报价表已经挂了偏远名单时只用那一份,没命中就不再回价卡邮编。
|
||||
* 没有这份产品名单时,改查目的国家的偏远邮编;国家名单没命中则返回 null,价卡上的邮编条件仍可用。
|
||||
*
|
||||
* @param linked 已对上的邮编组
|
||||
* @param postcode 收件邮编
|
||||
* @param countryCode 目的国二字码
|
||||
* @param countryName 目的国名称
|
||||
* @return 命中的偏远分区;产品有名单但没命中时返回空列表
|
||||
*/
|
||||
private List<PayRemoteBook.Hit> remoteHits(List<PayPostcodeGroup> linked, String postcode, String countryCode, String countryName)
|
||||
{
|
||||
boolean productBook = false;
|
||||
for (PayPostcodeGroup group : linked)
|
||||
{
|
||||
if (group != null && PayRemoteBook.remoteGroup(group))
|
||||
{
|
||||
productBook = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (productBook)
|
||||
{
|
||||
return hitsOf(linked, postcode, countryCode, countryName);
|
||||
}
|
||||
if (blank(countryCode) && blank(countryName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PayPostcodeGroup> countryGroups = payPostcodeMapper.selectRemoteGroupsByCountry(countryCode, countryName);
|
||||
if (countryGroups == null || countryGroups.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<PayRemoteBook.Hit> hits = hitsOf(countryGroups, postcode, countryCode, countryName);
|
||||
return hits == null || hits.isEmpty() ? null : hits;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在给定邮编组里做偏远匹配。没有偏远组时返回 null,有组但邮编没命中时返回空列表。
|
||||
*
|
||||
* @param groups 参与匹配的邮编组
|
||||
* @param postcode 收件邮编
|
||||
* @param countryCode 目的国二字码
|
||||
* @param countryName 目的国名称
|
||||
* @return 命中结果
|
||||
*/
|
||||
private List<PayRemoteBook.Hit> hitsOf(List<PayPostcodeGroup> groups, String postcode, String countryCode, String countryName)
|
||||
{
|
||||
List<Long> remoteIds = new ArrayList<>();
|
||||
boolean anyRemote = false;
|
||||
for (PayPostcodeGroup group : groups)
|
||||
{
|
||||
if (group == null || group.getGroupId() == null || !PayRemoteBook.remoteGroup(group))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
anyRemote = true;
|
||||
if (sameCountry(group, countryCode, countryName))
|
||||
{
|
||||
remoteIds.add(group.getGroupId());
|
||||
}
|
||||
}
|
||||
if (!anyRemote)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (remoteIds.isEmpty())
|
||||
{
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<PayPostcodeLine> lines = postcode == null || postcode.isBlank()
|
||||
? new ArrayList<>() : payPostcodeMapper.selectLinesByGroups(remoteIds);
|
||||
return PayRemoteBook.hits(groups, lines, postcode, countryCode, countryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 价卡有多个地区时,选出这一票对应的价格列。优先用产品关联的邮编分区,对不上再按名称关键字找。
|
||||
* 只有一个地区时返回 null,计费不再按分区过滤。
|
||||
*
|
||||
* @param channel 订单渠道,关键字匹配时备用
|
||||
* @param product 当前价卡版本
|
||||
* @param postcode 收件邮编
|
||||
* @param countryCode 目的国二字码
|
||||
* @param countryName 目的国名称
|
||||
* @param linked 已对上的邮编组
|
||||
* @return 价卡上的地区名,单地区时为 null
|
||||
*/
|
||||
private String resolveZone(ServiceChannel channel, PayProduct product, String postcode, String countryCode, String countryName,
|
||||
List<PayPostcodeGroup> linked)
|
||||
{
|
||||
List<String> zoneNames = zoneNames(product);
|
||||
if (zoneNames.size() <= 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Long> linkedZoneIds = zoneGroupIds(linked, countryCode, countryName);
|
||||
if (!linkedZoneIds.isEmpty())
|
||||
{
|
||||
return decideZone(zoneNames, linkedZoneIds, postcode);
|
||||
}
|
||||
List<String> tokens = PayZoneMatcher.searchTokens(product.getProductName(), product.getSheetName());
|
||||
if (tokens.isEmpty())
|
||||
{
|
||||
tokens = PayZoneMatcher.searchTokens(channel.getChannelName(), channel.getChannelCode());
|
||||
}
|
||||
if (tokens.isEmpty())
|
||||
{
|
||||
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,订单邮编无法对应到产品");
|
||||
}
|
||||
List<PayPostcodeGroup> groups = new ArrayList<>();
|
||||
for (PayPostcodeGroup group : payPostcodeMapper.selectGroupsByTokens(tokens))
|
||||
{
|
||||
if (sameCountry(group, countryCode, countryName))
|
||||
{
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
if (groups.isEmpty())
|
||||
{
|
||||
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,没有找到对应的邮编分区");
|
||||
}
|
||||
List<Long> groupIds = new ArrayList<>();
|
||||
for (PayPostcodeGroup group : groups)
|
||||
{
|
||||
groupIds.add(group.getGroupId());
|
||||
}
|
||||
Set<Long> usable = new LinkedHashSet<>();
|
||||
for (PayPostcodeLine key : payPostcodeMapper.selectRegionKeys(groupIds))
|
||||
{
|
||||
String region = key.getZoneName() != null && !key.getZoneName().isBlank() ? key.getZoneName() : key.getRegionName();
|
||||
if (PayZoneMatcher.mapRegion(zoneNames, region) != null)
|
||||
{
|
||||
usable.add(key.getGroupId());
|
||||
}
|
||||
}
|
||||
if (usable.isEmpty())
|
||||
{
|
||||
throw new ServiceException("产品「" + product.getProductName() + "」有多个地区,邮编分区对不上价卡上的地区");
|
||||
}
|
||||
return decideZone(zoneNames, new ArrayList<>(usable), postcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在给定邮编组里,用收件邮编决定价卡地区。对不上时抛出业务异常。
|
||||
*
|
||||
* @param zoneNames 价卡上的地区名
|
||||
* @param groupIds 参与匹配的邮编组
|
||||
* @param postcode 收件邮编
|
||||
* @return 命中的地区名
|
||||
*/
|
||||
private String decideZone(List<String> zoneNames, List<Long> groupIds, String postcode)
|
||||
{
|
||||
PayZoneMatcher.Decision decision = PayZoneMatcher.resolve(zoneNames, payPostcodeMapper.selectLinesByGroups(groupIds), postcode);
|
||||
if (decision.getMessage() != null)
|
||||
{
|
||||
throw new ServiceException(decision.getMessage());
|
||||
}
|
||||
if (decision.getZoneName() == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_NO_ZONE.exception();
|
||||
}
|
||||
return decision.getZoneName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取出用来选派送费的普通分区。偏远、附加费邮编和不可达不参与选区。
|
||||
*
|
||||
* @param linked 已对上的邮编组
|
||||
* @param countryCode 目的国二字码
|
||||
* @param countryName 目的国名称
|
||||
* @return 可参与选区的邮编组 ID
|
||||
*/
|
||||
private static List<Long> zoneGroupIds(List<PayPostcodeGroup> linked, String countryCode, String countryName)
|
||||
{
|
||||
List<Long> ids = new ArrayList<>();
|
||||
if (linked == null)
|
||||
{
|
||||
return ids;
|
||||
}
|
||||
for (PayPostcodeGroup group : linked)
|
||||
{
|
||||
if (group == null || group.getGroupId() == null || PayRemoteBook.remoteGroup(group) || "FEE".equals(group.getConfigKind()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ("UNREACH".equalsIgnoreCase(group.getCoverage() == null ? "" : group.getCoverage().trim()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!sameCountry(group, countryCode, countryName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ids.add(group.getGroupId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集价卡重量段和分区附加费上的地区名。
|
||||
*
|
||||
* @param product 当前价卡版本
|
||||
* @return 去重后的地区名
|
||||
*/
|
||||
private static List<String> zoneNames(PayProduct product)
|
||||
{
|
||||
Set<String> names = new LinkedHashSet<>();
|
||||
if (product.getWeightBands() != null)
|
||||
{
|
||||
for (PayWeightBand band : product.getWeightBands())
|
||||
{
|
||||
if (band != null && band.getZoneName() != null && !band.getZoneName().isBlank())
|
||||
{
|
||||
names.add(band.getZoneName().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (product.getSurcharges() != null)
|
||||
{
|
||||
for (PaySurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee != null && PaySurchargeRules.ZONE.equals(fee.getCalcRule()) && fee.getZoneName() != null && !fee.getZoneName().isBlank())
|
||||
{
|
||||
names.add(fee.getZoneName().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(names);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断邮编组是否和订单目的国相同。两边都没写国家时视为相同。
|
||||
*
|
||||
* @param group 邮编组
|
||||
* @param countryCode 订单目的国二字码
|
||||
* @param countryName 订单目的国名称
|
||||
* @return 国家能对上时为 true
|
||||
*/
|
||||
private static boolean sameCountry(PayPostcodeGroup group, String countryCode, String countryName)
|
||||
{
|
||||
if (blank(countryCode) && blank(countryName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (blank(group.getCountryCode()) && blank(group.getCountryName()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!blank(countryCode) && countryCode.equalsIgnoreCase(group.getCountryCode()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !blank(countryName) && countryName.equals(group.getCountryName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 从订单扩展找出渠道。先按渠道 ID,再按渠道编码,最后按渠道名称。
|
||||
*
|
||||
* @param ext 订单计费扩展
|
||||
* @return 服务渠道
|
||||
*/
|
||||
private ServiceChannel resolveChannel(PrcOrderBillExt ext)
|
||||
{
|
||||
if (ext == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_NO_CHANNEL.exception();
|
||||
}
|
||||
ServiceChannel channel = blank(ext.getProductChannelId()) ? null : serviceChannelMapper.selectServiceChannelById(ext.getProductChannelId().trim());
|
||||
if (channel == null && !blank(ext.getProductFloorCode()))
|
||||
{
|
||||
channel = serviceChannelMapper.selectServiceChannelByCode(ext.getProductFloorCode().trim());
|
||||
}
|
||||
if (channel == null && !blank(ext.getProductFloor()))
|
||||
{
|
||||
List<ServiceChannel> named = serviceChannelMapper.selectServiceChannelByName(ext.getProductFloor().trim());
|
||||
if (named != null && named.size() > 1)
|
||||
{
|
||||
throw new ServiceException("渠道名称「" + ext.getProductFloor().trim() + "」对应了多条渠道,请先在订单上指定渠道");
|
||||
}
|
||||
channel = named == null || named.isEmpty() ? null : named.get(0);
|
||||
}
|
||||
if (channel == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_CH_SYNC.exception();
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把日期格式化成 yyyy-MM-dd。空日期表示不限。
|
||||
*
|
||||
* @param date 有效期起或止
|
||||
* @return 日期文本
|
||||
*/
|
||||
private static String day(Date date)
|
||||
{
|
||||
if (date == null)
|
||||
{
|
||||
return "不限";
|
||||
}
|
||||
if (date instanceof java.sql.Date sql)
|
||||
{
|
||||
return sql.toLocalDate().toString();
|
||||
}
|
||||
return date.toInstant().atZone(SHANGHAI).toLocalDate().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按传入顺序取第一个大于 0 的重量。
|
||||
*
|
||||
* @param values 计费重、重量、实重、收货重
|
||||
* @return 第一个正数,都没有时返回 null
|
||||
*/
|
||||
private static BigDecimal firstPositive(BigDecimal... values)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
for (BigDecimal value : values)
|
||||
{
|
||||
if (value != null && value.compareTo(BigDecimal.ZERO) > 0)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断文本是否为空。
|
||||
*
|
||||
* @param value 待判断文本
|
||||
* @return 为 null 或空白时返回 true
|
||||
*/
|
||||
private static boolean blank(String value)
|
||||
{
|
||||
return value == null || value.isBlank();
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,14 @@ public interface IPayOrderCostService
|
||||
*/
|
||||
PayOrderCostResult generateIsolated(Long billId);
|
||||
|
||||
/**
|
||||
* 订单同步后落地尾程费用。已经进入应付账单的计算费用不再覆盖。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 本次落地的结果;费用已经出账时返回 null
|
||||
*/
|
||||
PayOrderCostResult landIfOpen(Long billId);
|
||||
|
||||
/**
|
||||
* 这票订单当前尾程价卡上的归属供应商名称。没有价卡时返回空字符串。
|
||||
*
|
||||
@@ -30,4 +38,12 @@ public interface IPayOrderCostService
|
||||
* @return 价卡归属名称
|
||||
*/
|
||||
String cardSupplierName(Long billId);
|
||||
|
||||
/**
|
||||
* 把这票订单记成应付计费失败。单独提交,不跟着外面回滚掉。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param reason 失败原因,最长 100 字
|
||||
*/
|
||||
void markCalcFail(Long billId, String reason);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRecalcCommand;
|
||||
import com.bms.price.domain.PayOrderRecalcResult;
|
||||
import com.bms.price.domain.PayOrderRow;
|
||||
|
||||
/** 应付列表。 */
|
||||
public interface IPayOrderListService
|
||||
{
|
||||
List<PayOrderRow> list(PayOrderQuery query);
|
||||
|
||||
PayOrderFeeBoard fees(String billId);
|
||||
|
||||
/**
|
||||
* 在指定费用段手工增加一行费用。来源记 MANUAL,创建人是当前登录用户。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param line 费用项、金额、币种、说明和所属阶段
|
||||
* @return 写入后的费用行
|
||||
*/
|
||||
PayOrderFeeLine addManualFee(String billId, PayOrderFeeLine line);
|
||||
|
||||
/**
|
||||
* 逻辑删除一条应付费用。已经进入应付账单的费用不能删。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
*/
|
||||
void removeFee(String feeId);
|
||||
|
||||
/**
|
||||
* 按订单号或提单号批量重算尾程应付。一票失败不影响其他订单。
|
||||
* 成功时应付主表记计费成功,应付总额按全部未删除明细重算。
|
||||
* 失败时记计费失败和原因。已经进入应付账单的费用不覆盖。
|
||||
*
|
||||
* @param command 重算方式(ORDER 或 LADING)和单号原文
|
||||
* @return 成功数、失败数和每一票的结果
|
||||
*/
|
||||
PayOrderRecalcResult recalc(PayOrderRecalcCommand command);
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.bms.price.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
import com.bms.price.domain.PrcPayBillFeeLog;
|
||||
import com.bms.price.mapper.PrcPayBillFeeLogMapper;
|
||||
|
||||
/**
|
||||
* 应付费用日志。各入口只调用这里,写入失败只打日志,不把异常交回业务。
|
||||
*/
|
||||
@Service
|
||||
public class PayBillFeeLogService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(PayBillFeeLogService.class);
|
||||
|
||||
/** 新增,字典 bms_pay_fee_log_type */
|
||||
public static final String ADD = "1";
|
||||
|
||||
/** 编辑 */
|
||||
public static final String EDIT = "2";
|
||||
|
||||
/** 删除 */
|
||||
public static final String DELETE = "3";
|
||||
|
||||
/** 重算费用 */
|
||||
public static final String RECALC = "4";
|
||||
|
||||
/** 废弃 */
|
||||
public static final String VOID = "5";
|
||||
|
||||
private static final int BATCH_SIZE = 200;
|
||||
|
||||
@Autowired
|
||||
private PrcPayBillFeeLogMapper payBillFeeLogMapper;
|
||||
|
||||
/**
|
||||
* 记一条费用日志。异常只打印,不向外抛。
|
||||
*
|
||||
* @param fee 费用项、金额、币种和所属订单
|
||||
* @param operationType 字典值,见本类常量
|
||||
*/
|
||||
public void record(PrcPayBillFee fee, String operationType)
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
record(Collections.singletonList(fee), operationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按同一操作类型记一批费用日志。异常只打印,不向外抛。
|
||||
*
|
||||
* @param fees 本次涉及的费用
|
||||
* @param operationType 字典值,见本类常量
|
||||
*/
|
||||
public void record(List<PrcPayBillFee> fees, String operationType)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<PrcPayBillFeeLog> rows = snapshots(fees, operationType);
|
||||
for (int from = 0; from < rows.size(); from += BATCH_SIZE)
|
||||
{
|
||||
payBillFeeLogMapper.insertBatch(rows.subList(from, Math.min(from + BATCH_SIZE, rows.size())));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.error("写入应付费用日志失败 operationType={}", operationType, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取一票订单的费用日志。表还没建或查询失败时返回空列表,并打印错误。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 日志,新的在前
|
||||
*/
|
||||
public List<PrcPayBillFeeLog> list(Long billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try
|
||||
{
|
||||
List<PrcPayBillFeeLog> rows = payBillFeeLogMapper.selectByBillId(billId);
|
||||
return rows == null ? Collections.emptyList() : rows;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.error("读取应付费用日志失败 billId={}", billId, ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
private List<PrcPayBillFeeLog> snapshots(List<PrcPayBillFee> fees, String operationType)
|
||||
{
|
||||
List<PrcPayBillFeeLog> rows = new ArrayList<>();
|
||||
if (fees == null || fees.isEmpty() || operationType == null || operationType.isBlank())
|
||||
{
|
||||
return rows;
|
||||
}
|
||||
String operator = operator();
|
||||
String type = cut(operationType.trim(), 32);
|
||||
for (PrcPayBillFee fee : fees)
|
||||
{
|
||||
if (fee == null || fee.getBillId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPayBillFeeLog row = new PrcPayBillFeeLog();
|
||||
row.setFeeId(cut(fee.getFeeId(), 64));
|
||||
row.setBillId(fee.getBillId());
|
||||
row.setFeeName(cut(nameOf(fee), 100));
|
||||
row.setAmount(fee.getAmount());
|
||||
String currency = fee.getCurrency() == null ? null : fee.getCurrency().trim();
|
||||
row.setCurrency(currency == null || currency.isEmpty() ? null : cut(currency, 10));
|
||||
row.setOperationType(type);
|
||||
row.setCreateBy(operator);
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private static String nameOf(PrcPayBillFee fee)
|
||||
{
|
||||
String name = fee.getFeeName() == null ? "" : fee.getFeeName().trim();
|
||||
if (!name.isEmpty())
|
||||
{
|
||||
return name;
|
||||
}
|
||||
String type = fee.getFeeType() == null ? "" : fee.getFeeType().trim();
|
||||
return type.isEmpty() ? "费用" : type;
|
||||
}
|
||||
|
||||
private static String operator()
|
||||
{
|
||||
try
|
||||
{
|
||||
String name = SecurityUtils.getUsername();
|
||||
if (name == null || name.isBlank())
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
return cut(name.trim(), 64);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
}
|
||||
|
||||
private static String cut(String value, int max)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = value.trim();
|
||||
return text.length() <= max ? text : text.substring(0, max);
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -48,6 +48,7 @@ import com.bms.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.bms.price.pay.PaySettleSupport;
|
||||
import com.bms.price.service.IPayBillService;
|
||||
import com.bms.price.service.IPayOrderCostService;
|
||||
import com.bms.price.service.PayBillFeeLogService;
|
||||
import com.bms.price.service.IPrcPayBillFeeService;
|
||||
|
||||
/**
|
||||
@@ -73,6 +74,9 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
@Autowired
|
||||
private IPrcPayBillFeeService payBillFeeService;
|
||||
|
||||
@Autowired
|
||||
private PayBillFeeLogService payBillFeeLogService;
|
||||
|
||||
@Autowired
|
||||
private PayFinanceMapper payFinanceMapper;
|
||||
|
||||
@@ -577,22 +581,19 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
adjust.setFeeId(UUID.randomUUID().toString());
|
||||
adjust.setBillId(line.getOrderBillId());
|
||||
adjust.setPayBillId(source == null ? null : source.getPayBillId());
|
||||
adjust.setFeeType("对账调整");
|
||||
adjust.setFeeType("ADJUST");
|
||||
adjust.setFeeName("对账调整");
|
||||
adjust.setScId(open.getDiffId());
|
||||
adjust.setFeeLevel(line.getFeeLevel());
|
||||
adjust.setAmount(delta);
|
||||
adjust.setCurrency(line.getCurrency());
|
||||
adjust.setFeeSource("MANUAL");
|
||||
adjust.setSourceId(source == null ? null : source.getFeeId());
|
||||
adjust.setSourceId(source == null ? null : source.getSourceId());
|
||||
adjust.setRemark(open.getReason());
|
||||
adjust.setSettleSupplierId(bill.getSupplierId());
|
||||
adjust.setSettleSupplierName(bill.getSupplierName());
|
||||
payBillFeeMapper.insertPrcPayBillFee(adjust);
|
||||
if (adjust.getSourceId() == null || adjust.getSourceId().isBlank())
|
||||
{
|
||||
payBillFeeMapper.fillSourceIdByFeeIds(List.of(adjust.getFeeId()));
|
||||
}
|
||||
payBillFeeLogService.record(adjust, PayBillFeeLogService.ADD);
|
||||
payFinanceMapper.stampFee(adjust.getFeeId(), bill.getSupplierId(), bill.getSupplierName());
|
||||
if (line.getOrderBillId() != null)
|
||||
{
|
||||
@@ -604,7 +605,7 @@ public class PayBillServiceImpl implements IPayBillService
|
||||
extra.setOrderBillId(line.getOrderBillId());
|
||||
extra.setOrderNo(line.getOrderNo());
|
||||
extra.setLadingNo(line.getLadingNo());
|
||||
extra.setFeeName(adjust.getFeeName());
|
||||
extra.setFeeName("对账调整");
|
||||
extra.setFeeSource("MANUAL");
|
||||
extra.setFeeLevel(line.getFeeLevel());
|
||||
extra.setAmount(delta);
|
||||
|
||||
+86
@@ -35,6 +35,7 @@ import com.bms.price.pay.PayRemoteBook;
|
||||
import com.bms.price.pay.PaySurchargeRules;
|
||||
import com.bms.price.pay.PayZoneMatcher;
|
||||
import com.bms.price.service.IPayOrderCostService;
|
||||
import com.bms.price.service.PayBillFeeLogService;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
import com.bms.price.service.IPaySurchargeRuleService;
|
||||
import com.bms.price.service.IPrcPayBillFeeService;
|
||||
@@ -66,6 +67,9 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
@Autowired
|
||||
private IPrcPayBillFeeService payBillFeeService;
|
||||
|
||||
@Autowired
|
||||
private PayBillFeeLogService payBillFeeLogService;
|
||||
|
||||
@Autowired
|
||||
private PaySettleSupport paySettleSupport;
|
||||
|
||||
@@ -89,6 +93,27 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
return generate(billId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单同步后落地尾程费用。已经进入应付账单的计算费用不再覆盖。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @return 本次落地的结果;费用已经出账时返回 null
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public PayOrderCostResult landIfOpen(Long billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (payBillFeeMapper.countSettledCalc(billId) > 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return generate(billId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PayOrderCostResult generate(Long billId)
|
||||
@@ -141,6 +166,42 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独记下计费失败。重算事务回滚后,这条状态仍然保留。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param reason 失败原因,超过 100 字会截断
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
|
||||
public void markCalcFail(Long billId, String reason)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String message = reason == null ? "" : reason.trim();
|
||||
if (message.length() > 100)
|
||||
{
|
||||
message = message.substring(0, 100);
|
||||
}
|
||||
String operator = "system";
|
||||
try
|
||||
{
|
||||
String name = SecurityUtils.getUsername();
|
||||
if (name != null && !name.isBlank())
|
||||
{
|
||||
operator = name;
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
operator = "system";
|
||||
}
|
||||
payBillMapper.insertMissingPayBills(List.of(billId), operator);
|
||||
payBillMapper.markCalcStatus(billId, 2, message, operator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cardSupplierName(Long billId)
|
||||
{
|
||||
@@ -587,6 +648,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
*/
|
||||
private void saveFees(Long billId, String payBillId, List<PayCostLine> fees)
|
||||
{
|
||||
boolean recalc = hasCalcFee(billId);
|
||||
payBillFeeMapper.deleteByBillId(billId);
|
||||
List<PrcPayBillFee> rows = new java.util.ArrayList<>();
|
||||
long fallback = 1L;
|
||||
@@ -618,6 +680,30 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
{
|
||||
payBillFeeService.refreshTotals(java.util.List.of(billId));
|
||||
}
|
||||
payBillFeeLogService.record(rows, recalc ? PayBillFeeLogService.RECALC : PayBillFeeLogService.ADD);
|
||||
}
|
||||
|
||||
/** 这票订单上还有没删除的计算费用。有则本次落库是重算,没有则是首次生成。 */
|
||||
private boolean hasCalcFee(Long billId)
|
||||
{
|
||||
List<PrcPayBillFee> current = payBillFeeMapper.selectByBillId(billId);
|
||||
if (current == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (PrcPayBillFee fee : current)
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String source = fee.getFeeSource();
|
||||
if (source == null || source.isBlank() || "CALC".equals(source))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+446
@@ -0,0 +1,446 @@
|
||||
package com.bms.price.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.bms.common.enums.PaymentMesEnum;
|
||||
import com.bms.common.exception.ServiceException;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderFeeSection;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRecalcCommand;
|
||||
import com.bms.price.domain.PayOrderRecalcLine;
|
||||
import com.bms.price.domain.PayOrderRecalcResult;
|
||||
import com.bms.price.domain.PayOrderRow;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
import com.bms.price.mapper.PayOrderListMapper;
|
||||
import com.bms.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcPayBillMapper;
|
||||
import com.bms.price.service.IPayOrderCostService;
|
||||
import com.bms.price.service.PayBillFeeLogService;
|
||||
import com.bms.price.service.IPayOrderListService;
|
||||
import com.bms.price.service.IPrcPayBillFeeService;
|
||||
|
||||
@Service
|
||||
public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
{
|
||||
private static final int MAX_ORDER_NOS = 500;
|
||||
|
||||
private static final Map<String, String> TITLES = new LinkedHashMap<>();
|
||||
|
||||
static
|
||||
{
|
||||
TITLES.put("1", "A段(头程仓储)");
|
||||
TITLES.put("2", "B段(提单运输)");
|
||||
TITLES.put("3", "C段(清关)");
|
||||
TITLES.put("4", "D段(尾程)");
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private PayOrderListMapper payOrderListMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPayBillFeeMapper payBillFeeMapper;
|
||||
|
||||
@Autowired
|
||||
private IPayOrderCostService payOrderCostService;
|
||||
|
||||
@Autowired
|
||||
private PrcPayBillMapper payBillMapper;
|
||||
|
||||
@Autowired
|
||||
private IPrcPayBillFeeService payBillFeeService;
|
||||
|
||||
@Autowired
|
||||
private PayBillFeeLogService payBillFeeLogService;
|
||||
|
||||
@Override
|
||||
public List<PayOrderRow> list(PayOrderQuery query)
|
||||
{
|
||||
PayOrderQuery safe = query == null ? new PayOrderQuery() : query;
|
||||
List<String> orderNos = orderNos(safe.getOrderNo());
|
||||
if (orderNos.size() > MAX_ORDER_NOS)
|
||||
{
|
||||
throw new ServiceException("一次最多查询" + MAX_ORDER_NOS + "个订单号");
|
||||
}
|
||||
if (orderNos.size() > 1)
|
||||
{
|
||||
safe.setOrderNos(orderNos);
|
||||
safe.setOrderNo(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
safe.setOrderNos(null);
|
||||
safe.setOrderNo(orderNos.isEmpty() ? null : orderNos.get(0));
|
||||
}
|
||||
return payOrderListMapper.selectList(safe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按订单号或提单号逐票重算尾程应付。找不到的单号记失败,已经出账的费用不覆盖。
|
||||
*
|
||||
* @param command 重算方式和单号原文
|
||||
* @return 成功数、失败数和明细
|
||||
*/
|
||||
@Override
|
||||
public PayOrderRecalcResult recalc(PayOrderRecalcCommand command)
|
||||
{
|
||||
if (command == null || command.getSourceType() == null || command.getSourceType().isBlank())
|
||||
{
|
||||
throw new ServiceException("请选择按订单号或按提单号重算");
|
||||
}
|
||||
String source = command.getSourceType().trim();
|
||||
List<String> nos = orderNos(command.getText());
|
||||
if (nos.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写单号");
|
||||
}
|
||||
if (nos.size() > MAX_ORDER_NOS)
|
||||
{
|
||||
throw new ServiceException("一次最多重算" + MAX_ORDER_NOS + "个单号");
|
||||
}
|
||||
boolean byOrder = "ORDER".equalsIgnoreCase(source);
|
||||
boolean byLading = "LADING".equalsIgnoreCase(source);
|
||||
if (!byOrder && !byLading)
|
||||
{
|
||||
throw new ServiceException("请选择按订单号或按提单号重算");
|
||||
}
|
||||
List<PayOrderRow> found = byOrder ? payOrderListMapper.selectByOrderNos(nos) : payOrderListMapper.selectByLadingNos(nos);
|
||||
if (found == null)
|
||||
{
|
||||
found = new ArrayList<>();
|
||||
}
|
||||
if (found.size() > MAX_ORDER_NOS)
|
||||
{
|
||||
throw new ServiceException("一次最多重算" + MAX_ORDER_NOS + "票订单");
|
||||
}
|
||||
PayOrderRecalcResult result = new PayOrderRecalcResult();
|
||||
LinkedHashSet<String> hit = new LinkedHashSet<>();
|
||||
for (PayOrderRow order : found)
|
||||
{
|
||||
if (order == null || order.getBillId() == null || order.getBillId().isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hit.add(byOrder ? order.getOrderNo() : order.getLadingNo());
|
||||
PayOrderRecalcLine line = new PayOrderRecalcLine();
|
||||
line.setOrderNo(order.getOrderNo());
|
||||
line.setLadingNo(order.getLadingNo());
|
||||
if (payBillFeeMapper.countSettledCalc(Long.valueOf(order.getBillId().trim())) > 0)
|
||||
{
|
||||
line.setSuccess(false);
|
||||
line.setMessage("费用已进入应付账单,未重算");
|
||||
result.getLines().add(line);
|
||||
result.setFailCount(result.getFailCount() + 1);
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
payOrderCostService.generateIsolated(Long.valueOf(order.getBillId().trim()));
|
||||
line.setSuccess(true);
|
||||
result.setSuccessCount(result.getSuccessCount() + 1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
String message = ex.getMessage() == null ? "应付费用生成失败" : ex.getMessage();
|
||||
try
|
||||
{
|
||||
payOrderCostService.markCalcFail(Long.valueOf(order.getBillId().trim()), message);
|
||||
}
|
||||
catch (Exception markEx)
|
||||
{
|
||||
message = message + ";计费状态未写入";
|
||||
}
|
||||
line.setSuccess(false);
|
||||
line.setMessage(message);
|
||||
result.setFailCount(result.getFailCount() + 1);
|
||||
}
|
||||
result.getLines().add(line);
|
||||
}
|
||||
for (String no : nos)
|
||||
{
|
||||
if (hit.contains(no))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PayOrderRecalcLine line = new PayOrderRecalcLine();
|
||||
if (byOrder)
|
||||
{
|
||||
line.setOrderNo(no);
|
||||
line.setMessage("没有找到这个订单");
|
||||
}
|
||||
else
|
||||
{
|
||||
line.setLadingNo(no);
|
||||
line.setMessage("这个提单下没有订单");
|
||||
}
|
||||
line.setSuccess(false);
|
||||
result.getLines().add(line);
|
||||
result.setFailCount(result.getFailCount() + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayOrderFeeBoard fees(String billId)
|
||||
{
|
||||
if (billId == null || billId.isBlank())
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PICK_ORDER.exception();
|
||||
}
|
||||
PayOrderRow order = payOrderListMapper.selectRow(billId.trim());
|
||||
if (order == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_ORDER_MISS.exception();
|
||||
}
|
||||
Map<String, PayOrderFeeSection> sections = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, String> title : TITLES.entrySet())
|
||||
{
|
||||
PayOrderFeeSection section = new PayOrderFeeSection();
|
||||
section.setLevel(title.getKey());
|
||||
section.setTitle(title.getValue());
|
||||
sections.put(title.getKey(), section);
|
||||
}
|
||||
List<PrcPayBillFee> owned = payBillFeeMapper.selectByBillId(Long.valueOf(order.getBillId().trim()));
|
||||
if (owned != null)
|
||||
{
|
||||
for (PrcPayBillFee fee : owned)
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sections.get(levelOf(fee)).getFees().add(toLine(fee));
|
||||
}
|
||||
}
|
||||
PayOrderFeeBoard board = new PayOrderFeeBoard();
|
||||
board.setBillId(order.getBillId());
|
||||
board.setOrderNo(order.getOrderNo());
|
||||
board.setLadingNo(order.getLadingNo());
|
||||
board.setSections(List.copyOf(sections.values()));
|
||||
board.setLogs(payBillFeeLogService.list(Long.valueOf(order.getBillId().trim())));
|
||||
return board;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定费用段增加一行手工费用,并按未删除明细重算应付总额。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param line 费用项、金额、币种、说明和所属阶段
|
||||
* @return 刚写入的费用行
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PayOrderFeeLine addManualFee(String billId, PayOrderFeeLine line)
|
||||
{
|
||||
PayOrderRow order = requireOrder(billId);
|
||||
if (line == null)
|
||||
{
|
||||
throw new ServiceException("请填写费用");
|
||||
}
|
||||
String level = line.getLevel() == null ? "" : line.getLevel().trim();
|
||||
if (!TITLES.containsKey(level))
|
||||
{
|
||||
throw new ServiceException("请选择费用阶段");
|
||||
}
|
||||
String feeName = firstText(line.getFeeName(), line.getFeeType());
|
||||
if (feeName.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写费用项");
|
||||
}
|
||||
if (feeName.length() > 100)
|
||||
{
|
||||
feeName = feeName.substring(0, 100);
|
||||
}
|
||||
String feeType = firstText(line.getFeeType(), "MANUAL");
|
||||
if (feeType.length() > 30)
|
||||
{
|
||||
feeType = "MANUAL";
|
||||
}
|
||||
if (line.getAmount() == null)
|
||||
{
|
||||
throw new ServiceException("请填写金额");
|
||||
}
|
||||
BigDecimal amount = line.getAmount().setScale(2, RoundingMode.HALF_UP);
|
||||
if (amount.abs().compareTo(new BigDecimal("9999999999.99")) > 0)
|
||||
{
|
||||
throw new ServiceException("金额超出范围");
|
||||
}
|
||||
String currency = firstText(line.getCurrency(), "CNY").toUpperCase();
|
||||
if (currency.length() > 10)
|
||||
{
|
||||
throw new ServiceException("币种过长");
|
||||
}
|
||||
String remark = line.getRemark() == null ? null : line.getRemark().trim();
|
||||
if (remark != null && remark.length() > 200)
|
||||
{
|
||||
throw new ServiceException("说明不能超过200字");
|
||||
}
|
||||
Long orderBillId = Long.valueOf(order.getBillId().trim());
|
||||
String operator = operator();
|
||||
payBillMapper.insertMissingPayBills(List.of(orderBillId), operator);
|
||||
PrcPayBill payBill = payBillMapper.selectByBillId(orderBillId);
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(orderBillId);
|
||||
fee.setPayBillId(payBill == null ? null : payBill.getPayBillId());
|
||||
fee.setFeeType(feeType);
|
||||
fee.setFeeName(feeName);
|
||||
fee.setScId(manualScId());
|
||||
fee.setFeeLevel(level);
|
||||
fee.setAmount(amount);
|
||||
fee.setCurrency(currency);
|
||||
fee.setRemark(remark == null || remark.isEmpty() ? null : remark);
|
||||
fee.setFeeSource("MANUAL");
|
||||
fee.setCreateBy(operator);
|
||||
fee.setUpdateBy(operator);
|
||||
payBillFeeMapper.insertManual(fee);
|
||||
payBillFeeService.refreshTotals(List.of(orderBillId));
|
||||
payBillFeeLogService.record(fee, PayBillFeeLogService.ADD);
|
||||
PrcPayBillFee saved = payBillFeeMapper.selectByFeeId(fee.getFeeId());
|
||||
return toLine(saved == null ? fee : saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除一条费用,并按剩余未删除明细重算应付总额。
|
||||
*
|
||||
* @param feeId 费用明细 ID
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeFee(String feeId)
|
||||
{
|
||||
if (feeId == null || feeId.isBlank())
|
||||
{
|
||||
throw new ServiceException("请选择要删除的费用");
|
||||
}
|
||||
PrcPayBillFee fee = payBillFeeMapper.selectByFeeId(feeId.trim());
|
||||
if (fee == null || "1".equals(fee.getIsDeleted()))
|
||||
{
|
||||
throw new ServiceException("费用不存在");
|
||||
}
|
||||
if (fee.getStatementLineId() != null)
|
||||
{
|
||||
throw new ServiceException("费用已进入应付账单,不能删除");
|
||||
}
|
||||
int rows = payBillFeeMapper.markFeeDeleted(feeId.trim(), operator());
|
||||
if (rows == 0)
|
||||
{
|
||||
throw new ServiceException("费用已进入应付账单,不能删除");
|
||||
}
|
||||
payBillFeeLogService.record(fee, PayBillFeeLogService.DELETE);
|
||||
if (fee.getBillId() != null)
|
||||
{
|
||||
payBillFeeService.refreshTotals(List.of(fee.getBillId()));
|
||||
}
|
||||
}
|
||||
|
||||
/** 费用弹框一行。手工费用直接用保存下来的名称。 */
|
||||
private static PayOrderFeeLine toLine(PrcPayBillFee fee)
|
||||
{
|
||||
PayOrderFeeLine line = new PayOrderFeeLine();
|
||||
line.setFeeId(fee.getFeeId());
|
||||
line.setFeeType(fee.getFeeType());
|
||||
line.setFeeName(fee.getFeeName());
|
||||
line.setLevel(fee.getFeeLevel());
|
||||
line.setAmount(fee.getAmount());
|
||||
line.setCurrency(fee.getCurrency());
|
||||
line.setFeeSource(fee.getFeeSource() == null || fee.getFeeSource().isBlank() ? "CALC" : fee.getFeeSource());
|
||||
line.setRemark(fee.getRemark());
|
||||
line.setStatementLineId(fee.getStatementLineId());
|
||||
line.setCreateBy(fee.getCreateBy());
|
||||
line.setCreateTime(fee.getCreateTime());
|
||||
line.setUpdateBy(fee.getUpdateBy());
|
||||
line.setUpdateTime(fee.getUpdateTime());
|
||||
return line;
|
||||
}
|
||||
|
||||
/** 当前登录人。同步线程没有登录信息时记 system。 */
|
||||
private static String operator()
|
||||
{
|
||||
try
|
||||
{
|
||||
String name = SecurityUtils.getUsername();
|
||||
return name == null || name.isBlank() ? "system" : name;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
}
|
||||
|
||||
private static String firstText(String primary, String fallback)
|
||||
{
|
||||
if (primary != null && !primary.isBlank())
|
||||
{
|
||||
return primary.trim();
|
||||
}
|
||||
return fallback == null ? "" : fallback.trim();
|
||||
}
|
||||
|
||||
/** 手工费用用负数序号,避免和同一费用项的计算费用撞上唯一键。 */
|
||||
private static long manualScId()
|
||||
{
|
||||
long tick = System.nanoTime();
|
||||
if (tick == Long.MIN_VALUE)
|
||||
{
|
||||
return -1L;
|
||||
}
|
||||
long value = -Math.abs(tick);
|
||||
return value == 0L ? -1L : value;
|
||||
}
|
||||
|
||||
private PayOrderRow requireOrder(String billId)
|
||||
{
|
||||
if (billId == null || billId.isBlank())
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PICK_ORDER.exception();
|
||||
}
|
||||
PayOrderRow order = payOrderListMapper.selectRow(billId.trim());
|
||||
if (order == null || order.getBillId() == null || order.getBillId().isBlank())
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_ORDER_MISS.exception();
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
/** 订单号按逗号、顿号、分号、空白拆开,并去掉重复和空白。 */
|
||||
private static List<String> orderNos(String text)
|
||||
{
|
||||
LinkedHashSet<String> values = new LinkedHashSet<>();
|
||||
if (text != null)
|
||||
{
|
||||
for (String part : text.split("[,,、;;\\s]+"))
|
||||
{
|
||||
String token = part.trim();
|
||||
if (!token.isEmpty())
|
||||
{
|
||||
values.add(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(values);
|
||||
}
|
||||
|
||||
/** 已经标明阶段的按阶段放。尾程计算出来的派送费和附加费没有阶段时归到 D 段。 */
|
||||
private static String levelOf(PrcPayBillFee fee)
|
||||
{
|
||||
String level = fee.getFeeLevel();
|
||||
if ("1".equals(level) || "2".equals(level) || "3".equals(level) || "4".equals(level))
|
||||
{
|
||||
return level;
|
||||
}
|
||||
return "4";
|
||||
}
|
||||
}
|
||||
+105
-1
@@ -106,6 +106,7 @@ import com.bms.customer.customermoney.api.CreditUsageCommand;
|
||||
import com.bms.customer.customermoney.api.CustomerFundBizType;
|
||||
import com.bms.customer.customermoney.api.ICustomerAccountApi;
|
||||
import com.bms.customer.customermoney.vo.CustomerAccountStatusVO;
|
||||
import com.bms.price.service.IPayOrderCostService;
|
||||
import com.bms.price.service.IPrcOrderBillService;
|
||||
import com.bms.price.service.IPrcSurchargeService;
|
||||
import com.bms.price.service.ITmsPriceQuoteService;
|
||||
@@ -124,6 +125,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
@Lazy
|
||||
private IPrcOrderBillService self;
|
||||
|
||||
@Autowired
|
||||
private IPayOrderCostService payOrderCostService;
|
||||
|
||||
@Autowired
|
||||
private ITmsPriceQuoteService tmsPriceQuoteService;
|
||||
|
||||
@@ -3270,7 +3274,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
|
||||
/**
|
||||
* 订单来源同步:用上游字段完整覆盖本地账单 + ext。
|
||||
* 不做报价、不占用授信、不涉及费用,也不校验 AR/退费。
|
||||
* 不做应收报价、不占用授信。订单提交成功后,再按应付产品落地尾程运费和订单附加费。
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -3375,9 +3379,109 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
// ES 映射中 response.ok 为 long 类型,使用 1/0 而非布尔 true/false。
|
||||
billSearchStore.save(EsLogType.BILL, bizId, req.toJSONString(),
|
||||
"{\"ok\":1,\"action\":\"UPSTREAM_SYNC\"}");
|
||||
landTailFeesAfterCommit(bill);
|
||||
return bill.getBillId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 等这票订单提交成功后再算尾程应付。生成失败只打日志并写入 ES,不回滚订单,也不往外抛。
|
||||
*
|
||||
* @param bill 刚写入的计费订单
|
||||
*/
|
||||
private void landTailFeesAfterCommit(PrcOrderBill bill)
|
||||
{
|
||||
if (bill == null || bill.getBillId() == null || payOrderCostService == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long billId = bill.getBillId();
|
||||
String orderNo = bill.getOrderNo();
|
||||
String transferNo = bill.getTransferNo();
|
||||
if (!TransactionSynchronizationManager.isSynchronizationActive())
|
||||
{
|
||||
landTailFeesQuietly(billId, orderNo, transferNo);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization()
|
||||
{
|
||||
@Override
|
||||
public void afterCommit()
|
||||
{
|
||||
landTailFeesQuietly(billId, orderNo, transferNo);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
log.warn("订单同步后应付费用未安排生成 billId={}", billId, ex);
|
||||
savePayFeeFailEs(billId, orderNo, transferNo, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 落地还没出账的尾程运费和订单附加费。任何失败都只记录异常并写入 ES,留给下次同步再试。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param orderNo 订单号
|
||||
* @param transferNo 转单号,ES 检索优先用它
|
||||
*/
|
||||
private void landTailFeesQuietly(Long billId, String orderNo, String transferNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
payOrderCostService.landIfOpen(billId);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.warn("订单同步后应付费用生成失败 billId={}", billId, ex);
|
||||
savePayFeeFailEs(billId, orderNo, transferNo, ex);
|
||||
try
|
||||
{
|
||||
payOrderCostService.markCalcFail(billId, ex.getMessage());
|
||||
}
|
||||
catch (Exception markEx)
|
||||
{
|
||||
log.warn("应付计费失败状态未写入 billId={}", billId, markEx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把应付费用生成失败写进订单原有的 ES 日志。bizId 与订单同步相同,优先转单号。
|
||||
*
|
||||
* @param billId 计费订单 ID
|
||||
* @param orderNo 订单号
|
||||
* @param transferNo 转单号
|
||||
* @param ex 生成失败的异常
|
||||
*/
|
||||
private void savePayFeeFailEs(Long billId, String orderNo, String transferNo, Exception ex)
|
||||
{
|
||||
if (billSearchStore == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String message = ex == null || ex.getMessage() == null ? "应付费用生成失败" : ex.getMessage();
|
||||
JSONObject req = new JSONObject();
|
||||
req.put("action", "PAY_FEE_FAIL");
|
||||
req.put("orderNo", orderNo);
|
||||
req.put("transferNo", transferNo);
|
||||
req.put("billId", billId);
|
||||
req.put("errorMessage", message);
|
||||
String bizId = StringUtils.isNotEmpty(transferNo) ? transferNo.trim()
|
||||
: (StringUtils.isNotEmpty(orderNo) ? orderNo.trim() : String.valueOf(billId));
|
||||
billSearchStore.save(EsLogType.BILL, bizId, req.toJSONString(),
|
||||
"{\"ok\":0,\"action\":\"PAY_FEE_FAIL\"}", EsBizLogSupport.STATUS_FAIL, message);
|
||||
}
|
||||
catch (Exception logEx)
|
||||
{
|
||||
log.warn("应付费用失败日志写入 ES 失败 billId={}", billId, logEx);
|
||||
}
|
||||
}
|
||||
|
||||
/** 按编码尽力查询客户 ID;查询不到时保留原 ID。 */
|
||||
private Long resolveCustomerIdByCode(String customerCode, Long previousId)
|
||||
{
|
||||
|
||||
-13
@@ -43,19 +43,6 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
{
|
||||
List<PrcPayBillFee> chunk = fees.subList(from, Math.min(from + BATCH_SIZE, fees.size()));
|
||||
payBillFeeMapper.insertBatch(chunk);
|
||||
List<String> ownIds = new ArrayList<>();
|
||||
for (PrcPayBillFee fee : chunk)
|
||||
{
|
||||
if (fee != null && fee.getFeeId() != null && !fee.getFeeId().isBlank()
|
||||
&& (fee.getSourceId() == null || fee.getSourceId().isBlank()))
|
||||
{
|
||||
ownIds.add(fee.getFeeId());
|
||||
}
|
||||
}
|
||||
if (!ownIds.isEmpty())
|
||||
{
|
||||
payBillFeeMapper.fillSourceIdByFeeIds(ownIds);
|
||||
}
|
||||
for (PrcPayBillFee fee : chunk)
|
||||
{
|
||||
if (fee != null && fee.getBillId() != null)
|
||||
|
||||
+17
-3
@@ -27,6 +27,7 @@ import com.bms.price.mapper.SrvBillAirAllocMapper;
|
||||
import com.bms.price.mapper.SrvBillAirFeeMapper;
|
||||
import com.bms.price.mapper.SrvBillAirMapper;
|
||||
import com.bms.price.service.IPrcPayBillFeeService;
|
||||
import com.bms.price.service.PayBillFeeLogService;
|
||||
import com.bms.price.service.ISrvBillAirAllocService;
|
||||
|
||||
/**
|
||||
@@ -59,6 +60,9 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
@Autowired
|
||||
private IPrcPayBillFeeService payBillFeeService;
|
||||
|
||||
@Autowired
|
||||
private PayBillFeeLogService payBillFeeLogService;
|
||||
|
||||
@Override
|
||||
public List<SrvBillAirAllocFee> preview(List<String> billCodes)
|
||||
{
|
||||
@@ -237,9 +241,8 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
row.setFeeId(UUID.randomUUID().toString());
|
||||
row.setBillId(order.getBillId());
|
||||
row.setPayBillId(payBillIds.get(order.getBillId()));
|
||||
String name = blankName(fee);
|
||||
row.setFeeType(name.length() <= 30 ? name : name.substring(0, 30));
|
||||
row.setFeeName(name);
|
||||
row.setFeeType(dictType(fee.getFeeType()));
|
||||
row.setFeeName(fee.getFeeName());
|
||||
row.setScId(fee.getId() == null ? 0L : fee.getId());
|
||||
row.setFeeLevel(fee.getFeeLevel());
|
||||
row.setAmount(amount);
|
||||
@@ -247,6 +250,7 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
row.setRoundMode("HALF_UP");
|
||||
row.setRemark(remark(fee));
|
||||
row.setFeeSource(FEE_SOURCE);
|
||||
row.setSourceId(fee.getId() == null ? null : String.valueOf(fee.getId()));
|
||||
row.setIsDeleted("0");
|
||||
return row;
|
||||
}
|
||||
@@ -259,6 +263,7 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
}
|
||||
int rows = batch.size();
|
||||
payBillFeeService.insertBatchAndRefreshTotals(new ArrayList<>(batch));
|
||||
payBillFeeLogService.record(batch, PayBillFeeLogService.ADD);
|
||||
batch.clear();
|
||||
return rows;
|
||||
}
|
||||
@@ -378,6 +383,15 @@ public class SrvBillAirAllocServiceImpl implements ISrvBillAirAllocService
|
||||
return ids;
|
||||
}
|
||||
|
||||
private static String dictType(String feeType)
|
||||
{
|
||||
if (feeType == null || !feeType.trim().matches("[A-Z][A-Z0-9_]*"))
|
||||
{
|
||||
return "SURCHARGE";
|
||||
}
|
||||
return feeType.trim();
|
||||
}
|
||||
|
||||
private static String blankName(SrvBillAirAllocFee fee)
|
||||
{
|
||||
if (fee.getFeeName() != null && !fee.getFeeName().isBlank())
|
||||
|
||||
+20
-6
@@ -28,12 +28,14 @@ import com.bms.price.airbill.domain.SrvBillAirRoleFeeCommand;
|
||||
import com.bms.price.airbill.domain.SrvBillAirRoleFeeQuery;
|
||||
import com.bms.price.airbill.domain.SrvBillAirFeeLog;
|
||||
import com.bms.price.airbill.domain.SrvBillAirFeeSave;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
import com.bms.price.domain.PrcSurcharge;
|
||||
import com.bms.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.mapper.SrvBillAirFeeMapper;
|
||||
import com.bms.price.mapper.SrvBillAirMapper;
|
||||
import com.bms.price.service.IPrcPayBillFeeService;
|
||||
import com.bms.price.service.PayBillFeeLogService;
|
||||
import com.bms.price.service.IPrcSurchargeService;
|
||||
import com.bms.price.service.ISrvBillAirFeeService;
|
||||
import com.bms.system.service.ISysDictTypeService;
|
||||
@@ -70,6 +72,9 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
@Autowired
|
||||
private IPrcPayBillFeeService payBillFeeService;
|
||||
|
||||
@Autowired
|
||||
private PayBillFeeLogService payBillFeeLogService;
|
||||
|
||||
@Autowired
|
||||
private IPrcSurchargeService surchargeService;
|
||||
|
||||
@@ -210,7 +215,8 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
throw new ServiceException("第" + line + "行备注不能超过500字");
|
||||
}
|
||||
SrvBillAirFee fee = new SrvBillAirFee();
|
||||
fee.setFeeType(String.valueOf(chosen.getScId()));
|
||||
fee.setScId(chosen.getScId());
|
||||
fee.setFeeType(chosen.getFeeType() == null || chosen.getFeeType().isBlank() ? "SURCHARGE" : chosen.getFeeType().trim());
|
||||
fee.setFeeName(chosen.getScName());
|
||||
fee.setFeeLevel(level);
|
||||
fee.setPrice(row.getPrice());
|
||||
@@ -410,7 +416,9 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
Operator operator = operator();
|
||||
Date now = DateUtils.getNowDate();
|
||||
List<Long> affectedBills = payBillFeeMapper.selectBillIdsByLadingFee(feeId);
|
||||
List<PrcPayBillFee> allocated = payBillFeeMapper.selectAliveByLadingFee(feeId);
|
||||
payBillFeeMapper.markLadingFeeDeleted(feeId);
|
||||
payBillFeeLogService.record(allocated, PayBillFeeLogService.VOID);
|
||||
payBillFeeService.refreshTotals(affectedBills);
|
||||
if (feeMapper.voidFee(feeId, code, operator.account, now) != 1)
|
||||
{
|
||||
@@ -556,7 +564,7 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
String feeLevel = trim(raw.getFeeLevel());
|
||||
String currency = trim(raw.getCurrency());
|
||||
String remark = trim(raw.getRemark());
|
||||
Long scId = parseScId(feeType);
|
||||
Long scId = raw.getScId() != null && raw.getScId() > 0 ? raw.getScId() : parseScId(feeType);
|
||||
if (scId == null)
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_PICK_ITEM.exception();
|
||||
@@ -566,7 +574,7 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_ITEM_MISS.exception();
|
||||
}
|
||||
feeType = String.valueOf(scId);
|
||||
feeType = surcharge.getFeeType() == null || surcharge.getFeeType().isBlank() ? "SURCHARGE" : surcharge.getFeeType().trim();
|
||||
if (!feeLevel.isEmpty() && (feeLevel.length() > 32 || !levelLabels.containsKey(feeLevel)))
|
||||
{
|
||||
throw PaymentMesEnum.BMS_PAY_LEVEL.exception();
|
||||
@@ -597,6 +605,7 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
}
|
||||
SrvBillAirFee fee = new SrvBillAirFee();
|
||||
fee.setFeeType(feeType);
|
||||
fee.setScId(scId);
|
||||
fee.setFeeLevel(feeLevel);
|
||||
fee.setFeeScene(trim(raw.getFeeScene()));
|
||||
fee.setAllocFlag("1");
|
||||
@@ -660,8 +669,8 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
Map<String, String> dimLabels, Map<String, String> statusLabels, Map<String, String> currencyLabels)
|
||||
{
|
||||
List<SrvBillAirFeeLog.FieldChange> changes = new ArrayList<>();
|
||||
addChange(changes, "feeType", "费用项", label(feeLabels, value(before, SrvBillAirFee::getFeeType)),
|
||||
label(feeLabels, value(after, SrvBillAirFee::getFeeType)));
|
||||
addChange(changes, "scId", "费用项", label(feeLabels, scKey(before)),
|
||||
label(feeLabels, scKey(after)));
|
||||
addChange(changes, "price", "价格", priceText(before), priceText(after));
|
||||
addChange(changes, "currency", "收费币种", label(currencyLabels, value(before, SrvBillAirFee::getCurrency)),
|
||||
label(currencyLabels, value(after, SrvBillAirFee::getCurrency)));
|
||||
@@ -766,7 +775,7 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
{
|
||||
return;
|
||||
}
|
||||
String id = trim(fee.getFeeType());
|
||||
String id = scKey(fee);
|
||||
if (id.isEmpty() || names.containsKey(id))
|
||||
{
|
||||
return;
|
||||
@@ -774,6 +783,11 @@ public class SrvBillAirFeeServiceImpl implements ISrvBillAirFeeService
|
||||
names.put(id, surchargeName(id));
|
||||
}
|
||||
|
||||
private static String scKey(SrvBillAirFee fee)
|
||||
{
|
||||
return fee == null || fee.getScId() == null ? "" : String.valueOf(fee.getScId());
|
||||
}
|
||||
|
||||
private String surchargeName(String feeType)
|
||||
{
|
||||
Long scId = parseScId(feeType);
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.bms.price.search.TabOrderSyncEsLog;
|
||||
import com.bms.price.service.IPrcOrderBillService;
|
||||
|
||||
/**
|
||||
* 分页读取 Oracle TAB_ORDER,再多线程覆盖本地账单字段(不计费)。
|
||||
* 分页读取 Oracle TAB_ORDER,覆盖本地订单,并在订单提交后落地尾程应付。
|
||||
*/
|
||||
@Component
|
||||
public class TabOrderSyncAsyncRunner
|
||||
@@ -316,7 +316,7 @@ public class TabOrderSyncAsyncRunner
|
||||
}
|
||||
}
|
||||
|
||||
/** 解析出 Oracle 行后覆盖本地账单及其扩展信息(不计费)。 */
|
||||
/** 解析出 Oracle 行后覆盖本地账单。应付费用在订单提交后另算,失败只记日志。 */
|
||||
private Long overwriteOne(com.bms.price.oracle.TabOrderRow row)
|
||||
{
|
||||
Map<String, Object> raw = row == null ? null : row.getRaw();
|
||||
|
||||
@@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="cooperationStartDate" column="cooperation_start_date" />
|
||||
<result property="contractEndDate" column="contract_end_date" />
|
||||
<result property="cooperationStatus" column="cooperation_status" />
|
||||
<result property="dataSource" column="data_source" />
|
||||
<result property="channelIds" column="channel_ids" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="createBy" column="create_by" />
|
||||
@@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
s.is_enable, s.purchaser_user_id, s.purchaser_user, s.settlement_user_id, s.settlement_user,
|
||||
s.service_user_id, s.service_user, s.ed, s.zq, s.settlement_type, s.temp_ed, s.account_balance,
|
||||
s.foreign_currency_balance, s.credit_ed, s.weight_threshold, s.throw_ratio, s.cooperation_start_date,
|
||||
s.contract_end_date, s.cooperation_status, s.channel_ids, s.remark,
|
||||
s.contract_end_date, s.cooperation_status, s.data_source, s.channel_ids, s.remark,
|
||||
s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag
|
||||
from sup_supplier s
|
||||
<!-- 数据权限:采购/销售(仅本人 s.purchaser_user_id)/部门经理(本部门 su.dept_id);
|
||||
@@ -124,6 +125,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cooperationStartDate != null">cooperation_start_date,</if>
|
||||
<if test="contractEndDate != null">contract_end_date,</if>
|
||||
<if test="cooperationStatus != null">cooperation_status,</if>
|
||||
<if test="dataSource != null">data_source,</if>
|
||||
<if test="channelIds != null">channel_ids,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
@@ -157,6 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cooperationStartDate != null">#{cooperationStartDate},</if>
|
||||
<if test="contractEndDate != null">#{contractEndDate},</if>
|
||||
<if test="cooperationStatus != null">#{cooperationStatus},</if>
|
||||
<if test="dataSource != null">#{dataSource},</if>
|
||||
<if test="channelIds != null">#{channelIds},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
@@ -194,6 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="cooperationStartDate != null">cooperation_start_date = #{cooperationStartDate},</if>
|
||||
contract_end_date = #{contractEndDate},
|
||||
<if test="cooperationStatus != null">cooperation_status = #{cooperationStatus},</if>
|
||||
data_source = #{dataSource},
|
||||
<if test="channelIds != null">channel_ids = #{channelIds},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
@@ -203,6 +207,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where supplier_id = #{supplierId}
|
||||
</update>
|
||||
|
||||
<update id="updateSupplierChannels" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplier">
|
||||
update sup_supplier
|
||||
set channel_ids = #{channelIds},
|
||||
update_by = #{updateBy},
|
||||
update_time = #{updateTime}
|
||||
where supplier_id = #{supplierId}
|
||||
and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<delete id="deleteBmsSupplierBySupplierId" parameterType="Long">
|
||||
delete from sup_supplier where supplier_id = #{supplierId}
|
||||
</delete>
|
||||
|
||||
@@ -58,9 +58,20 @@
|
||||
o.product_name as productName, o.country_code as countryCode, o.country_name as countryName,
|
||||
o.dest_postcode as destPostcode, e.air_no_old as ladingNo, e.product_floor as channelName,
|
||||
e.supplier_name as supplierName,
|
||||
(select group_concat(concat(ifnull(nullif(trim(f.fee_name), ''), ifnull(f.fee_type, '费用')), ' ', format(f.amount, 2))
|
||||
order by field(f.fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), f.fee_id separator ';')
|
||||
from prc_pay_bill_fee f where f.bill_id = o.bill_id and f.is_deleted = '0') as feeText,
|
||||
(select group_concat(concat(
|
||||
case
|
||||
when f.fee_source = 'LADING' and nullif(trim(air_sc.sc_name), '') is not null then air_sc.sc_name
|
||||
when f.fee_type = 'SURCHARGE' and nullif(trim(item_sc.sc_name), '') is not null then item_sc.sc_name
|
||||
when nullif(trim(dict.dict_label), '') is not null then dict.dict_label
|
||||
else ifnull(f.fee_type, '费用')
|
||||
end, ' ', format(f.amount, 2))
|
||||
order by field(f.fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND', 'ADJUST'), f.fee_id separator ';')
|
||||
from prc_pay_bill_fee f
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where f.bill_id = o.bill_id and f.is_deleted = '0') as feeText,
|
||||
(select count(*) from prc_pay_bill_fee f
|
||||
where f.bill_id = o.bill_id and ifnull(f.is_deleted, '0') = '0') as feeCount,
|
||||
(select count(*) from prc_pay_bill_fee f
|
||||
@@ -106,14 +117,24 @@
|
||||
</select>
|
||||
|
||||
<select id="selectOrderFees" resultType="com.bms.price.domain.PrcPayBillFee">
|
||||
select fee_id as feeId, bill_id as billId, pay_bill_id as payBillId, fee_type as feeType, fee_name as feeName,
|
||||
sc_id as scId, fee_level as feeLevel, amount, currency, fee_source as feeSource, source_id as sourceId,
|
||||
is_deleted as isDeleted
|
||||
from prc_pay_bill_fee
|
||||
where is_deleted = '0'
|
||||
and bill_id in
|
||||
select f.fee_id as feeId, f.bill_id as billId, f.pay_bill_id as payBillId, f.fee_type as feeType,
|
||||
case
|
||||
when f.fee_source = 'LADING' and nullif(trim(air_sc.sc_name), '') is not null then air_sc.sc_name
|
||||
when f.fee_type = 'SURCHARGE' and nullif(trim(item_sc.sc_name), '') is not null then item_sc.sc_name
|
||||
when nullif(trim(dict.dict_label), '') is not null then dict.dict_label
|
||||
else f.fee_type
|
||||
end as feeName,
|
||||
f.sc_id as scId, f.fee_level as feeLevel, f.amount, f.currency, f.fee_source as feeSource, f.source_id as sourceId,
|
||||
f.is_deleted as isDeleted
|
||||
from prc_pay_bill_fee f
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where f.is_deleted = '0'
|
||||
and f.bill_id in
|
||||
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by bill_id, fee_id
|
||||
order by f.bill_id, f.fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPayBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
@@ -228,10 +249,20 @@
|
||||
|
||||
<select id="selectFreeFees" resultType="com.bms.price.domain.PrcPayBillFee">
|
||||
select f.fee_id as feeId, f.bill_id as billId, f.pay_bill_id as payBillId, f.fee_type as feeType,
|
||||
f.fee_name as feeName, f.sc_id as scId, f.fee_level as feeLevel, f.amount, f.currency,
|
||||
case
|
||||
when f.fee_source = 'LADING' and nullif(trim(air_sc.sc_name), '') is not null then air_sc.sc_name
|
||||
when f.fee_type = 'SURCHARGE' and nullif(trim(item_sc.sc_name), '') is not null then item_sc.sc_name
|
||||
when nullif(trim(dict.dict_label), '') is not null then dict.dict_label
|
||||
else f.fee_type
|
||||
end as feeName,
|
||||
f.sc_id as scId, f.fee_level as feeLevel, f.amount, f.currency,
|
||||
f.fee_source as feeSource, f.source_id as sourceId, f.settle_supplier_id as settleSupplierId,
|
||||
f.settle_supplier_name as settleSupplierName
|
||||
from prc_pay_bill_fee f
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
where ifnull(f.is_deleted, '0') = '0'
|
||||
and f.statement_line_id is null
|
||||
and f.bill_id in
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PayOrderListMapper">
|
||||
|
||||
<sql id="orderColumns">
|
||||
select p.bill_id as billId,
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo,
|
||||
p.tracking_no as trackingNo,
|
||||
p.customer_name as customerName,
|
||||
p.product_name as productName,
|
||||
p.country_name as countryName,
|
||||
p.product_floor as channelName,
|
||||
p.charge_weight as chargeWeight,
|
||||
ifnull(b.pay_total, p.pay_total) as payTotal,
|
||||
p.currency as currency,
|
||||
b.pay_calc_status as payCalcStatus,
|
||||
b.pay_calc_msg as payCalcMsg,
|
||||
p.biz_date as bizDate
|
||||
from prc_order_bill p
|
||||
left join prc_order_bill_ext e on e.bill_id = p.bill_id
|
||||
left join prc_pay_bill b on b.bill_id = p.bill_id
|
||||
</sql>
|
||||
|
||||
<select id="selectList" resultType="com.bms.price.domain.PayOrderRow">
|
||||
<include refid="orderColumns"/>
|
||||
<where>
|
||||
<if test="orderNos != null and orderNos.size() > 0">
|
||||
and p.order_no in
|
||||
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</if>
|
||||
<if test="(orderNos == null or orderNos.size() == 0) and orderNo != null and orderNo != ''">
|
||||
and p.order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="ladingNo != null and ladingNo != ''">
|
||||
and trim(e.air_no_old) like concat('%', #{ladingNo}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
and (p.customer_name like concat('%', #{customerName}, '%')
|
||||
or p.customer_code like concat('%', #{customerName}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by p.create_time desc, p.bill_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectRow" resultType="com.bms.price.domain.PayOrderRow">
|
||||
<include refid="orderColumns"/>
|
||||
where p.bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<select id="selectByOrderNos" resultType="com.bms.price.domain.PayOrderRow">
|
||||
select p.bill_id as billId,
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo
|
||||
from prc_order_bill p
|
||||
left join prc_order_bill_ext e on e.bill_id = p.bill_id
|
||||
where p.order_no in
|
||||
<foreach collection="orderNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectByLadingNos" resultType="com.bms.price.domain.PayOrderRow">
|
||||
select p.bill_id as billId,
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo
|
||||
from prc_order_bill p
|
||||
left join prc_order_bill_ext e on e.bill_id = p.bill_id
|
||||
where trim(e.air_no_old) in
|
||||
<foreach collection="ladingNos" item="no" open="(" separator="," close=")">#{no}</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bms.price.mapper.PrcPayBillFeeLogMapper">
|
||||
|
||||
<resultMap type="PrcPayBillFeeLog" id="PrcPayBillFeeLogResult">
|
||||
<id property="logId" column="log_id" />
|
||||
<result property="feeId" column="fee_id" />
|
||||
<result property="billId" column="bill_id" />
|
||||
<result property="feeName" column="fee_name" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="operationType" column="operation_type" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insertBatch">
|
||||
insert into prc_pay_bill_fee_log (
|
||||
fee_id, bill_id, fee_name, amount, currency, operation_type, create_by, create_time
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.feeId}, #{item.billId}, #{item.feeName}, #{item.amount}, #{item.currency},
|
||||
#{item.operationType}, #{item.createBy}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectByBillId" resultMap="PrcPayBillFeeLogResult">
|
||||
select log_id, fee_id, bill_id, fee_name, amount, currency, operation_type, create_by, create_time
|
||||
from prc_pay_bill_fee_log
|
||||
where bill_id = #{billId}
|
||||
order by log_id desc
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -19,35 +19,91 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="remark" column="remark" />
|
||||
<result property="sourceId" column="source_id" />
|
||||
<result property="isDeleted" column="is_deleted" />
|
||||
<result property="statementLineId" column="statement_line_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="feeItemName">
|
||||
case
|
||||
when f.fee_source = 'MANUAL' and nullif(trim(f.fee_name), '') is not null then f.fee_name
|
||||
when f.fee_source = 'LADING' and nullif(trim(air_sc.sc_name), '') is not null then air_sc.sc_name
|
||||
when f.fee_type = 'SURCHARGE' and nullif(trim(item_sc.sc_name), '') is not null then item_sc.sc_name
|
||||
when nullif(trim(f.fee_name), '') is not null then f.fee_name
|
||||
when nullif(trim(dict.dict_label), '') is not null then dict.dict_label
|
||||
else f.fee_type
|
||||
end
|
||||
</sql>
|
||||
|
||||
<sql id="feeItemJoin">
|
||||
left join srv_bill_air_fee air on f.fee_source = 'LADING' and air.id = f.sc_id
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join prc_surcharge item_sc on ifnull(f.fee_source, '') <> 'LADING' and item_sc.sc_id = f.sc_id
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value = f.fee_type
|
||||
</sql>
|
||||
|
||||
<select id="selectByBillId" parameterType="Long" resultMap="PrcPayBillFeeResult">
|
||||
select fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
from prc_pay_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and is_deleted = '0'
|
||||
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND'), fee_id
|
||||
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
||||
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
||||
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
||||
f.create_by, f.create_time, f.update_by, f.update_time
|
||||
from prc_pay_bill_fee f
|
||||
<include refid="feeItemJoin"/>
|
||||
where f.bill_id = #{billId}
|
||||
and f.is_deleted = '0'
|
||||
order by field(f.fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE', 'REFUND', 'ADJUST'), f.fee_id
|
||||
</select>
|
||||
|
||||
<select id="selectByFeeId" resultMap="PrcPayBillFeeResult">
|
||||
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
||||
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
||||
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
||||
f.create_by, f.create_time, f.update_by, f.update_time
|
||||
from prc_pay_bill_fee f
|
||||
<include refid="feeItemJoin"/>
|
||||
where f.fee_id = #{feeId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertManual" parameterType="PrcPayBillFee">
|
||||
insert into prc_pay_bill_fee (
|
||||
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, remark,
|
||||
fee_source, is_deleted, create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{feeId}, #{billId}, #{payBillId}, #{feeType}, #{feeName}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{remark},
|
||||
'MANUAL', '0', #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="markFeeDeleted">
|
||||
update prc_pay_bill_fee
|
||||
set is_deleted = '1',
|
||||
update_by = #{operator},
|
||||
update_time = sysdate()
|
||||
where fee_id = #{feeId}
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
and statement_line_id is null
|
||||
</update>
|
||||
|
||||
<insert id="insertPrcPayBillFee" parameterType="PrcPayBillFee">
|
||||
insert into prc_pay_bill_fee (
|
||||
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_id, bill_id, pay_bill_id, fee_type, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
) values (
|
||||
#{feeId}, #{billId}, #{payBillId}, #{feeType}, #{feeName}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{roundMode}, #{remark},
|
||||
#{feeId}, #{billId}, #{payBillId}, #{feeType}, #{scId}, #{feeLevel}, #{amount}, #{currency}, #{roundMode}, #{remark},
|
||||
ifnull(#{feeSource}, 'CALC'), #{sourceId}, ifnull(#{isDeleted}, '0'), sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into prc_pay_bill_fee (
|
||||
fee_id, bill_id, pay_bill_id, fee_type, fee_name, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_id, bill_id, pay_bill_id, fee_type, sc_id, fee_level, amount, currency, round_mode, remark,
|
||||
fee_source, source_id, is_deleted, create_time
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.feeId}, #{item.billId}, #{item.payBillId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.feeLevel},
|
||||
(#{item.feeId}, #{item.billId}, #{item.payBillId}, #{item.feeType}, #{item.scId}, #{item.feeLevel},
|
||||
#{item.amount}, #{item.currency}, #{item.roundMode}, #{item.remark}, ifnull(#{item.feeSource}, 'CALC'),
|
||||
#{item.sourceId}, ifnull(#{item.isDeleted}, '0'), sysdate())
|
||||
</foreach>
|
||||
@@ -83,6 +139,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and bill_id is not null
|
||||
</select>
|
||||
|
||||
<select id="selectAliveByLadingFee" resultMap="PrcPayBillFeeResult">
|
||||
select f.fee_id, f.bill_id, f.pay_bill_id, f.fee_type, <include refid="feeItemName"/> as fee_name,
|
||||
f.sc_id, f.fee_level, f.amount, f.currency, f.round_mode, f.remark,
|
||||
f.fee_source, f.source_id, f.is_deleted, f.statement_line_id,
|
||||
f.create_by, f.create_time, f.update_by, f.update_time
|
||||
from prc_pay_bill_fee f
|
||||
<include refid="feeItemJoin"/>
|
||||
where f.fee_source = 'LADING'
|
||||
and f.sc_id = #{feeId}
|
||||
and ifnull(f.is_deleted, '0') = '0'
|
||||
</select>
|
||||
|
||||
<update id="markLadingFeeDeleted">
|
||||
update prc_pay_bill_fee
|
||||
set is_deleted = '1'
|
||||
@@ -91,13 +159,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
</update>
|
||||
|
||||
<update id="fillSourceIdByFeeIds">
|
||||
update prc_pay_bill_fee
|
||||
set source_id = fee_id
|
||||
where (source_id is null or source_id = '')
|
||||
and fee_id in
|
||||
<foreach collection="feeIds" item="feeId" open="(" separator="," close=")">#{feeId}</foreach>
|
||||
</update>
|
||||
<select id="countSettledCalc" resultType="int">
|
||||
select count(1)
|
||||
from prc_pay_bill_fee
|
||||
where bill_id = #{billId}
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
and (fee_source is null or fee_source = '' or fee_source = 'CALC')
|
||||
and statement_line_id is not null
|
||||
</select>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_pay_bill_fee
|
||||
|
||||
@@ -129,7 +129,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
<update id="markCalcStatus">
|
||||
update prc_pay_bill
|
||||
set pay_calc_status = #{status},
|
||||
pay_calc_msg = #{message},
|
||||
update_by = #{operator},
|
||||
update_time = sysdate()
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="String">
|
||||
delete from prc_pay_bill where bill_id = #{billId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
<select id="selectPendingFees" resultType="com.bms.price.airbill.domain.SrvBillAirAllocFee">
|
||||
select f.id, f.bill_code as billCode, a.guid as ladingId, f.fee_level as feeLevel,
|
||||
f.bill_fee_status as billFeeStatus, sc.sc_name as feeName, f.price, f.currency,
|
||||
f.bill_fee_status as billFeeStatus, f.fee_type as feeType, sc.sc_name as feeName, f.price, f.currency,
|
||||
f.alloc_dim as allocDim
|
||||
from srv_bill_air_fee f
|
||||
left join srv_bill_air a on a.bill_code = f.bill_code
|
||||
left join prc_surcharge sc on sc.sc_id = f.fee_type and ifnull(sc.is_del, '0') = '0'
|
||||
left join prc_surcharge sc on sc.sc_id = f.sc_id and ifnull(sc.is_del, '0') = '0'
|
||||
where f.del_flag = '0'
|
||||
and f.bill_fee_status = '0'
|
||||
and f.bill_code in
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
<mapper namespace="com.bms.price.mapper.SrvBillAirFeeMapper">
|
||||
|
||||
<select id="selectByBillCode" resultType="com.bms.price.airbill.domain.SrvBillAirFee">
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, sc.sc_name as feeName,
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, f.sc_id as scId, sc.sc_name as feeName,
|
||||
f.fee_level as feeLevel, f.bill_fee_status as billFeeStatus,
|
||||
f.alloc_flag as allocFlag, f.alloc_dim as allocDim, f.price, f.currency, f.remark,
|
||||
f.create_by as createBy, f.create_time as createTime, f.update_by as updateBy,
|
||||
f.update_time as updateTime, f.del_flag as delFlag
|
||||
from srv_bill_air_fee f
|
||||
left join prc_surcharge sc on sc.sc_id = f.fee_type and ifnull(sc.is_del, '0') = '0'
|
||||
left join prc_surcharge sc on sc.sc_id = f.sc_id and ifnull(sc.is_del, '0') = '0'
|
||||
where f.bill_code = #{billCode}
|
||||
and f.del_flag = '0'
|
||||
and ifnull(f.bill_fee_status, '0') <> '2'
|
||||
@@ -28,13 +28,13 @@
|
||||
</sql>
|
||||
|
||||
<select id="selectRoleFees" parameterType="com.bms.price.airbill.domain.SrvBillAirRoleFeeQuery" resultType="com.bms.price.airbill.domain.SrvBillAirFee">
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, sc.sc_name as feeName,
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, f.sc_id as scId, sc.sc_name as feeName,
|
||||
f.fee_level as feeLevel, f.fee_scene as feeScene, f.bill_fee_status as billFeeStatus,
|
||||
f.alloc_flag as allocFlag, f.alloc_dim as allocDim, f.price, f.currency, f.remark,
|
||||
f.create_by as createBy, f.create_time as createTime, f.update_by as updateBy,
|
||||
f.update_time as updateTime, f.del_flag as delFlag
|
||||
from srv_bill_air_fee f
|
||||
left join prc_surcharge sc on sc.sc_id = f.fee_type and ifnull(sc.is_del, '0') = '0'
|
||||
left join prc_surcharge sc on sc.sc_id = f.sc_id and ifnull(sc.is_del, '0') = '0'
|
||||
where f.del_flag = '0'
|
||||
and ifnull(f.bill_fee_status, '0') <> '2'
|
||||
and f.fee_scene = #{feeScene}
|
||||
@@ -64,13 +64,13 @@
|
||||
</select>
|
||||
|
||||
<select id="selectLive" resultType="com.bms.price.airbill.domain.SrvBillAirFee">
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, sc.sc_name as feeName,
|
||||
select f.id, f.bill_code as billCode, f.fee_type as feeType, f.sc_id as scId, sc.sc_name as feeName,
|
||||
f.fee_level as feeLevel, f.bill_fee_status as billFeeStatus,
|
||||
f.alloc_flag as allocFlag, f.alloc_dim as allocDim, f.price, f.currency, f.remark,
|
||||
f.create_by as createBy, f.create_time as createTime, f.update_by as updateBy,
|
||||
f.update_time as updateTime, f.del_flag as delFlag
|
||||
from srv_bill_air_fee f
|
||||
left join prc_surcharge sc on sc.sc_id = f.fee_type and ifnull(sc.is_del, '0') = '0'
|
||||
left join prc_surcharge sc on sc.sc_id = f.sc_id and ifnull(sc.is_del, '0') = '0'
|
||||
where f.id = #{id}
|
||||
and f.bill_code = #{billCode}
|
||||
and f.del_flag = '0'
|
||||
@@ -79,10 +79,10 @@
|
||||
|
||||
<insert id="insertFee" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into srv_bill_air_fee (
|
||||
bill_code, fee_type, fee_level, fee_scene, bill_fee_status, alloc_flag, alloc_dim, price, currency, remark,
|
||||
bill_code, fee_type, sc_id, fee_level, fee_scene, bill_fee_status, alloc_flag, alloc_dim, price, currency, remark,
|
||||
create_by, create_time, update_by, update_time, del_flag
|
||||
) values (
|
||||
#{billCode}, #{feeType}, #{feeLevel}, #{feeScene}, '0', #{allocFlag}, #{allocDim}, #{price}, #{currency}, #{remark},
|
||||
#{billCode}, #{feeType}, #{scId}, #{feeLevel}, #{feeScene}, '0', #{allocFlag}, #{allocDim}, #{price}, #{currency}, #{remark},
|
||||
#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, '0'
|
||||
)
|
||||
</insert>
|
||||
@@ -90,6 +90,7 @@
|
||||
<update id="updateFee">
|
||||
update srv_bill_air_fee
|
||||
set fee_type = #{feeType},
|
||||
sc_id = #{scId},
|
||||
fee_level = #{feeLevel},
|
||||
alloc_flag = #{allocFlag},
|
||||
alloc_dim = #{allocDim},
|
||||
|
||||
@@ -1798,6 +1798,7 @@ CREATE TABLE `sup_supplier` (
|
||||
`cooperation_start_date` date DEFAULT NULL COMMENT '合作开始日期',
|
||||
`contract_end_date` date DEFAULT NULL COMMENT '合同结束时间',
|
||||
`cooperation_status` char(1) DEFAULT '0' COMMENT '合作状态(0正常 1暂停 2终止)',
|
||||
`data_source` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据来源,字典 bms_supplier_data_source:1他人介绍,2官网',
|
||||
`channel_ids` varchar(1000) DEFAULT NULL COMMENT '绑定的渠道/服务ID(多个用逗号分隔)',
|
||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注说明',
|
||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-- 供应商信息增加绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2675, '绑定渠道', 2314, 6, '', '', 1, 0, 'F', '0', '0', 'customersupplier:supplierinfo:bindChannel', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2675 OR `perms` = 'customersupplier:supplierinfo:bindChannel');
|
||||
|
||||
-- 管理员拥有供应商绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, 2675
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` WHERE `role_id` = 1 AND `menu_id` = 2675);
|
||||
|
||||
-- 能看供应商信息的角色同时拥有绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, 2675
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
WHERE rm.`menu_id` = 2314
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = 2675);
|
||||
@@ -0,0 +1,14 @@
|
||||
-- `sup_supplier` 增加数据来源
|
||||
ALTER TABLE `bms`.`sup_supplier` ADD COLUMN `data_source` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '数据来源,字典 bms_supplier_data_source:1他人介绍,2官网' AFTER `cooperation_status`;
|
||||
|
||||
-- 新增供应商数据来源字典
|
||||
INSERT INTO `bms`.`sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES ('供应商数据来源', 'bms_supplier_data_source', '0', 'admin', sysdate(), '1他人介绍,2官网');
|
||||
|
||||
-- 供应商数据来源增加他人介绍
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (1, '他人介绍', '1', 'bms_supplier_data_source', '', 'warning', 'N', '0', 'admin', sysdate(), '供应商由他人介绍');
|
||||
|
||||
-- 供应商数据来源增加官网
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (2, '官网', '2', 'bms_supplier_data_source', '', 'primary', 'N', '0', 'admin', sysdate(), '供应商来自官网');
|
||||
@@ -0,0 +1,38 @@
|
||||
-- 新增应付费用日志表
|
||||
CREATE TABLE `bms`.`prc_pay_bill_fee_log` (
|
||||
`log_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`fee_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应付费用明细ID',
|
||||
`bill_id` bigint(20) NOT NULL COMMENT '计费订单ID',
|
||||
`fee_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '费用项',
|
||||
`amount` decimal(12,2) NULL DEFAULT NULL COMMENT '金额',
|
||||
`currency` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '币种',
|
||||
`operation_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作类型,字典 bms_pay_fee_log_type',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作人',
|
||||
`create_time` datetime NULL DEFAULT NULL COMMENT '操作时间',
|
||||
PRIMARY KEY (`log_id`),
|
||||
KEY `idx_prc_pay_bill_fee_log_bill` (`bill_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='应付费用日志';
|
||||
|
||||
-- 新增应付费用日志操作类型字典
|
||||
INSERT INTO `bms`.`sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES ('应付费用日志类型', 'bms_pay_fee_log_type', '0', 'admin', sysdate(), '1新增,2编辑,3删除,4重算费用,5废弃');
|
||||
|
||||
-- 应付费用日志类型增加新增
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (1, '新增', '1', 'bms_pay_fee_log_type', '', 'success', 'N', '0', 'admin', sysdate(), '新增应付费用');
|
||||
|
||||
-- 应付费用日志类型增加编辑
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (2, '编辑', '2', 'bms_pay_fee_log_type', '', 'warning', 'N', '0', 'admin', sysdate(), '编辑应付费用');
|
||||
|
||||
-- 应付费用日志类型增加删除
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (3, '删除', '3', 'bms_pay_fee_log_type', '', 'danger', 'N', '0', 'admin', sysdate(), '删除应付费用');
|
||||
|
||||
-- 应付费用日志类型增加重算费用
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (4, '重算费用', '4', 'bms_pay_fee_log_type', '', 'primary', 'N', '0', 'admin', sysdate(), '重算应付费用');
|
||||
|
||||
-- 应付费用日志类型增加废弃
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
VALUES (5, '废弃', '5', 'bms_pay_fee_log_type', '', 'info', 'N', '0', 'admin', sysdate(), '废弃应付费用');
|
||||
@@ -0,0 +1,18 @@
|
||||
-- 应付配置增加绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2671, '绑定渠道', 2508, 6, '', '', 1, 0, 'F', '0', '0', 'price:pay:bind', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2671 OR `perms` = 'price:pay:bind');
|
||||
|
||||
-- 管理员拥有绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, 2671
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` WHERE `role_id` = 1 AND `menu_id` = 2671);
|
||||
|
||||
-- 能看应付配置的角色同时拥有绑定渠道按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, 2671
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
WHERE rm.`menu_id` = 2508
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = 2671);
|
||||
@@ -0,0 +1,5 @@
|
||||
-- 提单分摊到订单的费用,来源id改为提单费用表 srv_bill_air_fee 的主键
|
||||
UPDATE `bms`.`prc_pay_bill_fee` SET `source_id` = CAST(`sc_id` AS CHAR) WHERE `fee_source` = 'LADING' AND IFNULL(`sc_id`, 0) > 0;
|
||||
|
||||
-- `prc_pay_bill_fee`.`source_id` 注明提单分摊时取提单费用主键
|
||||
ALTER TABLE `bms`.`prc_pay_bill_fee` MODIFY COLUMN `source_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '来源数据id。提单分摊时为 srv_bill_air_fee.id';
|
||||
@@ -0,0 +1,38 @@
|
||||
-- 费用类型字典补充对账调整,编码用英文
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 50, '对账调整', 'ADJUST', 'bms_fee_type', '', 'info', 'N', '0', 'admin', NOW(), '应付对账接受对方金额时补的差额'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_data` WHERE `dict_type` = 'bms_fee_type' AND `dict_value` = 'ADJUST');
|
||||
|
||||
-- 应付订单费用里写成中文名称的费用类型,改成费用类型字典的英文编码
|
||||
UPDATE `bms`.`prc_pay_bill_fee` f
|
||||
LEFT JOIN `bms`.`srv_bill_air_fee` a ON f.`fee_source` = 'LADING' AND a.`id` = f.`sc_id`
|
||||
LEFT JOIN `bms`.`prc_surcharge` sc ON sc.`sc_id` = a.`fee_type`
|
||||
LEFT JOIN `bms`.`sys_dict_data` by_value ON by_value.`dict_type` = 'bms_fee_type' AND by_value.`dict_value` = f.`fee_type` COLLATE utf8mb4_general_ci
|
||||
LEFT JOIN `bms`.`sys_dict_data` by_label ON by_label.`dict_type` = 'bms_fee_type' AND by_label.`dict_label` = f.`fee_type` COLLATE utf8mb4_general_ci
|
||||
SET f.`fee_type` = CASE
|
||||
WHEN sc.`fee_type` IS NOT NULL AND sc.`fee_type` <> '' THEN sc.`fee_type`
|
||||
WHEN by_label.`dict_value` IS NOT NULL THEN by_label.`dict_value`
|
||||
ELSE 'SURCHARGE'
|
||||
END
|
||||
WHERE by_value.`dict_code` IS NULL;
|
||||
|
||||
-- `srv_bill_air_fee` 增加附加费编号,用来挂费用项
|
||||
ALTER TABLE `bms`.`srv_bill_air_fee` ADD COLUMN `sc_id` bigint(20) DEFAULT NULL COMMENT '附加费配置ID,对应 prc_surcharge.sc_id' AFTER `fee_type`;
|
||||
|
||||
-- 提单费用的费用项编号从 fee_type 挪到 sc_id,fee_type 改为字典英文编码
|
||||
UPDATE `bms`.`srv_bill_air_fee` f
|
||||
LEFT JOIN `bms`.`prc_surcharge` sc ON sc.`sc_id` = f.`fee_type`
|
||||
LEFT JOIN `bms`.`sys_dict_data` d ON d.`dict_type` = 'bms_fee_type' AND d.`dict_value` = f.`fee_type` COLLATE utf8mb4_general_ci
|
||||
SET f.`sc_id` = CASE WHEN sc.`sc_id` IS NOT NULL THEN sc.`sc_id` ELSE f.`sc_id` END,
|
||||
f.`fee_type` = CASE
|
||||
WHEN d.`dict_value` IS NOT NULL THEN f.`fee_type`
|
||||
WHEN sc.`fee_type` IS NOT NULL AND sc.`fee_type` <> '' THEN sc.`fee_type`
|
||||
ELSE 'SURCHARGE'
|
||||
END;
|
||||
|
||||
-- `prc_pay_bill_fee`.`fee_type` 只保留费用类型字典的英文编码
|
||||
ALTER TABLE `bms`.`prc_pay_bill_fee` MODIFY COLUMN `fee_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '费用类型,字典 bms_fee_type 的英文编码';
|
||||
|
||||
-- `srv_bill_air_fee`.`fee_type` 改为费用类型字典的英文编码
|
||||
ALTER TABLE `bms`.`srv_bill_air_fee` MODIFY COLUMN `fee_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '费用类型,字典 bms_fee_type 的英文编码';
|
||||
@@ -0,0 +1,50 @@
|
||||
-- 新增应付管理目录
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 2670, '应付管理', 0, 5, 'payManage', NULL, '', '', 1, 0, 'M', '0', '0', '', 'money', 'admin', sysdate(), '应付配置'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2670);
|
||||
|
||||
-- 把应付配置挪到应付管理下面
|
||||
UPDATE `bms`.`sys_menu`
|
||||
SET `parent_id` = 2670, `order_num` = 1
|
||||
WHERE `perms` = 'price:pay:list';
|
||||
|
||||
-- 提单管理下新增应付列表
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `route_name`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 2665, '应付列表', 2650, 5, 'payOrder', 'price/billing/payOrder/index', '', 'PayOrderList', 1, 0, 'C', '0', '0', 'price:payOrder:list', 'list', 'admin', sysdate(), '按订单查看应付,费用按 abcd 段展示'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2665 OR `perms` = 'price:payOrder:list');
|
||||
|
||||
-- 应付列表查询按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2666, '应付列表查询', 2665, 1, '', '', 1, 0, 'F', '0', '0', 'price:payOrder:query', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2666 OR `perms` = 'price:payOrder:query');
|
||||
|
||||
-- 应付列表费用按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2667, '应付列表费用', 2665, 2, '', '', 1, 0, 'F', '0', '0', 'price:payOrder:fee', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2667 OR `perms` = 'price:payOrder:fee');
|
||||
|
||||
-- 能看应付配置的角色同时看到应付管理目录
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, 2670
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
INNER JOIN `bms`.`sys_menu` src ON src.`menu_id` = rm.`menu_id` AND src.`perms` = 'price:pay:list'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = 2670);
|
||||
|
||||
-- 能看提单管理的角色同时看到应付列表
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, m.`menu_id`
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
INNER JOIN `bms`.`sys_menu` m ON m.`menu_id` IN (2665, 2666, 2667)
|
||||
WHERE rm.`menu_id` = 2650
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = m.`menu_id`);
|
||||
|
||||
-- 管理员拥有应付管理和应付列表
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, m.`menu_id`
|
||||
FROM `bms`.`sys_menu` m
|
||||
WHERE m.`menu_id` IN (2670, 2665, 2666, 2667)
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` rm WHERE rm.`role_id` = 1 AND rm.`menu_id` = m.`menu_id`);
|
||||
@@ -0,0 +1,15 @@
|
||||
-- 渠道管理挪到应付管理下面
|
||||
UPDATE `bms`.`sys_menu` SET `parent_id` = 2670, `order_num` = 2 WHERE `menu_id` = 2502;
|
||||
|
||||
-- 路线产品管理挪到应付管理下面
|
||||
UPDATE `bms`.`sys_menu` SET `parent_id` = 2670, `order_num` = 3 WHERE `menu_id` = 2530;
|
||||
|
||||
-- 应付邮编配置挪到应付管理下面
|
||||
UPDATE `bms`.`sys_menu` SET `parent_id` = 2670, `order_num` = 4 WHERE `menu_id` = 2513;
|
||||
|
||||
-- 能看渠道管理、路线产品或应付邮编的角色同时看到应付管理
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, 2670
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
WHERE rm.`menu_id` IN (2502, 2530, 2513)
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = 2670);
|
||||
@@ -0,0 +1,35 @@
|
||||
-- `prc_pay_bill_fee` 增加创建人
|
||||
ALTER TABLE `bms`.`prc_pay_bill_fee` ADD COLUMN `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人' AFTER `create_time`;
|
||||
|
||||
-- `prc_pay_bill_fee` 增加更新人
|
||||
ALTER TABLE `bms`.`prc_pay_bill_fee` ADD COLUMN `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人' AFTER `create_by`;
|
||||
|
||||
-- `prc_pay_bill_fee` 增加更新时间
|
||||
ALTER TABLE `bms`.`prc_pay_bill_fee` ADD COLUMN `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间' AFTER `update_by`;
|
||||
|
||||
-- 应付列表增加手工费用按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2673, '增加费用', 2665, 4, '', '', 1, 0, 'F', '0', '0', 'price:payOrder:feeAdd', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2673 OR `perms` = 'price:payOrder:feeAdd');
|
||||
|
||||
-- 应付列表增加删除费用按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2674, '删除费用', 2665, 5, '', '', 1, 0, 'F', '0', '0', 'price:payOrder:feeRemove', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2674 OR `perms` = 'price:payOrder:feeRemove');
|
||||
|
||||
-- 管理员拥有增加费用和删除费用
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, m.`menu_id`
|
||||
FROM `bms`.`sys_menu` m
|
||||
WHERE m.`menu_id` IN (2673, 2674)
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` rm WHERE rm.`role_id` = 1 AND rm.`menu_id` = m.`menu_id`);
|
||||
|
||||
-- 能看应付列表的角色同时拥有增加费用和删除费用
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, m.`menu_id`
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
INNER JOIN `bms`.`sys_menu` m ON m.`menu_id` IN (2673, 2674)
|
||||
WHERE rm.`menu_id` = 2665
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = m.`menu_id`);
|
||||
@@ -0,0 +1,42 @@
|
||||
-- `prc_pay_bill` 增加应付计费状态
|
||||
ALTER TABLE `bms`.`prc_pay_bill` ADD COLUMN `pay_calc_status` int(2) NULL DEFAULT NULL COMMENT '应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败' AFTER `pay_total`;
|
||||
|
||||
-- `prc_pay_bill` 增加计费失败原因
|
||||
ALTER TABLE `bms`.`prc_pay_bill` ADD COLUMN `pay_calc_msg` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计费失败原因' AFTER `pay_calc_status`;
|
||||
|
||||
-- 新增应付计费状态字典
|
||||
INSERT INTO `bms`.`sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT '应付计费状态', 'bms_pay_calc_status', '0', 'admin', sysdate(), '1计费成功,2计费失败'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_type` WHERE `dict_type` = 'bms_pay_calc_status');
|
||||
|
||||
-- 应付计费状态增加计费成功
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 1, '计费成功', '1', 'bms_pay_calc_status', '', 'success', 'N', '0', 'admin', sysdate(), '应付计费成功'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_data` WHERE `dict_type` = 'bms_pay_calc_status' AND `dict_value` = '1');
|
||||
|
||||
-- 应付计费状态增加计费失败
|
||||
INSERT INTO `bms`.`sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `css_class`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||
SELECT 2, '计费失败', '2', 'bms_pay_calc_status', '', 'danger', 'N', '0', 'admin', sysdate(), '应付计费失败'
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_dict_data` WHERE `dict_type` = 'bms_pay_calc_status' AND `dict_value` = '2');
|
||||
|
||||
-- 应付列表增加费用重算按钮
|
||||
INSERT INTO `bms`.`sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`)
|
||||
SELECT 2672, '费用重算', 2665, 3, '', '', 1, 0, 'F', '0', '0', 'price:payOrder:recalc', '#', 'admin', sysdate()
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` WHERE `menu_id` = 2672 OR `perms` = 'price:payOrder:recalc');
|
||||
|
||||
-- 管理员拥有费用重算按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, 2672
|
||||
FROM DUAL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` WHERE `role_id` = 1 AND `menu_id` = 2672);
|
||||
|
||||
-- 能看应付列表的角色同时拥有费用重算按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT DISTINCT rm.`role_id`, 2672
|
||||
FROM `bms`.`sys_role_menu` rm
|
||||
WHERE rm.`menu_id` = 2665
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` x WHERE x.`role_id` = rm.`role_id` AND x.`menu_id` = 2672);
|
||||
@@ -26,6 +26,15 @@ export function addSupplier(data) {
|
||||
})
|
||||
}
|
||||
|
||||
// 只保存这一家供应商绑定的渠道
|
||||
export function bindSupplierChannels(supplierId, data) {
|
||||
return request({
|
||||
url: '/customersupplier/supplierinfo/' + supplierId + '/channels',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改供应商
|
||||
export function updateSupplier(data) {
|
||||
return request({
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listPayOrder(query) {
|
||||
return request({
|
||||
url: '/price/payOrder/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function listPayOrderFees(billId) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/fees',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function addPayOrderFee(billId, data) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/fees',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function removePayOrderFee(feeId) {
|
||||
return request({
|
||||
url: '/price/payOrder/fees/' + feeId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
export function recalcPayOrder(data) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
<template>
|
||||
<div class="channel-select">
|
||||
<el-button type="primary" plain icon="Connection" @click="openDialog">
|
||||
{{ selectedCodes.length ? '重新选择渠道' : '选择渠道' }}
|
||||
</el-button>
|
||||
<span class="cs-summary">
|
||||
已绑定 <b>{{ selectedCodes.length }}</b> 个渠道
|
||||
<el-button v-if="selectedCodes.length" link type="danger" @click="clearSelection">清空</el-button>
|
||||
</span>
|
||||
<template v-if="showTrigger">
|
||||
<el-button type="primary" plain icon="Connection" @click="openDialog">
|
||||
{{ selectedCodes.length ? '重新选择渠道' : '选择渠道' }}
|
||||
</el-button>
|
||||
<span class="cs-summary">
|
||||
已绑定 <b>{{ selectedCodes.length }}</b> 个渠道
|
||||
<el-button v-if="selectedCodes.length" link type="danger" @click="clearSelection">清空</el-button>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
@@ -85,7 +87,9 @@ import { useChannels } from './useChannels'
|
||||
|
||||
const props = defineProps({
|
||||
/** v-model 绑定值:逗号分隔的渠道编码串,如 "SK_DEPDHLL,015A" */
|
||||
modelValue: { type: [String, Number], default: '' }
|
||||
modelValue: { type: [String, Number], default: '' },
|
||||
/** 为 false 时不显示按钮,由父页面调用 open() 打开同一个弹框 */
|
||||
showTrigger: { type: Boolean, default: true }
|
||||
})
|
||||
const emit = defineEmits(['update:modelValue', 'change'])
|
||||
|
||||
@@ -186,8 +190,8 @@ function clearSelection() {
|
||||
emit('change', [])
|
||||
}
|
||||
|
||||
/** 供父组件预加载渠道缓存(tab 内明细表格使用) */
|
||||
defineExpose({ ensureChannels })
|
||||
/** 供父组件预加载渠道缓存,或直接打开选择弹框 */
|
||||
defineExpose({ ensureChannels, open: openDialog })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -172,6 +172,12 @@
|
||||
<el-table-column v-if="isColVisible('cooperationStatus')" label="合作状态" align="center" prop="cooperationStatus">
|
||||
<template #default="scope">{{ formatOption(cooperationStatusOptions, scope.row.cooperationStatus) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColVisible('dataSource')" label="数据来源" align="center" prop="dataSource" width="110">
|
||||
<template #default="scope">
|
||||
<dict-tag v-if="scope.row.dataSource" :options="bms_supplier_data_source" :value="scope.row.dataSource" />
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColVisible('channelIds')" label="绑定渠道" align="center" prop="channelIds" min-width="200" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span v-if="channelNames(scope.row.channelIds)">{{ channelNames(scope.row.channelIds) }}</span>
|
||||
@@ -179,9 +185,10 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="isColVisible('remark')" label="备注说明" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="270" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['customersupplier:supplierinfo:edit']">修改</el-button>
|
||||
<el-button link type="primary" icon="Connection" @click="openBind(scope.row)" v-hasPermi="['customersupplier:supplierinfo:bindChannel']">绑定渠道</el-button>
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['customersupplier:supplierinfo:remove']">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -195,6 +202,8 @@
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<channel-select ref="channelSelectRef" v-model="bindChannelIds" :show-trigger="false" @change="saveBind" />
|
||||
|
||||
<!-- 右键复制列值 -->
|
||||
<table-copy-menu
|
||||
ref="copyMenuRef"
|
||||
@@ -206,7 +215,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="Supplier">
|
||||
import { listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
|
||||
import { bindSupplierChannels, listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
|
||||
import { useChannels, parseChannelCodes } from '@/components/ChannelSelect/useChannels'
|
||||
import { useUsers } from '@/components/UserSelect/useUsers'
|
||||
import { useColumnSettings } from '@/utils/columnSettings'
|
||||
@@ -245,6 +254,7 @@ const columnDefs = [
|
||||
{ key: 'cooperationStartDate', label: '合作开始日期' },
|
||||
{ key: 'contractEndDate', label: '合同结束时间' },
|
||||
{ key: 'cooperationStatus', label: '合作状态' },
|
||||
{ key: 'dataSource', label: '数据来源' },
|
||||
{ key: 'channelIds', label: '绑定渠道' },
|
||||
{ key: 'remark', label: '备注说明' }
|
||||
]
|
||||
@@ -258,7 +268,7 @@ const single = ref(true)
|
||||
const multiple = ref(true)
|
||||
const total = ref(0)
|
||||
|
||||
const { sys_normal_disable, settlement_type, bms_supplier_type: supplierTypeOptions } = useDict("sys_normal_disable", "settlement_type", "bms_supplier_type")
|
||||
const { sys_normal_disable, settlement_type, bms_supplier_type: supplierTypeOptions, bms_supplier_data_source } = useDict("sys_normal_disable", "settlement_type", "bms_supplier_type", "bms_supplier_data_source")
|
||||
const invoiceTypeOptions = ref([
|
||||
{ value: "1", label: "增值税普通发票" },
|
||||
{ value: "2", label: "增值税专用发票" },
|
||||
@@ -318,6 +328,7 @@ const copyColumns = computed(() => [
|
||||
{ key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) },
|
||||
{ key: 'contractEndDate', label: '合同结束时间', get: r => formatDateOnly(r.contractEndDate) },
|
||||
{ key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) },
|
||||
{ key: 'dataSource', label: '数据来源', get: r => proxy.selectDictLabel(bms_supplier_data_source.value, r.dataSource) },
|
||||
{ key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) },
|
||||
{ key: 'remark', label: '备注说明', get: r => r.remark || '' }
|
||||
])
|
||||
@@ -415,6 +426,36 @@ function handleUpdate(row) {
|
||||
})
|
||||
}
|
||||
|
||||
const channelSelectRef = ref(null)
|
||||
const bindRow = ref(null)
|
||||
const bindChannelIds = ref('')
|
||||
|
||||
/** 打开和编辑页相同的选择渠道弹框,确定后只保存这一家的渠道 */
|
||||
function openBind(row) {
|
||||
if (!row || !row.supplierId) {
|
||||
return
|
||||
}
|
||||
bindRow.value = row
|
||||
bindChannelIds.value = row.channelIds || ''
|
||||
nextTick(() => {
|
||||
channelSelectRef.value && channelSelectRef.value.open()
|
||||
})
|
||||
}
|
||||
|
||||
function saveBind() {
|
||||
const row = bindRow.value
|
||||
if (!row || !row.supplierId) {
|
||||
return
|
||||
}
|
||||
const channelIds = bindChannelIds.value || ''
|
||||
bindSupplierChannels(row.supplierId, { channelIds }).then(() => {
|
||||
proxy.$modal.msgSuccess('渠道已绑定')
|
||||
getList()
|
||||
}).catch(() => {
|
||||
bindChannelIds.value = row.channelIds || ''
|
||||
})
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const _supplierIds = row.supplierId || ids.value
|
||||
|
||||
@@ -173,6 +173,13 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数据来源" prop="dataSource">
|
||||
<el-select v-model="form.dataSource" placeholder="请选择数据来源" clearable style="width: 100%;">
|
||||
<el-option v-for="opt in bms_supplier_data_source" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注说明" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入内容" />
|
||||
@@ -646,7 +653,7 @@ const rules = {
|
||||
supplierName: [{ required: true, message: '供应商名称不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const { bms_supplier_type: supplierTypeOptions } = useDict('bms_supplier_type')
|
||||
const { bms_supplier_type: supplierTypeOptions, bms_supplier_data_source } = useDict('bms_supplier_type', 'bms_supplier_data_source')
|
||||
const invoiceTypeOptions = ref([
|
||||
{ value: '1', label: '增值税普通发票' },
|
||||
{ value: '2', label: '增值税专用发票' },
|
||||
@@ -693,6 +700,7 @@ function buildEmptyForm() {
|
||||
cooperationStartDate: null,
|
||||
contractEndDate: null,
|
||||
cooperationStatus: null,
|
||||
dataSource: null,
|
||||
channelIds: null,
|
||||
attachmentList: [],
|
||||
companyList: [],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="panes.length" class="pay-detail">
|
||||
<section v-for="pane in panes" :key="pane.key" class="pay-product">
|
||||
<div class="pay-product-title">{{ pane.item.productName || '未命名产品' }}</div>
|
||||
<div class="pay-product-title">{{ pane.item.productName || '未命名服务商渠道' }}</div>
|
||||
<el-descriptions :column="3" border size="small" class="pay-summary">
|
||||
<el-descriptions-item label="价卡归属">{{ pane.item.supplierName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="生效日期">{{ pane.item.effectiveDate || '-' }}</el-descriptions-item>
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
scrollbar-always-on
|
||||
>
|
||||
<template #toolbar="{ selection, ids }">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Link" :disabled="selection.length !== 1" @click="openBind(selection)" v-hasPermi="['price:pay:bind']">绑定渠道</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Upload" @click="importRef.open()" v-hasPermi="['price:pay:import']">导入价卡</el-button>
|
||||
</el-col>
|
||||
@@ -64,6 +67,32 @@
|
||||
</basic-table>
|
||||
|
||||
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
|
||||
<el-dialog v-model="bindVisible" title="绑定渠道" width="640px" append-to-body @closed="resetBind">
|
||||
<el-form label-width="70px">
|
||||
<el-form-item label="产品">
|
||||
<el-select v-model="bindForm.productId" disabled style="width: 100%">
|
||||
<el-option :label="bindForm.productName" :value="bindForm.productId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="渠道">
|
||||
<el-select
|
||||
v-model="bindForm.channelIds"
|
||||
class="bind-channel-select"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
placeholder="输入渠道编码或名称搜索,勾选后显示在框内"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in channelOptions" :key="item.id" :label="channelLabel(item)" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="bindVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="bindSaving" @click="submitBind">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<pay-surcharge-rule-dialog ref="ruleRef" />
|
||||
|
||||
<el-drawer v-model="historyVisible" :title="historyTitle" size="980px" append-to-body destroy-on-close>
|
||||
@@ -192,7 +221,8 @@
|
||||
</template>
|
||||
|
||||
<script setup name="PricePay">
|
||||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog } from '@/api/price/pay'
|
||||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog, batchBindChannelPay } from '@/api/price/pay'
|
||||
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
|
||||
import PayImportDialog from './components/PayImportDialog.vue'
|
||||
import PayConfigDetail from './components/PayConfigDetail.vue'
|
||||
import PaySurchargeRuleDialog from './components/PaySurchargeRuleDialog.vue'
|
||||
@@ -233,6 +263,10 @@ const detailTitle = computed(() => {
|
||||
const termVisible = ref(false)
|
||||
const termSaving = ref(false)
|
||||
const termForm = reactive({ termId: null, productId: null, effectiveStart: '', effectiveEnd: '' })
|
||||
const bindVisible = ref(false)
|
||||
const bindSaving = ref(false)
|
||||
const channelOptions = ref([])
|
||||
const bindForm = reactive({ productId: null, productName: '', channelIds: [] })
|
||||
|
||||
const statusOptions = [
|
||||
{ label: '已识别', value: 'OK' },
|
||||
@@ -241,7 +275,7 @@ const statusOptions = [
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ label: '产品名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
|
||||
{ label: '服务商渠道名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
|
||||
{ label: '价卡归属', prop: 'supplierName', align: 'center', width: 100 },
|
||||
{ label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'chargeType', align: 'center', width: 110 },
|
||||
@@ -261,7 +295,7 @@ const columns = [
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '产品名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
|
||||
{ label: '服务商渠道名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
|
||||
{ label: '价卡归属', prop: 'supplierName', component: 'input', placeholder: '威狮、易德、GWE', width: '160px' },
|
||||
{ label: '来源文件', prop: 'sourceFile', component: 'input', placeholder: '文件名', width: '180px' },
|
||||
{ label: '报价工作表', prop: 'sheetName', component: 'input', placeholder: '工作表', width: '160px' },
|
||||
@@ -331,6 +365,57 @@ function openRule(selection) {
|
||||
ruleRef.value?.open(selection || [])
|
||||
}
|
||||
|
||||
function channelLabel(item) {
|
||||
const code = item?.channelCode || ''
|
||||
const name = item?.channelName || ''
|
||||
return [code, name].filter(Boolean).join(' ')
|
||||
}
|
||||
|
||||
function openBind(selection) {
|
||||
if (!selection || selection.length !== 1) return
|
||||
const row = selection[0]
|
||||
if (!row?.productId) {
|
||||
proxy.$modal.msgWarning('这个产品没有编号,不能绑定渠道')
|
||||
return
|
||||
}
|
||||
bindForm.productId = row.productId
|
||||
bindForm.productName = row.productName || ''
|
||||
bindForm.channelIds = []
|
||||
bindVisible.value = true
|
||||
if (!channelOptions.value.length) {
|
||||
listChannelOptions().then(res => {
|
||||
channelOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function resetBind() {
|
||||
bindForm.productId = null
|
||||
bindForm.productName = ''
|
||||
bindForm.channelIds = []
|
||||
}
|
||||
|
||||
function submitBind() {
|
||||
if (!bindForm.productId) {
|
||||
proxy.$modal.msgWarning('请选择一个产品')
|
||||
return
|
||||
}
|
||||
if (!bindForm.channelIds.length) {
|
||||
proxy.$modal.msgWarning('请选择渠道')
|
||||
return
|
||||
}
|
||||
bindSaving.value = true
|
||||
batchBindChannelPay({
|
||||
channelIds: bindForm.channelIds,
|
||||
apProductId: bindForm.productId
|
||||
}).then(res => {
|
||||
proxy.$modal.msgSuccess(typeof res.data === 'string' ? res.data : (res.msg || '绑定成功'))
|
||||
bindVisible.value = false
|
||||
}).finally(() => {
|
||||
bindSaving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openDetail(row) {
|
||||
detailVisible.value = true
|
||||
savingRowKey.value = ''
|
||||
@@ -596,4 +681,10 @@ function statusType(status) {
|
||||
.compare-panel :deep(tr.compare-removed:hover > td.el-table__cell) {
|
||||
background: var(--el-color-danger-light-8);
|
||||
}
|
||||
.bind-channel-select :deep(.el-select__wrapper),
|
||||
.bind-channel-select :deep(.el-input__wrapper) {
|
||||
min-height: 168px;
|
||||
align-items: flex-start;
|
||||
padding-top: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<el-table-column min-width="180">
|
||||
<template #header><span class="col-label"><i class="req-star">*</i>费用名称</span></template>
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%"
|
||||
@change="id => onFeeChange(row, id)">
|
||||
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
|
||||
@@ -240,12 +240,18 @@ async function loadFees(force = false) {
|
||||
searchSurcharge('')
|
||||
}
|
||||
|
||||
function pickedId(item) {
|
||||
if (item?.scId != null && item.scId !== '') return String(item.scId)
|
||||
const type = item?.feeType == null ? '' : String(item.feeType)
|
||||
return /^\d+$/.test(type) ? type : ''
|
||||
}
|
||||
|
||||
function toRow(item, saved) {
|
||||
const row = {
|
||||
rowKey: saved ? `fee-${item.id}` : `new-${++rowSeed}`,
|
||||
id: saved ? item.id : null,
|
||||
billCode: item.billCode || '',
|
||||
feeType: item.feeType == null ? '' : String(item.feeType),
|
||||
scId: pickedId(item),
|
||||
feeName: item.feeName || '',
|
||||
price: item.price === null || item.price === undefined ? null : Number(item.price),
|
||||
currency: item.currency || '',
|
||||
@@ -258,7 +264,7 @@ function toRow(item, saved) {
|
||||
|
||||
function snapshot(row) {
|
||||
return {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -267,7 +273,7 @@ function snapshot(row) {
|
||||
|
||||
function currentOf(row) {
|
||||
return {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -275,9 +281,9 @@ function currentOf(row) {
|
||||
}
|
||||
|
||||
function rowChanged(row) {
|
||||
if (!row.origin) return !!(row.feeType || row.price || row.currency || row.remark)
|
||||
if (!row.origin) return !!(row.scId || row.price || row.currency || row.remark)
|
||||
const now = currentOf(row)
|
||||
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
|
||||
return now.scId !== row.origin.scId || now.price !== row.origin.price
|
||||
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
|
||||
}
|
||||
|
||||
@@ -302,7 +308,7 @@ function removeRow(row) {
|
||||
|
||||
function rowError(row) {
|
||||
if (!row.billCode) return '请选择提单'
|
||||
if (!row.feeType) return '请选择费用名称'
|
||||
if (!row.scId) return '请选择费用名称'
|
||||
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
|
||||
if (Number(row.price) < 0) return '价格不能小于0'
|
||||
if (!row.currency) return '请选择币种'
|
||||
@@ -323,7 +329,7 @@ function save() {
|
||||
rows.value.forEach(row => {
|
||||
if (!rowChanged(row)) return
|
||||
const payload = {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
price: row.price,
|
||||
currency: row.currency || '',
|
||||
remark: (row.remark || '').trim()
|
||||
@@ -401,8 +407,8 @@ function onFeeChange(row, id) {
|
||||
function pinSelectedFees() {
|
||||
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
|
||||
rows.value.forEach(row => {
|
||||
if (row.feeType && !known.has(String(row.feeType))) {
|
||||
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
|
||||
if (row.scId && !known.has(String(row.scId))) {
|
||||
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
|
||||
}
|
||||
})
|
||||
surchargeOptions.value = [...known.values()]
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<el-table-column min-width="160">
|
||||
<template #header><span class="col-label"><i class="req-star">*</i>费用项</span></template>
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
|
||||
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%" @change="name => onFeeChange(row, name)">
|
||||
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
|
||||
</el-select>
|
||||
@@ -166,7 +166,7 @@ function loadFees() {
|
||||
rows.value = (feeRes.data || []).map(item => ({
|
||||
rowKey: `fee-${item.id}`,
|
||||
id: item.id,
|
||||
feeType: item.feeType == null ? '' : String(item.feeType),
|
||||
scId: pickedId(item),
|
||||
feeName: item.feeName || '',
|
||||
feeLevel: item.feeLevel == null ? '' : String(item.feeLevel),
|
||||
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
|
||||
@@ -186,9 +186,9 @@ function loadFees() {
|
||||
function pinSelectedFees() {
|
||||
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
|
||||
for (const row of rows.value) {
|
||||
if (!row.feeType) continue
|
||||
if (!known.has(String(row.feeType))) {
|
||||
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
|
||||
if (!row.scId) continue
|
||||
if (!known.has(String(row.scId))) {
|
||||
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
|
||||
}
|
||||
}
|
||||
surchargeOptions.value = [...known.values()]
|
||||
@@ -264,7 +264,7 @@ function addRow() {
|
||||
rows.value.push({
|
||||
rowKey: `new-${rowSeed}`,
|
||||
id: null,
|
||||
feeType: '',
|
||||
scId: '',
|
||||
feeName: '',
|
||||
feeLevel: '',
|
||||
allocFlag: '0',
|
||||
@@ -315,9 +315,15 @@ function removeRow(row) {
|
||||
rows.value = rows.value.filter(item => item.rowKey !== row.rowKey)
|
||||
}
|
||||
|
||||
function pickedId(item) {
|
||||
if (item?.scId != null && item.scId !== '') return String(item.scId)
|
||||
const type = item?.feeType == null ? '' : String(item.feeType)
|
||||
return /^\d+$/.test(type) ? type : ''
|
||||
}
|
||||
|
||||
function snapshot(item) {
|
||||
return {
|
||||
feeType: item.feeType || '',
|
||||
scId: pickedId(item),
|
||||
feeLevel: item.feeLevel || '',
|
||||
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
|
||||
allocDim: item.allocDim || '',
|
||||
@@ -329,7 +335,7 @@ function snapshot(item) {
|
||||
|
||||
function currentOf(row) {
|
||||
return {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
feeLevel: row.feeLevel || '',
|
||||
allocFlag: row.allocFlag || '',
|
||||
allocDim: String(row.allocFlag) === '1' ? (row.allocDim || '') : '',
|
||||
@@ -348,15 +354,15 @@ function normPrice(value) {
|
||||
function rowChanged(row) {
|
||||
if (!row.origin) {
|
||||
const now = currentOf(row)
|
||||
return !!(now.feeType || now.price || now.currency || now.remark)
|
||||
return !!(now.scId || now.price || now.currency || now.remark)
|
||||
}
|
||||
const now = currentOf(row)
|
||||
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
|
||||
return now.scId !== row.origin.scId || now.price !== row.origin.price
|
||||
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
|
||||
}
|
||||
|
||||
function rowError(row) {
|
||||
if (!row.feeType) return '请选择费用项'
|
||||
if (!row.scId) return '请选择费用项'
|
||||
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
|
||||
if (Number(row.price) < 0) return '价格不能小于0'
|
||||
if (!row.currency) return '请选择收费币种'
|
||||
@@ -374,7 +380,7 @@ function save() {
|
||||
rows.value.forEach(row => {
|
||||
if (!rowChanged(row)) return
|
||||
const payload = {
|
||||
feeType: row.feeType || '',
|
||||
scId: row.scId || '',
|
||||
feeLevel: row.feeLevel || '',
|
||||
price: row.price,
|
||||
currency: row.currency || '',
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :inline="true" :model="query" class="mb8">
|
||||
<el-form-item label="订单号">
|
||||
<el-input v-model="query.orderNo" type="textarea" :rows="2" clearable placeholder="多个订单号可用逗号、空格或换行分隔" style="width: 280px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="提单号">
|
||||
<el-input v-model="query.ladingNo" clearable placeholder="提单号" style="width: 180px" @keyup.enter="search" />
|
||||
</el-form-item>
|
||||
<el-form-item label="客户">
|
||||
<el-input v-model="query.customerName" clearable placeholder="客户名称或代码" style="width: 180px" @keyup.enter="search" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="search">查询</el-button>
|
||||
<el-button icon="Refresh" @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row class="mb8">
|
||||
<el-button type="primary" plain icon="RefreshRight" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" border>
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="160" fixed="left" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="150" fixed="left" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.ladingNo || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="trackingNo" label="运单号" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="channelName" label="渠道" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
|
||||
<el-table-column prop="payTotal" label="应付总额" width="110" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column label="计费状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<dict-tag v-if="row.payCalcStatus != null && row.payCalcStatus !== ''" :options="bms_pay_calc_status" :value="row.payCalcStatus" />
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="payCalcMsg" label="失败原因" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.payCalcMsg || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" v-hasPermi="['price:payOrder:query']" @click="openDetail(row)">详情</el-button>
|
||||
<el-button link type="primary" v-hasPermi="['price:payOrder:fee']" @click="openFees(row)">费用</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="query.pageNum" v-model:limit="query.pageSize" @pagination="loadList" />
|
||||
|
||||
<bill-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" />
|
||||
|
||||
<el-dialog v-model="feeOpen" :title="feeTitle" width="1280px" append-to-body destroy-on-close>
|
||||
<div v-loading="feeLoading" class="fee-board">
|
||||
<section v-for="section in sections" :key="section.level" class="fee-section">
|
||||
<div class="fee-head">{{ section.title }}</div>
|
||||
<div class="fee-tools">
|
||||
<el-button v-hasPermi="['price:payOrder:feeAdd']" type="primary" plain size="small" @click="addFeeRow(section)">增加费用</el-button>
|
||||
</div>
|
||||
<el-table :data="section.fees" border empty-text="无">
|
||||
<el-table-column label="费用项" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<el-select v-if="row.editing" v-model="row.pick" filterable allow-create default-first-option placeholder="选择或输入" style="width: 100%" @change="pickFee(row)">
|
||||
<el-option v-for="item in (bms_fee_type || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<span v-else>{{ row.feeName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-if="row.editing" v-model="row.amount" :precision="2" :controls="false" style="width: 100%" />
|
||||
<span v-else>{{ row.amount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" width="110" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-if="row.editing" v-model="row.currency" filterable style="width: 100%">
|
||||
<el-option v-for="item in (bms_currency || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<span v-else>{{ row.currency }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<el-input v-if="row.editing" v-model="row.remark" maxlength="200" />
|
||||
<span v-else>{{ row.remark }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="来源" width="100" align="center">
|
||||
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="创建人" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="创建时间" width="160" />
|
||||
<el-table-column prop="updateBy" label="更新人" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="updateTime" label="更新时间" width="160" />
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-if="row.editing" link type="primary" @click="saveFeeRow(section, row)">保存</el-button>
|
||||
<el-button v-if="row.editing" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
|
||||
<el-button v-else v-hasPermi="['price:payOrder:feeRemove']" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</section>
|
||||
<section class="fee-section">
|
||||
<div class="fee-head">费用日志</div>
|
||||
<el-table :data="feeLogs" border empty-text="无" max-height="280">
|
||||
<el-table-column prop="feeName" label="费用项" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="amount" label="金额" width="120" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="90" align="center" />
|
||||
<el-table-column label="操作类型" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="bms_pay_fee_log_type" :value="row.operationType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="操作人" width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="操作时间" width="170" align="center" />
|
||||
</el-table>
|
||||
</section>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body @closed="resetRecalc">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="重算方式">
|
||||
<el-radio-group v-model="recalcForm.sourceType">
|
||||
<el-radio value="ORDER">订单号</el-radio>
|
||||
<el-radio value="LADING">提单号</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item :label="recalcForm.sourceType === 'LADING' ? '提单号' : '订单号'">
|
||||
<el-input v-model="recalcForm.text" type="textarea" :rows="6" placeholder="多个单号可用逗号、空格或换行分隔,一次最多500个" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="recalcResult" class="recalc-result">
|
||||
<span>成功 {{ recalcResult.successCount }} 票,失败 {{ recalcResult.failCount }} 票</span>
|
||||
<el-table :data="recalcFails" border size="small" max-height="240" empty-text="没有失败记录">
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="message" label="原因" min-width="220" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="recalcOpen = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="recalcSaving" @click="submitRecalc">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PayOrderList">
|
||||
import { getBill } from '@/api/price/billing'
|
||||
import { addPayOrderFee, listPayOrder, listPayOrderFees, recalcPayOrder, removePayOrderFee } from '@/api/price/payOrder'
|
||||
import BillDetail from '../components/BillDetail.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_pay_calc_status, bms_fee_type, bms_currency, bms_pay_fee_log_type } = useDict('bms_pay_calc_status', 'bms_fee_type', 'bms_currency', 'bms_pay_fee_log_type')
|
||||
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const query = reactive({ orderNo: '', ladingNo: '', customerName: '', pageNum: 1, pageSize: 20 })
|
||||
|
||||
const detailOpen = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const detail = ref(null)
|
||||
|
||||
const feeOpen = ref(false)
|
||||
const feeLoading = ref(false)
|
||||
const feeTitle = ref('应付费用')
|
||||
const feeBillId = ref('')
|
||||
const sections = ref([])
|
||||
const feeLogs = ref([])
|
||||
const recalcOpen = ref(false)
|
||||
const recalcSaving = ref(false)
|
||||
const recalcForm = reactive({ sourceType: 'ORDER', text: '' })
|
||||
const recalcResult = ref(null)
|
||||
const recalcFails = computed(() => (recalcResult.value?.lines || []).filter(line => !line.success))
|
||||
|
||||
const sources = {
|
||||
CALC: '尾程计算',
|
||||
LADING: '提单分摊',
|
||||
MANUAL: '手工'
|
||||
}
|
||||
|
||||
function sourceText(value) {
|
||||
return sources[value] || value || '-'
|
||||
}
|
||||
|
||||
function search() {
|
||||
query.pageNum = 1
|
||||
loadList()
|
||||
}
|
||||
|
||||
function reset() {
|
||||
query.orderNo = ''
|
||||
query.ladingNo = ''
|
||||
query.customerName = ''
|
||||
search()
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
listPayOrder(query).then(res => {
|
||||
rows.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openDetail(row) {
|
||||
detail.value = null
|
||||
detailOpen.value = true
|
||||
detailLoading.value = true
|
||||
getBill(row.billId).then(res => {
|
||||
detail.value = res.data || null
|
||||
}).finally(() => {
|
||||
detailLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openFees(row) {
|
||||
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
|
||||
feeBillId.value = row.billId
|
||||
sections.value = []
|
||||
feeLogs.value = []
|
||||
feeOpen.value = true
|
||||
loadFees()
|
||||
}
|
||||
|
||||
function loadFees() {
|
||||
if (!feeBillId.value) {
|
||||
return
|
||||
}
|
||||
feeLoading.value = true
|
||||
listPayOrderFees(feeBillId.value).then(res => {
|
||||
sections.value = res.data?.sections || []
|
||||
feeLogs.value = res.data?.logs || []
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError('费用加载失败')
|
||||
}).finally(() => {
|
||||
feeLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function addFeeRow(section) {
|
||||
if ((section.fees || []).some(item => item.editing)) {
|
||||
proxy.$modal.msgWarning('请先保存当前新增的费用')
|
||||
return
|
||||
}
|
||||
if (!section.fees) {
|
||||
section.fees = []
|
||||
}
|
||||
section.fees.push({
|
||||
editing: true,
|
||||
pick: '',
|
||||
feeType: '',
|
||||
feeName: '',
|
||||
amount: null,
|
||||
currency: 'CNY',
|
||||
remark: '',
|
||||
feeSource: 'MANUAL'
|
||||
})
|
||||
}
|
||||
|
||||
function pickFee(row) {
|
||||
const dict = (bms_fee_type.value || []).find(item => item.value === row.pick)
|
||||
if (dict) {
|
||||
row.feeType = dict.value
|
||||
row.feeName = dict.label
|
||||
return
|
||||
}
|
||||
row.feeType = row.pick
|
||||
row.feeName = row.pick
|
||||
}
|
||||
|
||||
function saveFeeRow(section, row) {
|
||||
if (!row.feeName) {
|
||||
proxy.$modal.msgWarning('请填写费用项')
|
||||
return
|
||||
}
|
||||
if (row.amount === null || row.amount === undefined || row.amount === '') {
|
||||
proxy.$modal.msgWarning('请填写金额')
|
||||
return
|
||||
}
|
||||
feeLoading.value = true
|
||||
addPayOrderFee(feeBillId.value, {
|
||||
feeType: row.feeType,
|
||||
feeName: row.feeName,
|
||||
level: section.level,
|
||||
amount: row.amount,
|
||||
currency: row.currency || 'CNY',
|
||||
remark: row.remark
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已增加费用')
|
||||
loadFees()
|
||||
loadList()
|
||||
}).catch(() => {
|
||||
feeLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function removeFeeRow(section, row) {
|
||||
if (row.editing) {
|
||||
section.fees = section.fees.filter(item => item !== row)
|
||||
return
|
||||
}
|
||||
proxy.$modal.confirm('确认删除这条费用?').then(() => {
|
||||
feeLoading.value = true
|
||||
return removePayOrderFee(row.feeId)
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已删除')
|
||||
loadFees()
|
||||
loadList()
|
||||
}).catch(() => {
|
||||
feeLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openRecalc() {
|
||||
recalcResult.value = null
|
||||
recalcOpen.value = true
|
||||
}
|
||||
|
||||
function resetRecalc() {
|
||||
recalcForm.sourceType = 'ORDER'
|
||||
recalcForm.text = ''
|
||||
recalcResult.value = null
|
||||
}
|
||||
|
||||
function submitRecalc() {
|
||||
if (!recalcForm.text || !recalcForm.text.trim()) {
|
||||
proxy.$modal.msgWarning(recalcForm.sourceType === 'LADING' ? '请填写提单号' : '请填写订单号')
|
||||
return
|
||||
}
|
||||
recalcSaving.value = true
|
||||
recalcPayOrder({ sourceType: recalcForm.sourceType, text: recalcForm.text }).then(res => {
|
||||
recalcResult.value = res.data || { successCount: 0, failCount: 0, lines: [] }
|
||||
loadList()
|
||||
}).finally(() => {
|
||||
recalcSaving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
loadList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fee-board { max-height: 68vh; overflow: auto; }
|
||||
.fee-section { margin-bottom: 16px; }
|
||||
.fee-head {
|
||||
margin-bottom: 8px;
|
||||
padding: 8px 12px;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
background: var(--el-fill-color-light);
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
.fee-tools { margin-bottom: 8px; text-align: right; }
|
||||
.recalc-result { margin-top: 8px; }
|
||||
.recalc-result > span { display: block; margin-bottom: 8px; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user