diff --git a/bms-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/price/BillingController.java b/bms-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/price/BillingController.java index a382d026..a2e25cd0 100644 --- a/bms-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/price/BillingController.java +++ b/bms-back/ruoyi-admin/src/main/java/com/ruoyi/web/controller/price/BillingController.java @@ -47,7 +47,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)); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcCustomerPriceSet.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcCustomerPriceSet.java index 45f8c272..e2cad164 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcCustomerPriceSet.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcCustomerPriceSet.java @@ -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; diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuote.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuote.java index 250a6110..903ef458 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuote.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuote.java @@ -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; diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuoteFee.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuoteFee.java index 9ce02bf0..5914aacb 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuoteFee.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/PrcQuoteFee.java @@ -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; diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteRequest.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteRequest.java index 739ea736..9368006d 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteRequest.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteRequest.java @@ -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; diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteResult.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteResult.java index dc00323d..84b6eda5 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteResult.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/domain/vo/TmsPriceQuoteResult.java @@ -52,7 +52,7 @@ public class TmsPriceQuoteResult implements Serializable private String roundMode; /** 费用明细:运费/挂号费各一行,附加费按具体名称各一行 */ private List feeDetails; - private Long quoteId; + private String quoteId; /** true=命中已落库试算 */ private Boolean fromCache; } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcCustomerPriceSetMapper.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcCustomerPriceSetMapper.java index 2e965b6a..2056cb42 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcCustomerPriceSetMapper.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcCustomerPriceSetMapper.java @@ -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 selectEffectiveByCustomer( @Param("customerId") Long customerId, @Param("bizDate") java.util.Date bizDate); + + public java.util.List selectEffectiveByCustomerCode( + @Param("customerCode") String customerCode, + @Param("bizDate") java.util.Date bizDate); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteFeeMapper.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteFeeMapper.java index ffb19238..2b13d4f5 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteFeeMapper.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteFeeMapper.java @@ -7,11 +7,11 @@ import com.ruoyi.price.domain.PrcQuoteFee; /** billing quote fee detail mapper */ public interface PrcQuoteFeeMapper { - public List selectByQuoteId(Long quoteId); + public List selectByQuoteId(String quoteId); public int insertPrcQuoteFee(PrcQuoteFee fee); public int insertBatch(@Param("list") List fees); - public int deleteByQuoteId(Long quoteId); + public int deleteByQuoteId(String quoteId); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteMapper.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteMapper.java index 20e43beb..63c18966 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteMapper.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/mapper/PrcQuoteMapper.java @@ -10,13 +10,13 @@ public interface PrcQuoteMapper { public PrcQuote selectPrcQuoteByKey(String quoteKey); - public PrcQuote selectPrcQuoteById(Long quoteId); + public PrcQuote selectPrcQuoteById(String quoteId); public List 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); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/ITmsPriceQuoteService.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/ITmsPriceQuoteService.java index 4a118d79..2f50ddac 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/ITmsPriceQuoteService.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/ITmsPriceQuoteService.java @@ -20,5 +20,5 @@ public interface ITmsPriceQuoteService List selectQuoteList(PrcQuote query); - TmsPriceQuoteResult getQuote(Long quoteId); + TmsPriceQuoteResult getQuote(String quoteId); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/PrcPriceSetServiceImpl.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/PrcPriceSetServiceImpl.java index 9a3b0d20..9a653e1b 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/PrcPriceSetServiceImpl.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/PrcPriceSetServiceImpl.java @@ -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 customers = filterCustomers(set.getCustomers()); - Set seenCustomers = new HashSet(); + Set seenCustomers = new HashSet(); 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 seenCustomers = new HashSet(); + Set seenCustomers = new HashSet(); 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); } diff --git a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/TmsPriceQuoteServiceImpl.java b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/TmsPriceQuoteServiceImpl.java index 0a7338f6..80053a4a 100644 --- a/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/TmsPriceQuoteServiceImpl.java +++ b/bms-back/ruoyi-system/src/main/java/com/ruoyi/price/service/impl/TmsPriceQuoteServiceImpl.java @@ -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; @@ -119,7 +120,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService } @Override - public TmsPriceQuoteResult getQuote(Long quoteId) + public TmsPriceQuoteResult getQuote(String quoteId) { if (quoteId == null) { @@ -152,8 +153,17 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService } String productName = resolveProductName(productCode, bizDate); - List binds = customerPriceSetMapper.selectEffectiveByCustomer( - request.getCustomerId(), bizDate); + List binds; + if (StringUtils.isNotEmpty(request.getCustomerCode())) + { + binds = customerPriceSetMapper.selectEffectiveByCustomerCode( + request.getCustomerCode(), bizDate); + } + else + { + binds = customerPriceSetMapper.selectEffectiveByCustomer( + request.getCustomerId(), bizDate); + } if (binds != null) { @@ -455,8 +465,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 +549,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 fees = toFeeRows(quoteId, result); @@ -549,7 +560,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal()); } - private List toFeeRows(Long quoteId, TmsPriceQuoteResult result) + private List toFeeRows(String quoteId, TmsPriceQuoteResult result) { List fees = new ArrayList(); if (result.getFeeDetails() == null) @@ -664,7 +675,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 +770,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")); } diff --git a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcCustomerPriceSetMapper.xml b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcCustomerPriceSetMapper.xml index cfb9e56d..cc463d8e 100644 --- a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcCustomerPriceSetMapper.xml +++ b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcCustomerPriceSetMapper.xml @@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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" AND customer_id = #{customerId} + + AND customer_code = #{customerCode} + AND customer_name like concat('%', #{customerName}, '%') @@ -62,6 +66,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + insert into prc_customer_price_set ( price_set_id, customer_id, + customer_code, customer_name, bind_priority, pr_begindate, @@ -102,6 +131,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) values ( #{priceSetId}, #{customerId}, + #{customerCode}, #{customerName}, #{bindPriority}, #{prBegindate}, @@ -116,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update prc_customer_price_set customer_id = #{customerId}, + customer_code = #{customerCode}, customer_name = #{customerName}, bind_priority = #{bindPriority}, pr_begindate = #{prBegindate}, diff --git a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteFeeMapper.xml b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteFeeMapper.xml index 0e0fd649..5a2efcd2 100644 --- a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteFeeMapper.xml +++ b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteFeeMapper.xml @@ -17,32 +17,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 - + 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 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 - (#{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()) - + delete from prc_quote_fee where quote_id = #{quoteId} diff --git a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteMapper.xml b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteMapper.xml index 9d7d3122..b178c4f0 100644 --- a/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteMapper.xml +++ b/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcQuoteMapper.xml @@ -61,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where quote_key = #{quoteKey} - where quote_id = #{quoteId} @@ -100,9 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by quote_id desc - + 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}, diff --git a/bms-back/sql/price/customer_code_alter.sql b/bms-back/sql/price/customer_code_alter.sql new file mode 100644 index 00000000..45e2153c --- /dev/null +++ b/bms-back/sql/price/customer_code_alter.sql @@ -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 = ''; diff --git a/bms-back/sql/price/price_set.sql b/bms-back/sql/price/price_set.sql index 838f4147..52218344 100644 --- a/bms-back/sql/price/price_set.sql +++ b/bms-back/sql/price/price_set.sql @@ -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 diff --git a/bms-back/sql/price/quote_uuid_alter.sql b/bms-back/sql/price/quote_uuid_alter.sql new file mode 100644 index 00000000..74956797 --- /dev/null +++ b/bms-back/sql/price/quote_uuid_alter.sql @@ -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; \ No newline at end of file diff --git a/bms-back/sql/price/quote_uuid_backup.sql b/bms-back/sql/price/quote_uuid_backup.sql new file mode 100644 index 00000000..1c428ce5 --- /dev/null +++ b/bms-back/sql/price/quote_uuid_backup.sql @@ -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='计费试算费用明细-按费用类型一行'; diff --git a/bms-front/src/views/price/basic/surcharge/components/SurchargeFormDialog.vue b/bms-front/src/views/price/basic/surcharge/components/SurchargeFormDialog.vue new file mode 100644 index 00000000..9d2877a1 --- /dev/null +++ b/bms-front/src/views/price/basic/surcharge/components/SurchargeFormDialog.vue @@ -0,0 +1,190 @@ + + + diff --git a/bms-front/src/views/price/basic/surcharge/index.vue b/bms-front/src/views/price/basic/surcharge/index.vue index 649de759..1e2f3c5a 100644 --- a/bms-front/src/views/price/basic/surcharge/index.vue +++ b/bms-front/src/views/price/basic/surcharge/index.vue @@ -63,99 +63,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 有效 - 停用 - - - - - - - - - - +