Compare commits
4 Commits
9e99a4a6c2
...
645949ebfe
| Author | SHA1 | Date | |
|---|---|---|---|
| 645949ebfe | |||
| e69a6845f5 | |||
| 4f5ba43d28 | |||
| 6d718320e6 |
+35
@@ -2,10 +2,13 @@ package com.ruoyi.web.controller.api;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@@ -13,8 +16,10 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.config.properties.TmsApiProperties;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.ruoyi.price.service.IPrcBillService;
|
||||
import com.ruoyi.price.service.ITmsPriceQuoteService;
|
||||
|
||||
/**
|
||||
@@ -35,6 +40,9 @@ public class TmsPriceController extends BaseController
|
||||
@Autowired
|
||||
private ITmsPriceQuoteService tmsPriceQuoteService;
|
||||
|
||||
@Autowired
|
||||
private IPrcBillService prcBillService;
|
||||
|
||||
@Autowired
|
||||
private TmsApiProperties tmsApiProperties;
|
||||
|
||||
@@ -52,6 +60,33 @@ public class TmsPriceController extends BaseController
|
||||
return success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync order and persist receivable bill (prc_bill / prc_bill_fee).
|
||||
* Same price match as quote. Same orderNo upserts.
|
||||
*/
|
||||
@PostMapping("/bill")
|
||||
public AjaxResult bill(
|
||||
@RequestHeader(value = HEADER_API_CODE, required = false) String headerApiCode,
|
||||
@Validated @RequestBody TmsPriceBillRequest request)
|
||||
{
|
||||
assertApiCode(headerApiCode, request == null ? null : request.getApiCode());
|
||||
TmsPriceQuoteResult result = prcBillService.bill(request);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query receivable bill by orderNo after sync.
|
||||
*/
|
||||
@GetMapping("/bill/by-order/{orderNo}")
|
||||
public AjaxResult getBillByOrder(
|
||||
@RequestHeader(value = HEADER_API_CODE, required = false) String headerApiCode,
|
||||
@PathVariable("orderNo") String orderNo,
|
||||
@RequestParam(value = "apiCode", required = false) String apiCode)
|
||||
{
|
||||
assertApiCode(headerApiCode, apiCode);
|
||||
return success(prcBillService.getBillByOrderNo(orderNo));
|
||||
}
|
||||
|
||||
private void assertApiCode(String headerApiCode, String bodyApiCode)
|
||||
{
|
||||
String expected = tmsApiProperties.getApiCode();
|
||||
|
||||
+31
-1
@@ -13,9 +13,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.price.domain.PrcBill;
|
||||
import com.ruoyi.price.domain.PrcQuote;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.ruoyi.price.service.IPrcBillService;
|
||||
import com.ruoyi.price.service.ITmsPriceQuoteService;
|
||||
|
||||
/**
|
||||
@@ -30,6 +33,9 @@ public class BillingController extends BaseController
|
||||
@Autowired
|
||||
private ITmsPriceQuoteService tmsPriceQuoteService;
|
||||
|
||||
@Autowired
|
||||
private IPrcBillService prcBillService;
|
||||
|
||||
/**
|
||||
* Historical quote list.
|
||||
*/
|
||||
@@ -47,7 +53,7 @@ public class BillingController extends BaseController
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:quote')")
|
||||
@GetMapping("/quote/{quoteId}")
|
||||
public AjaxResult getInfo(@PathVariable Long quoteId)
|
||||
public AjaxResult getInfo(@PathVariable String quoteId)
|
||||
{
|
||||
return success(tmsPriceQuoteService.getQuote(quoteId));
|
||||
}
|
||||
@@ -62,4 +68,28 @@ public class BillingController extends BaseController
|
||||
TmsPriceQuoteResult result = tmsPriceQuoteService.quote(request);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill')")
|
||||
@GetMapping("/bill/list")
|
||||
public TableDataInfo billList(PrcBill query)
|
||||
{
|
||||
startPage();
|
||||
List<PrcBill> list = prcBillService.selectBillList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill')")
|
||||
@GetMapping("/bill/{billId}")
|
||||
public AjaxResult getBill(@PathVariable String billId)
|
||||
{
|
||||
return success(prcBillService.getBill(billId));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('price:billing:bill')")
|
||||
@PostMapping("/bill")
|
||||
public AjaxResult bill(@Validated @RequestBody TmsPriceBillRequest request)
|
||||
{
|
||||
TmsPriceQuoteResult result = prcBillService.bill(request);
|
||||
return success(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,4 +150,4 @@ xss:
|
||||
bms:
|
||||
tms:
|
||||
# Agreed API identification code for TMS callers
|
||||
api-code: BMS.TMS._Q2WnPXiXwGW2Dl-iSGNzLfrhUgQogNo
|
||||
api-code: BMS.TMS.ZYaOvlQzpcfau8TUaCFfO3Hp8ieHIqGw
|
||||
|
||||
@@ -77,6 +77,7 @@ price.set.customer.customerId.empty=客户ID不能为空
|
||||
price.set.customer.beginDate.empty=客户绑定生效日期不能为空
|
||||
price.set.customer.date.invalid=客户绑定生效日期不能晚于失效日期
|
||||
price.set.customer.alreadyBound=该客户已绑定套餐,一个客户只能绑定一个套餐
|
||||
price.set.customer.masterNotFound=客户主数据不存在
|
||||
price.set.customer.priority.invalid=优先级必须大于等于 1
|
||||
# 重量段 PrcWeight
|
||||
price.weight.range.empty=起始重量和结束重量不能为空
|
||||
@@ -119,3 +120,8 @@ price.quote.hitCustomerFixedPackageDetail=命中客户套餐固定价格明细
|
||||
|
||||
# ---- 状态自动刷新 ----
|
||||
price.status.refresh.success=状态刷新完成:bms_product 更新 {0} 行,bms_product_country 更新 {1} 行
|
||||
# receivable bill
|
||||
price.bill.orderNoRequired=订单号为空
|
||||
price.bill.billIdRequired=计费ID为空
|
||||
price.bill.notFound=计费记录不存在
|
||||
price.bill.bizDateRequired=业务日期为空
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class TmsApiProperties
|
||||
/**
|
||||
* Agreed API identification code (header X-Api-Code or body apiCode).
|
||||
*/
|
||||
private String apiCode = "BMS.TMS._Q2WnPXiXwGW2Dl-iSGNzLfrhUgQogNo";
|
||||
private String apiCode = "BMS.TMS.ZYaOvlQzpcfau8TUaCFfO3Hp8ieHIqGw";
|
||||
|
||||
public String getApiCode()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** receivable bill header prc_bill */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PrcBill extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String billId;
|
||||
private String billKey;
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
private Long customerId;
|
||||
private String customerCode;
|
||||
private String customerName;
|
||||
private Integer pieces;
|
||||
private BigDecimal actualWeight;
|
||||
private BigDecimal volume;
|
||||
private BigDecimal volumeWeight;
|
||||
private BigDecimal pkgLength;
|
||||
private BigDecimal pkgWidth;
|
||||
private BigDecimal pkgHeight;
|
||||
private String shipperName;
|
||||
private String consigneeName;
|
||||
private String destPostcode;
|
||||
private String warehouseCode;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date orderTime;
|
||||
private String orderRemark;
|
||||
private String productCode;
|
||||
private String productName;
|
||||
private String countryCode;
|
||||
private String countryName;
|
||||
private BigDecimal weight;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date bizDate;
|
||||
private Long tmsId;
|
||||
|
||||
private String matchSource;
|
||||
private String matchMessage;
|
||||
private Long priceSetId;
|
||||
private String priceSetCode;
|
||||
private String priceSetName;
|
||||
private String setType;
|
||||
private Integer bindPriority;
|
||||
private Long customerPricesetId;
|
||||
private Long productCountryId;
|
||||
private BigDecimal weightMin;
|
||||
private BigDecimal weightMax;
|
||||
private String weightLabel;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date effectiveDate;
|
||||
private BigDecimal chargeWeight;
|
||||
private BigDecimal freightRate;
|
||||
private BigDecimal baseFreightRate;
|
||||
private BigDecimal discountPercent;
|
||||
private BigDecimal registrationFee;
|
||||
private BigDecimal freightAmount;
|
||||
private BigDecimal surchargeAmount;
|
||||
private BigDecimal payableTotal;
|
||||
private String currency;
|
||||
private String roundMode;
|
||||
|
||||
private List<PrcBillFee> fees;
|
||||
}
|
||||
@@ -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 bill fee detail prc_bill_fee */
|
||||
@Data
|
||||
public class PrcBillFee 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 createdAt;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class PrcCustomerPriceSet extends BaseEntity
|
||||
private Long customerPricesetId;
|
||||
private Long priceSetId;
|
||||
private Long customerId;
|
||||
private String customerCode;
|
||||
private String customerName;
|
||||
/** 数字越小越优先 */
|
||||
private Integer bindPriority;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class PrcQuote extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long quoteId;
|
||||
private String quoteId;
|
||||
private String quoteKey;
|
||||
private Long customerId;
|
||||
private String productCode;
|
||||
|
||||
@@ -12,8 +12,8 @@ public class PrcQuoteFee implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long feeId;
|
||||
private Long quoteId;
|
||||
private String feeId;
|
||||
private String quoteId;
|
||||
/** bms_fee_type: BASIC_FREIGHT / REGISTRATION_FEE / SURCHARGE */
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.ruoyi.price.domain.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/** Sync order -> receivable bill. Quote fields plus order snapshot. */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TmsPriceBillRequest extends TmsPriceQuoteRequest
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotBlank(message = "orderNo is required")
|
||||
private String orderNo;
|
||||
|
||||
private String trackingNo;
|
||||
private String customerName;
|
||||
private Integer pieces;
|
||||
private BigDecimal actualWeight;
|
||||
private BigDecimal volume;
|
||||
private BigDecimal volumeWeight;
|
||||
private BigDecimal pkgLength;
|
||||
private BigDecimal pkgWidth;
|
||||
private BigDecimal pkgHeight;
|
||||
private String shipperName;
|
||||
private String consigneeName;
|
||||
private String destPostcode;
|
||||
private String warehouseCode;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date orderTime;
|
||||
private String orderRemark;
|
||||
|
||||
@JsonIgnore
|
||||
@AssertTrue(message = "bizDate is required")
|
||||
public boolean isBizDatePresent()
|
||||
{
|
||||
String bizDate = getBizDate();
|
||||
return bizDate != null && !bizDate.trim().isEmpty();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -12,9 +12,10 @@ public class TmsPriceQuoteRequest implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull(message = "customerId is required")
|
||||
private Long customerId;
|
||||
|
||||
private String customerCode;
|
||||
|
||||
@NotBlank(message = "productCode is required")
|
||||
private String productCode;
|
||||
|
||||
|
||||
+20
-2
@@ -52,7 +52,25 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private String roundMode;
|
||||
/** 费用明细:运费/挂号费各一行,附加费按具体名称各一行 */
|
||||
private List<TmsPriceQuoteFeeLine> feeDetails;
|
||||
private Long quoteId;
|
||||
/** true=命中已落库试算 */
|
||||
private String quoteId;
|
||||
private String billId;
|
||||
private String orderNo;
|
||||
private String trackingNo;
|
||||
private String customerCode;
|
||||
private String customerName;
|
||||
private Integer pieces;
|
||||
private BigDecimal actualWeight;
|
||||
private BigDecimal volume;
|
||||
private BigDecimal volumeWeight;
|
||||
private BigDecimal pkgLength;
|
||||
private BigDecimal pkgWidth;
|
||||
private BigDecimal pkgHeight;
|
||||
private String shipperName;
|
||||
private String consigneeName;
|
||||
private String destPostcode;
|
||||
private String warehouseCode;
|
||||
private Date orderTime;
|
||||
private String orderRemark;
|
||||
/** true=hit stored quote */
|
||||
private Boolean fromCache;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
+8
@@ -30,6 +30,10 @@ public interface PrcCustomerPriceSetMapper
|
||||
@Param("excludeId") Long excludeId,
|
||||
@Param("excludePriceSetId") Long excludePriceSetId);
|
||||
|
||||
public int countByCustomerCode(@Param("customerCode") String customerCode,
|
||||
@Param("excludeId") Long excludeId,
|
||||
@Param("excludePriceSetId") Long excludePriceSetId);
|
||||
|
||||
public int countOverlap(@Param("customerId") Long customerId,
|
||||
@Param("priceSetId") Long priceSetId,
|
||||
@Param("beginDate") java.util.Date beginDate,
|
||||
@@ -41,4 +45,8 @@ public interface PrcCustomerPriceSetMapper
|
||||
public java.util.List<PrcCustomerPriceSet> selectEffectiveByCustomer(
|
||||
@Param("customerId") Long customerId,
|
||||
@Param("bizDate") java.util.Date bizDate);
|
||||
|
||||
public java.util.List<PrcCustomerPriceSet> selectEffectiveByCustomerCode(
|
||||
@Param("customerCode") String customerCode,
|
||||
@Param("bizDate") java.util.Date bizDate);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import com.ruoyi.price.domain.PrcQuoteFee;
|
||||
/** billing quote fee detail mapper */
|
||||
public interface PrcQuoteFeeMapper
|
||||
{
|
||||
public List<PrcQuoteFee> selectByQuoteId(Long quoteId);
|
||||
public List<PrcQuoteFee> selectByQuoteId(String quoteId);
|
||||
|
||||
public int insertPrcQuoteFee(PrcQuoteFee fee);
|
||||
|
||||
public int insertBatch(@Param("list") List<PrcQuoteFee> fees);
|
||||
|
||||
public int deleteByQuoteId(Long quoteId);
|
||||
public int deleteByQuoteId(String quoteId);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ public interface PrcQuoteMapper
|
||||
{
|
||||
public PrcQuote selectPrcQuoteByKey(String quoteKey);
|
||||
|
||||
public PrcQuote selectPrcQuoteById(Long quoteId);
|
||||
public PrcQuote selectPrcQuoteById(String quoteId);
|
||||
|
||||
public List<PrcQuote> selectPrcQuoteList(PrcQuote quote);
|
||||
|
||||
public int insertPrcQuote(PrcQuote quote);
|
||||
|
||||
public int updateQuoteAmounts(@Param("quoteId") Long quoteId,
|
||||
public int updateQuoteAmounts(@Param("quoteId") String quoteId,
|
||||
@Param("surchargeAmount") BigDecimal surchargeAmount,
|
||||
@Param("payableTotal") BigDecimal payableTotal);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ruoyi.price.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.price.domain.PrcBill;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
|
||||
/** Receivable billing from synced orders. Same price match as quote, persist prc_bill. */
|
||||
public interface IPrcBillService
|
||||
{
|
||||
TmsPriceQuoteResult bill(TmsPriceBillRequest request);
|
||||
|
||||
List<PrcBill> selectBillList(PrcBill query);
|
||||
|
||||
TmsPriceQuoteResult getBill(String billId);
|
||||
|
||||
TmsPriceQuoteResult getBillByOrderNo(String orderNo);
|
||||
}
|
||||
+4
-1
@@ -18,7 +18,10 @@ public interface ITmsPriceQuoteService
|
||||
{
|
||||
TmsPriceQuoteResult quote(TmsPriceQuoteRequest request);
|
||||
|
||||
/** Calc only, no prc_quote persist. Used by receivable billing. */
|
||||
TmsPriceQuoteResult calculate(TmsPriceQuoteRequest request);
|
||||
|
||||
List<PrcQuote> selectQuoteList(PrcQuote query);
|
||||
|
||||
TmsPriceQuoteResult getQuote(Long quoteId);
|
||||
TmsPriceQuoteResult getQuote(String quoteId);
|
||||
}
|
||||
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
package com.ruoyi.price.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.sign.Md5Utils;
|
||||
import com.ruoyi.price.domain.PrcBill;
|
||||
import com.ruoyi.price.domain.PrcBillFee;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.ruoyi.price.mapper.PrcBillFeeMapper;
|
||||
import com.ruoyi.price.mapper.PrcBillMapper;
|
||||
import com.ruoyi.price.service.IPrcBillService;
|
||||
import com.ruoyi.price.service.ITmsPriceQuoteService;
|
||||
|
||||
@Service
|
||||
public class PrcBillServiceImpl implements IPrcBillService
|
||||
{
|
||||
@Autowired
|
||||
private ITmsPriceQuoteService tmsPriceQuoteService;
|
||||
|
||||
@Autowired
|
||||
private PrcBillMapper billMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcBillFeeMapper billFeeMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public TmsPriceQuoteResult bill(TmsPriceBillRequest request)
|
||||
{
|
||||
if (request == null || StringUtils.isEmpty(request.getOrderNo()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.orderNoRequired"));
|
||||
}
|
||||
request.setOrderNo(request.getOrderNo().trim());
|
||||
if (StringUtils.isEmpty(request.getBizDate()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.bizDateRequired"));
|
||||
}
|
||||
Date bizDate = resolveBizDate(request.getBizDate());
|
||||
BigDecimal weight = request.getWeight();
|
||||
TmsPriceQuoteResult result = tmsPriceQuoteService.calculate(request);
|
||||
persistBill(request, weight, bizDate, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcBill> selectBillList(PrcBill query)
|
||||
{
|
||||
return billMapper.selectPrcBillList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult getBill(String billId)
|
||||
{
|
||||
if (billId == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.billIdRequired"));
|
||||
}
|
||||
PrcBill bill = billMapper.selectPrcBillById(billId);
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
return toResult(bill, billFeeMapper.selectByBillId(billId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult getBillByOrderNo(String orderNo)
|
||||
{
|
||||
if (StringUtils.isEmpty(orderNo))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.orderNoRequired"));
|
||||
}
|
||||
PrcBill bill = billMapper.selectPrcBillByOrderNo(orderNo.trim());
|
||||
if (bill == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.notFound"));
|
||||
}
|
||||
return toResult(bill, billFeeMapper.selectByBillId(bill.getBillId()));
|
||||
}
|
||||
|
||||
private void persistBill(TmsPriceBillRequest request, BigDecimal weight, Date bizDate,
|
||||
TmsPriceQuoteResult result)
|
||||
{
|
||||
String orderNo = request.getOrderNo();
|
||||
String billKey = Md5Utils.hash(orderNo);
|
||||
PrcBill existed = billMapper.selectPrcBillByOrderNo(orderNo);
|
||||
PrcBill bill = existed == null ? new PrcBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
bill.setBillId(UUID.randomUUID().toString());
|
||||
}
|
||||
bill.setBillKey(billKey);
|
||||
bill.setOrderNo(orderNo);
|
||||
bill.setCustomerId(request.getCustomerId() == null ? Long.valueOf(0L) : request.getCustomerId());
|
||||
bill.setCustomerCode(request.getCustomerCode());
|
||||
bill.setCustomerName(request.getCustomerName());
|
||||
bill.setTrackingNo(request.getTrackingNo());
|
||||
bill.setPieces(request.getPieces());
|
||||
bill.setActualWeight(request.getActualWeight());
|
||||
bill.setVolume(request.getVolume());
|
||||
bill.setVolumeWeight(request.getVolumeWeight());
|
||||
bill.setPkgLength(request.getPkgLength());
|
||||
bill.setPkgWidth(request.getPkgWidth());
|
||||
bill.setPkgHeight(request.getPkgHeight());
|
||||
bill.setShipperName(request.getShipperName());
|
||||
bill.setConsigneeName(request.getConsigneeName());
|
||||
bill.setDestPostcode(request.getDestPostcode());
|
||||
bill.setWarehouseCode(request.getWarehouseCode());
|
||||
bill.setOrderTime(request.getOrderTime());
|
||||
bill.setOrderRemark(request.getOrderRemark());
|
||||
bill.setProductCode(result.getProductCode());
|
||||
bill.setProductName(result.getProductName());
|
||||
bill.setCountryCode(result.getCountryCode());
|
||||
bill.setCountryName(result.getCountryName());
|
||||
bill.setWeight(weight);
|
||||
bill.setBizDate(bizDate);
|
||||
bill.setTmsId(request.getTmsId() == null ? null : Long.valueOf(request.getTmsId()));
|
||||
bill.setMatchSource(result.getMatchSource());
|
||||
bill.setMatchMessage(result.getMatchMessage());
|
||||
bill.setPriceSetId(result.getPriceSetId());
|
||||
bill.setPriceSetCode(result.getPriceSetCode());
|
||||
bill.setPriceSetName(result.getPriceSetName());
|
||||
bill.setSetType(result.getSetType());
|
||||
bill.setBindPriority(result.getBindPriority());
|
||||
bill.setCustomerPricesetId(result.getCustomerPricesetId());
|
||||
bill.setProductCountryId(result.getProductCountryId());
|
||||
bill.setWeightMin(result.getWeightMin());
|
||||
bill.setWeightMax(result.getWeightMax());
|
||||
bill.setWeightLabel(result.getWeightLabel());
|
||||
bill.setEffectiveDate(result.getEffectiveDate());
|
||||
bill.setChargeWeight(result.getChargeWeight());
|
||||
bill.setFreightRate(result.getFreightRate());
|
||||
bill.setBaseFreightRate(result.getBaseFreightRate());
|
||||
bill.setDiscountPercent(result.getDiscountPercent());
|
||||
bill.setRegistrationFee(result.getRegistrationFee());
|
||||
bill.setFreightAmount(result.getFreightAmount());
|
||||
bill.setSurchargeAmount(result.getSurchargeAmount());
|
||||
bill.setPayableTotal(result.getPayableTotal());
|
||||
bill.setCurrency(result.getCurrency());
|
||||
bill.setRoundMode(result.getRoundMode());
|
||||
if (existed == null)
|
||||
{
|
||||
billMapper.insertPrcBill(bill);
|
||||
}
|
||||
else
|
||||
{
|
||||
billMapper.updatePrcBill(bill);
|
||||
billFeeMapper.deleteByBillId(bill.getBillId());
|
||||
}
|
||||
List<PrcBillFee> fees = toFeeRows(bill.getBillId(), result);
|
||||
if (!fees.isEmpty())
|
||||
{
|
||||
billFeeMapper.insertBatch(fees);
|
||||
}
|
||||
result.setBillId(bill.getBillId());
|
||||
result.setOrderNo(orderNo);
|
||||
result.setCustomerCode(request.getCustomerCode());
|
||||
fillResultOrder(result, bill);
|
||||
result.setFromCache(Boolean.valueOf(existed != null));
|
||||
}
|
||||
|
||||
private List<PrcBillFee> toFeeRows(String billId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcBillFee> fees = new ArrayList<PrcBillFee>();
|
||||
if (result.getFeeDetails() == null)
|
||||
{
|
||||
return fees;
|
||||
}
|
||||
for (TmsPriceQuoteFeeLine line : result.getFeeDetails())
|
||||
{
|
||||
PrcBillFee fee = new PrcBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
fee.setFeeName(line.getFeeName());
|
||||
fee.setScId(line.getScId() == null ? 0L : line.getScId());
|
||||
fee.setAmount(line.getAmount() == null ? BigDecimal.ZERO : line.getAmount());
|
||||
fee.setCurrency(line.getCurrency());
|
||||
fee.setRoundMode(line.getRoundMode());
|
||||
fee.setRemark(line.getRemark());
|
||||
fees.add(fee);
|
||||
}
|
||||
return fees;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult toResult(PrcBill bill, List<PrcBillFee> fees)
|
||||
{
|
||||
TmsPriceQuoteResult r = new TmsPriceQuoteResult();
|
||||
r.setBillId(bill.getBillId());
|
||||
r.setOrderNo(bill.getOrderNo());
|
||||
r.setCustomerCode(bill.getCustomerCode());
|
||||
fillResultOrder(r, bill);
|
||||
r.setFromCache(Boolean.TRUE);
|
||||
r.setMatchSource(bill.getMatchSource());
|
||||
r.setMatchMessage(bill.getMatchMessage());
|
||||
r.setCustomerId(bill.getCustomerId());
|
||||
r.setPriceSetId(bill.getPriceSetId());
|
||||
r.setPriceSetCode(bill.getPriceSetCode());
|
||||
r.setPriceSetName(bill.getPriceSetName());
|
||||
r.setSetType(bill.getSetType());
|
||||
r.setBindPriority(bill.getBindPriority());
|
||||
r.setCustomerPricesetId(bill.getCustomerPricesetId());
|
||||
r.setProductCode(bill.getProductCode());
|
||||
r.setProductName(bill.getProductName());
|
||||
r.setCountryCode(bill.getCountryCode());
|
||||
r.setCountryName(bill.getCountryName());
|
||||
r.setProductCountryId(bill.getProductCountryId());
|
||||
r.setWeightMin(bill.getWeightMin());
|
||||
r.setWeightMax(bill.getWeightMax());
|
||||
r.setWeightLabel(bill.getWeightLabel());
|
||||
r.setEffectiveDate(bill.getEffectiveDate());
|
||||
r.setWeight(bill.getWeight());
|
||||
r.setChargeWeight(bill.getChargeWeight());
|
||||
r.setFreightRate(bill.getFreightRate());
|
||||
r.setBaseFreightRate(bill.getBaseFreightRate());
|
||||
r.setDiscountPercent(bill.getDiscountPercent());
|
||||
r.setRegistrationFee(bill.getRegistrationFee());
|
||||
r.setFreightAmount(bill.getFreightAmount());
|
||||
r.setSurchargeAmount(bill.getSurchargeAmount());
|
||||
r.setPayableTotal(bill.getPayableTotal());
|
||||
r.setCurrency(bill.getCurrency());
|
||||
r.setRoundMode(bill.getRoundMode());
|
||||
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
|
||||
if (fees != null)
|
||||
{
|
||||
for (PrcBillFee fee : fees)
|
||||
{
|
||||
TmsPriceQuoteFeeLine line = new TmsPriceQuoteFeeLine();
|
||||
line.setFeeType(fee.getFeeType());
|
||||
line.setFeeName(fee.getFeeName());
|
||||
line.setScId(fee.getScId());
|
||||
line.setAmount(fee.getAmount());
|
||||
line.setCurrency(fee.getCurrency());
|
||||
line.setRoundMode(fee.getRoundMode());
|
||||
line.setRemark(fee.getRemark());
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
r.setFeeDetails(lines);
|
||||
return r;
|
||||
}
|
||||
|
||||
private void fillResultOrder(TmsPriceQuoteResult r, PrcBill bill)
|
||||
{
|
||||
r.setTrackingNo(bill.getTrackingNo());
|
||||
r.setCustomerName(bill.getCustomerName());
|
||||
r.setPieces(bill.getPieces());
|
||||
r.setActualWeight(bill.getActualWeight());
|
||||
r.setVolume(bill.getVolume());
|
||||
r.setVolumeWeight(bill.getVolumeWeight());
|
||||
r.setPkgLength(bill.getPkgLength());
|
||||
r.setPkgWidth(bill.getPkgWidth());
|
||||
r.setPkgHeight(bill.getPkgHeight());
|
||||
r.setShipperName(bill.getShipperName());
|
||||
r.setConsigneeName(bill.getConsigneeName());
|
||||
r.setDestPostcode(bill.getDestPostcode());
|
||||
r.setWarehouseCode(bill.getWarehouseCode());
|
||||
r.setOrderTime(bill.getOrderTime());
|
||||
r.setOrderRemark(bill.getOrderRemark());
|
||||
}
|
||||
|
||||
private Date resolveBizDate(String bizDate)
|
||||
{
|
||||
if (StringUtils.isEmpty(bizDate))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.bill.bizDateRequired"));
|
||||
}
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat("yyyy-MM-dd").parse(bizDate.trim());
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.quote.bizDateInvalid"));
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-9
@@ -1,11 +1,13 @@
|
||||
package com.ruoyi.price.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.CRC32;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -406,21 +408,21 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
|
||||
List<PrcCustomerPriceSet> customers = filterCustomers(set.getCustomers());
|
||||
Set<Long> seenCustomers = new HashSet<Long>();
|
||||
Set<String> seenCustomers = new HashSet<String>();
|
||||
int bound = 0;
|
||||
boolean dupInSet = false;
|
||||
for (PrcCustomerPriceSet c : customers)
|
||||
{
|
||||
if (c.getCustomerId() == null)
|
||||
if (StringUtils.isEmpty(c.getCustomerCode()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!seenCustomers.add(c.getCustomerId()))
|
||||
if (!seenCustomers.add(c.getCustomerCode()))
|
||||
{
|
||||
dupInSet = true;
|
||||
continue;
|
||||
}
|
||||
bound += customerMapper.countByCustomerId(c.getCustomerId(), c.getCustomerPricesetId(),
|
||||
bound += customerMapper.countByCustomerCode(c.getCustomerCode(), c.getCustomerPricesetId(),
|
||||
set.getPriceSetId());
|
||||
}
|
||||
if (dupInSet || bound > 0)
|
||||
@@ -581,10 +583,10 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
if (set.getCustomers() != null)
|
||||
{
|
||||
customerMapper.deletePrcCustomerPriceSetByPriceSetId(set.getPriceSetId());
|
||||
Set<Long> seenCustomers = new HashSet<Long>();
|
||||
Set<String> seenCustomers = new HashSet<String>();
|
||||
for (PrcCustomerPriceSet c : filterCustomers(set.getCustomers()))
|
||||
{
|
||||
if (c.getCustomerId() != null && !seenCustomers.add(c.getCustomerId()))
|
||||
if (StringUtils.isNotEmpty(c.getCustomerCode()) && !seenCustomers.add(c.getCustomerCode()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.alreadyBound"));
|
||||
}
|
||||
@@ -759,7 +761,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
|
||||
private void validateCustomer(PrcCustomerPriceSet customer, PrcPriceSet set)
|
||||
{
|
||||
if (customer.getCustomerId() == null || customer.getCustomerId().longValue() <= 0)
|
||||
if (StringUtils.isEmpty(customer.getCustomerCode()))
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.customerId.empty"));
|
||||
}
|
||||
@@ -779,12 +781,30 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.priority.invalid"));
|
||||
}
|
||||
int exists = customerMapper.countByCustomerId(customer.getCustomerId(),
|
||||
int exists = customerMapper.countByCustomerCode(customer.getCustomerCode(),
|
||||
customer.getCustomerPricesetId(), null);
|
||||
if (exists > 0)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.customer.alreadyBound"));
|
||||
}
|
||||
customer.setCustomerId(resolveNumericCustomerId(customer));
|
||||
}
|
||||
|
||||
private Long resolveNumericCustomerId(PrcCustomerPriceSet customer)
|
||||
{
|
||||
if (customer.getCustomerId() != null && customer.getCustomerId().longValue() > 0)
|
||||
{
|
||||
return customer.getCustomerId();
|
||||
}
|
||||
return hashCustomerCode(customer.getCustomerCode());
|
||||
}
|
||||
|
||||
private static Long hashCustomerCode(String customerCode)
|
||||
{
|
||||
CRC32 crc = new CRC32();
|
||||
crc.update(customerCode.getBytes(StandardCharsets.UTF_8));
|
||||
long v = crc.getValue();
|
||||
return v == 0L ? Long.valueOf(1L) : Long.valueOf(v);
|
||||
}
|
||||
|
||||
private void assertBasicEditable(PrcPriceSet db)
|
||||
@@ -882,7 +902,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
for (PrcCustomerPriceSet c : customers)
|
||||
{
|
||||
if (c != null && c.getCustomerId() != null && c.getCustomerId().longValue() > 0)
|
||||
if (c != null && StringUtils.isNotEmpty(c.getCustomerCode()))
|
||||
{
|
||||
list.add(c);
|
||||
}
|
||||
|
||||
+30
-8
@@ -9,6 +9,7 @@ import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -112,6 +113,16 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult calculate(TmsPriceQuoteRequest request)
|
||||
{
|
||||
validateRequest(request);
|
||||
Date bizDate = resolveBizDate(request.getBizDate());
|
||||
TmsPriceQuoteResult result = doQuote(request, bizDate);
|
||||
applySurchargesAndFees(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcQuote> selectQuoteList(PrcQuote query)
|
||||
{
|
||||
@@ -119,7 +130,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
|
||||
@Override
|
||||
public TmsPriceQuoteResult getQuote(Long quoteId)
|
||||
public TmsPriceQuoteResult getQuote(String quoteId)
|
||||
{
|
||||
if (quoteId == null)
|
||||
{
|
||||
@@ -152,8 +163,17 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
|
||||
String productName = resolveProductName(productCode, bizDate);
|
||||
List<PrcCustomerPriceSet> binds = customerPriceSetMapper.selectEffectiveByCustomer(
|
||||
request.getCustomerId(), bizDate);
|
||||
List<PrcCustomerPriceSet> binds;
|
||||
if (StringUtils.isNotEmpty(request.getCustomerCode()))
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomerCode(
|
||||
request.getCustomerCode(), bizDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
binds = customerPriceSetMapper.selectEffectiveByCustomer(
|
||||
request.getCustomerId(), bizDate);
|
||||
}
|
||||
|
||||
if (binds != null)
|
||||
{
|
||||
@@ -455,8 +475,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
Date bizDate, TmsPriceQuoteResult result)
|
||||
{
|
||||
PrcQuote quote = new PrcQuote();
|
||||
quote.setQuoteId(UUID.randomUUID().toString());
|
||||
quote.setQuoteKey(quoteKey);
|
||||
quote.setCustomerId(request.getCustomerId());
|
||||
quote.setCustomerId(request.getCustomerId() == null ? Long.valueOf(0L) : request.getCustomerId());
|
||||
quote.setProductCode(result.getProductCode());
|
||||
quote.setProductName(result.getProductName());
|
||||
quote.setCountryCode(result.getCountryCode());
|
||||
@@ -538,7 +559,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return false;
|
||||
}
|
||||
|
||||
private void replaceQuoteFees(Long quoteId, TmsPriceQuoteResult result)
|
||||
private void replaceQuoteFees(String quoteId, TmsPriceQuoteResult result)
|
||||
{
|
||||
quoteFeeMapper.deleteByQuoteId(quoteId);
|
||||
List<PrcQuoteFee> fees = toFeeRows(quoteId, result);
|
||||
@@ -549,7 +570,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal());
|
||||
}
|
||||
|
||||
private List<PrcQuoteFee> toFeeRows(Long quoteId, TmsPriceQuoteResult result)
|
||||
private List<PrcQuoteFee> toFeeRows(String quoteId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcQuoteFee> fees = new ArrayList<PrcQuoteFee>();
|
||||
if (result.getFeeDetails() == null)
|
||||
@@ -664,7 +685,8 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
}
|
||||
String countryName = emptyToNull(request.getCountryName());
|
||||
String biz = new SimpleDateFormat("yyyy-MM-dd").format(bizDate);
|
||||
String raw = request.getCustomerId() + "|"
|
||||
String raw = (StringUtils.isNotEmpty(request.getCustomerCode())
|
||||
? request.getCustomerCode() : String.valueOf(request.getCustomerId())) + "|"
|
||||
+ request.getProductCode().trim() + "|"
|
||||
+ nvlStr(countryCode) + "|"
|
||||
+ nvlStr(countryName) + "|"
|
||||
@@ -758,7 +780,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.quote.requestBodyRequired"));
|
||||
}
|
||||
if (request.getCustomerId() == null)
|
||||
if (StringUtils.isEmpty(request.getCustomerCode()) && request.getCustomerId() == null)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.quote.customerIdRequired"));
|
||||
}
|
||||
|
||||
@@ -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.PrcBillFeeMapper">
|
||||
|
||||
<resultMap type="PrcBillFee" id="PrcBillFeeResult">
|
||||
<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="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByBillId" parameterType="String" resultMap="PrcBillFeeResult">
|
||||
select fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
from prc_bill_fee
|
||||
where bill_id = #{billId}
|
||||
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcBillFee" parameterType="PrcBillFee">
|
||||
insert into prc_bill_fee (
|
||||
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
) values (
|
||||
#{feeId}, #{billId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into prc_bill_fee (
|
||||
fee_id, bill_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
) 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_bill_fee where bill_id = #{billId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,212 @@
|
||||
<?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.PrcBillMapper">
|
||||
|
||||
<resultMap type="PrcBill" id="PrcBillResult">
|
||||
<id property="billId" column="bill_id" />
|
||||
<result property="billKey" column="bill_key" />
|
||||
<result property="orderNo" column="order_no" />
|
||||
<result property="trackingNo" column="tracking_no" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="customerCode" column="customer_code" />
|
||||
<result property="customerName" column="customer_name" />
|
||||
<result property="pieces" column="pieces" />
|
||||
<result property="actualWeight" column="actual_weight" />
|
||||
<result property="volume" column="volume" />
|
||||
<result property="volumeWeight" column="volume_weight" />
|
||||
<result property="pkgLength" column="pkg_length" />
|
||||
<result property="pkgWidth" column="pkg_width" />
|
||||
<result property="pkgHeight" column="pkg_height" />
|
||||
<result property="shipperName" column="shipper_name" />
|
||||
<result property="consigneeName" column="consignee_name" />
|
||||
<result property="destPostcode" column="dest_postcode" />
|
||||
<result property="warehouseCode" column="warehouse_code" />
|
||||
<result property="orderTime" column="order_time" />
|
||||
<result property="orderRemark" column="order_remark" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="countryName" column="country_name" />
|
||||
<result property="weight" column="weight" />
|
||||
<result property="bizDate" column="biz_date" />
|
||||
<result property="tmsId" column="tms_id" />
|
||||
<result property="matchSource" column="match_source" />
|
||||
<result property="matchMessage" column="match_message" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="priceSetCode" column="price_set_code" />
|
||||
<result property="priceSetName" column="price_set_name" />
|
||||
<result property="setType" column="set_type" />
|
||||
<result property="bindPriority" column="bind_priority" />
|
||||
<result property="customerPricesetId" column="customer_priceset_id" />
|
||||
<result property="productCountryId" column="product_country_id" />
|
||||
<result property="weightMin" column="weight_min" />
|
||||
<result property="weightMax" column="weight_max" />
|
||||
<result property="weightLabel" column="weight_label" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="chargeWeight" column="charge_weight" />
|
||||
<result property="freightRate" column="freight_rate" />
|
||||
<result property="baseFreightRate" column="base_freight_rate" />
|
||||
<result property="discountPercent" column="discount_percent" />
|
||||
<result property="registrationFee" column="registration_fee" />
|
||||
<result property="freightAmount" column="freight_amount" />
|
||||
<result property="surchargeAmount" column="surcharge_amount" />
|
||||
<result property="payableTotal" column="payable_total" />
|
||||
<result property="currency" column="currency" />
|
||||
<result property="roundMode" column="round_mode" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="created_at" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="updated_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcBillVo">
|
||||
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,
|
||||
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark,
|
||||
product_code, product_name, country_code, country_name, weight, biz_date, tms_id,
|
||||
match_source, match_message, price_set_id, price_set_code, price_set_name,
|
||||
set_type, bind_priority, customer_priceset_id, product_country_id,
|
||||
weight_min, weight_max, weight_label, effective_date, charge_weight,
|
||||
freight_rate, base_freight_rate, discount_percent, registration_fee,
|
||||
freight_amount, surcharge_amount, payable_total, currency, round_mode,
|
||||
created_by, created_at, updated_by, updated_at
|
||||
from prc_bill
|
||||
</sql>
|
||||
|
||||
<select id="selectPrcBillByOrderNo" parameterType="String" resultMap="PrcBillResult">
|
||||
<include refid="selectPrcBillVo"/>
|
||||
where order_no = #{orderNo}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcBillById" parameterType="String" resultMap="PrcBillResult">
|
||||
<include refid="selectPrcBillVo"/>
|
||||
where bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcBillList" parameterType="PrcBill" resultMap="PrcBillResult">
|
||||
<include refid="selectPrcBillVo"/>
|
||||
<where>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
AND order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="trackingNo != null and trackingNo != ''">
|
||||
AND tracking_no like concat('%', #{trackingNo}, '%')
|
||||
</if>
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
AND customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
AND customer_name like concat('%', #{customerName}, '%')
|
||||
</if>
|
||||
<if test="productCode != null and productCode != ''">
|
||||
AND product_code like concat('%', #{productCode}, '%')
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
AND country_code = #{countryCode}
|
||||
</if>
|
||||
<if test="matchSource != null and matchSource != ''">
|
||||
AND match_source = #{matchSource}
|
||||
</if>
|
||||
<if test="bizDate != null">
|
||||
AND biz_date = #{bizDate}
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''">
|
||||
AND date_format(created_at,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''">
|
||||
AND date_format(created_at,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
order by created_at desc, bill_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcBill" parameterType="PrcBill">
|
||||
insert into prc_bill (
|
||||
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,
|
||||
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark,
|
||||
product_code, product_name, country_code, country_name, weight, biz_date, tms_id,
|
||||
match_source, match_message, price_set_id, price_set_code, price_set_name,
|
||||
set_type, bind_priority, customer_priceset_id, product_country_id,
|
||||
weight_min, weight_max, weight_label, effective_date, charge_weight,
|
||||
freight_rate, base_freight_rate, discount_percent, registration_fee,
|
||||
freight_amount, surcharge_amount, payable_total, currency, round_mode,
|
||||
created_at
|
||||
) values (
|
||||
#{billId}, #{billKey}, #{orderNo}, #{trackingNo}, #{customerId}, #{customerCode}, #{customerName},
|
||||
#{pieces}, #{actualWeight}, #{volume}, #{volumeWeight}, #{pkgLength}, #{pkgWidth}, #{pkgHeight},
|
||||
#{shipperName}, #{consigneeName}, #{destPostcode}, #{warehouseCode}, #{orderTime}, #{orderRemark},
|
||||
#{productCode}, #{productName}, #{countryCode}, #{countryName}, #{weight}, #{bizDate}, #{tmsId},
|
||||
#{matchSource}, #{matchMessage}, #{priceSetId}, #{priceSetCode}, #{priceSetName},
|
||||
#{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId},
|
||||
#{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight},
|
||||
#{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee},
|
||||
#{freightAmount}, #{surchargeAmount}, #{payableTotal}, #{currency}, #{roundMode},
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrcBill" parameterType="PrcBill">
|
||||
update prc_bill
|
||||
set bill_key = #{billKey},
|
||||
tracking_no = #{trackingNo},
|
||||
customer_id = #{customerId},
|
||||
customer_code = #{customerCode},
|
||||
customer_name = #{customerName},
|
||||
pieces = #{pieces},
|
||||
actual_weight = #{actualWeight},
|
||||
volume = #{volume},
|
||||
volume_weight = #{volumeWeight},
|
||||
pkg_length = #{pkgLength},
|
||||
pkg_width = #{pkgWidth},
|
||||
pkg_height = #{pkgHeight},
|
||||
shipper_name = #{shipperName},
|
||||
consignee_name = #{consigneeName},
|
||||
dest_postcode = #{destPostcode},
|
||||
warehouse_code = #{warehouseCode},
|
||||
order_time = #{orderTime},
|
||||
order_remark = #{orderRemark},
|
||||
product_code = #{productCode},
|
||||
product_name = #{productName},
|
||||
country_code = #{countryCode},
|
||||
country_name = #{countryName},
|
||||
weight = #{weight},
|
||||
biz_date = #{bizDate},
|
||||
tms_id = #{tmsId},
|
||||
match_source = #{matchSource},
|
||||
match_message = #{matchMessage},
|
||||
price_set_id = #{priceSetId},
|
||||
price_set_code = #{priceSetCode},
|
||||
price_set_name = #{priceSetName},
|
||||
set_type = #{setType},
|
||||
bind_priority = #{bindPriority},
|
||||
customer_priceset_id = #{customerPricesetId},
|
||||
product_country_id = #{productCountryId},
|
||||
weight_min = #{weightMin},
|
||||
weight_max = #{weightMax},
|
||||
weight_label = #{weightLabel},
|
||||
effective_date = #{effectiveDate},
|
||||
charge_weight = #{chargeWeight},
|
||||
freight_rate = #{freightRate},
|
||||
base_freight_rate = #{baseFreightRate},
|
||||
discount_percent = #{discountPercent},
|
||||
registration_fee = #{registrationFee},
|
||||
freight_amount = #{freightAmount},
|
||||
surcharge_amount = #{surchargeAmount},
|
||||
payable_total = #{payableTotal},
|
||||
currency = #{currency},
|
||||
round_mode = #{roundMode},
|
||||
updated_at = sysdate()
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
|
||||
<update id="updateBillAmounts">
|
||||
update prc_bill
|
||||
set surcharge_amount = #{surchargeAmount},
|
||||
payable_total = #{payableTotal},
|
||||
updated_at = sysdate()
|
||||
where bill_id = #{billId}
|
||||
</update>
|
||||
</mapper>
|
||||
+33
-2
@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<id property="customerPricesetId" column="customer_priceset_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="customerCode" column="customer_code" />
|
||||
<result property="customerName" column="customer_name" />
|
||||
<result property="bindPriority" column="bind_priority" />
|
||||
<result property="prBegindate" column="pr_begindate" />
|
||||
@@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcCustomerPriceSetVo">
|
||||
select customer_priceset_id, price_set_id, customer_id, customer_name, bind_priority,
|
||||
select customer_priceset_id, price_set_id, customer_id, customer_code, customer_name, bind_priority,
|
||||
pr_begindate, pr_enddate, price_set_note,
|
||||
created_by, created_at, updated_by, updated_at
|
||||
from prc_customer_price_set
|
||||
@@ -40,6 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="customerId != null">
|
||||
AND customer_id = #{customerId}
|
||||
</if>
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
AND customer_code = #{customerCode}
|
||||
</if>
|
||||
<if test="customerName != null and customerName != ''">
|
||||
AND customer_name like concat('%', #{customerName}, '%')
|
||||
</if>
|
||||
@@ -62,6 +66,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countByCustomerCode" resultType="int">
|
||||
select count(1) from prc_customer_price_set
|
||||
where customer_code = #{customerCode}
|
||||
<if test="excludeId != null">
|
||||
AND customer_priceset_id <> #{excludeId}
|
||||
</if>
|
||||
<if test="excludePriceSetId != null">
|
||||
AND price_set_id <> #{excludePriceSetId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countOverlap" resultType="int">
|
||||
select count(1)
|
||||
from prc_customer_price_set c
|
||||
@@ -76,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectEffectiveByCustomer" resultMap="PrcCustomerPriceSetResult">
|
||||
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_name, c.bind_priority,
|
||||
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name, c.bind_priority,
|
||||
c.pr_begindate, c.pr_enddate, c.price_set_note,
|
||||
c.created_by, c.created_at, c.updated_by, c.updated_at
|
||||
from prc_customer_price_set c
|
||||
@@ -88,10 +103,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectEffectiveByCustomerCode" resultMap="PrcCustomerPriceSetResult">
|
||||
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name, c.bind_priority,
|
||||
c.pr_begindate, c.pr_enddate, c.price_set_note,
|
||||
c.created_by, c.created_at, c.updated_by, c.updated_at
|
||||
from prc_customer_price_set c
|
||||
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
||||
where c.customer_code = #{customerCode}
|
||||
and s.status = 'E'
|
||||
and c.pr_begindate <= #{bizDate}
|
||||
and ifnull(c.pr_enddate, '9999-12-31') >= #{bizDate}
|
||||
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcCustomerPriceSet" parameterType="PrcCustomerPriceSet" useGeneratedKeys="true" keyProperty="customerPricesetId">
|
||||
insert into prc_customer_price_set (
|
||||
<if test="priceSetId != null">price_set_id,</if>
|
||||
<if test="customerId != null">customer_id,</if>
|
||||
<if test="customerCode != null and customerCode != ''">customer_code,</if>
|
||||
<if test="customerName != null">customer_name,</if>
|
||||
<if test="bindPriority != null">bind_priority,</if>
|
||||
<if test="prBegindate != null">pr_begindate,</if>
|
||||
@@ -102,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
) values (
|
||||
<if test="priceSetId != null">#{priceSetId},</if>
|
||||
<if test="customerId != null">#{customerId},</if>
|
||||
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
|
||||
<if test="customerName != null">#{customerName},</if>
|
||||
<if test="bindPriority != null">#{bindPriority},</if>
|
||||
<if test="prBegindate != null">#{prBegindate},</if>
|
||||
@@ -116,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update prc_customer_price_set
|
||||
<set>
|
||||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||||
<if test="customerCode != null">customer_code = #{customerCode},</if>
|
||||
<if test="customerName != null">customer_name = #{customerName},</if>
|
||||
<if test="bindPriority != null">bind_priority = #{bindPriority},</if>
|
||||
<if test="prBegindate != null">pr_begindate = #{prBegindate},</if>
|
||||
|
||||
@@ -17,32 +17,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByQuoteId" parameterType="Long" resultMap="PrcQuoteFeeResult">
|
||||
<select id="selectByQuoteId" parameterType="String" resultMap="PrcQuoteFeeResult">
|
||||
select fee_id, quote_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
from prc_quote_fee
|
||||
where quote_id = #{quoteId}
|
||||
order by field(fee_type, 'BASIC_FREIGHT', 'REGISTRATION_FEE', 'SURCHARGE'), fee_id
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcQuoteFee" parameterType="PrcQuoteFee" useGeneratedKeys="true" keyProperty="feeId">
|
||||
<insert id="insertPrcQuoteFee" parameterType="PrcQuoteFee">
|
||||
insert into prc_quote_fee (
|
||||
quote_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
fee_id, quote_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
) values (
|
||||
#{quoteId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate()
|
||||
#{feeId}, #{quoteId}, #{feeType}, #{feeName}, #{scId}, #{amount}, #{currency}, #{roundMode}, #{remark}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into prc_quote_fee (
|
||||
quote_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
fee_id, quote_id, fee_type, fee_name, sc_id, amount, currency, round_mode, remark, created_at
|
||||
) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.quoteId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.amount},
|
||||
(#{item.feeId}, #{item.quoteId}, #{item.feeType}, #{item.feeName}, #{item.scId}, #{item.amount},
|
||||
#{item.currency}, #{item.roundMode}, #{item.remark}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByQuoteId" parameterType="Long">
|
||||
<delete id="deleteByQuoteId" parameterType="String">
|
||||
delete from prc_quote_fee where quote_id = #{quoteId}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
||||
@@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where quote_key = #{quoteKey}
|
||||
</select>
|
||||
|
||||
<select id="selectPrcQuoteById" parameterType="Long" resultMap="PrcQuoteResult">
|
||||
<select id="selectPrcQuoteById" parameterType="String" resultMap="PrcQuoteResult">
|
||||
<include refid="selectPrcQuoteVo"/>
|
||||
where quote_id = #{quoteId}
|
||||
</select>
|
||||
@@ -100,9 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by quote_id desc
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcQuote" parameterType="PrcQuote" useGeneratedKeys="true" keyProperty="quoteId">
|
||||
<insert id="insertPrcQuote" parameterType="PrcQuote">
|
||||
insert into prc_quote (
|
||||
quote_key, customer_id, product_code, product_name,
|
||||
quote_id, quote_key, customer_id, product_code, product_name,
|
||||
country_code, country_name, weight, biz_date, tms_id,
|
||||
match_source, match_message, price_set_id, price_set_code, price_set_name,
|
||||
set_type, bind_priority, customer_priceset_id, product_country_id,
|
||||
@@ -111,7 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
freight_amount, surcharge_amount, payable_total, currency, round_mode,
|
||||
created_at
|
||||
) values (
|
||||
#{quoteKey}, #{customerId}, #{productCode}, #{productName},
|
||||
#{quoteId}, #{quoteKey}, #{customerId}, #{productCode}, #{productName},
|
||||
#{countryCode}, #{countryName}, #{weight}, #{bizDate}, #{tmsId},
|
||||
#{matchSource}, #{matchMessage}, #{priceSetId}, #{priceSetCode}, #{priceSetName},
|
||||
#{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId},
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
-- prc_bill / prc_bill_fee: receivable billing from synced orders
|
||||
-- fields follow prc_quote / prc_quote_fee; extra order_no + customer_code
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS prc_bill (
|
||||
bill_id VARCHAR(36) NOT NULL COMMENT '计费ID',
|
||||
bill_key CHAR(32) NOT NULL COMMENT 'MD5(order_no)',
|
||||
order_no VARCHAR(64) NOT NULL COMMENT '订单号',
|
||||
tracking_no VARCHAR(64) DEFAULT NULL COMMENT '运单号',
|
||||
customer_id BIGINT(20) NOT NULL DEFAULT 0 COMMENT '客户ID',
|
||||
customer_code VARCHAR(50) DEFAULT NULL COMMENT '客户代码',
|
||||
customer_name VARCHAR(100) DEFAULT NULL COMMENT '客户名称',
|
||||
pieces INT(11) DEFAULT NULL COMMENT '件数',
|
||||
actual_weight DECIMAL(10,3) DEFAULT NULL COMMENT '实际重量KG',
|
||||
volume DECIMAL(12,4) DEFAULT NULL COMMENT '体积m3',
|
||||
volume_weight DECIMAL(10,3) DEFAULT NULL COMMENT '材积重KG',
|
||||
pkg_length DECIMAL(10,2) DEFAULT NULL COMMENT '长CM',
|
||||
pkg_width DECIMAL(10,2) DEFAULT NULL COMMENT '宽CM',
|
||||
pkg_height DECIMAL(10,2) DEFAULT NULL COMMENT '高CM',
|
||||
shipper_name VARCHAR(100) DEFAULT NULL COMMENT '发件人',
|
||||
consignee_name VARCHAR(100) DEFAULT NULL COMMENT '收件人',
|
||||
dest_postcode VARCHAR(20) DEFAULT NULL COMMENT '目的邮编',
|
||||
warehouse_code VARCHAR(50) DEFAULT NULL COMMENT '仓库',
|
||||
order_time DATETIME DEFAULT NULL COMMENT '下单时间',
|
||||
order_remark VARCHAR(500) DEFAULT NULL COMMENT '订单备注',
|
||||
product_code VARCHAR(20) NOT NULL COMMENT '产品代码',
|
||||
product_name VARCHAR(100) DEFAULT NULL COMMENT '产品名称',
|
||||
country_code CHAR(2) DEFAULT NULL COMMENT '国家二字码',
|
||||
country_name VARCHAR(50) DEFAULT NULL COMMENT '国家名称',
|
||||
weight DECIMAL(10,3) NOT NULL COMMENT '计费重量KG',
|
||||
biz_date DATE NOT NULL COMMENT '计费日期',
|
||||
tms_id BIGINT(20) DEFAULT NULL COMMENT '多租户系统ID',
|
||||
match_source VARCHAR(30) DEFAULT NULL COMMENT '命中来源',
|
||||
match_message VARCHAR(200) DEFAULT NULL COMMENT '命中说明',
|
||||
price_set_id BIGINT(20) DEFAULT NULL COMMENT '价格套餐ID',
|
||||
price_set_code VARCHAR(20) DEFAULT NULL COMMENT '套餐编码',
|
||||
price_set_name VARCHAR(50) DEFAULT NULL COMMENT '套餐名称',
|
||||
set_type VARCHAR(10) DEFAULT NULL COMMENT '计价类型',
|
||||
bind_priority INT(11) DEFAULT NULL COMMENT '客户套餐优先级',
|
||||
customer_priceset_id BIGINT(20) DEFAULT NULL COMMENT '客户套餐绑定ID',
|
||||
product_country_id BIGINT(20) DEFAULT NULL COMMENT '关联 bms_product_country.detail_id',
|
||||
weight_min DECIMAL(10,4) DEFAULT NULL COMMENT '重量段下限',
|
||||
weight_max DECIMAL(10,4) DEFAULT NULL COMMENT '重量段上限',
|
||||
weight_label VARCHAR(50) DEFAULT NULL COMMENT '重量段展示',
|
||||
effective_date DATE DEFAULT NULL COMMENT '产品明细生效日',
|
||||
charge_weight DECIMAL(10,3) DEFAULT NULL COMMENT '计费重量',
|
||||
freight_rate DECIMAL(10,4) DEFAULT NULL COMMENT '运费单价',
|
||||
base_freight_rate DECIMAL(10,4) DEFAULT NULL COMMENT '折扣前单价',
|
||||
discount_percent DECIMAL(5,2) DEFAULT NULL COMMENT '折扣百分数',
|
||||
registration_fee DECIMAL(10,2) DEFAULT NULL COMMENT '挂号费',
|
||||
freight_amount DECIMAL(10,2) DEFAULT NULL COMMENT '运费金额',
|
||||
surcharge_amount DECIMAL(10,2) DEFAULT NULL COMMENT '附加费合计',
|
||||
payable_total DECIMAL(10,2) DEFAULT NULL COMMENT '应收总额',
|
||||
currency VARCHAR(10) NOT NULL DEFAULT 'CNY' COMMENT '币种',
|
||||
round_mode VARCHAR(20) NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式',
|
||||
created_by VARCHAR(64) DEFAULT '' COMMENT '创建人',
|
||||
created_at DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
updated_by VARCHAR(64) DEFAULT '' COMMENT '更新人',
|
||||
updated_at DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (bill_id),
|
||||
UNIQUE KEY uk_bill_order (order_no),
|
||||
UNIQUE KEY uk_bill_key (bill_key),
|
||||
INDEX idx_bill_customer (customer_code, biz_date),
|
||||
INDEX idx_bill_product (product_code, country_code)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费应收主表-订单同步计费';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS prc_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 '备注',
|
||||
created_at DATETIME DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (fee_id),
|
||||
UNIQUE KEY uk_bill_fee_item (bill_id, fee_type, sc_id),
|
||||
INDEX idx_bill_fee_type (fee_type),
|
||||
CONSTRAINT fk_bill_fee_bill FOREIGN KEY (bill_id) REFERENCES prc_bill (bill_id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费应收费用明细';
|
||||
@@ -0,0 +1,23 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- visible C menu under billing center (2300)
|
||||
INSERT INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, remark)
|
||||
SELECT 2310, N'同步计费', 2300, 2, 'bill', 'price/billing/bill', '', 'BillingBill', 1, 0, 'C', '0', '0', 'price:billing:bill', 'list', 'admin', sysdate(), N'订单同步计费应收'
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2310);
|
||||
|
||||
UPDATE sys_menu SET menu_name = N'同步计费', parent_id = 2300, order_num = 2, path = 'bill', component = 'price/billing/bill', route_name = 'BillingBill', menu_type = 'C', visible = '0', perms = 'price:billing:bill', remark = N'订单同步计费应收'
|
||||
WHERE menu_id = 2310;
|
||||
|
||||
INSERT INTO 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 2311, N'计费查询', 2310, 1, '', NULL, 1, 0, 'F', '0', '0', 'price:billing:bill', '#', 'admin', sysdate()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2311);
|
||||
|
||||
UPDATE sys_menu SET menu_name = N'计费查询', parent_id = 2310, menu_type = 'F', path = '', component = NULL, perms = 'price:billing:bill' WHERE menu_id = 2311;
|
||||
|
||||
INSERT INTO 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 2312, N'计费详情', 2310, 2, '', NULL, 1, 0, 'F', '0', '0', 'price:billing:bill', '#', 'admin', sysdate()
|
||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_id = 2312);
|
||||
|
||||
INSERT INTO sys_role_menu (role_id, menu_id)
|
||||
SELECT 1, m.menu_id FROM (SELECT 2310 AS menu_id UNION SELECT 2311 UNION SELECT 2312) m
|
||||
WHERE NOT EXISTS (SELECT 1 FROM sys_role_menu rm WHERE rm.role_id = 1 AND rm.menu_id = m.menu_id);
|
||||
@@ -0,0 +1,21 @@
|
||||
-- prc_bill add order snapshot columns
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE prc_bill
|
||||
ADD COLUMN tracking_no VARCHAR(64) DEFAULT NULL COMMENT '运单号' AFTER order_no,
|
||||
ADD COLUMN customer_name VARCHAR(100) DEFAULT NULL COMMENT '客户名称' AFTER customer_code,
|
||||
ADD COLUMN pieces INT(11) DEFAULT NULL COMMENT '件数' AFTER customer_name,
|
||||
ADD COLUMN actual_weight DECIMAL(10,3) DEFAULT NULL COMMENT '实际重量KG' AFTER pieces,
|
||||
ADD COLUMN volume DECIMAL(12,4) DEFAULT NULL COMMENT '体积m3' AFTER actual_weight,
|
||||
ADD COLUMN volume_weight DECIMAL(10,3) DEFAULT NULL COMMENT '材积重KG' AFTER volume,
|
||||
ADD COLUMN pkg_length DECIMAL(10,2) DEFAULT NULL COMMENT '长CM' AFTER volume_weight,
|
||||
ADD COLUMN pkg_width DECIMAL(10,2) DEFAULT NULL COMMENT '宽CM' AFTER pkg_length,
|
||||
ADD COLUMN pkg_height DECIMAL(10,2) DEFAULT NULL COMMENT '高CM' AFTER pkg_width,
|
||||
ADD COLUMN shipper_name VARCHAR(100) DEFAULT NULL COMMENT '发件人' AFTER pkg_height,
|
||||
ADD COLUMN consignee_name VARCHAR(100) DEFAULT NULL COMMENT '收件人' AFTER shipper_name,
|
||||
ADD COLUMN dest_postcode VARCHAR(20) DEFAULT NULL COMMENT '目的邮编' AFTER consignee_name,
|
||||
ADD COLUMN warehouse_code VARCHAR(50) DEFAULT NULL COMMENT '仓库' AFTER dest_postcode,
|
||||
ADD COLUMN order_time DATETIME DEFAULT NULL COMMENT '下单时间' AFTER warehouse_code,
|
||||
ADD COLUMN order_remark VARCHAR(500) DEFAULT NULL COMMENT '订单备注' AFTER order_time;
|
||||
|
||||
ALTER TABLE prc_bill ADD INDEX idx_bill_tracking (tracking_no);
|
||||
@@ -0,0 +1,10 @@
|
||||
-- prc_customer_price_set add customer_code
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE prc_customer_price_set
|
||||
ADD COLUMN customer_code varchar(50) DEFAULT NULL COMMENT '客户代码' AFTER customer_id;
|
||||
|
||||
UPDATE prc_customer_price_set cps
|
||||
INNER JOIN bms_customer c ON c.customer_id = cps.customer_id
|
||||
SET cps.customer_code = c.customer_code
|
||||
WHERE cps.customer_code IS NULL OR cps.customer_code = '';
|
||||
@@ -61,7 +61,8 @@ CREATE TABLE IF NOT EXISTS prc_price_set_detail (
|
||||
CREATE TABLE IF NOT EXISTS prc_customer_price_set (
|
||||
customer_priceset_id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '客户价格套餐id',
|
||||
price_set_id BIGINT(20) NOT NULL COMMENT '价格套餐id',
|
||||
customer_id BIGINT(20) NOT NULL COMMENT '客户id',
|
||||
customer_id BIGINT(20) DEFAULT NULL COMMENT '客户id',
|
||||
customer_code VARCHAR(50) DEFAULT NULL COMMENT '客户代码',
|
||||
customer_name VARCHAR(100) DEFAULT NULL COMMENT '客户名称(展示)',
|
||||
bind_priority INT(11) NOT NULL DEFAULT 1 COMMENT '优先级,数字越小越优先',
|
||||
pr_begindate DATETIME NOT NULL COMMENT '价格开始生效日期',
|
||||
@@ -72,7 +73,7 @@ CREATE TABLE IF NOT EXISTS prc_customer_price_set (
|
||||
updated_by VARCHAR(64) DEFAULT '' COMMENT '更新人',
|
||||
updated_at DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (customer_priceset_id),
|
||||
UNIQUE KEY uk_customer_one_set (customer_id),
|
||||
UNIQUE KEY uk_customer_one_set (customer_code),
|
||||
INDEX idx_customer_set (customer_id, pr_begindate, pr_enddate),
|
||||
INDEX idx_cps_set (price_set_id),
|
||||
CONSTRAINT fk_customer_price_set FOREIGN KEY (price_set_id) REFERENCES prc_price_set (price_set_id) ON DELETE RESTRICT
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
-- ======================================================================
|
||||
-- prc_quote / prc_quote_fee 主键改 UUID 改造(VARCHAR(36))
|
||||
--
|
||||
-- 背景:测试大数据量场景下 UUID 主键的查询性能
|
||||
-- 风险:会清空 prc_quote / prc_quote_fee 全部数据
|
||||
-- 备份:quote_uuid_backup.sql(保留原始 schema)
|
||||
--
|
||||
-- 关键顺序(踩坑总结):
|
||||
-- 1. DROP FOREIGN KEY
|
||||
-- 2. TRUNCATE TABLE
|
||||
-- 3. **先 MODIFY 列去掉 AUTO_INCREMENT**,再 DROP PRIMARY KEY
|
||||
-- 否则 InnoDB 报 1075「auto column must be defined as a key」
|
||||
-- 4. 再 MODIFY quote_id 列 / ADD PRIMARY KEY
|
||||
-- 5. ADD FOREIGN KEY 时**会自动创建 quote_id 索引**,不要额外 ADD INDEX
|
||||
-- 否则报 1061「Duplicate key name」
|
||||
--
|
||||
-- 回滚:参考 quote_uuid_backup.sql,重建表结构即可
|
||||
-- ======================================================================
|
||||
|
||||
-- === 1. 解除外键 ===
|
||||
ALTER TABLE prc_quote_fee DROP FOREIGN KEY fk_quote_fee_quote;
|
||||
|
||||
-- === 2. 清空数据 ===
|
||||
TRUNCATE TABLE prc_quote_fee;
|
||||
TRUNCATE TABLE prc_quote;
|
||||
|
||||
-- === 3. prc_quote: PK 改 UUID ===
|
||||
-- 顺序很关键:先 MODIFY 列去掉 AUTO_INCREMENT
|
||||
ALTER TABLE prc_quote MODIFY quote_id VARCHAR(36) NOT NULL COMMENT '试算ID(UUID)';
|
||||
ALTER TABLE prc_quote DROP PRIMARY KEY;
|
||||
ALTER TABLE prc_quote ADD PRIMARY KEY (quote_id);
|
||||
|
||||
-- === 4. prc_quote_fee: PK 改 UUID; quote_id 列同步 ===
|
||||
ALTER TABLE prc_quote_fee MODIFY fee_id VARCHAR(36) NOT NULL COMMENT '费用明细ID(UUID)';
|
||||
ALTER TABLE prc_quote_fee DROP PRIMARY KEY;
|
||||
ALTER TABLE prc_quote_fee MODIFY quote_id VARCHAR(36) NOT NULL COMMENT '试算ID(UUID)';
|
||||
ALTER TABLE prc_quote_fee ADD PRIMARY KEY (fee_id);
|
||||
|
||||
-- === 5. 重建 FK(自动创建 idx_quote_fee_quote_id 索引,无需手动加) ===
|
||||
ALTER TABLE prc_quote_fee ADD CONSTRAINT fk_quote_fee_quote
|
||||
FOREIGN KEY (quote_id) REFERENCES prc_quote (quote_id) ON DELETE CASCADE;
|
||||
@@ -0,0 +1,61 @@
|
||||
CREATE TABLE `prc_quote` (
|
||||
`quote_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '试算ID',
|
||||
`quote_key` char(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '试算指纹 MD5(客户|产品|国家|重量|计费日期)',
|
||||
`customer_id` bigint(20) NOT NULL COMMENT '客户ID',
|
||||
`product_code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '产品代码',
|
||||
`product_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '产品名称',
|
||||
`country_code` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '国家二字码',
|
||||
`country_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '国家名称',
|
||||
`weight` decimal(10,3) NOT NULL COMMENT '计费重量KG',
|
||||
`biz_date` date NOT NULL COMMENT '计费日期',
|
||||
`tms_id` bigint(20) DEFAULT NULL COMMENT '多租户系统ID',
|
||||
`match_source` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '命中来源 PACKAGE_FIXED/套餐固定价 PACKAGE_DISCOUNT/套餐折扣 PRODUCT_DEFAULT/产品默认价',
|
||||
`match_message` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '命中说明',
|
||||
`price_set_id` bigint(20) DEFAULT NULL COMMENT '价格套餐ID',
|
||||
`price_set_code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '套餐编码',
|
||||
`price_set_name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '套餐名称',
|
||||
`set_type` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '计价类型 FIXED=固定价 DISCOUNT=折扣',
|
||||
`bind_priority` int(11) DEFAULT NULL COMMENT '客户套餐优先级',
|
||||
`customer_priceset_id` bigint(20) DEFAULT NULL COMMENT '客户套餐绑定ID',
|
||||
`product_country_id` bigint(20) DEFAULT NULL COMMENT '关联 bms_product_country.detail_id',
|
||||
`weight_min` decimal(10,4) DEFAULT NULL COMMENT '重量段下限',
|
||||
`weight_max` decimal(10,4) DEFAULT NULL COMMENT '重量段上限',
|
||||
`weight_label` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '重量段展示',
|
||||
`effective_date` date DEFAULT NULL COMMENT '产品明细生效日',
|
||||
`charge_weight` decimal(10,3) DEFAULT NULL COMMENT '计费重量',
|
||||
`freight_rate` decimal(10,4) DEFAULT NULL COMMENT '运费单价',
|
||||
`base_freight_rate` decimal(10,4) DEFAULT NULL COMMENT '折扣前单价',
|
||||
`discount_percent` decimal(5,2) DEFAULT NULL COMMENT '折扣百分数',
|
||||
`registration_fee` decimal(10,2) DEFAULT NULL COMMENT '挂号费',
|
||||
`freight_amount` decimal(10,2) DEFAULT NULL COMMENT '运费金额',
|
||||
`surcharge_amount` decimal(10,2) DEFAULT NULL COMMENT '附加费合计',
|
||||
`payable_total` decimal(10,2) DEFAULT NULL COMMENT '应付总额',
|
||||
`currency` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'RMB' COMMENT '币种',
|
||||
`round_mode` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
`created_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建人',
|
||||
`created_at` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`updated_by` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新人',
|
||||
`updated_at` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`quote_id`),
|
||||
UNIQUE KEY `uk_quote_key` (`quote_key`),
|
||||
KEY `idx_quote_customer` (`customer_id`,`biz_date`),
|
||||
KEY `idx_quote_product` (`product_code`,`country_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=150000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费试算主表';
|
||||
|
||||
CREATE TABLE `prc_quote_fee` (
|
||||
`fee_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '费用明细ID',
|
||||
`quote_id` bigint(20) NOT NULL COMMENT '试算ID',
|
||||
`fee_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '费用类型(字典bms_fee_type)',
|
||||
`fee_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '费用名称(附加费取配置名称)',
|
||||
`sc_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '附加费配置ID,运费/挂号费为0',
|
||||
`amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
|
||||
`currency` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'RMB' COMMENT '币种',
|
||||
`round_mode` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT 'HALF_UP' COMMENT '取值方式(字典bms_round_mode)',
|
||||
`remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注(附加费明细摘要)',
|
||||
`created_at` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
PRIMARY KEY (`fee_id`),
|
||||
UNIQUE KEY `uk_quote_fee_item` (`quote_id`,`fee_type`,`sc_id`),
|
||||
KEY `idx_quote_fee_type` (`fee_type`),
|
||||
KEY `idx_quote_fee_quote_id` (`quote_id`),
|
||||
CONSTRAINT `fk_quote_fee_quote` FOREIGN KEY (`quote_id`) REFERENCES `prc_quote` (`quote_id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=236791 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='计费试算费用明细-按费用类型一行';
|
||||
@@ -25,3 +25,29 @@ export function getQuote(quoteId) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/** Sync order receivable bill */
|
||||
export function billOrder(data) {
|
||||
return request({
|
||||
url: '/price/billing/bill',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** Receivable bill list */
|
||||
export function listBill(query) {
|
||||
return request({
|
||||
url: '/price/billing/bill/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
/** Receivable bill detail */
|
||||
export function getBill(billId) {
|
||||
return request({
|
||||
url: '/price/billing/bill/' + billId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<el-dialog :title="title" v-model="visible" width="640px" append-to-body>
|
||||
<basic-form ref="formRef" v-model="form" :schemas="schemas" label-width="100px" />
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="visible = false">取 消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasicForm from '@/components/BasicForm'
|
||||
import { getSurcharge, addSurcharge, updateSurcharge } from '@/api/price/surcharge'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const formRef = ref()
|
||||
const visible = ref(false)
|
||||
const title = ref('')
|
||||
const form = ref(emptyForm())
|
||||
const regionOptions = ref([])
|
||||
|
||||
const countrySelectOptions = computed(() => {
|
||||
const all = [{ label: "全部国家", value: '' }]
|
||||
return all.concat((regionOptions.value || []).map(r => ({
|
||||
label: regionLabel(r),
|
||||
value: r.countryCode2
|
||||
})))
|
||||
})
|
||||
|
||||
const schemas = computed(() => [
|
||||
{
|
||||
label: "附加费名称",
|
||||
prop: 'scName',
|
||||
component: 'input',
|
||||
placeholder: "如 燃油附加费",
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { maxlength: 100 },
|
||||
rules: [{ required: true, message: "附加费名称不能为空", trigger: 'blur' }]
|
||||
},
|
||||
{
|
||||
label: "费用类型",
|
||||
prop: 'feeType',
|
||||
component: 'select',
|
||||
placeholder: "请选择",
|
||||
dict: 'bms_fee_type',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
disabled: true,
|
||||
rules: [{ required: true, message: "请选择费用类型", trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: "计费方式",
|
||||
prop: 'chargeType',
|
||||
component: 'select',
|
||||
placeholder: "请选择",
|
||||
dict: 'bms_charge_type',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
rules: [{ required: true, message: "请选择计费方式", trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: "计费数值",
|
||||
prop: 'chargeValue',
|
||||
component: 'inputNumber',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { min: 0, precision: 6, step: 1, controlsPosition: 'right' },
|
||||
rules: [{ required: true, message: "计费数值不能为空", trigger: 'blur' }]
|
||||
},
|
||||
{
|
||||
label: "币种",
|
||||
prop: 'currency',
|
||||
component: 'select',
|
||||
placeholder: "请选择",
|
||||
dict: 'bms_currency',
|
||||
span: 12,
|
||||
width: '100%'
|
||||
},
|
||||
{
|
||||
label: "取值方式",
|
||||
prop: 'roundMode',
|
||||
component: 'select',
|
||||
placeholder: "请选择",
|
||||
dict: 'bms_round_mode',
|
||||
span: 12,
|
||||
width: '100%',
|
||||
rules: [{ required: true, message: "请选择取值方式", trigger: 'change' }]
|
||||
},
|
||||
{
|
||||
label: "适用国家",
|
||||
prop: 'countryCode',
|
||||
component: 'select',
|
||||
placeholder: "全部国家",
|
||||
options: countrySelectOptions.value,
|
||||
span: 12,
|
||||
width: '100%',
|
||||
props: { filterable: true, clearable: true }
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
prop: 'ssCode',
|
||||
component: 'radio',
|
||||
span: 12,
|
||||
options: [
|
||||
{ label: "有效", value: 'on' },
|
||||
{ label: "停用", value: 'of' }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "备注",
|
||||
prop: 'scNote',
|
||||
component: 'textarea',
|
||||
placeholder: "请输入备注",
|
||||
span: 24,
|
||||
width: '100%',
|
||||
props: { rows: 2, maxlength: 500 }
|
||||
}
|
||||
])
|
||||
|
||||
function emptyForm() {
|
||||
return {
|
||||
scId: undefined,
|
||||
scName: undefined,
|
||||
feeType: 'SURCHARGE',
|
||||
chargeType: 'FIXED',
|
||||
chargeValue: undefined,
|
||||
currency: 'CNY',
|
||||
roundMode: 'HALF_UP',
|
||||
ssCode: 'on',
|
||||
countryCode: undefined,
|
||||
scNote: undefined
|
||||
}
|
||||
}
|
||||
|
||||
function regionLabel(r) {
|
||||
const cn = r.countryNameCn || r.countryNameEn || ''
|
||||
return cn ? `${r.flagEmoji || ''} ${cn} (${r.countryCode2})`.trim() : r.countryCode2
|
||||
}
|
||||
|
||||
function ensureRegions() {
|
||||
if (regionOptions.value.length) return Promise.resolve()
|
||||
return listRegionOptions().then(res => {
|
||||
regionOptions.value = res.data || []
|
||||
})
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = emptyForm()
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
function open(row) {
|
||||
reset()
|
||||
ensureRegions()
|
||||
if (!row) {
|
||||
title.value = "新建附加费"
|
||||
visible.value = true
|
||||
return
|
||||
}
|
||||
getSurcharge(row.scId).then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.ssCode) data.ssCode = String(data.ssCode).toLowerCase()
|
||||
form.value = { ...emptyForm(), ...data }
|
||||
title.value = "修改附加费"
|
||||
visible.value = true
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
})
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
formRef.value.validate(valid => {
|
||||
if (!valid) return
|
||||
const payload = { ...form.value }
|
||||
if (!payload.countryCode) payload.countryCode = undefined
|
||||
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
|
||||
const req = payload.scId != null ? updateSurcharge(payload) : addSurcharge(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess(payload.scId != null ? "修改成功" : "新增成功")
|
||||
visible.value = false
|
||||
emit('success')
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
@@ -63,99 +63,24 @@
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<el-dialog :title="title" v-model="open" width="640px" append-to-body>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="附加费名称" prop="scName">
|
||||
<el-input v-model="form.scName" placeholder="如 燃油附加费" maxlength="100" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="费用类型" prop="feeType">
|
||||
<el-select v-model="form.feeType" placeholder="请选择" style="width: 100%" disabled>
|
||||
<el-option v-for="d in bms_fee_type" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费方式" prop="chargeType">
|
||||
<el-select v-model="form.chargeType" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_charge_type" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="计费数值" prop="chargeValue">
|
||||
<el-input-number v-model="form.chargeValue" :min="0" :precision="6" :step="1" controls-position="right" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="币种" prop="currency">
|
||||
<el-select v-model="form.currency" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="c in bms_currency" :key="c.value" :label="c.label" :value="c.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="取值方式" prop="roundMode">
|
||||
<el-select v-model="form.roundMode" placeholder="请选择" style="width: 100%">
|
||||
<el-option v-for="d in bms_round_mode" :key="d.value" :label="d.label" :value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="适用国家" prop="countryCode">
|
||||
<el-select v-model="form.countryCode" placeholder="全部国家" clearable filterable style="width: 100%">
|
||||
<el-option label="全部国家" value="" />
|
||||
<el-option v-for="r in regionOptions" :key="r.countryCode2" :label="regionLabel(r)" :value="r.countryCode2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态" prop="ssCode">
|
||||
<el-radio-group v-model="form.ssCode">
|
||||
<el-radio value="on">有效</el-radio>
|
||||
<el-radio value="of">停用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注" prop="scNote">
|
||||
<el-input v-model="form.scNote" type="textarea" :rows="2" placeholder="请输入备注" maxlength="500" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="open = false">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<surcharge-form-dialog ref="formDialogRef" @success="() => tableRef.refresh()" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PriceSurcharge">
|
||||
import { listSurcharge, getSurcharge, addSurcharge, updateSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import { listSurcharge, delSurcharge } from '@/api/price/surcharge'
|
||||
import SurchargeFormDialog from './components/SurchargeFormDialog.vue'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
import { onMounted } from 'vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { bms_fee_type, bms_round_mode, bms_charge_type, bms_currency } = useDict('bms_fee_type', 'bms_round_mode', 'bms_charge_type', 'bms_currency')
|
||||
const { bms_charge_type } = useDict('bms_charge_type')
|
||||
|
||||
const tableRef = ref()
|
||||
const open = ref(false)
|
||||
const title = ref('')
|
||||
const formDialogRef = ref()
|
||||
const regionOptions = ref([])
|
||||
|
||||
const columns = [
|
||||
{ label: 'scId', prop: 'scId', align: 'center', width: 80 },
|
||||
{ label: '附加费名称', prop: 'scName', align: 'center', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'feeType', align: 'center', width: 110, dict: 'bms_fee_type' },
|
||||
{ label: '计费方式', prop: 'chargeType', align: 'center', width: 130 },
|
||||
@@ -192,18 +117,6 @@ const searchColumns = [
|
||||
}
|
||||
]
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
rules: {
|
||||
scName: [{ required: true, message: '附加费名称不能为空', trigger: 'blur' }],
|
||||
feeType: [{ required: true, message: '请选择费用类型', trigger: 'change' }],
|
||||
chargeType: [{ required: true, message: '请选择计费方式', trigger: 'change' }],
|
||||
chargeValue: [{ required: true, message: '计费数值不能为空', trigger: 'blur' }],
|
||||
roundMode: [{ required: true, message: '请选择取值方式', trigger: 'change' }]
|
||||
}
|
||||
})
|
||||
const { form, rules } = toRefs(data)
|
||||
|
||||
function queryList(params) {
|
||||
return listSurcharge(params)
|
||||
}
|
||||
@@ -213,11 +126,6 @@ function chargeTypeLabel(val) {
|
||||
return found ? found.label : (val || '-')
|
||||
}
|
||||
|
||||
function regionLabel(r) {
|
||||
const cn = r.countryNameCn || r.countryNameEn || ''
|
||||
return cn ? `${r.flagEmoji || ''} ${cn} (${r.countryCode2})`.trim() : r.countryCode2
|
||||
}
|
||||
|
||||
function countryLabel(code) {
|
||||
if (!code) return '全部'
|
||||
const found = regionOptions.value.find(r => r.countryCode2 === code)
|
||||
@@ -243,52 +151,12 @@ function formatChargeValue(row) {
|
||||
return v + ' ' + (row.currency || 'CNY')
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.value = {
|
||||
scId: undefined,
|
||||
scName: undefined,
|
||||
feeType: 'SURCHARGE',
|
||||
chargeType: 'FIXED',
|
||||
chargeValue: undefined,
|
||||
currency: 'CNY',
|
||||
roundMode: 'HALF_UP',
|
||||
ssCode: 'on',
|
||||
countryCode: undefined,
|
||||
scNote: undefined
|
||||
}
|
||||
proxy.resetForm('formRef')
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
reset()
|
||||
open.value = true
|
||||
title.value = '新建附加费'
|
||||
formDialogRef.value.open()
|
||||
}
|
||||
|
||||
function handleUpdate(row) {
|
||||
reset()
|
||||
getSurcharge(row.scId).then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.ssCode) data.ssCode = String(data.ssCode).toLowerCase()
|
||||
form.value = data
|
||||
open.value = true
|
||||
title.value = '修改附加费'
|
||||
})
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
proxy.$refs['formRef'].validate(valid => {
|
||||
if (!valid) return
|
||||
const payload = { ...form.value }
|
||||
if (!payload.countryCode) payload.countryCode = undefined
|
||||
if (payload.chargeValue != null) payload.chargeValue = Number(payload.chargeValue)
|
||||
const req = payload.scId != null ? updateSurcharge(payload) : addSurcharge(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess(payload.scId != null ? '修改成功' : '新增成功')
|
||||
open.value = false
|
||||
tableRef.value.refresh()
|
||||
})
|
||||
})
|
||||
formDialogRef.value.open(row)
|
||||
}
|
||||
|
||||
function handleDelete(ids) {
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div class="app-container billing-bill">
|
||||
<basic-table
|
||||
ref="tableRef"
|
||||
:columns="columns"
|
||||
:search-columns="searchColumns"
|
||||
:query="queryList"
|
||||
row-key="billId"
|
||||
>
|
||||
<template #col-product="{ row }">
|
||||
{{ row.productName || '-' }} ({{ row.productCode }})
|
||||
</template>
|
||||
<template #col-country="{ row }">
|
||||
{{ row.countryName || '-' }} ({{ row.countryCode || '-' }})
|
||||
</template>
|
||||
<template #col-matchSource="{ row }">
|
||||
<el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag>
|
||||
</template>
|
||||
<template #col-payableTotal="{ row }">
|
||||
<span class="payable">{{ formatMoney(row.payableTotal) }}</span>
|
||||
</template>
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
|
||||
</template>
|
||||
</basic-table>
|
||||
|
||||
<el-drawer v-model="open" size="780px" :title="title" append-to-body>
|
||||
<div v-loading="loading">
|
||||
<el-empty v-if="!detail" description="暂无详情" />
|
||||
<div v-else class="bill-detail">
|
||||
<div class="sec-title">订单信息</div>
|
||||
<el-descriptions :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="客户">{{ displayCustomer(detail) }}</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="目的国/地区">{{ (detail.countryName || '-') + ' (' + (detail.countryCode || '-') + ')' }}</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)">{{ formatMoney(detail.actualWeight) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="材积重(kg)">{{ formatMoney(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>
|
||||
|
||||
<div class="sec-title">计费信息</div>
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="产品">{{ (detail.productName || '-') + ' (' + (detail.productCode || '-') + ')' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费重量(kg)">{{ detail.chargeWeight ?? detail.weight ?? '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="重量段">{{ detail.weightLabel || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计费日期">{{ formatDate(detail.bizDate) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="计价来源">
|
||||
<el-tag size="small" :type="sourceTagType(detail.matchSource)">{{ sourceLabel(detail.matchSource) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="套餐">{{ detail.priceSetName || '-' }} {{ detail.priceSetCode ? '(' + detail.priceSetCode + ')' : '' }}</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="运费单价">{{ formatMoney(detail.freightRate) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="运费金额">{{ formatMoney(detail.freightAmount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="挂号费">{{ formatMoney(detail.registrationFee) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="附加费">{{ formatMoney(detail.surchargeAmount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应收总额">
|
||||
<span class="payable">{{ formatMoney(detail.payableTotal) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="命中说明" :span="2">{{ detail.matchMessage || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-table
|
||||
v-if="detail.feeDetails && detail.feeDetails.length"
|
||||
:data="detail.feeDetails"
|
||||
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="费用类型" width="110" align="center">
|
||||
<template #default="{ row }">{{ feeTypeLabel(row.feeType) || row.feeType }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" align="right">
|
||||
<template #default="{ row }">{{ formatMoney(row.amount) }}</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>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="BillingBill">
|
||||
import { listBill, getBill } from '@/api/price/billing'
|
||||
|
||||
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
|
||||
const tableRef = ref()
|
||||
const open = ref(false)
|
||||
const title = ref('计费详情')
|
||||
const loading = ref(false)
|
||||
const detail = ref(null)
|
||||
|
||||
const columns = [
|
||||
{ label: '订单号', prop: 'orderNo', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '运单号', prop: 'trackingNo', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '客户', prop: 'customerName', minWidth: 140, showOverflowTooltip: true },
|
||||
{ label: '客户代码', prop: 'customerCode', width: 120 },
|
||||
{ label: '产品', prop: 'product', minWidth: 160, slot: 'product' },
|
||||
{ label: '国家', prop: 'country', minWidth: 130, slot: 'country' },
|
||||
{ label: '件数', prop: 'pieces', align: 'center', width: 70 },
|
||||
{ label: '计费重', prop: 'chargeWeight', align: 'center', width: 90 },
|
||||
{ label: '应收总额', prop: 'payableTotal', align: 'right', width: 120, slot: 'payableTotal' },
|
||||
{ label: '计价来源', prop: 'matchSource', align: 'center', width: 130, slot: 'matchSource' },
|
||||
{ label: '下单时间', prop: 'orderTime', align: 'center', width: 170, parseTime: true },
|
||||
{ label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false }
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '订单号', prop: 'orderNo', component: 'input', placeholder: '订单号', width: '160px' },
|
||||
{ label: '运单号', prop: 'trackingNo', component: 'input', placeholder: '运单号', width: '160px' },
|
||||
{ label: '客户代码', prop: 'customerCode', component: 'input', placeholder: '客户代码', width: '140px' },
|
||||
{ label: '产品代码', prop: 'productCode', component: 'input', placeholder: '产品代码', width: '140px' }
|
||||
]
|
||||
|
||||
function queryList(params) {
|
||||
return listBill(params)
|
||||
}
|
||||
|
||||
function handleView(row) {
|
||||
title.value = '计费详情 #' + (row.orderNo || row.billId)
|
||||
open.value = true
|
||||
loading.value = true
|
||||
detail.value = null
|
||||
getBill(row.billId).then(res => {
|
||||
detail.value = res.data || null
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function displayCustomer(row) {
|
||||
if (row.customerName && row.customerCode) return row.customerName + ' (' + row.customerCode + ')'
|
||||
return row.customerName || row.customerCode || row.customerId || '-'
|
||||
}
|
||||
|
||||
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(4)
|
||||
}
|
||||
|
||||
function formatDate(val) {
|
||||
if (!val) return '-'
|
||||
const d = new Date(val)
|
||||
if (Number.isNaN(d.getTime())) return val
|
||||
return d.toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
function sourceLabel(source) {
|
||||
const map = {
|
||||
PACKAGE_FIXED: '客户固定价套餐',
|
||||
PACKAGE_DISCOUNT: '客户折扣套餐',
|
||||
PRODUCT_DEFAULT: '产品默认价',
|
||||
FIXED: '客户固定价套餐',
|
||||
DISCOUNT: '客户折扣套餐'
|
||||
}
|
||||
return map[source] || source || '-'
|
||||
}
|
||||
|
||||
function roundModeLabel(mode) {
|
||||
const map = { UP: '向上取值', DOWN: '向下取整', HALF_UP: '四舍五入' }
|
||||
return map[mode] || mode || '四舍五入'
|
||||
}
|
||||
|
||||
function feeTypeLabel(type) {
|
||||
const found = (bms_fee_type.value || []).find(d => d.value === type)
|
||||
return found ? found.label : ''
|
||||
}
|
||||
|
||||
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 sourceTagType(source) {
|
||||
if (source === 'PACKAGE_FIXED' || source === 'FIXED') return 'success'
|
||||
if (source === 'PACKAGE_DISCOUNT' || source === 'DISCOUNT') return 'warning'
|
||||
if (source === 'PRODUCT_DEFAULT') return 'info'
|
||||
return ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.billing-bill .payable {
|
||||
color: #f56c6c;
|
||||
font-weight: 600;
|
||||
}
|
||||
.billing-bill .sec-title {
|
||||
margin: 12px 0 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.billing-bill .sec-title:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.billing-bill .fee-table {
|
||||
margin-top: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -5,15 +5,9 @@
|
||||
<el-card shadow="never">
|
||||
<template #header><span>试算参数</span></template>
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="客户ID" prop="customerId">
|
||||
<el-input-number
|
||||
v-model="form.customerId"
|
||||
:min="1"
|
||||
:controls="false"
|
||||
placeholder="请输入客户ID"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-hint">与套餐绑定客户ID一致;无套餐时走产品默认价</div>
|
||||
<el-form-item label="客户" prop="customerCode">
|
||||
<customer-select v-model="form.customerCode" value-key="customerCode" placeholder="请选择客户" />
|
||||
<div class="form-hint">与套餐绑定客户一致;无套餐时走产品默认价</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品" prop="productCode">
|
||||
<el-select
|
||||
@@ -285,7 +279,7 @@ function handleViewHistory(row) {
|
||||
}
|
||||
|
||||
const form = reactive({
|
||||
customerId: undefined,
|
||||
customerCode: undefined,
|
||||
productCode: undefined,
|
||||
countryCode: undefined,
|
||||
weight: undefined,
|
||||
@@ -293,7 +287,7 @@ const form = reactive({
|
||||
})
|
||||
|
||||
const rules = {
|
||||
customerId: [{ required: true, message: '请输入客户ID', trigger: 'blur' }],
|
||||
customerCode: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
productCode: [{ required: true, message: '请选择产品', trigger: 'change' }],
|
||||
countryCode: [{ required: true, message: '请选择目的国/地区', trigger: 'change' }],
|
||||
weight: [{ required: true, message: '请输入计费重量', trigger: 'blur' }]
|
||||
@@ -340,7 +334,7 @@ function handleQuote() {
|
||||
result.value = null
|
||||
errorMsg.value = ''
|
||||
const payload = {
|
||||
customerId: form.customerId,
|
||||
customerCode: form.customerCode,
|
||||
productCode: form.productCode,
|
||||
countryCode: form.countryCode,
|
||||
weight: form.weight
|
||||
@@ -364,7 +358,7 @@ function handleQuote() {
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
form.customerId = undefined
|
||||
form.customerCode = undefined
|
||||
form.productCode = undefined
|
||||
form.countryCode = undefined
|
||||
form.weight = undefined
|
||||
|
||||
@@ -222,16 +222,18 @@
|
||||
title="套餐创建后处于草稿状态,可暂不绑定客户。一个客户只能绑定一个套餐。"
|
||||
/>
|
||||
<el-table :data="form.customers" border empty-text="暂未绑定客户">
|
||||
<el-table-column label="客户ID" min-width="120">
|
||||
<el-table-column label="客户" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.customerId" placeholder="客户ID" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户名称" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.customerName" placeholder="客户名称" />
|
||||
<customer-select
|
||||
v-model="row.customerCode"
|
||||
value-key="customerCode"
|
||||
placeholder="请选择客户"
|
||||
@change="(code, item) => onBindCustomerChange(row, code, item)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="优先级" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-model="row.bindPriority" :min="1" controls-position="right" style="width: 100%" />
|
||||
@@ -448,6 +450,7 @@ function emptyDetail() {
|
||||
function emptyCustomer() {
|
||||
return {
|
||||
customerId: undefined,
|
||||
customerCode: undefined,
|
||||
customerName: '',
|
||||
bindPriority: form.customers.length + 1,
|
||||
prBegindate: form.effectiveDate,
|
||||
@@ -463,6 +466,13 @@ function addCustomerRow() {
|
||||
form.customers.push(emptyCustomer())
|
||||
}
|
||||
|
||||
function onBindCustomerChange(row, code, item) {
|
||||
console.log('onBindCustomerChange', row, code, item)
|
||||
row.customerCode = code || undefined
|
||||
row.customerName = item ? item.customerName : ''
|
||||
row.customerId = item ? item.customerId : undefined
|
||||
}
|
||||
|
||||
function clearCascadeAfterProduct(row) {
|
||||
row.countryCode = undefined
|
||||
row.countryName = undefined
|
||||
@@ -545,10 +555,10 @@ function buildPayload(submitFlag) {
|
||||
roundMode: d.roundMode || 'HALF_UP'
|
||||
}))
|
||||
const customers = (form.customers || [])
|
||||
.filter(c => c.customerId)
|
||||
.filter(c => c.customerCode)
|
||||
.map(c => ({
|
||||
...c,
|
||||
customerId: Number(c.customerId)
|
||||
customerCode: c.customerCode
|
||||
}))
|
||||
console.log('details', details)
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
<el-table :data="set.customers || []" border empty-text="暂未绑定客户">
|
||||
<el-table-column label="绑定ID" prop="customerPricesetId" width="100" />
|
||||
<el-table-column label="客户ID" prop="customerId" width="110" />
|
||||
<el-table-column label="客户代码" prop="customerCode" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="客户名称" prop="customerName" min-width="140" />
|
||||
<el-table-column label="优先级" width="110">
|
||||
<template #default="{ row }">{{ row.bindPriority }}{{ row.bindPriority === 1 ? '(最高)' : '' }}</template>
|
||||
@@ -241,11 +242,19 @@
|
||||
|
||||
<el-dialog :title="customerTitle" v-model="customerOpen" width="520px" append-to-body>
|
||||
<el-form ref="customerFormRef" :model="customerForm" :rules="customerRules" label-width="110px">
|
||||
<el-form-item label="客户ID" prop="customerId">
|
||||
<el-input v-model="customerForm.customerId" />
|
||||
<el-form-item label="客户" prop="customerCode">
|
||||
<customer-select
|
||||
v-model="customerForm.customerCode"
|
||||
value-key="customerCode"
|
||||
placeholder="请选择客户"
|
||||
@change="onCustomerSelectChange"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="客户名称" prop="customerName">
|
||||
<el-input v-model="customerForm.customerName" maxlength="100" />
|
||||
<el-form-item label="客户代码">
|
||||
<el-input v-model="customerForm.customerCode" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="客户名称">
|
||||
<el-input v-model="customerForm.customerName" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="优先级" prop="bindPriority">
|
||||
<el-input-number v-model="customerForm.bindPriority" :min="1" controls-position="right" />
|
||||
@@ -299,7 +308,7 @@ const customerTitle = ref('')
|
||||
const customerFormRef = ref()
|
||||
const customerForm = ref({})
|
||||
const customerRules = {
|
||||
customerId: [{ required: true, message: '客户ID不能为空', trigger: 'blur' }],
|
||||
customerCode: [{ required: true, message: '请选择客户', trigger: 'change' }],
|
||||
prBegindate: [{ required: true, message: '生效日期不能为空', trigger: 'change' }]
|
||||
}
|
||||
|
||||
@@ -605,10 +614,17 @@ function removeDetail(row) {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function onCustomerSelectChange(code, item) {
|
||||
customerForm.value.customerCode = code || undefined
|
||||
customerForm.value.customerName = item ? item.customerName : ''
|
||||
customerForm.value.customerId = item ? item.customerId : undefined
|
||||
}
|
||||
|
||||
function openCustomerDialog(row) {
|
||||
customerForm.value = row ? { ...row } : {
|
||||
priceSetId: set.value.priceSetId,
|
||||
customerId: undefined,
|
||||
customerCode: undefined,
|
||||
customerName: '',
|
||||
bindPriority: 1,
|
||||
prBegindate: set.value.effectiveDate,
|
||||
@@ -624,8 +640,10 @@ function submitCustomer() {
|
||||
const payload = {
|
||||
...customerForm.value,
|
||||
priceSetId: set.value.priceSetId,
|
||||
customerId: Number(customerForm.value.customerId)
|
||||
customerId: customerForm.value.customerId,
|
||||
customerCode: customerForm.value.customerCode
|
||||
}
|
||||
console.log('submitCustomer', payload)
|
||||
const req = payload.customerPricesetId ? updateSetCustomer(payload) : addSetCustomer(payload)
|
||||
req.then(() => {
|
||||
proxy.$modal.msgSuccess('保存成功')
|
||||
|
||||
Reference in New Issue
Block a user