修改计费信息表结构

This commit is contained in:
wuweihua
2026-09-14 14:53:05 +08:00
parent 479b72b59f
commit 4bd95cb472
21 changed files with 378 additions and 137 deletions
@@ -22,7 +22,7 @@ import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
import com.ruoyi.price.search.EsBizLogSupport; import com.ruoyi.price.search.EsBizLogSupport;
import com.ruoyi.price.search.EsLogType; import com.ruoyi.price.search.EsLogType;
import com.ruoyi.price.search.IBillSearchStore; import com.ruoyi.price.search.IBillSearchStore;
import com.ruoyi.price.service.IPrcBillService; import com.ruoyi.price.service.IPrcOrderBillService;
import com.ruoyi.price.service.ITmsPriceQuoteService; import com.ruoyi.price.service.ITmsPriceQuoteService;
/** /**
@@ -44,7 +44,7 @@ public class TmsPriceController extends BaseController
private ITmsPriceQuoteService tmsPriceQuoteService; private ITmsPriceQuoteService tmsPriceQuoteService;
@Autowired @Autowired
private IPrcBillService prcBillService; private IPrcOrderBillService prcOrderBillService;
@Autowired @Autowired
private TmsApiProperties tmsApiProperties; private TmsApiProperties tmsApiProperties;
@@ -76,7 +76,7 @@ public class TmsPriceController extends BaseController
} }
/** /**
* Sync order and persist receivable bill (prc_bill / prc_bill_fee). * Sync order and persist prc_order_bill / prc_income_bill_fee.
* Same price match as quote. Same orderNo upserts. * Same price match as quote. Same orderNo upserts.
*/ */
@PostMapping("/bill") @PostMapping("/bill")
@@ -93,12 +93,12 @@ public class TmsPriceController extends BaseController
EsBizLogSupport.saveFail(billSearchStore, EsLogType.BILL, EsBizLogSupport.billFailBizId(request), request, e); EsBizLogSupport.saveFail(billSearchStore, EsLogType.BILL, EsBizLogSupport.billFailBizId(request), request, e);
throw e; throw e;
} }
TmsPriceQuoteResult result = prcBillService.bill(request); TmsPriceQuoteResult result = prcOrderBillService.bill(request);
return success(result); return success(result);
} }
/** /**
* Query receivable bill by orderNo after sync. * Query order bill by orderNo after sync.
*/ */
@GetMapping("/bill/by-order/{orderNo}") @GetMapping("/bill/by-order/{orderNo}")
public AjaxResult getBillByOrder( public AjaxResult getBillByOrder(
@@ -107,7 +107,7 @@ public class TmsPriceController extends BaseController
@RequestParam(value = "apiCode", required = false) String apiCode) @RequestParam(value = "apiCode", required = false) String apiCode)
{ {
assertApiCode(headerApiCode, apiCode); assertApiCode(headerApiCode, apiCode);
return success(prcBillService.getBillByOrderNo(orderNo)); return success(prcOrderBillService.getBillByOrderNo(orderNo));
} }
private void assertApiCode(String headerApiCode, String bodyApiCode) private void assertApiCode(String headerApiCode, String bodyApiCode)
@@ -13,12 +13,12 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.price.domain.PrcBill; import com.ruoyi.price.domain.PrcOrderBill;
import com.ruoyi.price.domain.PrcQuote; import com.ruoyi.price.domain.PrcQuote;
import com.ruoyi.price.domain.vo.TmsPriceBillRequest; import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
import com.ruoyi.price.domain.vo.TmsPriceQuoteRequest; import com.ruoyi.price.domain.vo.TmsPriceQuoteRequest;
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult; import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
import com.ruoyi.price.service.IPrcBillService; import com.ruoyi.price.service.IPrcOrderBillService;
import com.ruoyi.price.service.ITmsPriceQuoteService; import com.ruoyi.price.service.ITmsPriceQuoteService;
/** /**
@@ -34,7 +34,7 @@ public class BillingController extends BaseController
private ITmsPriceQuoteService tmsPriceQuoteService; private ITmsPriceQuoteService tmsPriceQuoteService;
@Autowired @Autowired
private IPrcBillService prcBillService; private IPrcOrderBillService prcOrderBillService;
/** /**
* Historical quote list. * Historical quote list.
@@ -71,10 +71,10 @@ public class BillingController extends BaseController
@PreAuthorize("@ss.hasPermi('price:billing:bill')") @PreAuthorize("@ss.hasPermi('price:billing:bill')")
@GetMapping("/bill/list") @GetMapping("/bill/list")
public TableDataInfo billList(PrcBill query) public TableDataInfo billList(PrcOrderBill query)
{ {
startPage(); startPage();
List<PrcBill> list = prcBillService.selectBillList(query); List<PrcOrderBill> list = prcOrderBillService.selectBillList(query);
return getDataTable(list); return getDataTable(list);
} }
@@ -82,14 +82,14 @@ public class BillingController extends BaseController
@GetMapping("/bill/{billId}") @GetMapping("/bill/{billId}")
public AjaxResult getBill(@PathVariable String billId) public AjaxResult getBill(@PathVariable String billId)
{ {
return success(prcBillService.getBill(billId)); return success(prcOrderBillService.getBill(billId));
} }
@PreAuthorize("@ss.hasPermi('price:billing:bill')") @PreAuthorize("@ss.hasPermi('price:billing:bill')")
@PostMapping("/bill") @PostMapping("/bill")
public AjaxResult bill(@Validated @RequestBody TmsPriceBillRequest request) public AjaxResult bill(@Validated @RequestBody TmsPriceBillRequest request)
{ {
TmsPriceQuoteResult result = prcBillService.bill(request); TmsPriceQuoteResult result = prcOrderBillService.bill(request);
return success(result); return success(result);
} }
} }
@@ -0,0 +1,26 @@
package com.ruoyi.price.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
/** receivable fee detail prc_income_bill_fee */
@Data
public class PrcIncomeBillFee implements Serializable
{
private static final long serialVersionUID = 1L;
private String feeId;
private String billId;
private String feeType;
private String feeName;
private Long scId;
private BigDecimal amount;
private String currency;
private String roundMode;
private String remark;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}
@@ -8,10 +8,10 @@ import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
/** receivable bill header prc_bill */ /** order info header prc_order_bill */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class PrcBill extends BaseEntity public class PrcOrderBill extends BaseEntity
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -66,9 +66,13 @@ public class PrcBill extends BaseEntity
private BigDecimal registrationFee; private BigDecimal registrationFee;
private BigDecimal freightAmount; private BigDecimal freightAmount;
private BigDecimal surchargeAmount; private BigDecimal surchargeAmount;
private BigDecimal payableTotal; /** receivable total */
private BigDecimal incomeTotal;
/** payable total */
private BigDecimal payTotal;
private String currency; private String currency;
private String roundMode; private String roundMode;
private List<PrcBillFee> fees; private List<PrcIncomeBillFee> incomeFees;
private List<PrcPayBillFee> payFees;
} }
@@ -6,9 +6,9 @@ import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
/** receivable bill fee detail prc_bill_fee */ /** payable fee detail prc_pay_bill_fee */
@Data @Data
public class PrcBillFee implements Serializable public class PrcPayBillFee implements Serializable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -47,6 +47,11 @@ public class TmsPriceQuoteResult implements Serializable
private BigDecimal freightAmount; private BigDecimal freightAmount;
/** 附加费合计(按产品关联命中后汇总) */ /** 附加费合计(按产品关联命中后汇总) */
private BigDecimal surchargeAmount; private BigDecimal surchargeAmount;
/** receivable total (order bill) */
private BigDecimal incomeTotal;
/** payable total (order bill); also quote payable */
private BigDecimal payTotal;
/** quote / legacy field; same as incomeTotal for bill sync */
private BigDecimal payableTotal; private BigDecimal payableTotal;
private String currency = "CNY"; private String currency = "CNY";
/** UP / DOWN / HALF_UP */ /** UP / DOWN / HALF_UP */
@@ -1,17 +0,0 @@
package com.ruoyi.price.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.price.domain.PrcBillFee;
/** receivable bill fee detail mapper */
public interface PrcBillFeeMapper
{
public List<PrcBillFee> selectByBillId(String billId);
public int insertPrcBillFee(PrcBillFee fee);
public int insertBatch(@Param("list") List<PrcBillFee> fees);
public int deleteByBillId(String billId);
}
@@ -1,24 +0,0 @@
package com.ruoyi.price.mapper;
import java.math.BigDecimal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.price.domain.PrcBill;
/** receivable bill header mapper */
public interface PrcBillMapper
{
public PrcBill selectPrcBillByOrderNo(String orderNo);
public PrcBill selectPrcBillById(String billId);
public List<PrcBill> selectPrcBillList(PrcBill bill);
public int insertPrcBill(PrcBill bill);
public int updatePrcBill(PrcBill bill);
public int updateBillAmounts(@Param("billId") String billId,
@Param("surchargeAmount") BigDecimal surchargeAmount,
@Param("payableTotal") BigDecimal payableTotal);
}
@@ -0,0 +1,17 @@
package com.ruoyi.price.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.price.domain.PrcIncomeBillFee;
/** receivable bill fee mapper */
public interface PrcIncomeBillFeeMapper
{
public List<PrcIncomeBillFee> selectByBillId(String billId);
public int insertPrcIncomeBillFee(PrcIncomeBillFee fee);
public int insertBatch(@Param("list") List<PrcIncomeBillFee> fees);
public int deleteByBillId(String billId);
}
@@ -0,0 +1,25 @@
package com.ruoyi.price.mapper;
import java.math.BigDecimal;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.price.domain.PrcOrderBill;
/** order bill header mapper */
public interface PrcOrderBillMapper
{
public PrcOrderBill selectPrcOrderBillByOrderNo(String orderNo);
public PrcOrderBill selectPrcOrderBillById(String billId);
public List<PrcOrderBill> selectPrcOrderBillList(PrcOrderBill bill);
public int insertPrcOrderBill(PrcOrderBill bill);
public int updatePrcOrderBill(PrcOrderBill bill);
public int updateOrderBillAmounts(@Param("billId") String billId,
@Param("surchargeAmount") BigDecimal surchargeAmount,
@Param("incomeTotal") BigDecimal incomeTotal,
@Param("payTotal") BigDecimal payTotal);
}
@@ -0,0 +1,17 @@
package com.ruoyi.price.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.price.domain.PrcPayBillFee;
/** payable bill fee mapper */
public interface PrcPayBillFeeMapper
{
public List<PrcPayBillFee> selectByBillId(String billId);
public int insertPrcPayBillFee(PrcPayBillFee fee);
public int insertBatch(@Param("list") List<PrcPayBillFee> fees);
public int deleteByBillId(String billId);
}
@@ -1,16 +1,16 @@
package com.ruoyi.price.service; package com.ruoyi.price.service;
import java.util.List; import java.util.List;
import com.ruoyi.price.domain.PrcBill; import com.ruoyi.price.domain.PrcOrderBill;
import com.ruoyi.price.domain.vo.TmsPriceBillRequest; import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult; import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
/** Receivable billing from synced orders. Same price match as quote, persist prc_bill. */ /** Order billing: persist prc_order_bill + prc_income_bill_fee. Same price match as quote. */
public interface IPrcBillService public interface IPrcOrderBillService
{ {
TmsPriceQuoteResult bill(TmsPriceBillRequest request); TmsPriceQuoteResult bill(TmsPriceBillRequest request);
List<PrcBill> selectBillList(PrcBill query); List<PrcOrderBill> selectBillList(PrcOrderBill query);
TmsPriceQuoteResult getBill(String billId); TmsPriceQuoteResult getBill(String billId);
@@ -16,30 +16,30 @@ import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sign.Md5Utils; import com.ruoyi.common.utils.sign.Md5Utils;
import com.ruoyi.price.domain.PrcBill; import com.ruoyi.price.domain.PrcIncomeBillFee;
import com.ruoyi.price.domain.PrcBillFee; import com.ruoyi.price.domain.PrcOrderBill;
import com.ruoyi.price.domain.vo.TmsPriceBillRequest; import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine; import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult; import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
import com.ruoyi.price.mapper.PrcBillFeeMapper; import com.ruoyi.price.mapper.PrcIncomeBillFeeMapper;
import com.ruoyi.price.mapper.PrcBillMapper; import com.ruoyi.price.mapper.PrcOrderBillMapper;
import com.ruoyi.price.search.EsBizLogSupport; import com.ruoyi.price.search.EsBizLogSupport;
import com.ruoyi.price.search.EsLogType; import com.ruoyi.price.search.EsLogType;
import com.ruoyi.price.search.IBillSearchStore; import com.ruoyi.price.search.IBillSearchStore;
import com.ruoyi.price.service.IPrcBillService; import com.ruoyi.price.service.IPrcOrderBillService;
import com.ruoyi.price.service.ITmsPriceQuoteService; import com.ruoyi.price.service.ITmsPriceQuoteService;
@Service @Service
public class PrcBillServiceImpl implements IPrcBillService public class PrcOrderBillServiceImpl implements IPrcOrderBillService
{ {
@Autowired @Autowired
private ITmsPriceQuoteService tmsPriceQuoteService; private ITmsPriceQuoteService tmsPriceQuoteService;
@Autowired @Autowired
private PrcBillMapper billMapper; private PrcOrderBillMapper orderBillMapper;
@Autowired @Autowired
private PrcBillFeeMapper billFeeMapper; private PrcIncomeBillFeeMapper incomeBillFeeMapper;
@Autowired @Autowired
private IBillSearchStore billSearchStore; private IBillSearchStore billSearchStore;
@@ -73,9 +73,9 @@ public class PrcBillServiceImpl implements IPrcBillService
} }
@Override @Override
public List<PrcBill> selectBillList(PrcBill query) public List<PrcOrderBill> selectBillList(PrcOrderBill query)
{ {
return billMapper.selectPrcBillList(query); return orderBillMapper.selectPrcOrderBillList(query);
} }
@Override @Override
@@ -85,12 +85,12 @@ public class PrcBillServiceImpl implements IPrcBillService
{ {
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired")); throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
} }
PrcBill bill = billMapper.selectPrcBillById(billId); PrcOrderBill bill = orderBillMapper.selectPrcOrderBillById(billId);
if (bill == null) if (bill == null)
{ {
throw new ServiceException(MessageUtils.message("price.bill.notFound")); throw new ServiceException(MessageUtils.message("price.bill.notFound"));
} }
return toResult(bill, billFeeMapper.selectByBillId(billId)); return toResult(bill, incomeBillFeeMapper.selectByBillId(billId));
} }
@Override @Override
@@ -100,12 +100,12 @@ public class PrcBillServiceImpl implements IPrcBillService
{ {
throw new ServiceException(MessageUtils.message("price.bill.orderNoRequired")); throw new ServiceException(MessageUtils.message("price.bill.orderNoRequired"));
} }
PrcBill bill = billMapper.selectPrcBillByOrderNo(orderNo.trim()); PrcOrderBill bill = orderBillMapper.selectPrcOrderBillByOrderNo(orderNo.trim());
if (bill == null) if (bill == null)
{ {
throw new ServiceException(MessageUtils.message("price.bill.notFound")); throw new ServiceException(MessageUtils.message("price.bill.notFound"));
} }
return toResult(bill, billFeeMapper.selectByBillId(bill.getBillId())); return toResult(bill, incomeBillFeeMapper.selectByBillId(bill.getBillId()));
} }
private void persistBill(TmsPriceBillRequest request, BigDecimal weight, Date bizDate, private void persistBill(TmsPriceBillRequest request, BigDecimal weight, Date bizDate,
@@ -113,8 +113,8 @@ public class PrcBillServiceImpl implements IPrcBillService
{ {
String orderNo = request.getOrderNo(); String orderNo = request.getOrderNo();
String billKey = Md5Utils.hash(orderNo); String billKey = Md5Utils.hash(orderNo);
PrcBill existed = billMapper.selectPrcBillByOrderNo(orderNo); PrcOrderBill existed = orderBillMapper.selectPrcOrderBillByOrderNo(orderNo);
PrcBill bill = existed == null ? new PrcBill() : existed; PrcOrderBill bill = existed == null ? new PrcOrderBill() : existed;
if (existed == null) if (existed == null)
{ {
bill.setBillId(UUID.randomUUID().toString()); bill.setBillId(UUID.randomUUID().toString());
@@ -165,41 +165,45 @@ public class PrcBillServiceImpl implements IPrcBillService
bill.setRegistrationFee(result.getRegistrationFee()); bill.setRegistrationFee(result.getRegistrationFee());
bill.setFreightAmount(result.getFreightAmount()); bill.setFreightAmount(result.getFreightAmount());
bill.setSurchargeAmount(result.getSurchargeAmount()); bill.setSurchargeAmount(result.getSurchargeAmount());
bill.setPayableTotal(result.getPayableTotal()); bill.setIncomeTotal(result.getPayableTotal());
bill.setPayTotal(result.getPayTotal() == null ? BigDecimal.ZERO : result.getPayTotal());
bill.setCurrency(result.getCurrency()); bill.setCurrency(result.getCurrency());
bill.setRoundMode(result.getRoundMode()); bill.setRoundMode(result.getRoundMode());
result.setBillId(bill.getBillId()); result.setBillId(bill.getBillId());
result.setOrderNo(orderNo); result.setOrderNo(orderNo);
result.setCustomerCode(request.getCustomerCode()); result.setCustomerCode(request.getCustomerCode());
result.setIncomeTotal(bill.getIncomeTotal());
result.setPayTotal(bill.getPayTotal());
result.setPayableTotal(bill.getIncomeTotal());
fillResultOrder(result, bill); fillResultOrder(result, bill);
result.setFromCache(Boolean.valueOf(existed != null)); result.setFromCache(Boolean.valueOf(existed != null));
if (existed == null) if (existed == null)
{ {
billMapper.insertPrcBill(bill); orderBillMapper.insertPrcOrderBill(bill);
} }
else else
{ {
billMapper.updatePrcBill(bill); orderBillMapper.updatePrcOrderBill(bill);
billFeeMapper.deleteByBillId(bill.getBillId()); incomeBillFeeMapper.deleteByBillId(bill.getBillId());
} }
List<PrcBillFee> fees = toFeeRows(bill.getBillId(), result); List<PrcIncomeBillFee> fees = toFeeRows(bill.getBillId(), result);
if (!fees.isEmpty()) if (!fees.isEmpty())
{ {
billFeeMapper.insertBatch(fees); incomeBillFeeMapper.insertBatch(fees);
} }
billSearchStore.save(EsLogType.BILL, orderNo, toRequestJson(request), toResponseJson(result)); billSearchStore.save(EsLogType.BILL, orderNo, toRequestJson(request), toResponseJson(result));
} }
private List<PrcBillFee> toFeeRows(String billId, TmsPriceQuoteResult result) private List<PrcIncomeBillFee> toFeeRows(String billId, TmsPriceQuoteResult result)
{ {
List<PrcBillFee> fees = new ArrayList<PrcBillFee>(); List<PrcIncomeBillFee> fees = new ArrayList<PrcIncomeBillFee>();
if (result.getFeeDetails() == null) if (result.getFeeDetails() == null)
{ {
return fees; return fees;
} }
for (TmsPriceQuoteFeeLine line : result.getFeeDetails()) for (TmsPriceQuoteFeeLine line : result.getFeeDetails())
{ {
PrcBillFee fee = new PrcBillFee(); PrcIncomeBillFee fee = new PrcIncomeBillFee();
fee.setFeeId(UUID.randomUUID().toString()); fee.setFeeId(UUID.randomUUID().toString());
fee.setBillId(billId); fee.setBillId(billId);
fee.setFeeType(line.getFeeType()); fee.setFeeType(line.getFeeType());
@@ -214,7 +218,7 @@ public class PrcBillServiceImpl implements IPrcBillService
return fees; return fees;
} }
private TmsPriceQuoteResult toResult(PrcBill bill, List<PrcBillFee> fees) private TmsPriceQuoteResult toResult(PrcOrderBill bill, List<PrcIncomeBillFee> fees)
{ {
TmsPriceQuoteResult r = new TmsPriceQuoteResult(); TmsPriceQuoteResult r = new TmsPriceQuoteResult();
r.setBillId(bill.getBillId()); r.setBillId(bill.getBillId());
@@ -248,14 +252,16 @@ public class PrcBillServiceImpl implements IPrcBillService
r.setRegistrationFee(bill.getRegistrationFee()); r.setRegistrationFee(bill.getRegistrationFee());
r.setFreightAmount(bill.getFreightAmount()); r.setFreightAmount(bill.getFreightAmount());
r.setSurchargeAmount(bill.getSurchargeAmount()); r.setSurchargeAmount(bill.getSurchargeAmount());
r.setPayableTotal(bill.getPayableTotal()); r.setIncomeTotal(bill.getIncomeTotal());
r.setPayTotal(bill.getPayTotal());
r.setPayableTotal(bill.getIncomeTotal());
r.setCurrency(bill.getCurrency()); r.setCurrency(bill.getCurrency());
r.setRoundMode(bill.getRoundMode()); r.setRoundMode(bill.getRoundMode());
r.setBizDate(bill.getBizDate()); r.setBizDate(bill.getBizDate());
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>(); List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
if (fees != null) if (fees != null)
{ {
for (PrcBillFee fee : fees) for (PrcIncomeBillFee fee : fees)
{ {
TmsPriceQuoteFeeLine line = new TmsPriceQuoteFeeLine(); TmsPriceQuoteFeeLine line = new TmsPriceQuoteFeeLine();
line.setFeeType(fee.getFeeType()); line.setFeeType(fee.getFeeType());
@@ -272,7 +278,7 @@ public class PrcBillServiceImpl implements IPrcBillService
return r; return r;
} }
private void fillResultOrder(TmsPriceQuoteResult r, PrcBill bill) private void fillResultOrder(TmsPriceQuoteResult r, PrcOrderBill bill)
{ {
r.setTrackingNo(bill.getTrackingNo()); r.setTrackingNo(bill.getTrackingNo());
r.setCustomerName(bill.getCustomerName()); r.setCustomerName(bill.getCustomerName());
@@ -0,0 +1,48 @@
<?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.ruoyi.price.mapper.PrcIncomeBillFeeMapper">
<resultMap type="PrcIncomeBillFee" id="PrcIncomeBillFeeResult">
<id property="feeId" column="fee_id" />
<result property="billId" column="bill_id" />
<result property="feeType" column="fee_type" />
<result property="feeName" column="fee_name" />
<result property="scId" column="sc_id" />
<result property="amount" column="amount" />
<result property="currency" column="currency" />
<result property="roundMode" column="round_mode" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
</resultMap>
<select id="selectByBillId" parameterType="String" resultMap="PrcIncomeBillFeeResult">
select fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
from prc_income_bill_fee
where bill_id = #{billId}
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
</select>
<insert id="insertPrcIncomeBillFee" parameterType="PrcIncomeBillFee">
insert into prc_income_bill_fee (
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
) values (
#{feeId}, #{billId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate()
)
</insert>
<insert id="insertBatch" parameterType="java.util.List">
insert into prc_income_bill_fee (
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
) values
<foreach collection="list" item="item" separator=",">
(#{item.feeId}, #{item.billId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.amount},
#{item.currency}, #{item.roundMode}, #{item.remark}, sysdate())
</foreach>
</insert>
<delete id="deleteByBillId" parameterType="String">
delete from prc_income_bill_fee where bill_id = #{billId}
</delete>
</mapper>
@@ -2,9 +2,9 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.price.mapper.PrcBillMapper"> <mapper namespace="com.ruoyi.price.mapper.PrcOrderBillMapper">
<resultMap type="PrcBill" id="PrcBillResult"> <resultMap type="PrcOrderBill" id="PrcOrderBillResult">
<id property="billId" column="bill_id" /> <id property="billId" column="bill_id" />
<result property="billKey" column="bill_key" /> <result property="billKey" column="bill_key" />
<result property="orderNo" column="order_no" /> <result property="orderNo" column="order_no" />
@@ -52,7 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="registrationFee" column="registration_fee" /> <result property="registrationFee" column="registration_fee" />
<result property="freightAmount" column="freight_amount" /> <result property="freightAmount" column="freight_amount" />
<result property="surchargeAmount" column="surcharge_amount" /> <result property="surchargeAmount" column="surcharge_amount" />
<result property="payableTotal" column="payable_total" /> <result property="incomeTotal" column="income_total" />
<result property="payTotal" column="pay_total" />
<result property="currency" column="currency" /> <result property="currency" column="currency" />
<result property="roundMode" column="round_mode" /> <result property="roundMode" column="round_mode" />
<result property="createBy" column="created_by" /> <result property="createBy" column="created_by" />
@@ -61,7 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectPrcBillVo"> <sql id="selectPrcOrderBillVo">
select bill_id, bill_key, order_no, tracking_no, customer_id, customer_code, customer_name, select bill_id, bill_key, order_no, tracking_no, customer_id, customer_code, customer_name,
pieces, actual_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height, pieces, actual_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height,
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark, shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark,
@@ -70,23 +71,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set_type, bind_priority, customer_priceset_id, product_country_id, set_type, bind_priority, customer_priceset_id, product_country_id,
weight_min, weight_max, weight_label, effective_date, charge_weight, weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee, freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, payable_total, currency, round_mode, freight_amount, surcharge_amount, income_total, pay_total, currency, round_mode,
created_by, create_time, updated_by, update_time created_by, create_time, updated_by, update_time
from prc_bill from prc_order_bill
</sql> </sql>
<select id="selectPrcBillByOrderNo" parameterType="String" resultMap="PrcBillResult"> <select id="selectPrcOrderBillByOrderNo" parameterType="String" resultMap="PrcOrderBillResult">
<include refid="selectPrcBillVo"/> <include refid="selectPrcOrderBillVo"/>
where order_no = #{orderNo} where order_no = #{orderNo}
</select> </select>
<select id="selectPrcBillById" parameterType="String" resultMap="PrcBillResult"> <select id="selectPrcOrderBillById" parameterType="String" resultMap="PrcOrderBillResult">
<include refid="selectPrcBillVo"/> <include refid="selectPrcOrderBillVo"/>
where bill_id = #{billId} where bill_id = #{billId}
</select> </select>
<select id="selectPrcBillList" parameterType="PrcBill" resultMap="PrcBillResult"> <select id="selectPrcOrderBillList" parameterType="PrcOrderBill" resultMap="PrcOrderBillResult">
<include refid="selectPrcBillVo"/> <include refid="selectPrcOrderBillVo"/>
<where> <where>
<if test="orderNo != null and orderNo != ''"> <if test="orderNo != null and orderNo != ''">
AND order_no like concat('%', #{orderNo}, '%') AND order_no like concat('%', #{orderNo}, '%')
@@ -122,8 +123,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by create_time desc, bill_id desc order by create_time desc, bill_id desc
</select> </select>
<insert id="insertPrcBill" parameterType="PrcBill"> <insert id="insertPrcOrderBill" parameterType="PrcOrderBill">
insert into prc_bill ( insert into prc_order_bill (
bill_id, bill_key, order_no, tracking_no, customer_id, customer_code, customer_name, bill_id, bill_key, order_no, tracking_no, customer_id, customer_code, customer_name,
pieces, actual_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height, pieces, actual_weight, volume, volume_weight, pkg_length, pkg_width, pkg_height,
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark, shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark,
@@ -132,7 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set_type, bind_priority, customer_priceset_id, product_country_id, set_type, bind_priority, customer_priceset_id, product_country_id,
weight_min, weight_max, weight_label, effective_date, charge_weight, weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee, freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, payable_total, currency, round_mode, freight_amount, surcharge_amount, income_total, pay_total, currency, round_mode,
create_time create_time
) values ( ) values (
#{billId}, #{billKey}, #{orderNo}, #{trackingNo}, #{customerId}, #{customerCode}, #{customerName}, #{billId}, #{billKey}, #{orderNo}, #{trackingNo}, #{customerId}, #{customerCode}, #{customerName},
@@ -143,13 +144,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId}, #{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId},
#{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight}, #{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight},
#{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee}, #{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee},
#{freightAmount}, #{surchargeAmount}, #{payableTotal}, #{currency}, #{roundMode}, #{freightAmount}, #{surchargeAmount}, #{incomeTotal}, #{payTotal}, #{currency}, #{roundMode},
sysdate() sysdate()
) )
</insert> </insert>
<update id="updatePrcBill" parameterType="PrcBill"> <update id="updatePrcOrderBill" parameterType="PrcOrderBill">
update prc_bill update prc_order_bill
set bill_key = #{billKey}, set bill_key = #{billKey},
tracking_no = #{trackingNo}, tracking_no = #{trackingNo},
customer_id = #{customerId}, customer_id = #{customerId},
@@ -195,17 +196,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
registration_fee = #{registrationFee}, registration_fee = #{registrationFee},
freight_amount = #{freightAmount}, freight_amount = #{freightAmount},
surcharge_amount = #{surchargeAmount}, surcharge_amount = #{surchargeAmount},
payable_total = #{payableTotal}, income_total = #{incomeTotal},
pay_total = #{payTotal},
currency = #{currency}, currency = #{currency},
round_mode = #{roundMode}, round_mode = #{roundMode},
update_time = sysdate() update_time = sysdate()
where bill_id = #{billId} where bill_id = #{billId}
</update> </update>
<update id="updateBillAmounts"> <update id="updateOrderBillAmounts">
update prc_bill update prc_order_bill
set surcharge_amount = #{surchargeAmount}, set surcharge_amount = #{surchargeAmount},
payable_total = #{payableTotal}, income_total = #{incomeTotal},
pay_total = #{payTotal},
update_time = sysdate() update_time = sysdate()
where bill_id = #{billId} where bill_id = #{billId}
</update> </update>
@@ -2,9 +2,9 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.price.mapper.PrcBillFeeMapper"> <mapper namespace="com.ruoyi.price.mapper.PrcPayBillFeeMapper">
<resultMap type="PrcBillFee" id="PrcBillFeeResult"> <resultMap type="PrcPayBillFee" id="PrcPayBillFeeResult">
<id property="feeId" column="fee_id" /> <id property="feeId" column="fee_id" />
<result property="billId" column="bill_id" /> <result property="billId" column="bill_id" />
<result property="feeType" column="fee_type" /> <result property="feeType" column="fee_type" />
@@ -17,15 +17,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<select id="selectByBillId" parameterType="String" resultMap="PrcBillFeeResult"> <select id="selectByBillId" parameterType="String" resultMap="PrcPayBillFeeResult">
select fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time select fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
from prc_bill_fee from prc_pay_bill_fee
where bill_id = #{billId} where bill_id = #{billId}
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
</select> </select>
<insert id="insertPrcBillFee" parameterType="PrcBillFee"> <insert id="insertPrcPayBillFee" parameterType="PrcPayBillFee">
insert into prc_bill_fee ( insert into prc_pay_bill_fee (
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
) values ( ) values (
#{feeId}, #{billId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate() #{feeId}, #{billId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate()
@@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
<insert id="insertBatch" parameterType="java.util.List"> <insert id="insertBatch" parameterType="java.util.List">
insert into prc_bill_fee ( insert into prc_pay_bill_fee (
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, create_time
) values ) values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
@@ -43,6 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
<delete id="deleteByBillId" parameterType="String"> <delete id="deleteByBillId" parameterType="String">
delete from prc_bill_fee where bill_id = #{billId} delete from prc_pay_bill_fee where bill_id = #{billId}
</delete> </delete>
</mapper> </mapper>
+29 -9
View File
@@ -1,8 +1,10 @@
-- prc_bill / prc_bill_fee: receivable billing from synced orders -- prc_order_bill: order info header
-- prc_income_bill_fee: receivable fee lines
-- prc_pay_bill_fee: payable fee lines
-- fields follow prc_quote / prc_quote_fee; extra order_no + customer_code -- fields follow prc_quote / prc_quote_fee; extra order_no + customer_code
SET NAMES utf8mb4; SET NAMES utf8mb4;
CREATE TABLE IF NOT EXISTS prc_bill ( CREATE TABLE IF NOT EXISTS prc_order_bill (
bill_id VARCHAR(36) NOT NULL COMMENT '计费ID', bill_id VARCHAR(36) NOT NULL COMMENT '计费ID',
bill_key CHAR(32) NOT NULL COMMENT 'MD5(order_no)', bill_key CHAR(32) NOT NULL COMMENT 'MD5(order_no)',
order_no VARCHAR(64) NOT NULL COMMENT '订单号', order_no VARCHAR(64) NOT NULL COMMENT '订单号',
@@ -50,7 +52,8 @@ CREATE TABLE IF NOT EXISTS prc_bill (
registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费', registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费',
freight_amount DECIMAL(10,2) DEFAULT NULL COMMENT '运费金额', freight_amount DECIMAL(10,2) DEFAULT NULL COMMENT '运费金额',
surcharge_amount DECIMAL(10,2) DEFAULT NULL COMMENT '附加费合计', surcharge_amount DECIMAL(10,2) DEFAULT NULL COMMENT '附加费合计',
payable_total DECIMAL(10,2) DEFAULT NULL COMMENT '应收总额', income_total DECIMAL(10,2) DEFAULT NULL COMMENT '应收总额',
pay_total DECIMAL(10,2) DEFAULT NULL COMMENT '应付总额',
currency VARCHAR(10) NOT NULL DEFAULT 'CNY' COMMENT '币种', currency VARCHAR(10) NOT NULL DEFAULT 'CNY' COMMENT '币种',
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式', round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式',
created_by VARCHAR(64) DEFAULT '' COMMENT '创建人', created_by VARCHAR(64) DEFAULT '' COMMENT '创建人',
@@ -62,9 +65,9 @@ CREATE TABLE IF NOT EXISTS prc_bill (
UNIQUE KEY uk_bill_key (bill_key), UNIQUE KEY uk_bill_key (bill_key),
INDEX idx_bill_customer (customer_code, biz_date), INDEX idx_bill_customer (customer_code, biz_date),
INDEX idx_bill_product (product_code, country_code) INDEX idx_bill_product (product_code, country_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费应收主表-订单同步计费'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单信息主表';
CREATE TABLE IF NOT EXISTS prc_bill_fee ( CREATE TABLE IF NOT EXISTS prc_income_bill_fee (
fee_id VARCHAR(36) NOT NULL COMMENT '费用明细ID', fee_id VARCHAR(36) NOT NULL COMMENT '费用明细ID',
bill_id VARCHAR(36) NOT NULL COMMENT '计费ID', bill_id VARCHAR(36) NOT NULL COMMENT '计费ID',
fee_type VARCHAR(30) NOT NULL COMMENT '费用类型(字典bms_fee_type)', fee_type VARCHAR(30) NOT NULL COMMENT '费用类型(字典bms_fee_type)',
@@ -76,7 +79,24 @@ CREATE TABLE IF NOT EXISTS prc_bill_fee (
remark VARCHAR(500) DEFAULT NULL COMMENT '备注', remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
create_time DATETIME DEFAULT NULL COMMENT '创建时间', create_time DATETIME DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (fee_id), PRIMARY KEY (fee_id),
UNIQUE KEY uk_bill_fee_item (bill_id, fee_type, sc_id), UNIQUE KEY uk_income_bill_fee_item (bill_id, fee_type, sc_id),
INDEX idx_bill_fee_type (fee_type), INDEX idx_income_bill_fee_type (fee_type),
CONSTRAINT fk_bill_fee_bill FOREIGN KEY (bill_id) REFERENCES prc_bill (bill_id) ON DELETE CASCADE CONSTRAINT fk_income_bill_fee_order FOREIGN KEY (bill_id) REFERENCES prc_order_bill (bill_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费应收费用明细'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='应收费用明细';
CREATE TABLE IF NOT EXISTS prc_pay_bill_fee (
fee_id VARCHAR(36) NOT NULL COMMENT '费用明细ID',
bill_id VARCHAR(36) NOT NULL COMMENT '计费ID',
fee_type VARCHAR(30) NOT NULL COMMENT '费用类型(字典bms_fee_type)',
fee_name VARCHAR(100) DEFAULT NULL COMMENT '费用名称',
sc_id BIGINT(20) NOT NULL DEFAULT 0 COMMENT '附加费配置ID',
amount DECIMAL(12,2) NOT NULL DEFAULT 0 COMMENT '金额',
currency VARCHAR(10) NOT NULL DEFAULT 'CNY' COMMENT '币种',
round_mode VARCHAR(20) DEFAULT 'HALF_UP' COMMENT '取值方式',
remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
create_time DATETIME DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (fee_id),
UNIQUE KEY uk_pay_bill_fee_item (bill_id, fee_type, sc_id),
INDEX idx_pay_bill_fee_type (fee_type),
CONSTRAINT fk_pay_bill_fee_order FOREIGN KEY (bill_id) REFERENCES prc_order_bill (bill_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='应付费用明细';
@@ -0,0 +1,35 @@
-- prc_order_bill: income_total + pay_total
SET NAMES utf8mb4;
SET @db := DATABASE();
SET @has_income := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill' AND COLUMN_NAME = 'income_total'
);
SET @has_payable := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill' AND COLUMN_NAME = 'payable_total'
);
SET @sql := IF(@has_income = 0 AND @has_payable > 0,
'ALTER TABLE prc_order_bill CHANGE COLUMN payable_total income_total DECIMAL(10,2) DEFAULT NULL COMMENT \'应收总额\'',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @has_income2 := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill' AND COLUMN_NAME = 'income_total'
);
SET @sql := IF(@has_income2 = 0,
'ALTER TABLE prc_order_bill ADD COLUMN income_total DECIMAL(10,2) DEFAULT NULL COMMENT \'应收总额\' AFTER surcharge_amount',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @has_pay := (
SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill' AND COLUMN_NAME = 'pay_total'
);
SET @sql := IF(@has_pay = 0,
'ALTER TABLE prc_order_bill ADD COLUMN pay_total DECIMAL(10,2) DEFAULT NULL COMMENT \'应付总额\' AFTER income_total',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
+68
View File
@@ -0,0 +1,68 @@
-- rename prc_bill -> prc_order_bill, prc_bill_fee -> prc_income_bill_fee, add prc_pay_bill_fee
SET NAMES utf8mb4;
SET @db := DATABASE();
SET @fk := (
SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_bill_fee' AND CONSTRAINT_TYPE = 'FOREIGN KEY'
LIMIT 1
);
SET @sql := IF(@fk IS NOT NULL,
CONCAT('ALTER TABLE prc_bill_fee DROP FOREIGN KEY `', @fk, '`'),
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @has_old := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_bill'
);
SET @has_new := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill'
);
SET @sql := IF(@has_old > 0 AND @has_new = 0, 'RENAME TABLE prc_bill TO prc_order_bill', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @has_old_fee := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_bill_fee'
);
SET @has_new_fee := (
SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_income_bill_fee'
);
SET @sql := IF(@has_old_fee > 0 AND @has_new_fee = 0, 'RENAME TABLE prc_bill_fee TO prc_income_bill_fee', 'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @fk2 := (
SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_income_bill_fee'
AND CONSTRAINT_TYPE = 'FOREIGN KEY'
LIMIT 1
);
SET @sql := IF(@fk2 IS NULL,
'ALTER TABLE prc_income_bill_fee ADD CONSTRAINT fk_income_bill_fee_order FOREIGN KEY (bill_id) REFERENCES prc_order_bill (bill_id) ON DELETE CASCADE',
'SELECT 1');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
ALTER TABLE prc_order_bill COMMENT = '订单信息主表';
ALTER TABLE prc_income_bill_fee COMMENT = '应收费用明细';
CREATE TABLE IF NOT EXISTS prc_pay_bill_fee (
fee_id VARCHAR(36) NOT NULL COMMENT '费用明细ID',
bill_id VARCHAR(36) NOT NULL COMMENT '计费ID',
fee_type VARCHAR(30) NOT NULL COMMENT '费用类型(字典bms_fee_type)',
fee_name VARCHAR(100) DEFAULT NULL COMMENT '费用名称',
sc_id BIGINT(20) NOT NULL DEFAULT 0 COMMENT '附加费配置ID',
amount DECIMAL(12,2) NOT NULL DEFAULT 0 COMMENT '金额',
currency VARCHAR(10) NOT NULL DEFAULT 'CNY' COMMENT '币种',
round_mode VARCHAR(20) DEFAULT 'HALF_UP' COMMENT '取值方式',
remark VARCHAR(500) DEFAULT NULL COMMENT '备注',
create_time DATETIME DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (fee_id),
UNIQUE KEY uk_pay_bill_fee_item (bill_id, fee_type, sc_id),
INDEX idx_pay_bill_fee_type (fee_type),
CONSTRAINT fk_pay_bill_fee_order FOREIGN KEY (bill_id) REFERENCES prc_order_bill (bill_id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='应付费用明细';
+7 -3
View File
@@ -16,8 +16,11 @@
<template #col-matchSource="{ row }"> <template #col-matchSource="{ row }">
<el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag> <el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag>
</template> </template>
<template #col-payableTotal="{ row }"> <template #col-incomeTotal="{ row }">
<span class="payable">{{ formatMoney(row.payableTotal) }}</span> <span class="payable">{{ formatMoney(row.incomeTotal) }}</span>
</template>
<template #col-payTotal="{ row }">
<span class="payable">{{ formatMoney(row.payTotal) }}</span>
</template> </template>
<template #col-action="{ row }"> <template #col-action="{ row }">
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button> <el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
@@ -47,7 +50,8 @@ const columns = [
{ label: '国家', prop: 'country', minWidth: 130, slot: 'country' }, { label: '国家', prop: 'country', minWidth: 130, slot: 'country' },
{ label: '件数', prop: 'pieces', align: 'center', width: 70 }, { label: '件数', prop: 'pieces', align: 'center', width: 70 },
{ label: '计费重', prop: 'chargeWeight', align: 'center', width: 90 }, { label: '计费重', prop: 'chargeWeight', align: 'center', width: 90 },
{ label: '应收总额', prop: 'payableTotal', align: 'right', width: 120, slot: 'payableTotal' }, { label: '应收总额', prop: 'incomeTotal', align: 'right', width: 120, slot: 'incomeTotal' },
{ label: '应付总额', prop: 'payTotal', align: 'right', width: 120, slot: 'payTotal' },
{ label: '计价来源', prop: 'matchSource', align: 'center', width: 130, slot: 'matchSource' }, { label: '计价来源', prop: 'matchSource', align: 'center', width: 130, slot: 'matchSource' },
{ label: '下单时间', prop: 'orderTime', align: 'center', width: 170, parseTime: true }, { label: '下单时间', prop: 'orderTime', align: 'center', width: 170, parseTime: true },
{ label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false } { label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false }
@@ -49,7 +49,11 @@
</div> </div>
<div class="amount-card is-total"> <div class="amount-card is-total">
<div class="amount-label">应收总额</div> <div class="amount-label">应收总额</div>
<div class="amount-value">{{ formatMoney(detail.payableTotal) }}</div> <div class="amount-value">{{ formatMoney(detail.incomeTotal ?? detail.payableTotal) }}</div>
</div>
<div class="amount-card is-total">
<div class="amount-label">应付总额</div>
<div class="amount-value">{{ formatMoney(detail.payTotal) }}</div>
</div> </div>
</div> </div>
<el-descriptions class="detail-desc" :column="2" border size="small"> <el-descriptions class="detail-desc" :column="2" border size="small">
@@ -246,7 +250,7 @@ function sourceTagType(source) {
} }
.amount-summary { .amount-summary {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(5, 1fr);
gap: 10px; gap: 10px;
margin-bottom: 12px; margin-bottom: 12px;
} }