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 686b4f02..bb8b5bf7 100644 --- a/bms-back/bms-admin/src/main/resources/i18n/messages.properties +++ b/bms-back/bms-admin/src/main/resources/i18n/messages.properties @@ -112,6 +112,7 @@ price.zone.countryCode.empty=国家编码不能为空,请检查 region.country # 产品导入 BmsProduct price.product.codeDate.exists=同一产品代码与生效日期已存在,不能覆盖历史数据 price.product.effectiveDate.empty=生效日期不能为空 +price.redline.delete.pendingOnly=仅待生效红线价可删除,以下不符合:{0} price.product.delete.pendingOnly=仅待生效产品可删除,以下不符合:{0} price.product.import.effEmpty=缺少生效日期,已跳过 price.product.import.effRequired=请选择生效时间 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 1d69272a..31cafbae 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 @@ -31,7 +31,12 @@ public class BmsProduct extends BaseEntity public static final String STATUS_PENDING = "0"; public static final String STATUS_ACTIVE = "1"; public static final String STATUS_EXPIRED = "2"; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; private String status; + /** 0未删除 1已删除 */ + private String isDel; private String sourceSheet; /** FK prc_price_excel_file.pef_id */ private Long pefId; 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 50573368..8564bedd 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 @@ -40,6 +40,10 @@ public class BmsProductCountry implements Serializable private Date expireDate; /** 0 pending, 1 active, 2 expired */ private String status; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; + private String isDel; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProduct.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProduct.java index 303a0166..3bef5d68 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProduct.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProduct.java @@ -31,7 +31,12 @@ public class BmsRedlineProduct extends BaseEntity public static final String STATUS_PENDING = "0"; public static final String STATUS_ACTIVE = "1"; public static final String STATUS_EXPIRED = "2"; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; private String status; + /** 0未删除 1已删除 */ + private String isDel; private String sourceSheet; /** FK prc_price_excel_file.pef_id */ private Long pefId; diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProductCountry.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProductCountry.java index 901a6ef7..99a6fd43 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProductCountry.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/BmsRedlineProductCountry.java @@ -38,6 +38,10 @@ public class BmsRedlineProductCountry implements Serializable private Date expireDate; /** 0 pending, 1 active, 2 expired */ private String status; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; + private String isDel; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") diff --git a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurcharge.java b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurcharge.java index c29d5c47..fc50125a 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurcharge.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/domain/PrcSurcharge.java @@ -24,6 +24,10 @@ public class PrcSurcharge extends BaseEntity private String roundMode; /** on / of */ private String ssCode; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; + private String isDel; private String countryCode; private String scNote; private Long tmsId; 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 13f32007..a73f8f3f 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 @@ -37,6 +37,10 @@ public class PrcSurchargeRel extends BaseEntity private String priceType; /** 适用国家ISO2(空=全部),rel 表字段 */ private String countryCode; + /** 0未删除 1已删除 */ + public static final String IS_DEL_NO = "0"; + public static final String IS_DEL_YES = "1"; + private String isDel; /** 附加费冗余展示字段 */ private String scName; 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 499c126f..96cbe5ae 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,10 +23,13 @@ public interface BmsProductCountryMapper /** Import overlay: update price/zone/attrs on matched country row */ public int updateBmsProductCountryImport(BmsProductCountry country); + /** Soft delete by product_id */ public int deleteByProductId(Long productId); + /** Soft delete by product_code */ public int deleteByProductCode(String productCode); + /** Soft delete by product_code + effective_date */ public int deleteByProductCodeAndEffectiveDate( @Param("productCode") String productCode, @Param("effectiveDate") Date effectiveDate); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductMapper.java index 5321b3d7..d337e1f8 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsProductMapper.java @@ -31,6 +31,7 @@ public interface BmsProductMapper public int updateBmsProduct(BmsProduct product); + /** Soft delete: set del_flag = 2 */ public int deleteBmsProductByIds(Long[] productIds); /** Close previous open versions: expire_date = newEffectiveDate */ diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductCountryMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductCountryMapper.java index 3df6d950..0f01c5a3 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductCountryMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductCountryMapper.java @@ -39,6 +39,11 @@ public interface BmsRedlineProductCountryMapper @Param("productCode") String productCode, @Param("newEffectiveDate") Date newEffectiveDate); + /** After deleting a pending version: reopen rows closed at that effective date */ + public int reopenExpiredByProductCodeAndExpireDate( + @Param("productCode") String productCode, + @Param("expireDate") Date expireDate); + /** * Close open rows for one product + country where effective_date < newEffectiveDate. * Match by country_code when present, otherwise country_name. diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductMapper.java index be5f243c..b9a63ab1 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/BmsRedlineProductMapper.java @@ -39,6 +39,11 @@ public interface BmsRedlineProductMapper @Param("newEffectiveDate") Date newEffectiveDate, @Param("excludeId") Long excludeId); + /** After deleting a pending version: reopen rows closed at that effective date */ + public int reopenExpiredByProductCodeAndExpireDate( + @Param("productCode") String productCode, + @Param("expireDate") Date expireDate); + /** 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/service/impl/BmsRedlineProductServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsRedlineProductServiceImpl.java index a4eafd0a..6a951a0f 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsRedlineProductServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/BmsRedlineProductServiceImpl.java @@ -174,6 +174,9 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService { return 0; } + List deletableIds = new ArrayList(); + List notPendingTips = new ArrayList(); + List toReopen = new ArrayList(); List relProductIds = new ArrayList(); for (Long id : productIds) { @@ -182,19 +185,51 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService { continue; } + String liveStatus = resolveStoredStatus(p.getEffectiveDate(), p.getExpireDate()); + if (!BmsRedlineProduct.STATUS_PENDING.equals(liveStatus)) + { + String tip = p.getProductCode(); + if (p.getEffectiveDate() != null) + { + tip = tip + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(p.getEffectiveDate()) + ")"; + } + notPendingTips.add(tip); + continue; + } if (p.getProductId() != null) { countryMapper.deleteByProductId(p.getProductId()); relProductIds.add(p.getProductId()); } countryMapper.deleteByProductCodeAndEffectiveDate(p.getProductCode(), p.getEffectiveDate()); + deletableIds.add(p.getProductId()); + if (p.getEffectiveDate() != null) + { + toReopen.add(p); + } + } + if (!notPendingTips.isEmpty()) + { + throw new ServiceException(MessageUtils.message("price.redline.delete.pendingOnly", + String.join("\u3001", notPendingTips))); + } + if (deletableIds.isEmpty()) + { + return 0; } if (!relProductIds.isEmpty()) { - // REDLINE rels bind redline_product.product_id (not shared with product catalog) surchargeRelMapper.deleteByProductIdsAndPriceType(relProductIds, PrcSurchargeRel.PRICE_TYPE_REDLINE); } - return productMapper.deleteBmsRedlineProductByIds(productIds); + int rows = productMapper.deleteBmsRedlineProductByIds(deletableIds.toArray(new Long[0])); + for (BmsRedlineProduct p : toReopen) + { + productMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate()); + countryMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate()); + } + productMapper.refreshStatusByDates(); + countryMapper.refreshStatusByDates(); + return rows; } @Override 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 5d1b4ed5..3793251f 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 @@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -33,13 +34,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 + c.effective_date, c.expire_date, c.status, c.is_del, c.create_time, c.update_time from product_country c select max(effective_date) from product_country where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null @@ -167,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and (effective_date is null or effective_date < #{newEffectiveDate}) @@ -176,6 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set expire_date = null, update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date = #{expireDate} @@ -184,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and (effective_date is null or effective_date < #{newEffectiveDate}) @@ -203,21 +220,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" when effective_date is null or effective_date > now() then '0' else '1' end + where ifnull(is_del, '0') = '0' - - delete from product_country + + update product_country + set is_del = '1', update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and ( (#{effectiveDate} is null and effective_date is null) or effective_date = #{effectiveDate} ) - + - - delete from product_country + + update product_country + set is_del = '1', update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and ( (#{effectiveDate} is null and effective_date is null) @@ -231,11 +253,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and country_name = #{countryName} - + where c.product_code = #{productCode} + and ifnull(c.is_del, '0') = '0' and c.expire_date is null order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc @@ -304,14 +329,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 + effective_date, expire_date, status, is_del, create_time ) select #{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() + #{effectiveDate}, null, IFNULL(#{status}, '0'), '0', sysdate() from product_country where product_code = #{productCode} + and ifnull(is_del, '0') = '0' 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 ce32e527..46159be8 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 @@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -30,28 +31,34 @@ 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.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status, p.is_del, p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time, (select count(distinct c.country_name) from product_country c - where c.product_id = p.product_id + where ifnull(c.is_del, '0') = '0' + and (c.product_id = p.product_id or (c.product_id is null and c.product_code = p.product_code and ( (p.effective_date is null and c.effective_date is null) or c.effective_date = p.effective_date - )) + ))) ) as country_count, - (select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'PRODUCT') as surcharge_count + (select count(*) from prc_surcharge_rel r + inner join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0' + where ifnull(r.is_del, '0') = '0' + and r.product_id = p.product_id and r.price_type = 'PRODUCT') as surcharge_count from product p @@ -59,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where p.product_code = #{productCode} + and ifnull(p.is_del, '0') = '0' and (p.effective_date is null or #{bizDate} is null or p.effective_date <= #{bizDate}) and (p.expire_date is null or #{bizDate} is null or p.expire_date > #{bizDate}) order by p.effective_date desc, p.product_id desc @@ -82,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + and ifnull(c.is_del, '0') = '0' AND c.product_id = #{productId} @@ -85,12 +87,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 + effective_date, expire_date, status, is_del, create_time ) values ( #{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName}, #{weightMin}, #{weightMax}, #{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime}, - #{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate() + #{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), IFNULL(#{isDel}, '0'), sysdate() ) @@ -132,41 +134,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where detail_id = #{detailId} - - delete from redline_product_country where product_id = #{productId} - + + update redline_product_country + set is_del = '1', update_time = sysdate() + where product_id = #{productId} + and ifnull(is_del, '0') = '0' + - - delete from redline_product_country where product_code = #{productCode} - + + update redline_product_country + set is_del = '1', update_time = sysdate() + where product_code = #{productCode} + and ifnull(is_del, '0') = '0' + - - delete from redline_product_country where product_code in + + update redline_product_country + set is_del = '1', update_time = sysdate() + where ifnull(is_del, '0') = '0' + and product_code in #{code} - + - - delete from redline_product_country + + update redline_product_country + set is_del = '1', update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and ( (#{effectiveDate} is null and effective_date is null) or effective_date = #{effectiveDate} ) - + + + update redline_product_country + set expire_date = null, + update_time = sysdate() + where product_code = #{productCode} + and ifnull(is_del, '0') = '0' + and expire_date = #{expireDate} + + update redline_product_country set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and (effective_date is null or effective_date < #{newEffectiveDate}) @@ -176,6 +200,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" set expire_date = #{newEffectiveDate}, update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and (effective_date is null or effective_date < #{newEffectiveDate}) @@ -195,21 +220,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" when effective_date is null or effective_date > now() then '0' else '1' end + where ifnull(is_del, '0') = '0' - - delete from redline_product_country + + update redline_product_country + set is_del = '1', update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and ( (#{effectiveDate} is null and effective_date is null) or effective_date = #{effectiveDate} ) - + - - delete from redline_product_country + + update redline_product_country + set is_del = '1', update_time = sysdate() where product_code = #{productCode} + and ifnull(is_del, '0') = '0' and expire_date is null and ( (#{effectiveDate} is null and effective_date is null) @@ -223,11 +253,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and country_name = #{countryName} - + where c.product_code = #{productCode} + and ifnull(c.is_del, '0') = '0' and c.expire_date is null order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc @@ -296,14 +329,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" insert into redline_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 + effective_date, expire_date, status, is_del, create_time ) select #{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() + #{effectiveDate}, null, IFNULL(#{status}, '0'), '0', sysdate() from redline_product_country where product_code = #{productCode} + and ifnull(is_del, '0') = '0' 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/BmsRedlineProductMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/BmsRedlineProductMapper.xml index c1064d60..7ccf2a1b 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/BmsRedlineProductMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/BmsRedlineProductMapper.xml @@ -16,6 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -30,28 +31,34 @@ 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.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status, p.is_del, p.source_sheet, p.pef_id, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time, (select count(distinct c.country_name) from redline_product_country c - where c.product_id = p.product_id + where ifnull(c.is_del, '0') = '0' + and (c.product_id = p.product_id or (c.product_id is null and c.product_code = p.product_code and ( (p.effective_date is null and c.effective_date is null) or c.effective_date = p.effective_date - )) + ))) ) as country_count, - (select count(*) from prc_surcharge_rel r where r.product_id = p.product_id and r.price_type = 'REDLINE') as surcharge_count + (select count(*) from prc_surcharge_rel r + inner join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0' + where ifnull(r.is_del, '0') = '0' + and r.product_id = p.product_id and r.price_type = 'REDLINE') as surcharge_count from redline_product p @@ -59,6 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where p.product_code = #{productCode} + and ifnull(p.is_del, '0') = '0' and (p.effective_date is null or #{bizDate} is null or p.effective_date <= #{bizDate}) and (p.expire_date is null or #{bizDate} is null or p.expire_date > #{bizDate}) order by p.effective_date desc, p.product_id desc @@ -82,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeMapper.xml index 4fa82926..1799d99b 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PrcSurchargeMapper.xml @@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select sc_id, sc_name, fee_type, charge_type, charge_value, currency, round_mode, ss_code, + select sc_id, sc_name, fee_type, charge_type, charge_value, currency, round_mode, ss_code, is_del, country_code, sc_note, tms_id, created_by, create_time, updated_by, update_time from prc_surcharge @@ -31,11 +32,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + and ifnull(r.is_del, '0') = '0' AND r.product_id = #{productId} @@ -69,7 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"