应付订单新增批量添加费用和调整应付金额汇总
This commit is contained in:
@@ -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`);
|
||||
Reference in New Issue
Block a user