From 0ad90f6183c2e001d8503c05c0acc27af40f665e Mon Sep 17 00:00:00 2001 From: wuweihua <88888888> Date: Mon, 28 Sep 2026 21:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=A7=E5=93=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/TmsPriceController.java | 2 +- .../controller/price/ProductController.java | 8 - .../main/resources/i18n/messages.properties | 2 - .../java/com/bms/price/domain/BmsProduct.java | 2 +- .../bms/price/domain/BmsProductCountry.java | 8 +- .../price/domain/BmsProductPriceVersion.java | 32 ---- .../bms/price/domain/PrcPriceSetDetail.java | 8 +- .../java/com/bms/price/domain/PrcQuote.java | 4 + .../com/bms/price/domain/PrcSurchargeRel.java | 2 +- .../price/domain/vo/TmsPriceQuoteResult.java | 8 +- .../price/mapper/BmsProductCountryMapper.java | 20 +-- .../mapper/BmsProductPriceVersionMapper.java | 38 ---- .../price/mapper/PrcPriceSetDetailMapper.java | 14 +- .../com/bms/price/mapper/PrcQuoteMapper.java | 5 +- .../bms/price/service/IBmsProductService.java | 3 - .../service/impl/BmsProductServiceImpl.java | 165 +++--------------- .../service/impl/PrcOrderBillServiceImpl.java | 28 +-- .../service/impl/PrcPriceSetServiceImpl.java | 18 +- .../impl/TmsPriceQuoteServiceImpl.java | 47 ++++- .../mapper/price/BmsProductCountryMapper.xml | 82 +++------ .../mapper/price/BmsProductMapper.xml | 14 +- .../price/BmsProductPriceVersionMapper.xml | 123 ------------- .../mapper/price/PrcPriceSetDetailMapper.xml | 39 +---- .../resources/mapper/price/PrcQuoteMapper.xml | 16 +- .../mapper/price/PrcSurchargeRelMapper.xml | 2 +- bms-back/sql/bms_init.sql | 60 +++---- bms-back/sql/price/prc_quote_cost_alter.sql | 17 ++ .../sql/price/product_price_version_alter.sql | 98 ----------- .../sql/price/product_rename_drop_version.sql | 91 ++++++++++ bms-front/src/views/price/billing/quote.vue | 33 +++- .../set/composables/usePriceSetRefData.js | 4 +- .../src/views/price/set/utils/priceSet.js | 6 +- 32 files changed, 339 insertions(+), 660 deletions(-) delete mode 100644 bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductPriceVersion.java delete mode 100644 bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductPriceVersionMapper.java delete mode 100644 bms-back/bms-system/src/main/resources/mapper/price/BmsProductPriceVersionMapper.xml create mode 100644 bms-back/sql/price/prc_quote_cost_alter.sql delete mode 100644 bms-back/sql/price/product_price_version_alter.sql create mode 100644 bms-back/sql/price/product_rename_drop_version.sql diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/api/TmsPriceController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/api/TmsPriceController.java index c15ead06..0d500937 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/api/TmsPriceController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/api/TmsPriceController.java @@ -60,7 +60,7 @@ public class TmsPriceController extends BaseController /** * Quote by customer + product + country + weight (+ destPostcode when country has zones). - * Zone resolve: destPostcode -> prc_zone_detail/prc_zone -> bms_product_country.zone_code. + * Zone resolve: destPostcode -> prc_zone_detail/prc_zone -> product_country.zone_code. * Match: customer package FIXED > DISCOUNT > product default. */ @PostMapping("/quote") diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/ProductController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/ProductController.java index da267dd8..ac4aa212 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/ProductController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/price/ProductController.java @@ -22,7 +22,6 @@ import com.bms.common.core.page.TableDataInfo; import com.bms.common.enums.BusinessType; import com.bms.price.domain.BmsProduct; import com.bms.price.domain.BmsProductCountry; -import com.bms.price.domain.BmsProductPriceVersion; import com.bms.price.service.IBmsProductService; /** @@ -46,13 +45,6 @@ public class ProductController extends BaseController return getDataTable(list); } - @PreAuthorize("@ss.hasPermi('price:product:query') or @ss.hasPermi('price:product:list') or @ss.hasPermi('price:set:add') or @ss.hasPermi('price:set:query')") - @GetMapping("/priceVersions") - public AjaxResult priceVersions() - { - List list = productService.selectPriceVersionOptions(); - return success(list); - } @PreAuthorize("@ss.hasPermi('price:product:query')") @GetMapping("/{productCode}/countries") diff --git a/bms-back/bms-admin/src/main/resources/i18n/messages.properties b/bms-back/bms-admin/src/main/resources/i18n/messages.properties index 8a70c6e6..0d2989c5 100644 --- a/bms-back/bms-admin/src/main/resources/i18n/messages.properties +++ b/bms-back/bms-admin/src/main/resources/i18n/messages.properties @@ -53,7 +53,6 @@ price.set.name.empty=套餐名称不能为空 price.set.name.exists=套餐名称已存在 price.set.effectiveDate.empty=生效日期不能为空 price.set.date.invalid=生效日期不能晚于失效日期 -price.set.baseVersionNo.empty=请选择基础价格版本 price.set.discount.range=折扣模式默认折扣需在 1~99 price.set.delete.statusNotAllowed=仅待启用或驳回状态的套餐允许删除:{0} price.set.delete.boundCustomer=套餐【{0}】已绑定客户,请先解绑后再删除 @@ -114,7 +113,6 @@ price.product.import.regionEmpty=bms_region 无可用国家数据,请先同步 price.product.import.partialFail=导入完成但存在失败项:新增 {0},跳过 {1};失败明细:{2} price.product.import.effTooEarly=生效日期 {0} 早于当前开放版 {1},请使用更晚的生效日期导入 price.product.import.needFeeAlter=请先执行 SQL:bms-back/sql/price/product_country_fee_alter.sql(缺少运费/挂号费字段) -price.product.import.needVersionAlter=请先执行 SQL:bms-back/sql/price/product_price_version_alter.sql(缺少产品基础价格版本表/字段) price.product.import.needExpireAlter=请先执行 SQL:bms-back/sql/price/product_country_expire_alter.sql(缺少失效日期/版本唯一键) price.product.import.needCodeEffUnique=无法新增「同代码、不同生效日」的产品。请先执行 SQL:bms-back/sql/price/product_code_eff_unique_alter.sql(去掉 product_code 单列唯一,改为代码+生效日唯一) price.product.import.success=导入成功:新增 {0} 个产品,跳过 {1} 个(同代码同生效日不覆盖);写入国家/重量段明细 {2} 行。 diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProduct.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProduct.java index 679cce40..4023e142 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProduct.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProduct.java @@ -7,7 +7,7 @@ import com.bms.common.core.domain.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; -/** BMS产品主表 bms_product */ +/** BMS产品主表 product */ @Data @EqualsAndHashCode(callSuper = true) public class BmsProduct extends BaseEntity diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductCountry.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductCountry.java index 2a31c2a9..ec8e98b8 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductCountry.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductCountry.java @@ -6,19 +6,15 @@ import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; -/** 产品国家服务明细 bms_product_country */ +/** 产品国家服务明细 product_country */ @Data public class BmsProductCountry implements Serializable { private static final long serialVersionUID = 1L; private Long detailId; - /** FK to bms_product.product_id (one country version belongs to one product row) */ + /** FK to product.product_id */ private Long productId; - /** FK to bms_product_price_version.ppv_id */ - private Long ppvId; - /** Display only: joined from bms_product_price_version.version_no */ - private String versionNo; private String productCode; private String countryName; private String countryCode; diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductPriceVersion.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductPriceVersion.java deleted file mode 100644 index 9c37f731..00000000 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsProductPriceVersion.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.bms.price.domain; - -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.bms.common.core.domain.BaseEntity; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** Product base price version bms_product_price_version */ -@Data -@EqualsAndHashCode(callSuper = true) -public class BmsProductPriceVersion extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - private Long ppvId; - private String productCode; - /** Linked bms_product.product_id for this version row */ - private Long productId; - /** V1 / V2 */ - private String versionNo; - private Integer versionSeq; - @JsonFormat(pattern = "yyyy-MM-dd") - private Date effectiveDate; - /** null = open; set to next version effective_date when that version starts */ - @JsonFormat(pattern = "yyyy-MM-dd") - private Date expireDate; - /** 0 pending / 1 active / 2 expired */ - private String status; - /** query only: product count for this effective_date option */ - private Integer productCount; -} diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSetDetail.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSetDetail.java index 652a2705..f7b89760 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSetDetail.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPriceSetDetail.java @@ -30,16 +30,16 @@ public class PrcPriceSetDetail implements Serializable private Long zdId; private Long wsdId; private String weightLabel; - /** KG inclusive, same as bms_product_country */ + /** KG inclusive, same as product_country */ private BigDecimal weightMin; private BigDecimal weightMax; - /** bms_product_country.detail_id */ + /** product_country.detail_id */ private Long productCountryId; private BigDecimal fvValue; private BigDecimal fvRegistrationFee; - /** product base freight from bms_product_country (display only) */ + /** product base freight from product_country (display only) */ private BigDecimal baseFreightPrice; - /** product base registration from bms_product_country (display only) */ + /** product base registration from product_country (display only) */ private BigDecimal baseRegistrationFee; private BigDecimal discountValue; /** UP / DOWN / HALF_UP */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcQuote.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcQuote.java index fb10d023..0f3b45d4 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcQuote.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcQuote.java @@ -52,6 +52,10 @@ public class PrcQuote extends BaseEntity private BigDecimal freightAmount; private BigDecimal surchargeAmount; private BigDecimal payableTotal; + private BigDecimal productAmount; + private BigDecimal redlineAmount; + private BigDecimal costAmount; + private BigDecimal payTotal; private String currency; private String roundMode; diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurchargeRel.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurchargeRel.java index bd538233..3432495f 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurchargeRel.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurchargeRel.java @@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode; /** * 附加费与产品/明细关联 prc_surcharge_rel - * 同时携带附加费展示字段(JOIN prc_surcharge)与明细展示字段(LEFT JOIN bms_product_country), + * 同时携带附加费展示字段(JOIN prc_surcharge)与明细展示字段(LEFT JOIN product_country), * 便于产品列表抽屉直接渲染。 * * 语义: diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/TmsPriceQuoteResult.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/TmsPriceQuoteResult.java index 70cab17f..3b0cde48 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/TmsPriceQuoteResult.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/vo/TmsPriceQuoteResult.java @@ -44,7 +44,7 @@ public class TmsPriceQuoteResult implements Serializable private BigDecimal weightMax; private String weightLabel; private Date bizDate; - /** bms_product_country.effective_date */ + /** product_country.effective_date */ private Date effectiveDate; private BigDecimal weight; @@ -56,6 +56,12 @@ public class TmsPriceQuoteResult implements Serializable private BigDecimal freightAmount; /** 附加费合计(按产品关联命中后汇总) */ private BigDecimal surchargeAmount; + /** product catalog total: base freight*weight + base registration (no package surcharge) */ + private BigDecimal productAmount; + /** redline total reserved */ + private BigDecimal redlineAmount; + /** cost total (currently = product catalog amount) */ + private BigDecimal costAmount; /** receivable total (order bill) */ private BigDecimal incomeTotal; /** payable total (order bill); also quote payable */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductCountryMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductCountryMapper.java index db2502a7..f40d717b 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductCountryMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductCountryMapper.java @@ -23,9 +23,6 @@ public interface BmsProductCountryMapper /** Import overlay: update price/zone/attrs on matched country row */ public int updateBmsProductCountryImport(BmsProductCountry country); - /** Bind legacy open row to a version */ - public int updatePpvId(@Param("detailId") Long detailId, @Param("ppvId") Long ppvId); - public int deleteByProductId(Long productId); public int deleteByProductCode(String productCode); @@ -53,22 +50,9 @@ public interface BmsProductCountryMapper /** Open country rows (expire_date is null) for product */ public List selectOpenByProductCode(@Param("productCode") String productCode); - /** Country rows under a price version */ - public List selectByPpvId(@Param("ppvId") Long ppvId); - - /** Copy open/source version rows into a new version (new ppv_id / product_id / effective_date) */ - public int copyCountriesFromVersion( - @Param("srcPpvId") Long srcPpvId, - @Param("newPpvId") Long newPpvId, - @Param("productId") Long productId, + /** Copy previously open rows into a new effective_date (caller must expire first) */ + public int copyOpenCountries( @Param("productCode") String productCode, - @Param("effectiveDate") Date effectiveDate, - @Param("status") String status); - - /** Copy currently open rows (legacy / no ppv_id) into a new version */ - public int copyOpenCountriesToVersion( - @Param("productCode") String productCode, - @Param("newPpvId") Long newPpvId, @Param("productId") Long productId, @Param("effectiveDate") Date effectiveDate, @Param("status") String status); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductPriceVersionMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductPriceVersionMapper.java deleted file mode 100644 index 398cff60..00000000 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductPriceVersionMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.bms.price.mapper; - -import java.util.Date; -import java.util.List; -import org.apache.ibatis.annotations.Param; -import com.bms.price.domain.BmsProductPriceVersion; - -/** - * Product base price version - */ -public interface BmsProductPriceVersionMapper -{ - public BmsProductPriceVersion selectBmsProductPriceVersionById(Long ppvId); - - /** Open version (expire_date is null), prefer latest effective_date */ - public BmsProductPriceVersion selectOpenByProductCode(@Param("productCode") String productCode); - - public BmsProductPriceVersion selectByProductCodeAndEffectiveDate( - @Param("productCode") String productCode, - @Param("effectiveDate") Date effectiveDate); - - public Integer selectMaxVersionSeq(@Param("productCode") String productCode); - - /** Distinct effective_date options for package create dropdown (desc) */ - public List selectVersionOptions(); - - public int insertBmsProductPriceVersion(BmsProductPriceVersion version); - - public int updateBmsProductPriceVersion(BmsProductPriceVersion version); - - /** Close open versions: set expire_date = newEffectiveDate where effective_date < newEffectiveDate */ - public int expireOpenByProductCode( - @Param("productCode") String productCode, - @Param("newEffectiveDate") Date newEffectiveDate); - - /** Recompute status from effective_date / expire_date vs today */ - public int refreshStatusByDates(); -} diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcPriceSetDetailMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcPriceSetDetailMapper.java index 3695a93d..6268e4ac 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcPriceSetDetailMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcPriceSetDetailMapper.java @@ -42,23 +42,17 @@ public interface PrcPriceSetDetailMapper /** Copy all details from src version into new version (new psd_id, same price_set_id) */ public int copyDetailsFromVersion(@Param("srcPsvId") Long srcPsvId, @Param("newPsvId") Long newPsvId); - /** - * FIXED: insert details from product country library. - * When baseVersionNo is set, pull that base-price version only; - * otherwise asOf window or openOnly fallback. - */ + /** FIXED: insert details from product country library (asOf window or openOnly). */ public int insertFixedDetailsFromLibrary( @Param("priceSetId") Long priceSetId, @Param("psvId") Long psvId, @Param("asOf") Date asOf, - @Param("openOnly") boolean openOnly, - @Param("baseVersionNo") String baseVersionNo); + @Param("openOnly") boolean openOnly); - /** DISCOUNT: one detail row per product (optionally scoped to base version_no) */ + /** DISCOUNT: one detail row per effective product */ public int insertDiscountDetailsFromLibrary( @Param("priceSetId") Long priceSetId, - @Param("psvId") Long psvId, - @Param("baseVersionNo") String baseVersionNo); + @Param("psvId") Long psvId); /** FIXED: product + country + zone + productCountryId / weight; optional psvId scopes to version */ public PrcPriceSetDetail selectFixedMatch( diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcQuoteMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcQuoteMapper.java index e8f3e2f3..2fea3249 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcQuoteMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcQuoteMapper.java @@ -18,5 +18,8 @@ public interface PrcQuoteMapper public int updateQuoteAmounts(@Param("quoteId") String quoteId, @Param("surchargeAmount") BigDecimal surchargeAmount, - @Param("payableTotal") BigDecimal payableTotal); + @Param("payableTotal") BigDecimal payableTotal, + @Param("productAmount") BigDecimal productAmount, + @Param("costAmount") BigDecimal costAmount, + @Param("payTotal") BigDecimal payTotal); } diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/IBmsProductService.java b/bms-back/bms-system/src/main/java/com/bms/price/service/IBmsProductService.java index a47b51f8..96a3b94b 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/IBmsProductService.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/IBmsProductService.java @@ -5,7 +5,6 @@ import java.util.List; import org.springframework.web.multipart.MultipartFile; import com.bms.price.domain.BmsProduct; import com.bms.price.domain.BmsProductCountry; -import com.bms.price.domain.BmsProductPriceVersion; /** * 产品列表 服务层 @@ -56,8 +55,6 @@ public interface IBmsProductService */ public String importCountryProductExcel(MultipartFile file, String countryCode, String operName) throws Exception; - /** Distinct base-price version options (by effective_date desc) for package create */ - public List selectPriceVersionOptions(); /** * Parse Weishi B2C quote Excel into productCode -> country/zone/weight price rows (no persist). diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsProductServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsProductServiceImpl.java index f4a77a6b..97022b09 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsProductServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsProductServiceImpl.java @@ -35,11 +35,9 @@ import com.bms.common.utils.MessageUtils; import com.bms.common.utils.StringUtils; import com.bms.price.domain.BmsProduct; import com.bms.price.domain.BmsProductCountry; -import com.bms.price.domain.BmsProductPriceVersion; import com.bms.price.domain.PrcZone; import com.bms.price.mapper.BmsProductCountryMapper; import com.bms.price.mapper.BmsProductMapper; -import com.bms.price.mapper.BmsProductPriceVersionMapper; import com.bms.price.mapper.PrcZoneMapper; import com.bms.price.service.IBmsProductService; import com.bms.price.service.IPrcSurchargeRelService; @@ -77,8 +75,6 @@ public class BmsProductServiceImpl implements IBmsProductService @Autowired private BmsProductCountryMapper countryMapper; - @Autowired - private BmsProductPriceVersionMapper priceVersionMapper; @Autowired private BmsRegionMapper regionMapper; @@ -103,7 +99,6 @@ public class BmsProductServiceImpl implements IBmsProductService { productMapper.refreshStatusByDates(); countryMapper.refreshStatusByDates(); - priceVersionMapper.refreshStatusByDates(); if (product != null) { product.setStatus(normalizeStatusCode(product.getStatus())); @@ -489,12 +484,6 @@ public class BmsProductServiceImpl implements IBmsProductService } } - @Override - public List selectPriceVersionOptions() - { - List list = priceVersionMapper.selectVersionOptions(); - return list == null ? new ArrayList<>() : list; - } /** @return int[]{added, skipped, countryRows} */ private int[] importOneProduct(Workbook workbook, BmsProduct product, String operName, @@ -532,7 +521,7 @@ public class BmsProductServiceImpl implements IBmsProductService if (existing != null) { product.setProductId(existing.getProductId()); - int countryRows = saveCountriesVersioned(product, countries); + int countryRows = saveCountries(product, countries); return new int[] { 0, 1, countryRows }; } @@ -551,19 +540,18 @@ public class BmsProductServiceImpl implements IBmsProductService } productMapper.expireOpenByProductCode(product.getProductCode(), newEff, product.getProductId()); productMapper.refreshStatusByDates(); - int countryRows = saveCountriesVersioned(product, countries); + int countryRows = saveCountries(product, countries); return new int[] { 1, 0, countryRows }; } + /** - * Versioned country save: - * - require effective_date - * - newEff > last open: expire previous version (expire_date = newEff), create new version, - * copy previous country rows, then match import (hit=update, miss=insert) - * - newEff equals last open: reuse open version, match update/insert (no full replace) + * Save country rows by effective_date: + * - newEff > last open: expire previous open rows, copy them to newEff, then match import (hit=update, miss=insert) + * - newEff equals last open: match update/insert on open rows * - newEff < last open: reject */ - private int saveCountriesVersioned(BmsProduct product, List countries) + private int saveCountries(BmsProduct product, List countries) { if (product == null || countries == null || countries.isEmpty()) { @@ -581,72 +569,36 @@ public class BmsProductServiceImpl implements IBmsProductService throw new ServiceException(MessageUtils.message("price.product.import.effEmpty")); } - BmsProductPriceVersion openVer = priceVersionMapper.selectOpenByProductCode(productCode); - Date lastOpenEff = openVer != null ? toDateOnly(openVer.getEffectiveDate()) - : toDateOnly(countryMapper.selectMaxOpenEffectiveDate(productCode)); - + Date lastOpenEff = toDateOnly(countryMapper.selectMaxOpenEffectiveDate(productCode)); if (lastOpenEff != null && newEff.before(lastOpenEff)) { throw new ServiceException(MessageUtils.message("price.product.import.effTooEarly", formatDate(newEff), formatDate(lastOpenEff))); } - BmsProductPriceVersion targetVer; boolean newVersionDay = lastOpenEff == null || newEff.after(lastOpenEff); - - if (newVersionDay) + if (newVersionDay && lastOpenEff != null) { - List prevSnapshot = null; - Long srcPpvId = openVer != null ? openVer.getPpvId() : null; - if (lastOpenEff != null) - { - if (srcPpvId != null) - { - prevSnapshot = null; // copy via SQL by ppv_id after expire - } - else - { - prevSnapshot = countryMapper.selectOpenByProductCode(productCode); - } - priceVersionMapper.expireOpenByProductCode(productCode, newEff); - countryMapper.expireOpenByProductCode(productCode, newEff); - } - targetVer = createPriceVersion(product, newEff); String newStatus = resolveStoredStatus(newEff, null); - if (srcPpvId != null) - { - countryMapper.copyCountriesFromVersion(srcPpvId, targetVer.getPpvId(), productId, - productCode, newEff, newStatus); - } - else if (prevSnapshot != null && !prevSnapshot.isEmpty()) - { - insertCountryCopies(prevSnapshot, targetVer.getPpvId(), productId, productCode, newEff, newStatus); - } - } - else - { - targetVer = priceVersionMapper.selectByProductCodeAndEffectiveDate(productCode, newEff); - if (targetVer == null) - { - targetVer = openVer != null ? openVer : createPriceVersion(product, newEff); - } - else if (targetVer.getProductId() == null && productId != null) - { - targetVer.setProductId(productId); - targetVer.setUpdateBy(product.getUpdateBy()); - priceVersionMapper.updateBmsProductPriceVersion(targetVer); - } - assignOpenRowsToVersion(productCode, targetVer.getPpvId()); + // Copy open rows first (effective_date < newEff), then expire the previous open set. + countryMapper.copyOpenCountries(productCode, productId, newEff, newStatus); + countryMapper.expireOpenByProductCode(productCode, newEff); } - List baseRows = countryMapper.selectByPpvId(targetVer.getPpvId()); + List baseRows = countryMapper.selectOpenByProductCode(productCode); if (baseRows == null) { baseRows = new ArrayList<>(); } + // keep only rows for this effective date when same-day / after copy Map byKey = new HashMap<>(); for (BmsProductCountry row : baseRows) { + Date rowEff = toDateOnly(row.getEffectiveDate()); + if (rowEff != null && !rowEff.equals(newEff)) + { + continue; + } byKey.put(countryMatchKey(row), row); } @@ -655,7 +607,6 @@ public class BmsProductServiceImpl implements IBmsProductService { incoming.setProductId(productId); incoming.setProductCode(productCode); - incoming.setPpvId(targetVer.getPpvId()); incoming.setEffectiveDate(newEff); incoming.setExpireDate(null); incoming.setStatus(resolveStoredStatus(newEff, null)); @@ -667,7 +618,6 @@ public class BmsProductServiceImpl implements IBmsProductService if (existing != null) { existing.setProductId(productId); - existing.setPpvId(targetVer.getPpvId()); existing.setCountryCode(incoming.getCountryCode()); existing.setZoneId(incoming.getZoneId()); existing.setZoneCode(incoming.getZoneCode()); @@ -698,10 +648,6 @@ public class BmsProductServiceImpl implements IBmsProductService { throw new ServiceException(MessageUtils.message("price.product.import.needFeeAlter")); } - if (tip.contains("ppv_id") || tip.contains("bms_product_price_version")) - { - throw new ServiceException(MessageUtils.message("price.product.import.needVersionAlter")); - } if (tip.contains("expire_date") || tip.contains("uk_product_country_weight") || tip.contains("uk_product_country_zone_weight")) { @@ -711,76 +657,9 @@ public class BmsProductServiceImpl implements IBmsProductService } } countryMapper.refreshStatusByDates(); - priceVersionMapper.refreshStatusByDates(); return touched; } - private BmsProductPriceVersion createPriceVersion(BmsProduct product, Date effectiveDate) - { - Integer maxSeq = priceVersionMapper.selectMaxVersionSeq(product.getProductCode()); - int seq = maxSeq == null ? 1 : maxSeq.intValue() + 1; - BmsProductPriceVersion ver = new BmsProductPriceVersion(); - ver.setProductCode(product.getProductCode()); - ver.setProductId(product.getProductId()); - ver.setVersionSeq(Integer.valueOf(seq)); - ver.setVersionNo("V" + seq); - ver.setEffectiveDate(effectiveDate); - ver.setExpireDate(null); - ver.setStatus(resolveStoredStatus(effectiveDate, null)); - ver.setCreateBy(product.getCreateBy() != null ? product.getCreateBy() : product.getUpdateBy()); - priceVersionMapper.insertBmsProductPriceVersion(ver); - return ver; - } - - /** After expire, insert in-memory previous open rows into the new version */ - private void insertCountryCopies(List prevSnapshot, Long newPpvId, Long productId, - String productCode, Date newEff, String status) - { - for (BmsProductCountry src : prevSnapshot) - { - BmsProductCountry copy = new BmsProductCountry(); - copy.setProductId(productId); - copy.setPpvId(newPpvId); - copy.setProductCode(productCode); - copy.setCountryName(src.getCountryName()); - copy.setCountryCode(src.getCountryCode()); - copy.setZoneId(src.getZoneId()); - copy.setZoneCode(src.getZoneCode()); - copy.setZoneName(src.getZoneName()); - copy.setWeightMin(src.getWeightMin()); - copy.setWeightMax(src.getWeightMax()); - copy.setFreightPrice(src.getFreightPrice()); - copy.setRegistrationFee(src.getRegistrationFee()); - copy.setSizeLimit(src.getSizeLimit()); - copy.setLastMile(src.getLastMile()); - copy.setLeadTime(src.getLeadTime()); - copy.setEffectiveDate(newEff); - copy.setExpireDate(null); - copy.setStatus(status); - countryMapper.insertBmsProductCountry(copy); - } - } - - private void assignOpenRowsToVersion(String productCode, Long ppvId) - { - if (ppvId == null) - { - return; - } - List openRows = countryMapper.selectOpenByProductCode(productCode); - if (openRows == null) - { - return; - } - for (BmsProductCountry row : openRows) - { - if (row.getPpvId() == null) - { - countryMapper.updatePpvId(row.getDetailId(), ppvId); - } - } - } - /** Match key: country + zone + weight band */ private String countryMatchKey(BmsProductCountry row) { @@ -912,7 +791,7 @@ public class BmsProductServiceImpl implements IBmsProductService { BmsProduct p = new BmsProduct(); p.setProductCode(productCode); - saveCountriesVersioned(p, countries); + saveCountries(p, countries); } private List parseCatalog(Sheet sheet) @@ -1936,7 +1815,7 @@ public class BmsProductServiceImpl implements IBmsProductService if (existing != null) { product.setProductId(existing.getProductId()); - int countryRows = saveCountriesVersioned(product, countries); + int countryRows = saveCountries(product, countries); return new int[] { 0, 1, countryRows }; } applyProductStatus(product); @@ -1954,7 +1833,7 @@ public class BmsProductServiceImpl implements IBmsProductService } productMapper.expireOpenByProductCode(product.getProductCode(), newEff, product.getProductId()); productMapper.refreshStatusByDates(); - int countryRows = saveCountriesVersioned(product, countries); + int countryRows = saveCountries(product, countries); return new int[] { 1, 0, countryRows }; } diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java index ff036422..f478d539 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcOrderBillServiceImpl.java @@ -187,7 +187,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService PrcIncomeBill incomeBill = incomeBillMapper.selectByBillId(bill.getBillId()); if (incomeBill == null) { - incomeBill = persistIncomeBill(bill); + incomeBill = persistIncomeBill(bill, null); } PrcIncomeBillFee refundFee = new PrcIncomeBillFee(); @@ -854,7 +854,12 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService bill.setFreightAmount(result.getFreightAmount()); bill.setSurchargeAmount(result.getSurchargeAmount()); bill.setIncomeTotal(result.getPayableTotal()); - bill.setPayTotal(result.getPayTotal() == null ? BigDecimal.ZERO : result.getPayTotal()); + BigDecimal payTotal = result.getPayTotal(); + if (payTotal == null) + { + payTotal = result.getProductAmount(); + } + bill.setPayTotal(payTotal == null ? BigDecimal.ZERO : payTotal); bill.setCurrency(result.getCurrency()); bill.setRoundMode(result.getRoundMode()); // Credit soft-fail before persist so insert/update stores arrears flag in one write. @@ -883,7 +888,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService incomeBillFeeMapper.deleteByBillId(bill.getBillId()); payBillFeeMapper.deleteByBillId(bill.getBillId()); } - PrcIncomeBill incomeBill = persistIncomeBill(bill); + PrcIncomeBill incomeBill = persistIncomeBill(bill, result); List fees = toFeeRows(bill.getBillId(), incomeBill == null ? null : incomeBill.getIncomeBillId(), result); if (!fees.isEmpty()) @@ -891,7 +896,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService incomeBillFeeMapper.insertBatch(fees); } orderBillMapper.refreshArBillStatusByBillIds(Arrays.asList(bill.getBillId())); - PrcPayBill payBill = persistPayBill(bill); + PrcPayBill payBill = persistPayBill(bill, result); List payFees = toPayFeeRows(bill.getBillId(), payBill == null ? null : payBill.getPayBillId(), result); if (!payFees.isEmpty()) @@ -1101,8 +1106,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService return fees; } - /** 应收主表与订单计费一对一落库;当前写入销售价/应收合计,产品价/红线价预留。 */ - private PrcIncomeBill persistIncomeBill(PrcOrderBill bill) + /** 应收主表与订单计费一对一落库;销售价=套餐计费,产品价=产品目录价;红线价预留。 */ + private PrcIncomeBill persistIncomeBill(PrcOrderBill bill, TmsPriceQuoteResult result) { if (bill == null || StringUtils.isEmpty(bill.getBillId())) { @@ -1118,7 +1123,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService row.setCreateBy(bill.getCreateBy()); } row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency()); - // 产品价/红线价预留 + // 产品价=目录价;红线价预留 + row.setProductAmount(result == null ? null : result.getProductAmount()); row.setSalesAmount(sales); row.setIncomeTotal(sales); row.setBelongSaler(bill.getBelongSaler()); @@ -1163,8 +1169,8 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService return fees; } - /** 应付主表与订单计费一对一落库;当前写入成本价/应付合计,产品价/红线价预留。 */ - private PrcPayBill persistPayBill(PrcOrderBill bill) + /** 应付主表与订单计费一对一落库;成本价/应付=产品目录价,同步写入 product_amount;红线价预留。 */ + private PrcPayBill persistPayBill(PrcOrderBill bill, TmsPriceQuoteResult result) { if (bill == null || StringUtils.isEmpty(bill.getBillId())) { @@ -1180,7 +1186,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService row.setCreateBy(bill.getCreateBy()); } row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency()); - // 产品价/红线价预留 + // 产品价/成本价=目录价;红线价预留 + BigDecimal product = result == null ? null : result.getProductAmount(); + row.setProductAmount(product); row.setCostAmount(pay); row.setPayTotal(pay); row.setBelongSaler(bill.getBelongSaler()); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcPriceSetServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcPriceSetServiceImpl.java index 1c9d0fb3..c49a46f7 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcPriceSetServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PrcPriceSetServiceImpl.java @@ -577,7 +577,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService for (PrcPriceSetDetail d : details) { boolean noCountry = StringUtils.isEmpty(d.getCountryCode()) && StringUtils.isEmpty(d.getCountryName()); - // 运费单价 / 挂号费不参与完整性校验:原基础表 bms_product_country 可能没有值, + // 运费单价 / 挂号费不参与完整性校验:原基础表 product_country 可能没有值, // 留空表示该条明细不覆盖该项,计费回退产品默认价(见 TmsPriceQuoteServiceImpl.tryFixed)。 if (StringUtils.isEmpty(d.getProductCode()) || noCountry || (d.getWsdId() == null && StringUtils.isEmpty(d.getWeightLabel()))) @@ -588,7 +588,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService if (details.isEmpty()) { items.add(new PrcPriceSetCheckItem("FIXED 明细完整性", "PASS", - "\u65e0\u5957\u9910\u660e\u7ec6\uff1a\u8ba1\u8d39\u53d6 bms_product / bms_product_country \u9ed8\u8ba4\u8fd0\u8d39\u4e0e\u6302\u53f7\u8d39")); + "\u65e0\u5957\u9910\u660e\u7ec6\uff1a\u8ba1\u8d39\u53d6 product / product_country \u9ed8\u8ba4\u8fd0\u8d39\u4e0e\u6302\u53f7\u8d39")); } else if (incomplete > 0) { @@ -673,11 +673,11 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService if (TYPE_FIXED.equals(setType) && !details.isEmpty()) { - items.add(new PrcPriceSetCheckItem("\u8fd0\u8d39\u5355\u4ef7 vs \u9ed8\u8ba4\u7b49\u7ea7\u4ef7\u504f\u5dee", "INFO", "\u6709\u8986\u76d6\u660e\u7ec6\u65f6\u4f18\u5148\u53d6\u5957\u9910\u56fa\u5b9a\u4ef7\uff1b\u672a\u547d\u4e2d\u5219\u56de\u9000 bms_product_country")); + items.add(new PrcPriceSetCheckItem("\u8fd0\u8d39\u5355\u4ef7 vs \u9ed8\u8ba4\u7b49\u7ea7\u4ef7\u504f\u5dee", "INFO", "\u6709\u8986\u76d6\u660e\u7ec6\u65f6\u4f18\u5148\u53d6\u5957\u9910\u56fa\u5b9a\u4ef7\uff1b\u672a\u547d\u4e2d\u5219\u56de\u9000 product_country")); } else if (TYPE_FIXED.equals(setType)) { - items.add(new PrcPriceSetCheckItem("\u8fd0\u8d39\u5355\u4ef7 vs \u9ed8\u8ba4\u7b49\u7ea7\u4ef7\u504f\u5dee", "INFO", "\u65e0\u5957\u9910\u660e\u7ec6\uff0c\u5168\u90e8\u8d70 bms_product_country \u9ed8\u8ba4\u8fd0\u8d39/\u6302\u53f7\u8d39")); + items.add(new PrcPriceSetCheckItem("\u8fd0\u8d39\u5355\u4ef7 vs \u9ed8\u8ba4\u7b49\u7ea7\u4ef7\u504f\u5dee", "INFO", "\u65e0\u5957\u9910\u660e\u7ec6\uff0c\u5168\u90e8\u8d70 product_country \u9ed8\u8ba4\u8fd0\u8d39/\u6302\u53f7\u8d39")); } else if (TYPE_DISCOUNT.equals(setType)) { @@ -1337,7 +1337,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService { throw new ServiceException(MessageUtils.message("price.set.detail.weight.empty")); } - // 运费单价 / 挂号费不做必填校验:原基础表 bms_product_country 可能没有值, + // 运费单价 / 挂号费不做必填校验:原基础表 product_country 可能没有值, // 前端对应单元格会禁用(PriceEditDrawer.isBaseMissing)。 // 任一为空时该条明细不参与覆盖,计费按「未命中」回退产品默认价 // (见 TmsPriceQuoteServiceImpl.tryFixed)。 @@ -1466,7 +1466,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService } /** - * Resolve / verify product_country_id from bms_product_country when missing. + * Resolve / verify product_country_id from product_country when missing. */ private void fillProductCountryId(PrcPriceSetDetail detail) { @@ -2100,17 +2100,17 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService if (TYPE_DISCOUNT.equals(set.getSetType())) { inserted = detailMapper.insertDiscountDetailsFromLibrary( - set.getPriceSetId(), version.getPsvId(), null); + set.getPriceSetId(), version.getPsvId()); } else { // Prefer currently effective open country rows; fallback asOf window if needed inserted = detailMapper.insertFixedDetailsFromLibrary( - set.getPriceSetId(), version.getPsvId(), null, true, null); + set.getPriceSetId(), version.getPsvId(), null, true); if (inserted <= 0) { inserted = detailMapper.insertFixedDetailsFromLibrary( - set.getPriceSetId(), version.getPsvId(), new Date(), false, null); + set.getPriceSetId(), version.getPsvId(), new Date(), false); } } if (inserted <= 0) diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/TmsPriceQuoteServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/TmsPriceQuoteServiceImpl.java index 0458a81c..ebc12184 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/TmsPriceQuoteServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/TmsPriceQuoteServiceImpl.java @@ -645,9 +645,35 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService r.setCurrency("CNY"); r.setRoundMode(mode); r.setFromCache(false); + fillProductAmountAndPay(r, base, weight, rm, mode); return r; } + /** + * Product catalog amount (product_amount) and payable cost (pay_total / payFeeDetails). + * Formula: product_country.freight_price * weight + registration_fee. + * Cost currently equals product catalog amount (no separate cost table yet). + */ + private void fillProductAmountAndPay(TmsPriceQuoteResult r, BmsProductCountry base, + BigDecimal weight, RoundingMode rm, String roundMode) + { + if (r == null || base == null || weight == null || base.getFreightPrice() == null) + { + return; + } + BigDecimal baseReg = base.getRegistrationFee() == null ? BigDecimal.ZERO : base.getRegistrationFee(); + BigDecimal productFreight = base.getFreightPrice().multiply(weight).setScale(2, rm); + BigDecimal productAmount = productFreight.add(baseReg).setScale(2, rm); + r.setProductAmount(productAmount); + r.setCostAmount(productAmount); + r.setPayTotal(productAmount); + String currency = normalizeCurrency(r.getCurrency()); + List payLines = new ArrayList(); + payLines.add(feeLine(FEE_BASIC, feeNameOf(FEE_BASIC), 0L, productFreight, currency, roundMode, null)); + payLines.add(feeLine(FEE_REG, feeNameOf(FEE_REG), 0L, baseReg, currency, roundMode, null)); + r.setPayFeeDetails(payLines); + } + private void applySurchargesAndFees(TmsPriceQuoteResult result) { BigDecimal freightAmount = nvl(result.getFreightAmount()); @@ -691,6 +717,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService surchargeTotal = surchargeTotal.setScale(2, rm); result.setSurchargeAmount(surchargeTotal); result.setPayableTotal(freightAmount.add(registrationFee).add(surchargeTotal).setScale(2, rm)); + result.setIncomeTotal(result.getPayableTotal()); result.setFeeDetails(lines); } @@ -839,6 +866,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService quote.setFreightAmount(result.getFreightAmount()); quote.setSurchargeAmount(result.getSurchargeAmount()); quote.setPayableTotal(result.getPayableTotal()); + quote.setProductAmount(result.getProductAmount()); + quote.setRedlineAmount(result.getRedlineAmount()); + quote.setCostAmount(result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount()); + quote.setPayTotal(result.getPayTotal() != null ? result.getPayTotal() : result.getProductAmount()); quote.setCurrency(result.getCurrency()); quote.setRoundMode(result.getRoundMode()); try @@ -901,7 +932,10 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService { quoteFeeMapper.insertBatch(fees); } - quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal()); + BigDecimal cost = result.getCostAmount() != null ? result.getCostAmount() : result.getProductAmount(); + BigDecimal pay = result.getPayTotal() != null ? result.getPayTotal() : cost; + quoteMapper.updateQuoteAmounts(quoteId, result.getSurchargeAmount(), result.getPayableTotal(), + result.getProductAmount(), cost, pay); } private List toFeeRows(String quoteId, TmsPriceQuoteResult result) @@ -962,6 +996,11 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService r.setFreightAmount(quote.getFreightAmount()); r.setSurchargeAmount(quote.getSurchargeAmount()); r.setPayableTotal(quote.getPayableTotal()); + r.setProductAmount(quote.getProductAmount()); + r.setRedlineAmount(quote.getRedlineAmount()); + r.setCostAmount(quote.getCostAmount()); + r.setPayTotal(quote.getPayTotal()); + r.setIncomeTotal(quote.getPayableTotal()); r.setCurrency(normalizeCurrency(quote.getCurrency())); r.setRoundMode(quote.getRoundMode()); List lines = new ArrayList(); @@ -1013,9 +1052,15 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService to.setFreightAmount(from.getFreightAmount()); to.setSurchargeAmount(from.getSurchargeAmount()); to.setPayableTotal(from.getPayableTotal()); + to.setProductAmount(from.getProductAmount()); + to.setRedlineAmount(from.getRedlineAmount()); + to.setCostAmount(from.getCostAmount()); + to.setIncomeTotal(from.getIncomeTotal()); + to.setPayTotal(from.getPayTotal()); to.setCurrency(from.getCurrency()); to.setRoundMode(from.getRoundMode()); to.setFeeDetails(from.getFeeDetails()); + to.setPayFeeDetails(from.getPayFeeDetails()); } private String buildQuoteKey(TmsPriceQuoteRequest request, BigDecimal weight, Date bizDate) diff --git a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductCountryMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/BmsProductCountryMapper.xml index 0b5797bb..40438f88 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductCountryMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/BmsProductCountryMapper.xml @@ -7,8 +7,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - @@ -31,13 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select c.detail_id, c.product_id, c.ppv_id, v.version_no, c.product_code, c.country_name, c.country_code, + select c.detail_id, c.product_id, c.product_code, c.country_name, c.country_code, c.zone_id, c.zone_code, c.zone_name, c.weight_min, c.weight_max, c.freight_price, c.registration_fee, c.size_limit, c.last_mile, c.lead_time, c.effective_date, c.expire_date, c.status, c.create_time, c.update_time - from bms_product_country c - left join bms_product_price_version v on v.ppv_id = c.ppv_id + from product_country c - insert into bms_product_country ( - product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name, + insert into product_country ( + product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name, weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time, effective_date, expire_date, status, create_time ) values ( - #{productId}, #{ppvId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName}, + #{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName}, #{weightMin}, #{weightMax}, #{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime}, #{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate() ) - + - update bms_product_country + update product_country set weight_min = #{weightMin}, weight_max = #{weightMax}, freight_price = #{freightPrice}, @@ -118,9 +112,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bms_product_country + update product_country set product_id = #{productId}, - ppv_id = #{ppvId}, country_code = #{countryCode}, zone_id = #{zoneId}, zone_code = #{zoneCode}, @@ -139,30 +132,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where detail_id = #{detailId} - - update bms_product_country - set ppv_id = #{ppvId}, - update_time = sysdate() - where detail_id = #{detailId} - - - delete from bms_product_country where product_id = #{productId} + delete from product_country where product_id = #{productId} - delete from bms_product_country where product_code = #{productCode} + delete from product_country where product_code = #{productCode} - delete from bms_product_country where product_code in + delete from product_country where product_code in #{code} - delete from bms_product_country + delete from product_country where product_code = #{productCode} and ( (#{effectiveDate} is null and effective_date is null) @@ -171,13 +157,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bms_product_country + update product_country set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} @@ -186,7 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bms_product_country + update product_country set status = case when expire_date is not null and expire_date <= curdate() then '2' when effective_date is null or effective_date > curdate() then '0' @@ -195,7 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from bms_product_country + delete from product_country where product_code = #{productCode} and expire_date is null and ( @@ -241,7 +227,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - insert into bms_product_country ( - product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name, + + insert into product_country ( + product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name, weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time, effective_date, expire_date, status, create_time ) select - #{productId}, #{newPpvId}, #{productCode}, country_name, country_code, zone_id, zone_code, zone_name, + #{productId}, product_code, country_name, country_code, zone_id, zone_code, zone_name, weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time, #{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate() - from bms_product_country - where ppv_id = #{srcPpvId} - order by detail_id asc - - - - insert into bms_product_country ( - product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name, - weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time, - effective_date, expire_date, status, create_time - ) - select - #{productId}, #{newPpvId}, product_code, country_name, country_code, zone_id, zone_code, zone_name, - weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time, - #{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate() - from bms_product_country + from product_country where product_code = #{productCode} and expire_date is null + and (effective_date is null or effective_date < #{effectiveDate}) order by detail_id asc diff --git a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/BmsProductMapper.xml index 059fcdeb..392edde0 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/BmsProductMapper.xml @@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr, p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status, p.source_sheet, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time, - (select count(distinct c.country_name) from bms_product_country c + (select count(distinct c.country_name) from product_country c where c.product_id = p.product_id or (c.product_id is null and c.product_code = p.product_code and ( @@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" )) ) as country_count, (select count(*) from prc_surcharge_rel r where r.product_id = p.product_id) as surcharge_count - from bms_product p + from product p - insert into bms_product ( + insert into product ( product_code, product_name, service_level, @@ -163,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bms_product + update product product_code = #{productCode}, product_name = #{productName}, @@ -185,14 +185,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from bms_product where product_id in + delete from product where product_id in #{productId} - update bms_product + update product set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} @@ -204,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update bms_product + update product set status = case when expire_date is not null and expire_date <= curdate() then '2' when effective_date is null or effective_date > curdate() then '0' diff --git a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductPriceVersionMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/BmsProductPriceVersionMapper.xml deleted file mode 100644 index e0fa01fa..00000000 --- a/bms-back/bms-system/src/main/resources/mapper/price/BmsProductPriceVersionMapper.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - select ppv_id, product_code, product_id, version_no, version_seq, - effective_date, expire_date, status, - created_by, create_time, updated_by, update_time - from bms_product_price_version - - - - - - - - - - - - - - insert into bms_product_price_version ( - product_code, product_id, version_no, version_seq, - effective_date, expire_date, status, created_by, create_time - ) values ( - #{productCode}, #{productId}, #{versionNo}, #{versionSeq}, - #{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), #{createBy}, sysdate() - ) - - - - update bms_product_price_version - - product_id = #{productId}, - version_no = #{versionNo}, - version_seq = #{versionSeq}, - effective_date = #{effectiveDate}, - expire_date = #{expireDate}, - status = #{status}, - updated_by = #{updateBy}, - update_time = sysdate() - - where ppv_id = #{ppvId} - - - - update bms_product_price_version - set expire_date = #{newEffectiveDate}, - update_time = sysdate() - where product_code = #{productCode} - and expire_date is null - and (effective_date is null or effective_date < #{newEffectiveDate}) - - - - update bms_product_price_version - set status = case - when expire_date is not null and expire_date <= curdate() then '2' - when effective_date is null or effective_date > curdate() then '0' - else '1' - end - - - diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetDetailMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetDetailMapper.xml index c0fa26ca..e6d4939a 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetDetailMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcPriceSetDetailMapper.xml @@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" c.registration_fee as base_registration_fee, d.discount_value, d.round_mode, d.pr_id, d.effective_date, d.expire_date, d.create_time, d.update_time from prc_price_set_detail d - left join bms_product_country c on c.detail_id = d.product_country_id + left join product_country c on c.detail_id = d.product_country_id AND d.price_set_id = #{priceSetId} @@ -161,21 +161,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" c.effective_date, c.expire_date, sysdate() - from bms_product_country c - inner join bms_product p on p.product_id = c.product_id + from product_country c + inner join product p on p.product_id = c.product_id - - - and exists ( - select 1 from bms_product_price_version v - where v.ppv_id = c.ppv_id - and v.version_no = #{baseVersionNo} - ) - - and p.status = '1' and p.product_id = ( - select max(p2.product_id) from bms_product p2 + select max(p2.product_id) from product p2 where p2.product_code = p.product_code and p2.status = '1' ) and ifnull(c.status, '1') <> '2' @@ -189,9 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and (c.expire_date is null or date(c.expire_date) > date(#{asOf})) - - - + order by p.product_code asc, c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc @@ -206,26 +195,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" p.product_name, 'HALF_UP', sysdate() - from bms_product p + from product p - - - and exists ( - select 1 from bms_product_country c - inner join bms_product_price_version v on v.ppv_id = c.ppv_id - where c.product_id = p.product_id - and v.version_no = #{baseVersionNo} - ) - - and p.status = '1' and p.product_id = ( - select max(p2.product_id) from bms_product p2 + select max(p2.product_id) from product p2 where p2.product_code = p.product_code and p2.status = '1' ) - - - + order by p.product_code asc diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcQuoteMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcQuoteMapper.xml index f0000cae..349a666c 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcQuoteMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcQuoteMapper.xml @@ -38,6 +38,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + @@ -53,7 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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, + freight_amount, surcharge_amount, payable_total, + product_amount, redline_amount, cost_amount, pay_total, currency, round_mode, created_by, create_time, updated_by, update_time from prc_quote @@ -113,7 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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, + freight_amount, surcharge_amount, payable_total, + product_amount, redline_amount, cost_amount, pay_total, currency, round_mode, create_time ) values ( #{quoteId}, #{quoteKey}, #{customerId}, #{customerCode}, #{productCode}, #{productName}, @@ -122,7 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId}, #{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight}, #{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee}, - #{freightAmount}, #{surchargeAmount}, #{payableTotal}, #{currency}, #{roundMode}, + #{freightAmount}, #{surchargeAmount}, #{payableTotal}, + #{productAmount}, #{redlineAmount}, #{costAmount}, #{payTotal}, #{currency}, #{roundMode}, sysdate() ) @@ -131,6 +138,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update prc_quote set surcharge_amount = #{surchargeAmount}, payable_total = #{payableTotal}, + product_amount = #{productAmount}, + cost_amount = #{costAmount}, + pay_total = #{payTotal}, update_time = sysdate() where quote_id = #{quoteId} diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeRelMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeRelMapper.xml index 09666969..a6736928 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeRelMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeRelMapper.xml @@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" c.country_name, c.weight_min, c.weight_max from prc_surcharge_rel r join prc_surcharge s on s.sc_id = r.sc_id - left join bms_product_country c on c.detail_id = r.detail_id + left join product_country c on c.detail_id = r.detail_id