Compare commits
1 Commits
test
...
lmh-20261120
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c2d4a23c2 |
@@ -14,6 +14,7 @@ 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.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
import com.bms.price.domain.PayOrderRecalcCommand;
|
||||
@@ -112,6 +113,19 @@ public class PayOrderController extends BaseController
|
||||
return success(payOrderListService.fees(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 给勾选订单批量增加手工费用。创建人取当前登录用户,来源为手工,并记新增日志。
|
||||
*
|
||||
* @param batch 订单和费用行
|
||||
* @return 写入的费用条数
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:payOrder:feeBatch')")
|
||||
@PostMapping("/fees/batch")
|
||||
public AjaxResult addFees(@RequestBody PayOrderFeeBatch batch)
|
||||
{
|
||||
return success(payOrderListService.addManualFees(batch));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在某一段手工增加一行应付费用。创建人取当前登录用户。
|
||||
*
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.bms.price.domain;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付列表勾选订单后,批量写入同一组手工费用。 */
|
||||
@Data
|
||||
public class PayOrderFeeBatch
|
||||
{
|
||||
/** 勾选的计费订单 ID */
|
||||
private List<String> billIds;
|
||||
|
||||
/** 要加到每一票订单上的费用 */
|
||||
private List<PayOrderFeeLine> fees;
|
||||
}
|
||||
@@ -17,6 +17,9 @@ public class PayOrderRow
|
||||
|
||||
private String trackingNo;
|
||||
|
||||
/** 客户编码,列表展示用 */
|
||||
private String customerCode;
|
||||
|
||||
private String customerName;
|
||||
|
||||
private String productName;
|
||||
|
||||
@@ -24,9 +24,21 @@ public class PrcPayBill implements Serializable
|
||||
private BigDecimal redlineAmount;
|
||||
/** 成本价合计(当前计费结果) */
|
||||
private BigDecimal costAmount;
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细重算) */
|
||||
/** 应付合计(当前等于成本价,落库后按全部未删除明细折人民币重算) */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** A段合计,人民币 */
|
||||
private BigDecimal amountA;
|
||||
|
||||
/** B段合计,人民币 */
|
||||
private BigDecimal amountB;
|
||||
|
||||
/** C段合计,人民币 */
|
||||
private BigDecimal amountC;
|
||||
|
||||
/** D段合计,人民币 */
|
||||
private BigDecimal amountD;
|
||||
|
||||
/** 应付计费状态,字典 bms_pay_calc_status:1计费成功,2计费失败 */
|
||||
private Integer payCalcStatus;
|
||||
|
||||
|
||||
@@ -72,6 +72,18 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private BigDecimal incomeTotal;
|
||||
/** 应付合计(订单账单);也是报价应付 */
|
||||
private BigDecimal payTotal;
|
||||
|
||||
/** 应付 A 段合计,来自 prc_pay_bill.amount_a */
|
||||
private BigDecimal amountA;
|
||||
|
||||
/** 应付 B 段合计,来自 prc_pay_bill.amount_b */
|
||||
private BigDecimal amountB;
|
||||
|
||||
/** 应付 C 段合计,来自 prc_pay_bill.amount_c */
|
||||
private BigDecimal amountC;
|
||||
|
||||
/** 应付 D 段合计,来自 prc_pay_bill.amount_d */
|
||||
private BigDecimal amountD;
|
||||
/** 报价 / 历史字段;账单同步时与 incomeTotal 相同 */
|
||||
private BigDecimal payableTotal;
|
||||
private String currency = "CNY";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.bms.price.mapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
@@ -64,8 +63,8 @@ public interface PrcPayBillMapper
|
||||
*/
|
||||
int refreshPayTotal(@Param("billIds") List<Long> billIds);
|
||||
|
||||
/** 把折成人民币后的应付汇总写到主表,明细金额和币种不动。 */
|
||||
int updateCnyPayTotal(@Param("billId") Long billId, @Param("payTotal") BigDecimal payTotal);
|
||||
/** 把折成人民币后的应付总额和 ABCD 段合计写到主表,明细金额和币种不动。 */
|
||||
int updateCnyPayTotal(PrcPayBill row);
|
||||
|
||||
/** 订单还没有应付主表时补一行,总额随后按明细重算。单次不超过 1000 个订单。 */
|
||||
int insertMissingPayBills(@Param("billIds") List<Long> billIds, @Param("operator") String operator);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bms.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
import com.bms.price.domain.PayOrderQuery;
|
||||
@@ -26,6 +27,14 @@ public interface IPayOrderListService
|
||||
*/
|
||||
PayOrderFeeLine addManualFee(String billId, PayOrderFeeLine line);
|
||||
|
||||
/**
|
||||
* 给勾选的订单批量增加同一组手工费用。来源记 MANUAL,创建人是当前登录用户,并记新增日志。
|
||||
*
|
||||
* @param batch 订单和费用行
|
||||
* @return 写入的费用条数
|
||||
*/
|
||||
int addManualFees(PayOrderFeeBatch batch);
|
||||
|
||||
/**
|
||||
* 逻辑删除一条应付费用。已经进入应付账单的费用不能删。
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IPrcPayBillFeeService
|
||||
{
|
||||
/**
|
||||
* 分批写入应付明细,并回写这些订单的应付总额。
|
||||
* 明细每批最多 1000 条,金额和币种按原样写入 prc_pay_bill_fee。汇总时外币按汇率折成人民币,只回写 prc_pay_bill.pay_total。
|
||||
* 明细每批最多 1000 条,金额和币种按原样写入 prc_pay_bill_fee。汇总时外币按汇率折成人民币,ABCD 段分别四舍五入到两位后写入 prc_pay_bill,应付总额取这四段之和。
|
||||
*
|
||||
* @param fees 本次新增的应付明细
|
||||
*/
|
||||
|
||||
+1
@@ -698,6 +698,7 @@ public class PayOrderCostServiceImpl implements IPayOrderCostService
|
||||
scId = fallback++;
|
||||
}
|
||||
row.setScId(scId);
|
||||
row.setFeeLevel("4");
|
||||
String userId = PayFeeMoney.userId();
|
||||
row.setAmount(fee.getAmount());
|
||||
row.setCurrency(fee.getCurrency());
|
||||
|
||||
+172
-59
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
@@ -23,6 +24,7 @@ import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.bms.price.domain.PayOrderCostResult;
|
||||
import com.bms.price.domain.PayOrderFeeBatch;
|
||||
import com.bms.price.domain.PayOrderFeeBoard;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
import com.bms.price.domain.PayOrderFeeLine;
|
||||
@@ -51,6 +53,10 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
|
||||
private static final int MAX_LADING_NOS = 10;
|
||||
|
||||
private static final int MAX_BATCH_LINES = 20;
|
||||
|
||||
private static final AtomicLong MANUAL_SC_SEQ = new AtomicLong();
|
||||
|
||||
private static final Map<String, String> TITLES = new LinkedHashMap<>();
|
||||
|
||||
static
|
||||
@@ -434,67 +440,12 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
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("请填写金额");
|
||||
}
|
||||
String currency = firstText(line.getCurrency(), "CNY").toUpperCase();
|
||||
if (currency.length() > 10)
|
||||
{
|
||||
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 remark = line.getRemark() == null ? null : line.getRemark().trim();
|
||||
if (remark != null && remark.length() > 200)
|
||||
{
|
||||
throw new ServiceException("说明不能超过200字");
|
||||
}
|
||||
PayOrderFeeLine ready = checkedLine(line);
|
||||
Long orderBillId = Long.valueOf(order.getBillId().trim());
|
||||
String operator = operator();
|
||||
String userId = PayFeeMoney.userId();
|
||||
payBillMapper.insertMissingPayBills(List.of(orderBillId), 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(userId);
|
||||
fee.setUpdateBy(userId);
|
||||
PrcPayBillFee fee = newManualFee(orderBillId, payBill == null ? null : payBill.getPayBillId(), ready, userId);
|
||||
payBillFeeMapper.insertManual(fee);
|
||||
payBillFeeService.refreshTotals(List.of(orderBillId));
|
||||
payBillFeeLogService.record(fee, PayBillFeeLogService.ADD);
|
||||
@@ -502,6 +453,34 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
return toLine(saved == null ? fee : saved);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一组费用写到每一票勾选订单上。应付总额和 ABCD 段在写入后一起重算。
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int addManualFees(PayOrderFeeBatch batch)
|
||||
{
|
||||
List<Long> billIds = batchBillIds(batch);
|
||||
List<PayOrderFeeLine> lines = batchLines(batch);
|
||||
List<PayOrderRow> orders = payOrderListMapper.selectByBillIds(billIds);
|
||||
if (orders == null || orders.size() != billIds.size())
|
||||
{
|
||||
throw new ServiceException("有订单不在应付列表中,请重新勾选");
|
||||
}
|
||||
String userId = PayFeeMoney.userId();
|
||||
List<PrcPayBillFee> fees = new ArrayList<>(billIds.size() * lines.size());
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
for (PayOrderFeeLine line : lines)
|
||||
{
|
||||
fees.add(newManualFee(billId, null, line, userId));
|
||||
}
|
||||
}
|
||||
payBillFeeService.insertBatchAndRefreshTotals(fees);
|
||||
payBillFeeLogService.record(fees, PayBillFeeLogService.ADD);
|
||||
return fees.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除一条费用,并按剩余未删除明细重算应付总额。
|
||||
*
|
||||
@@ -579,10 +558,144 @@ public class PayOrderListServiceImpl implements IPayOrderListService
|
||||
return fallback == null ? "" : fallback.trim();
|
||||
}
|
||||
|
||||
/** 校验并收成可落库的一行。金额保留三位,和费用明细的小数位一致。 */
|
||||
private PayOrderFeeLine checkedLine(PayOrderFeeLine line)
|
||||
{
|
||||
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("请填写金额");
|
||||
}
|
||||
String currency = firstText(line.getCurrency(), "CNY").toUpperCase(Locale.ROOT);
|
||||
if (currency.length() > 10)
|
||||
{
|
||||
throw new ServiceException("币种过长");
|
||||
}
|
||||
BigDecimal amount = line.getAmount().setScale(3, RoundingMode.HALF_UP);
|
||||
if (amount.abs().compareTo(new BigDecimal("9999999999.999")) > 0)
|
||||
{
|
||||
throw new ServiceException("金额超出范围");
|
||||
}
|
||||
String remark = line.getRemark() == null ? null : line.getRemark().trim();
|
||||
if (remark != null && remark.length() > 200)
|
||||
{
|
||||
throw new ServiceException("说明不能超过200字");
|
||||
}
|
||||
PayOrderFeeLine ready = new PayOrderFeeLine();
|
||||
ready.setLevel(level);
|
||||
ready.setFeeName(feeName);
|
||||
ready.setFeeType(feeType);
|
||||
ready.setAmount(amount);
|
||||
ready.setCurrency(currency);
|
||||
ready.setRemark(remark == null || remark.isEmpty() ? null : remark);
|
||||
return ready;
|
||||
}
|
||||
|
||||
private List<Long> batchBillIds(PayOrderFeeBatch batch)
|
||||
{
|
||||
if (batch == null || batch.getBillIds() == null || batch.getBillIds().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请勾选订单");
|
||||
}
|
||||
LinkedHashSet<Long> ids = new LinkedHashSet<>();
|
||||
for (String raw : batch.getBillIds())
|
||||
{
|
||||
if (raw == null || raw.isBlank())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
ids.add(Long.valueOf(raw.trim()));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
throw new ServiceException("订单编号不正确");
|
||||
}
|
||||
}
|
||||
if (ids.isEmpty())
|
||||
{
|
||||
throw new ServiceException("请勾选订单");
|
||||
}
|
||||
if (ids.size() > MAX_ORDER_NOS)
|
||||
{
|
||||
throw new ServiceException("一次最多选择" + MAX_ORDER_NOS + "个订单");
|
||||
}
|
||||
return new ArrayList<>(ids);
|
||||
}
|
||||
|
||||
private List<PayOrderFeeLine> batchLines(PayOrderFeeBatch batch)
|
||||
{
|
||||
if (batch.getFees() == null || batch.getFees().isEmpty())
|
||||
{
|
||||
throw new ServiceException("请填写费用");
|
||||
}
|
||||
if (batch.getFees().size() > MAX_BATCH_LINES)
|
||||
{
|
||||
throw new ServiceException("一次最多增加" + MAX_BATCH_LINES + "条费用");
|
||||
}
|
||||
List<PayOrderFeeLine> lines = new ArrayList<>(batch.getFees().size());
|
||||
for (PayOrderFeeLine line : batch.getFees())
|
||||
{
|
||||
if (line != null && (line.getLevel() == null || line.getLevel().isBlank()))
|
||||
{
|
||||
line.setLevel("4");
|
||||
}
|
||||
lines.add(checkedLine(line));
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** 手工费用。创建人和更新人记当前登录用户主键,来源固定为手工。 */
|
||||
private static PrcPayBillFee newManualFee(Long billId, String payBillId, PayOrderFeeLine line, String userId)
|
||||
{
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setPayBillId(payBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
fee.setFeeName(line.getFeeName());
|
||||
fee.setScId(manualScId());
|
||||
fee.setFeeLevel(line.getLevel());
|
||||
fee.setAmount(line.getAmount());
|
||||
fee.setCurrency(line.getCurrency());
|
||||
fee.setRemark(line.getRemark());
|
||||
fee.setFeeSource("MANUAL");
|
||||
fee.setIsDeleted("0");
|
||||
fee.setCreateBy(userId);
|
||||
fee.setUpdateBy(userId);
|
||||
return fee;
|
||||
}
|
||||
|
||||
/** 手工费用用负数序号,避免和同一费用项的计算费用撞上唯一键。 */
|
||||
private static long manualScId()
|
||||
{
|
||||
long tick = System.nanoTime();
|
||||
long tick = MANUAL_SC_SEQ.updateAndGet(current -> {
|
||||
long next = System.nanoTime();
|
||||
return next > current ? next : current + 1L;
|
||||
});
|
||||
if (tick == Long.MIN_VALUE)
|
||||
{
|
||||
return -1L;
|
||||
|
||||
+9
-2
@@ -493,9 +493,16 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
TmsPriceQuoteResult result = toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()),
|
||||
payBillFeeMapper.selectByBillId(bill.getBillId()));
|
||||
PrcPayBill payBill = payBillMapper.selectByBillId(bill.getBillId());
|
||||
if (payBill != null && payBill.getPayTotal() != null)
|
||||
if (payBill != null)
|
||||
{
|
||||
result.setPayTotal(payBill.getPayTotal());
|
||||
if (payBill.getPayTotal() != null)
|
||||
{
|
||||
result.setPayTotal(payBill.getPayTotal());
|
||||
}
|
||||
result.setAmountA(payBill.getAmountA());
|
||||
result.setAmountB(payBill.getAmountB());
|
||||
result.setAmountC(payBill.getAmountC());
|
||||
result.setAmountD(payBill.getAmountD());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+39
-6
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.bms.common.utils.SecurityUtils;
|
||||
import com.bms.price.domain.PrcPayBill;
|
||||
import com.bms.price.domain.PrcPayBillFee;
|
||||
import com.bms.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcPayBillMapper;
|
||||
@@ -83,13 +84,13 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
}
|
||||
}
|
||||
|
||||
/** 不改 prc_pay_bill_fee。按计费日汇率把明细折成人民币后相加,四舍五入到两位,只写入 prc_pay_bill.pay_total。 */
|
||||
/** 不改 prc_pay_bill_fee。按计费日汇率把明细折成人民币后,ABCD 段分别四舍五入到两位,应付总额取这四段之和,写入 prc_pay_bill。 */
|
||||
private void writeCnyTotals(List<Long> billIds)
|
||||
{
|
||||
Map<Long, BigDecimal> sums = new LinkedHashMap<>();
|
||||
Map<Long, BigDecimal[]> sums = new LinkedHashMap<>();
|
||||
for (Long billId : billIds)
|
||||
{
|
||||
sums.put(billId, BigDecimal.ZERO);
|
||||
sums.put(billId, new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO });
|
||||
}
|
||||
List<PrcPayBillFee> fees = payBillFeeMapper.selectOpenFees(billIds);
|
||||
if (fees != null)
|
||||
@@ -100,20 +101,52 @@ public class PrcPayBillFeeServiceImpl implements IPrcPayBillFeeService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal[] bucket = sums.get(fee.getBillId());
|
||||
if (bucket == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
BigDecimal cny = payFeeMoney.toCny(fee.getAmount(), fee.getCurrency(), fee.getBizDate());
|
||||
if (cny == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sums.merge(fee.getBillId(), cny, BigDecimal::add);
|
||||
int segment = segmentIndex(fee.getFeeLevel());
|
||||
bucket[segment] = bucket[segment].add(cny);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<Long, BigDecimal> entry : sums.entrySet())
|
||||
for (Map.Entry<Long, BigDecimal[]> entry : sums.entrySet())
|
||||
{
|
||||
payBillMapper.updateCnyPayTotal(entry.getKey(), PayFeeMoney.total(entry.getValue()));
|
||||
BigDecimal[] bucket = entry.getValue();
|
||||
PrcPayBill row = new PrcPayBill();
|
||||
row.setBillId(entry.getKey());
|
||||
row.setAmountA(PayFeeMoney.total(bucket[0]));
|
||||
row.setAmountB(PayFeeMoney.total(bucket[1]));
|
||||
row.setAmountC(PayFeeMoney.total(bucket[2]));
|
||||
row.setAmountD(PayFeeMoney.total(bucket[3]));
|
||||
row.setPayTotal(row.getAmountA().add(row.getAmountB()).add(row.getAmountC()).add(row.getAmountD()));
|
||||
payBillMapper.updateCnyPayTotal(row);
|
||||
}
|
||||
}
|
||||
|
||||
/** 0A 1B 2C,其余含未标阶段的尾程计算费用归到 D。 */
|
||||
private static int segmentIndex(String feeLevel)
|
||||
{
|
||||
if ("1".equals(feeLevel))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ("2".equals(feeLevel))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ("3".equals(feeLevel))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
private static String currentOperator()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
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
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
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,
|
||||
@@ -130,7 +130,7 @@
|
||||
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
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
where f.is_deleted = '0'
|
||||
and f.bill_id in
|
||||
<foreach collection="billIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
@@ -262,7 +262,7 @@
|
||||
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
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
where ifnull(f.is_deleted, '0') = '0'
|
||||
and f.statement_line_id is null
|
||||
and f.bill_id in
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
p.order_no as orderNo,
|
||||
nullif(trim(e.air_no_old), '') as ladingNo,
|
||||
p.tracking_no as trackingNo,
|
||||
p.customer_code as customerCode,
|
||||
p.customer_name as customerName,
|
||||
p.product_name as productName,
|
||||
p.country_name as countryName,
|
||||
|
||||
@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
left join prc_surcharge air_sc on air_sc.sc_id = air.sc_id
|
||||
left join pay_surcharge pay_sc on f.fee_type = 'SURCHARGE' and ifnull(f.fee_source, '') <> 'LADING' and pay_sc.surcharge_id = f.sc_id
|
||||
left join prc_surcharge item_sc on f.fee_type = 'SURCHARGE' and 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
|
||||
left join sys_dict_data dict on dict.dict_type = 'bms_fee_type' and dict.dict_value COLLATE utf8mb4_general_ci = f.fee_type COLLATE utf8mb4_general_ci
|
||||
</sql>
|
||||
|
||||
<sql id="feeActorName">
|
||||
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where u.del_flag = '0'
|
||||
and (
|
||||
(${column} regexp '^[0-9]+$' and u.user_id = cast(${column} as unsigned))
|
||||
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name = ${column} COLLATE utf8mb4_general_ci)
|
||||
or (ifnull(${column}, '') not regexp '^[0-9]+$' and u.user_name COLLATE utf8mb4_general_ci = ${column} COLLATE utf8mb4_general_ci)
|
||||
)
|
||||
limit 1
|
||||
), ${column})
|
||||
@@ -197,7 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectOpenFees" resultMap="PrcPayBillFeeResult">
|
||||
select f.fee_id, f.bill_id, f.amount, f.currency, b.biz_date
|
||||
select f.fee_id, f.bill_id, f.fee_level, f.amount, f.currency, b.biz_date
|
||||
from prc_pay_bill_fee f
|
||||
left join prc_order_bill b on b.bill_id = f.bill_id
|
||||
where ifnull(f.is_deleted, '0') = '0'
|
||||
|
||||
@@ -12,6 +12,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="redlineAmount" column="redline_amount" />
|
||||
<result property="costAmount" column="cost_amount" />
|
||||
<result property="payTotal" column="pay_total" />
|
||||
<result property="amountA" column="amount_a" />
|
||||
<result property="amountB" column="amount_b" />
|
||||
<result property="amountC" column="amount_c" />
|
||||
<result property="amountD" column="amount_d" />
|
||||
<result property="belongSaler" column="belong_saler" />
|
||||
<result property="belongSalerCode" column="belong_saler_code" />
|
||||
<result property="settlementMan" column="settlement_man" />
|
||||
@@ -24,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectPrcPayBillVo">
|
||||
select pay_bill_id, bill_id, currency, product_amount, redline_amount,
|
||||
cost_amount, pay_total,
|
||||
cost_amount, pay_total, amount_a, amount_b, amount_c, amount_d,
|
||||
belong_saler, belong_saler_code, settlement_man, settlement_man_code,
|
||||
create_by, create_time, update_by, update_time
|
||||
from prc_pay_bill
|
||||
@@ -138,9 +142,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach collection="billIds" item="billId" open="(" separator="," close=")">#{billId}</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateCnyPayTotal">
|
||||
<update id="updateCnyPayTotal" parameterType="PrcPayBill">
|
||||
update prc_pay_bill
|
||||
set pay_total = #{payTotal},
|
||||
amount_a = #{amountA},
|
||||
amount_b = #{amountB},
|
||||
amount_c = #{amountC},
|
||||
amount_d = #{amountD},
|
||||
currency = 'CNY',
|
||||
update_time = sysdate()
|
||||
where bill_id = #{billId}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
-- 应付列表增加批量新增费用按钮
|
||||
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 (SELECT IFNULL(MAX(`t`.`menu_id`), 0) + 1 FROM (SELECT `menu_id` FROM `bms`.`sys_menu`) `t`), '批量新增费用', `p`.`menu_id`, (SELECT IFNULL(MAX(`c`.`order_num`), 0) + 1 FROM (SELECT `parent_id`, `order_num` FROM `bms`.`sys_menu`) `c` WHERE `c`.`parent_id` = `p`.`menu_id`), '', '', 1, 0, 'F', '0', '0', 'price:payOrder:feeBatch', '#', 'admin', sysdate()
|
||||
FROM `bms`.`sys_menu` `p`
|
||||
WHERE `p`.`perms` = 'price:payOrder:list' AND `p`.`menu_type` = 'C'
|
||||
AND NOT EXISTS (SELECT 1 FROM `bms`.`sys_menu` `e` WHERE `e`.`perms` = 'price:payOrder:feeBatch')
|
||||
ORDER BY `p`.`menu_id`
|
||||
LIMIT 1;
|
||||
|
||||
-- 管理员拥有批量新增费用按钮
|
||||
INSERT INTO `bms`.`sys_role_menu` (`role_id`, `menu_id`)
|
||||
SELECT 1, `m`.`menu_id`
|
||||
FROM `bms`.`sys_menu` `m`
|
||||
WHERE `m`.`perms` = 'price:payOrder:feeBatch'
|
||||
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`, `btn`.`menu_id`
|
||||
FROM `bms`.`sys_role_menu` `rm`
|
||||
INNER JOIN `bms`.`sys_menu` `parent` ON `parent`.`menu_id` = `rm`.`menu_id` AND `parent`.`perms` = 'price:payOrder:list' AND `parent`.`menu_type` = 'C'
|
||||
INNER JOIN `bms`.`sys_menu` `btn` ON `btn`.`perms` = 'price:payOrder:feeBatch'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `bms`.`sys_role_menu` `x` WHERE `x`.`role_id` = `rm`.`role_id` AND `x`.`menu_id` = `btn`.`menu_id`);
|
||||
@@ -38,6 +38,14 @@ export function addPayOrderFee(billId, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function addPayOrderFees(data) {
|
||||
return request({
|
||||
url: '/price/payOrder/fees/batch',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function removePayOrderFee(feeId) {
|
||||
return request({
|
||||
url: '/price/payOrder/fees/' + feeId,
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品名称" required>
|
||||
<el-input v-model="form.productName" maxlength="80" placeholder="渠道或产品名称" />
|
||||
<el-form-item label="价卡名称" required>
|
||||
<el-input v-model="form.productName" maxlength="80" placeholder="价卡名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
:title="title"
|
||||
size="840px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="bill-detail-drawer"
|
||||
@update:model-value="$emit('update:modelValue', $event)"
|
||||
>
|
||||
<div v-loading="loading" class="bill-detail-wrap">
|
||||
<el-empty v-if="!detail" description="暂无详情" />
|
||||
<div v-else class="bill-detail">
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">订单信息</div>
|
||||
<el-descriptions class="detail-desc" :column="2" border size="small">
|
||||
<el-descriptions-item label="订单号">{{ detail.orderNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运单号">{{ detail.trackingNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="转单号">{{ detail.transferNo || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="销售员">{{ detail.belongSaler || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="结算员">{{ detail.settlementMan || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客服员">{{ detail.serviceMan || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户">{{ displayCustomer(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户状态">{{ customerActiveLabel(detail.customerActiveStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="额度欠费">{{ creditArrearsLabel(detail.creditArrearsStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="退费状态">{{ refundLabel(detail.refundStatus) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库">{{ detail.warehouseCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="发件人">{{ detail.shipperName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收件人">{{ detail.consigneeName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="目的国/地区">{{ countryLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="目的邮编">{{ detail.destPostcode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="件数">{{ detail.pieces != null ? detail.pieces : '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="尺寸(cm)">{{ dimLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="实重(kg)">{{ formatWeight(detail.actualWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收货重(kg)">{{ formatWeight(detail.receiveWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="材积重(kg)">{{ formatWeight(detail.volumeWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="体积(m³)">{{ formatMoney(detail.volume) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="下单时间">{{ formatDateTime(detail.orderTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单备注" :span="2">{{ detail.orderRemark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">计费信息</div>
|
||||
<div class="amount-summary">
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">A段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountA) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">B段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountB) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">C段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountC) }}</div>
|
||||
</div>
|
||||
<div class="amount-card">
|
||||
<div class="amount-label">D段</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.amountD) }}</div>
|
||||
</div>
|
||||
<div class="amount-card is-total">
|
||||
<div class="amount-label">应付总额</div>
|
||||
<div class="amount-value">{{ formatMoney(detail.payTotal) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-descriptions class="detail-desc" :column="2" border size="small">
|
||||
<el-descriptions-item label="产品">{{ productLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="客户确认重(kg)">{{ formatWeight(detail.chargeWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费重量(kg)">{{ formatWeight(detail.chargeWeight ?? detail.weight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="重量段">{{ detail.weightLabel || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费时间">{{ detail.bizDate || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道编码">{{ detail.productFloorCode || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="渠道名称">{{ detail.productFloor || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费状态">
|
||||
<el-tag size="small" :type="billingFailTagType(detail.billingFailStatus)">{{ billingFailLabel(detail.billingFailStatus) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐">{{ priceSetLabel(detail) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(detail.currency)" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="取值方式">{{ roundModeLabel(detail.roundMode) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运费单价">{{ formatRate(detail.freightRate) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="挂号费">{{ formatMoney(detail.registrationFee) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section class="detail-block">
|
||||
<div class="sec-title">费用明细</div>
|
||||
<div v-if="!readonly" class="pay-generate">
|
||||
<el-button type="primary" plain size="small" v-hasPermi="['price:billing:bill']" @click="handlePayBill">生成应付</el-button>
|
||||
</div>
|
||||
<el-table v-if="payFees.length" :data="payFees" border size="small" class="fee-table">
|
||||
<el-table-column label="费用名称" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ displayFeeName(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="费用类型" min-width="140" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="feeTypeTag(row.feeType)" effect="plain">
|
||||
{{ payFeeTypeLabel(row) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="fee-amount">{{ formatFeeAmount(row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" width="90" align="center">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="bms_currency" :value="displayCurrency(row.currency)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-else description="暂无应付明细" :image-size="64" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { generatePayBill } from '@/api/price/pay'
|
||||
import { getPayOrder } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: { type: Boolean, default: false },
|
||||
title: { type: String, default: '订单详情' },
|
||||
loading: { type: Boolean, default: false },
|
||||
detail: { type: Object, default: null },
|
||||
readonly: { type: Boolean, default: false }
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue', 'updated'])
|
||||
|
||||
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
|
||||
|
||||
const payFees = computed(() => {
|
||||
const d = props.detail
|
||||
if (!d) return []
|
||||
return d.payFeeDetails || []
|
||||
})
|
||||
|
||||
function handlePayBill() {
|
||||
const billId = props.detail?.billId
|
||||
if (!billId) return
|
||||
ElMessageBox.confirm('确认生成应付?', '生成应付', { type: 'warning' })
|
||||
.then(() => generatePayBill(billId))
|
||||
.then(() => {
|
||||
ElMessage.success('操作成功')
|
||||
return getPayOrder(billId)
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) emit('updated', res.data)
|
||||
})
|
||||
.catch(err => {
|
||||
if (err === 'cancel' || err === 'close') return
|
||||
})
|
||||
}
|
||||
|
||||
function customerActiveLabel(status) {
|
||||
const map = { ACTIVE: '正常', MISSING: '不存在', DISABLED: '停用' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
function creditArrearsLabel(status) {
|
||||
const map = { NORMAL: '正常', ARREARS: '欠费' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
function displayCustomer(row) {
|
||||
if (row.customerName && row.customerCode) return row.customerName + ' (' + row.customerCode + ')'
|
||||
return row.customerName || row.customerCode || row.customerId || '-'
|
||||
}
|
||||
|
||||
function countryLabel(row) {
|
||||
return (row.countryName || '-') + ' (' + (row.countryCode || '-') + ')'
|
||||
}
|
||||
|
||||
function productLabel(row) {
|
||||
return (row.productName || '-') + ' (' + (row.productCode || '-') + ')'
|
||||
}
|
||||
|
||||
function priceSetLabel(row) {
|
||||
const name = row.priceSetName || '-'
|
||||
return row.priceSetCode ? name + ' (' + row.priceSetCode + ')' : name
|
||||
}
|
||||
|
||||
function dimLabel(row) {
|
||||
if (row.pkgLength == null && row.pkgWidth == null && row.pkgHeight == null) return '-'
|
||||
return [row.pkgLength, row.pkgWidth, row.pkgHeight].map(v => v == null ? '-' : v).join(' × ')
|
||||
}
|
||||
|
||||
function formatMoney(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
function formatFeeAmount(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(3)
|
||||
}
|
||||
|
||||
function formatWeight(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(3)
|
||||
}
|
||||
|
||||
function formatRate(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
function formatDateTime(val) {
|
||||
if (!val) return '-'
|
||||
const d = new Date(val)
|
||||
if (Number.isNaN(d.getTime())) return val
|
||||
const pad = n => String(n).padStart(2, '0')
|
||||
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
|
||||
}
|
||||
|
||||
const billingFailStatusOptions = [
|
||||
{ label: '计费成功', value: 0 },
|
||||
{ label: '销售价未匹配产品', value: 1 },
|
||||
{ label: '销售价未匹配国家', value: 2 },
|
||||
{ label: '销售价未匹配重量段', value: 3 },
|
||||
{ label: '产品价未匹配产品', value: 23 },
|
||||
{ label: '产品价未匹配国家', value: 24 },
|
||||
{ label: '产品价未匹配重量段', value: 25 },
|
||||
{ label: '未绑定套餐', value: 4 },
|
||||
{ label: '套餐未启用/无生效版本', value: 5 },
|
||||
{ label: '已生成应收账单', value: 6 },
|
||||
{ label: '产品档案缺失', value: 7 },
|
||||
{ label: '未命中价格', value: 8 },
|
||||
{ label: '分区无价格', value: 9 },
|
||||
{ label: '邮编必填', value: 10 },
|
||||
{ label: '邮编未匹配分区', value: 11 },
|
||||
{ label: '上游订单不存在', value: 12 },
|
||||
{ label: '上游订单号为空', value: 13 },
|
||||
{ label: '上游客户为空', value: 14 },
|
||||
{ label: '上游产品为空', value: 15 },
|
||||
{ label: '上游重量无效', value: 16 },
|
||||
{ label: '计费时间为空', value: 17 },
|
||||
{ label: '退费订单无法解析', value: 18 },
|
||||
{ label: '客户代码为空', value: 19 },
|
||||
{ label: '客户已停用', value: 20 },
|
||||
{ label: '运费为空', value: 21 },
|
||||
{ label: '未知失败', value: 22 },
|
||||
{ label: '未计费', value: 26 }
|
||||
]
|
||||
|
||||
function billingFailLabel(status) {
|
||||
const code = status == null ? 0 : Number(status)
|
||||
const hit = billingFailStatusOptions.find(item => item.value === code)
|
||||
return hit ? hit.label : '未知失败'
|
||||
}
|
||||
|
||||
function billingFailTagType(status) {
|
||||
const code = status == null ? 0 : Number(status)
|
||||
if (code === 26) return 'info'
|
||||
if (code > 0) return 'danger'
|
||||
return 'success'
|
||||
}
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
const map = { UP: '向上取值', DOWN: '向下取整', HALF_UP: '四舍五入' }
|
||||
return map[mode] || mode || '四舍五入'
|
||||
}
|
||||
|
||||
function payFeeTypeLabel(row) {
|
||||
const name = String(row?.feeName || row?.fee_name || '').trim()
|
||||
if (row?.feeType === 'LADING' || row?.feeSource === 'LADING') return name || '提单费用'
|
||||
return feeTypeLabel(row?.feeType) || row?.feeType || '-'
|
||||
}
|
||||
|
||||
function feeTypeLabel(type) {
|
||||
const found = (bms_fee_type.value || []).find(d => d.value === type)
|
||||
return found ? found.label : ''
|
||||
}
|
||||
|
||||
function feeTypeTag(type) {
|
||||
if (type === 'FREIGHT') return ''
|
||||
if (type === 'REGISTRATION') return 'warning'
|
||||
if (type === 'SURCHARGE') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function displayCurrency(v) {
|
||||
if (!v || v === 'RMB' || v === 'rmb') return 'CNY'
|
||||
return v
|
||||
}
|
||||
|
||||
function displayFeeName(row) {
|
||||
const typeLabel = feeTypeLabel(row.feeType)
|
||||
const name = String(row.feeName || row.fee_name || '').trim()
|
||||
const isSurcharge = row.feeType === 'SURCHARGE' || row.feeType === '附加费'
|
||||
if (isSurcharge && name && name !== typeLabel && name !== 'SURCHARGE' && name !== '附加费') {
|
||||
return name
|
||||
}
|
||||
return name || typeLabel || row.feeType || '-'
|
||||
}
|
||||
|
||||
function refundLabel(status) {
|
||||
const map = { NONE: '未退费', REFUNDED: '已退费' }
|
||||
return map[status] || status || '未退费'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bill-detail-wrap { min-height: 240px; }
|
||||
.pay-generate { margin-bottom: 8px; }
|
||||
.bill-detail { padding-bottom: 8px; }
|
||||
.detail-block { margin-bottom: 20px; }
|
||||
.detail-block:last-child { margin-bottom: 0; }
|
||||
.sec-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
line-height: 1;
|
||||
}
|
||||
.sec-title::before {
|
||||
content: '';
|
||||
width: 3px;
|
||||
height: 14px;
|
||||
border-radius: 2px;
|
||||
background: var(--el-color-primary);
|
||||
}
|
||||
.amount-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.amount-card {
|
||||
padding: 12px 14px;
|
||||
background: #f7f8fa;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.amount-card.is-total { background: #fff1f0; }
|
||||
.amount-label { font-size: 12px; color: #909399; line-height: 1.2; }
|
||||
.amount-value {
|
||||
margin-top: 6px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.amount-card.is-total .amount-value { color: #f56c6c; }
|
||||
.detail-desc :deep(.el-descriptions__label) {
|
||||
width: 108px;
|
||||
color: #909399;
|
||||
font-weight: 400;
|
||||
background: #fafbfc;
|
||||
}
|
||||
.detail-desc :deep(.el-descriptions__content) { color: #303133; }
|
||||
.detail-desc :deep(.el-descriptions__cell) { padding: 9px 12px; }
|
||||
.fee-amount { font-variant-numeric: tabular-nums; font-weight: 500; }
|
||||
</style>
|
||||
@@ -29,18 +29,22 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row class="mb8">
|
||||
<el-row class="mb8" align="middle">
|
||||
<el-button type="primary" plain icon="RefreshRight" :loading="recalcRunning" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
|
||||
<el-button type="primary" plain icon="Plus" v-hasPermi="['price:payOrder:feeBatch']" @click="openBatch">新增费用</el-button>
|
||||
<span v-if="selectedOrders.length" class="picked-count">已选 {{ selectedOrders.length }} 个订单</span>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" border>
|
||||
<el-table ref="orderTableRef" v-loading="loading" :data="rows" row-key="billId" border @selection-change="onSelectionChange">
|
||||
<el-table-column type="selection" width="48" reserve-selection fixed="left" />
|
||||
<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="customerCode" label="客户编码" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.customerCode || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="destPostcode" label="邮编" width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.destPostcode || '-' }}</template>
|
||||
@@ -77,7 +81,7 @@
|
||||
</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" :show-income="false" />
|
||||
<pay-order-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" @updated="onDetailUpdated" />
|
||||
|
||||
<el-dialog v-model="feeOpen" :title="feeTitle" width="1280px" append-to-body destroy-on-close>
|
||||
<div v-loading="feeLoading" class="fee-board">
|
||||
@@ -172,6 +176,63 @@
|
||||
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="batchOpen" title="批量新增费用" width="1080px" append-to-body destroy-on-close :close-on-click-modal="false">
|
||||
<div class="batch-block batch-orders">
|
||||
<div class="fee-head">已选订单({{ batchOrders.length }})</div>
|
||||
<div class="batch-order-list">
|
||||
<el-tag
|
||||
v-for="row in batchOrders"
|
||||
:key="row.billId"
|
||||
closable
|
||||
effect="plain"
|
||||
@close="removeBatchOrder(row)"
|
||||
>{{ row.orderNo || '-' }}</el-tag>
|
||||
<span v-if="!batchOrders.length" class="batch-order-empty">没有订单</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="batch-block">
|
||||
<div class="fee-head">新增费用</div>
|
||||
<div class="fee-tools">
|
||||
<el-button type="primary" plain size="small" @click="addBatchFee">增加一行</el-button>
|
||||
</div>
|
||||
<el-table class="fee-table" :data="batchFees" border empty-text="请增加费用">
|
||||
<el-table-column label="费用项" min-width="160" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.feeType" filterable placeholder="选择费用项">
|
||||
<el-option v-for="item in (bms_fee_type || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.amount" :precision="3" :controls="false" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" min-width="120" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.currency" filterable placeholder="选择币种">
|
||||
<el-option v-for="item in (bms_currency || [])" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="说明" min-width="180" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.remark" maxlength="200" placeholder="选填" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center" class-name="fee-op">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="danger" @click="removeBatchFee(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="batchOpen = false">取消</el-button>
|
||||
<el-button type="primary" :loading="batchSaving" @click="submitBatch">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body :close-on-click-modal="false">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="重算方式">
|
||||
@@ -252,9 +313,9 @@
|
||||
</template>
|
||||
|
||||
<script setup name="PayOrderList">
|
||||
import { addPayOrderFee, cancelPayOrderRecalc, getPayOrder, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { addPayOrderFee, addPayOrderFees, cancelPayOrderRecalc, getPayOrder, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import BillDetail from '../components/BillDetail.vue'
|
||||
import PayOrderDetail from './PayOrderDetail.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')
|
||||
@@ -263,6 +324,14 @@ const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const query = reactive({ orderNo: '', ladingNo: '', customerName: '', pageNum: 1, pageSize: 20 })
|
||||
const orderTableRef = ref()
|
||||
const selectedMap = ref(new Map())
|
||||
const selectedOrders = computed(() => Array.from(selectedMap.value.values()))
|
||||
const batchOpen = ref(false)
|
||||
const batchSaving = ref(false)
|
||||
const batchOrders = ref([])
|
||||
const batchFees = ref([])
|
||||
let batchFeeSeed = 1
|
||||
|
||||
const detailOpen = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
@@ -397,6 +466,30 @@ function reset() {
|
||||
search()
|
||||
}
|
||||
|
||||
function snapshotOrder(row) {
|
||||
return {
|
||||
billId: row.billId,
|
||||
orderNo: row.orderNo,
|
||||
ladingNo: row.ladingNo,
|
||||
customerName: row.customerName,
|
||||
productName: row.productName
|
||||
}
|
||||
}
|
||||
|
||||
function onSelectionChange(selection) {
|
||||
if (loading.value) return
|
||||
const pageIds = new Set((rows.value || []).map(row => String(row.billId)))
|
||||
const next = new Map(selectedMap.value)
|
||||
for (const id of pageIds) next.delete(id)
|
||||
for (const row of selection || []) next.set(String(row.billId), snapshotOrder(row))
|
||||
selectedMap.value = next
|
||||
}
|
||||
|
||||
function syncSelection() {
|
||||
const selection = orderTableRef.value?.getSelectionRows?.() || []
|
||||
onSelectionChange(selection)
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
listPayOrder(query).then(res => {
|
||||
@@ -404,6 +497,98 @@ function loadList() {
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
nextTick(syncSelection)
|
||||
})
|
||||
}
|
||||
|
||||
function emptyBatchFee() {
|
||||
batchFeeSeed += 1
|
||||
return { key: batchFeeSeed, level: '4', feeType: '', amount: null, currency: 'CNY', remark: '' }
|
||||
}
|
||||
|
||||
function openBatch() {
|
||||
if (!selectedOrders.value.length) {
|
||||
proxy.$modal.msgWarning('请先勾选订单')
|
||||
return
|
||||
}
|
||||
batchOrders.value = selectedOrders.value.map(row => ({ ...row }))
|
||||
batchFees.value = [emptyBatchFee()]
|
||||
batchOpen.value = true
|
||||
}
|
||||
|
||||
function removeBatchOrder(row) {
|
||||
const id = String(row.billId)
|
||||
batchOrders.value = batchOrders.value.filter(item => String(item.billId) !== id)
|
||||
const stored = selectedMap.value.get(id)
|
||||
const current = (rows.value || []).find(item => String(item.billId) === id)
|
||||
orderTableRef.value?.toggleRowSelection(current || stored || row, false)
|
||||
const next = new Map(selectedMap.value)
|
||||
next.delete(id)
|
||||
selectedMap.value = next
|
||||
}
|
||||
|
||||
function addBatchFee() {
|
||||
if (batchFees.value.length >= 20) {
|
||||
proxy.$modal.msgWarning('一次最多增加20条费用')
|
||||
return
|
||||
}
|
||||
batchFees.value.push(emptyBatchFee())
|
||||
}
|
||||
|
||||
function removeBatchFee(row) {
|
||||
batchFees.value = batchFees.value.filter(item => item !== row)
|
||||
}
|
||||
|
||||
function submitBatch() {
|
||||
if (!batchOrders.value.length) {
|
||||
proxy.$modal.msgWarning('请勾选订单')
|
||||
return
|
||||
}
|
||||
if (!batchFees.value.length) {
|
||||
proxy.$modal.msgWarning('请增加费用')
|
||||
return
|
||||
}
|
||||
const fees = []
|
||||
for (const row of batchFees.value) {
|
||||
if (!row.feeType) {
|
||||
proxy.$modal.msgWarning('请选择费用项')
|
||||
return
|
||||
}
|
||||
if (row.amount === null || row.amount === undefined || row.amount === '') {
|
||||
proxy.$modal.msgWarning('请填写金额')
|
||||
return
|
||||
}
|
||||
if (!row.currency) {
|
||||
proxy.$modal.msgWarning('请选择币种')
|
||||
return
|
||||
}
|
||||
const dict = (bms_fee_type.value || []).find(item => item.value === row.feeType)
|
||||
fees.push({
|
||||
feeType: row.feeType,
|
||||
feeName: dict ? dict.label : row.feeType,
|
||||
level: '4',
|
||||
amount: row.amount,
|
||||
currency: row.currency,
|
||||
remark: row.remark
|
||||
})
|
||||
}
|
||||
const orderCount = batchOrders.value.length
|
||||
proxy.$modal.confirm('确认为 ' + orderCount + ' 个订单各增加 ' + fees.length + ' 条手工费用?').then(() => {
|
||||
batchSaving.value = true
|
||||
return addPayOrderFees({
|
||||
billIds: batchOrders.value.map(row => String(row.billId)),
|
||||
fees
|
||||
})
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已为 ' + orderCount + ' 个订单增加费用')
|
||||
batchOpen.value = false
|
||||
selectedMap.value = new Map()
|
||||
orderTableRef.value?.clearSelection()
|
||||
loadList()
|
||||
}).catch(() => {
|
||||
/* 取消或接口失败时保留弹框 */
|
||||
}).finally(() => {
|
||||
batchSaving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -418,6 +603,12 @@ function openDetail(row) {
|
||||
})
|
||||
}
|
||||
|
||||
function onDetailUpdated(data) {
|
||||
if (data) {
|
||||
detail.value = data
|
||||
}
|
||||
}
|
||||
|
||||
function openFees(row) {
|
||||
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
|
||||
feeBillId.value = row.billId
|
||||
@@ -831,6 +1022,20 @@ loadList()
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
.fee-tools { margin-bottom: 8px; text-align: right; }
|
||||
.picked-count { margin-left: 12px; color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
.batch-block { margin-bottom: 16px; }
|
||||
.batch-order-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
max-height: 132px;
|
||||
overflow: auto;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-top: none;
|
||||
}
|
||||
.batch-orders .fee-head { margin-bottom: 0; }
|
||||
.batch-order-empty { color: var(--el-text-color-secondary); font-size: 13px; line-height: 24px; }
|
||||
.log-change { line-height: 1.6; }
|
||||
.log-empty { color: var(--el-text-color-secondary); }
|
||||
.rebill-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
|
||||
|
||||
Reference in New Issue
Block a user