diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcSurchargeRelMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcSurchargeRelMapper.java index 5280b65b..3e20c8cf 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcSurchargeRelMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PrcSurchargeRelMapper.java @@ -16,6 +16,9 @@ public interface PrcSurchargeRelMapper */ public List selectPrcSurchargeRelList(PrcSurchargeRel rel); + /** 按套餐版本查销售附加费关联(产品或明细) */ + public List selectSalesRelsByPsvId(@Param("psvId") Long psvId); + public List selectByDetailIdsAndPriceType( @Param("detailIds") List detailIds, @Param("priceType") String priceType); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/IPrcPriceSetService.java b/bms-back/bms-system/src/main/java/com/bms/price/service/IPrcPriceSetService.java index af2fc775..6611920f 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/IPrcPriceSetService.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/IPrcPriceSetService.java @@ -84,8 +84,8 @@ public interface IPrcPriceSetService public List selectDetailListByVersion(Long psvId); /** - * 版本明细搜索下拉选项:按版本去重后的 产品/国家/分区 列表。 - * 返回 { products: [{code,name}], countries: [{code,name}], zones: [{code,name}] } + * 版本明细搜索下拉选项:按版本去重后的 产品/国家/分区。 + * products 项含 surcharges(轻量,供查看详情产品列表)。 */ public Map selectDetailOptions(Long psvId); 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 438ed0e6..70b0c301 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 @@ -994,13 +994,87 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService zones.putIfAbsent(zoneCode != null ? zoneCode : zoneName, item); } } + // 补全套餐产品表(无明细时也能展示) + PrcPriceSetProduct pq = new PrcPriceSetProduct(); + pq.setPsvId(psvId); + List setProducts = setProductMapper.selectPrcPriceSetProductList(pq); + if (setProducts != null) + { + for (PrcPriceSetProduct sp : setProducts) + { + if (sp == null || StringUtils.isBlank(sp.getProductCode())) + { + continue; + } + Map item = new LinkedHashMap(); + item.put("code", sp.getProductCode()); + item.put("name", StringUtils.isNotBlank(sp.getProductName()) ? sp.getProductName() : sp.getProductCode()); + products.putIfAbsent(sp.getProductCode(), item); + } + } + // 产品列表轻量挂附加费,避免查看详情拉整版明细 + Map> scByProduct = loadSalesSurchargesByProduct(psvId); + List> productRows = new ArrayList>(); + for (Map p : products.values()) + { + Map row = new LinkedHashMap(); + row.put("code", p.get("code")); + row.put("name", p.get("name")); + String code = p.get("code"); + List sc = code == null ? null : scByProduct.get(code); + row.put("surcharges", sc != null ? sc : new ArrayList()); + productRows.add(row); + } Map result = new HashMap(); - result.put("products", new ArrayList>(products.values())); + result.put("products", productRows); result.put("countries", new ArrayList>(countries.values())); result.put("zones", new ArrayList>(zones.values())); return result; } + /** 按产品代码汇总版本销售附加费(scId 去重) */ + private Map> loadSalesSurchargesByProduct(Long psvId) + { + Map> out = new LinkedHashMap>(); + if (psvId == null) + { + return out; + } + List rels = surchargeRelMapper.selectSalesRelsByPsvId(psvId); + if (rels == null || rels.isEmpty()) + { + return out; + } + Map> dedupe = new LinkedHashMap>(); + for (PrcSurchargeRel rel : rels) + { + if (rel == null || rel.getScId() == null) + { + continue; + } + String code = StringUtils.trim(rel.getProductCode()); + if (StringUtils.isEmpty(code)) + { + continue; + } + Map bySc = dedupe.get(code); + if (bySc == null) + { + bySc = new LinkedHashMap(); + dedupe.put(code, bySc); + } + if (!bySc.containsKey(rel.getScId())) + { + bySc.put(rel.getScId(), rel); + } + } + for (Map.Entry> e : dedupe.entrySet()) + { + out.put(e.getKey(), new ArrayList(e.getValue().values())); + } + return out; + } + /** 为一页明细挂载 SALES 附加费关联(detail_id=psd_id)。 */ private void fillDetailSurcharges(List details) { @@ -3670,6 +3744,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService version.setProducts(products == null ? new ArrayList() : products); // 明细 + SALES 附加费关联按需加载(编辑价格/明细抽屉) version.setDetails(new ArrayList()); + version.setDetailCount(Integer.valueOf(detailMapper.countByPsvId(version.getPsvId()))); } private PrcPriceSetVersion pickCurrentVersion(List versions) 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 2726b699..85c81fec 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 @@ -71,19 +71,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.fv_registration_fee as base_registration_fee, d.discount_value, d.round_mode, d.pr_id, d.effective_date, d.expire_date, d.is_del, d.create_time, d.update_time from prc_price_set_detail d - left join prc_price_set_detail bp - on bp.price_type = 'PRODUCT' - and bp.product_code = d.product_code - and ifnull(bp.country_code,'') = ifnull(d.country_code,'') - and ifnull(bp.zone_code,'') = ifnull(d.zone_code,'') - and ifnull(bp.weight_min,-1) = ifnull(d.weight_min,-1) - and ifnull(bp.weight_max,-1) = ifnull(d.weight_max,-1) - and ifnull(bp.is_del, '0') = '0' - and bp.psv_id = ( - select v.psv_id from prc_price_set_version v - where v.price_type = 'PRODUCT' and v.price_set_id is null and v.status = '1' - order by v.version_seq desc limit 1 - ) + left join ( + select bp0.psd_id, bp0.product_code, bp0.country_code, bp0.zone_code, + bp0.weight_min, bp0.weight_max, bp0.fv_value, bp0.fv_registration_fee + from prc_price_set_detail bp0 + where bp0.price_type = 'PRODUCT' + and ifnull(bp0.is_del, '0') = '0' + and bp0.psv_id = ( + select v.psv_id from prc_price_set_version v + where v.price_type = 'PRODUCT' and v.price_set_id is null and v.status = '1' + order by v.version_seq desc limit 1 + ) + ) bp + on bp.product_code = d.product_code + and bp.country_code <=> d.country_code + and bp.zone_code <=> d.zone_code + and bp.weight_min <=> d.weight_min + and bp.weight_max <=> d.weight_max and ifnull(d.is_del, '0') = '0' 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 bfd45561..d1c6f982 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 @@ -80,6 +80,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" order by r.detail_id is not null, r.rel_id asc + + +