3 Commits

Author SHA1 Message Date
wuweihua a4440d7932 修改订单数据源的产品检测 2026-10-21 11:42:08 +08:00
wuweihua 35f1048190 删除productCountryId 2026-10-21 11:36:25 +08:00
wuweihua 8f1cf5c755 修改比对规则 2026-10-21 11:01:59 +08:00
12 changed files with 413 additions and 126 deletions
@@ -180,7 +180,8 @@ public class BillingController extends BaseController
}
/**
* Detect package sales products (as of billing end time) missing from product catalog.
* Compare local order-bill products vs customer bound package SALES products
* (includes product_code_mapping).
*/
@PreAuthorize("@ss.hasPermi('price:orderBill:list')")
@PostMapping("/orderBill/checkProducts")
@@ -97,7 +97,6 @@ public class PrcOrderBill extends BaseEntity
private Long psvId;
/** 套餐明细ID(prc_price_set_detail.psd_id) */
private Long psdId;
private Long productCountryId;
private BigDecimal weightMin;
private BigDecimal weightMax;
private String weightLabel;
@@ -3,35 +3,243 @@ package com.bms.price.domain.vo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* Order-bill product check: customer package (sales) products vs product catalog.
* Local order-bill products vs customer bound package (SALES) comparison.
* Matching also accepts product_code_mapping (upstream -> BMS).
*/
@Data
public class OrderBillProductCheckResult implements Serializable
{
private static final long serialVersionUID = 1L;
/** Orders matched by search filters (customer + billing time). */
private long orderTotal;
private int distinctOrderProducts;
private int packageProductCount;
private int matchedCount;
private int missingCount;
private String asOfTime;
private List<ProductRow> packageProducts = new ArrayList<ProductRow>();
private List<ProductRow> missingProducts = new ArrayList<ProductRow>();
private List<PackageProductRow> packageProducts = new ArrayList<PackageProductRow>();
private List<OrderProductRow> orderProducts = new ArrayList<OrderProductRow>();
private List<OrderProductRow> missingProducts = new ArrayList<OrderProductRow>();
@Data
public static class ProductRow implements Serializable
public long getOrderTotal()
{
return orderTotal;
}
public void setOrderTotal(long orderTotal)
{
this.orderTotal = orderTotal;
}
public int getDistinctOrderProducts()
{
return distinctOrderProducts;
}
public void setDistinctOrderProducts(int distinctOrderProducts)
{
this.distinctOrderProducts = distinctOrderProducts;
}
public int getPackageProductCount()
{
return packageProductCount;
}
public void setPackageProductCount(int packageProductCount)
{
this.packageProductCount = packageProductCount;
}
public int getMatchedCount()
{
return matchedCount;
}
public void setMatchedCount(int matchedCount)
{
this.matchedCount = matchedCount;
}
public int getMissingCount()
{
return missingCount;
}
public void setMissingCount(int missingCount)
{
this.missingCount = missingCount;
}
public String getAsOfTime()
{
return asOfTime;
}
public void setAsOfTime(String asOfTime)
{
this.asOfTime = asOfTime;
}
public List<PackageProductRow> getPackageProducts()
{
return packageProducts;
}
public void setPackageProducts(List<PackageProductRow> packageProducts)
{
this.packageProducts = packageProducts;
}
public List<OrderProductRow> getOrderProducts()
{
return orderProducts;
}
public void setOrderProducts(List<OrderProductRow> orderProducts)
{
this.orderProducts = orderProducts;
}
public List<OrderProductRow> getMissingProducts()
{
return missingProducts;
}
public void setMissingProducts(List<OrderProductRow> missingProducts)
{
this.missingProducts = missingProducts;
}
public static class PackageProductRow implements Serializable
{
private static final long serialVersionUID = 1L;
private String customerCode;
private String productCode;
private String productName;
/** Whether product exists in catalog (effective at asOf). */
private boolean inLibrary;
/** Order count in search billing window for this product. */
public String getCustomerCode()
{
return customerCode;
}
public void setCustomerCode(String customerCode)
{
this.customerCode = customerCode;
}
public String getProductCode()
{
return productCode;
}
public void setProductCode(String productCode)
{
this.productCode = productCode;
}
public String getProductName()
{
return productName;
}
public void setProductName(String productName)
{
this.productName = productName;
}
}
public static class OrderProductRow implements Serializable
{
private static final long serialVersionUID = 1L;
private String customerCode;
private String upstreamCode;
private String productName;
private String mappedCode;
private boolean inPackage;
private boolean mappedInPackage;
private boolean covered;
private int orderCount;
public String getCustomerCode()
{
return customerCode;
}
public void setCustomerCode(String customerCode)
{
this.customerCode = customerCode;
}
public String getUpstreamCode()
{
return upstreamCode;
}
public void setUpstreamCode(String upstreamCode)
{
this.upstreamCode = upstreamCode;
}
public String getProductName()
{
return productName;
}
public void setProductName(String productName)
{
this.productName = productName;
}
public String getMappedCode()
{
return mappedCode;
}
public void setMappedCode(String mappedCode)
{
this.mappedCode = mappedCode;
}
public boolean isInPackage()
{
return inPackage;
}
public void setInPackage(boolean inPackage)
{
this.inPackage = inPackage;
}
public boolean isMappedInPackage()
{
return mappedInPackage;
}
public void setMappedInPackage(boolean mappedInPackage)
{
this.mappedInPackage = mappedInPackage;
}
public boolean isCovered()
{
return covered;
}
public void setCovered(boolean covered)
{
this.covered = covered;
}
public int getOrderCount()
{
return orderCount;
}
public void setOrderCount(int orderCount)
{
this.orderCount = orderCount;
}
}
}
@@ -36,7 +36,7 @@ public class TabOrderMonitorQuery implements Serializable
* 有单号时不再强制要求客户+提货时间。
*/
private List<String> orderIdentifiers;
/** 上游产品代码 PRODUCT_CODE(产品比对点进订单号时使用) */
/** 上游产品代码 LINE_CODE(产品比对点进订单号时使用) */
private String productCode;
/** 分批同步计费每批条数 */
private Integer batchSize;
@@ -3,6 +3,7 @@ package com.bms.price.service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
@@ -17,16 +18,17 @@ import org.springframework.stereotype.Service;
import com.bms.common.annotation.DataScope;
import com.bms.common.exception.ServiceException;
import com.bms.common.utils.StringUtils;
import com.bms.price.domain.BmsProduct;
import com.bms.price.domain.PrcOrderBill;
import com.bms.price.domain.PrcPriceSetProduct;
import com.bms.price.domain.vo.OrderBillProductCheckResult;
import com.bms.price.domain.vo.OrderBillProductCheckResult.ProductRow;
import com.bms.price.mapper.BmsProductMapper;
import com.bms.price.domain.vo.OrderBillProductCheckResult.OrderProductRow;
import com.bms.price.domain.vo.OrderBillProductCheckResult.PackageProductRow;
import com.bms.price.mapper.PrcOrderBillMapper;
import com.bms.system.service.IBmsProductCodeMappingService;
/**
* Detect package sales products (as of billing end time) that are missing from product catalog.
* Compare local order-bill product codes against customer bound package SALES products.
* Also accepts product_code_mapping (upstream -> BMS).
*/
@Service
public class OrderBillProductCheckService
@@ -37,7 +39,7 @@ public class OrderBillProductCheckService
private ITmsPriceQuoteService tmsPriceQuoteService;
@Autowired
private BmsProductMapper productMapper;
private IBmsProductCodeMappingService productCodeMappingService;
@Autowired
private PrcOrderBillMapper orderBillMapper;
@@ -51,74 +53,125 @@ public class OrderBillProductCheckService
OrderBillProductCheckResult result = new OrderBillProductCheckResult();
result.setAsOfTime(formatAsOf(asOf));
List<String> customerCodes = normalizeCodes(query.getCustomerCodes());
Map<String, Integer> orderCountByKey = loadOrderCounts(query);
long orderTotal = 0L;
for (Integer c : orderCountByKey.values())
List<Map<String, Object>> groups = orderBillMapper.selectDistinctProductGroups(query);
if (groups == null || groups.isEmpty())
{
if (c != null)
{
orderTotal += c.intValue();
}
result.setOrderTotal(0L);
return result;
}
result.setOrderTotal(orderTotal);
List<ProductRow> packageRows = new ArrayList<ProductRow>();
List<ProductRow> missingRows = new ArrayList<ProductRow>();
int matched = 0;
for (String customerCode : customerCodes)
long orderTotal = 0L;
Set<String> customerCodes = new HashSet<String>();
for (Map<String, Object> g : groups)
{
List<PrcPriceSetProduct> products = tmsPriceQuoteService.listAllBoundPackageProducts(customerCode, asOf);
Set<String> seen = new HashSet<String>();
if (products == null)
String customerCode = trim(str(g, "customer_code"));
String productCode = trim(str(g, "product_code"));
if (StringUtils.isEmpty(customerCode) || StringUtils.isEmpty(productCode))
{
continue;
}
for (PrcPriceSetProduct p : products)
customerCodes.add(customerCode);
orderTotal += longValue(g, "order_count");
}
Map<String, Set<String>> packageCodeByCustomer = new HashMap<String, Set<String>>();
List<PackageProductRow> packageRows = new ArrayList<PackageProductRow>();
for (String customerCode : customerCodes)
{
List<PrcPriceSetProduct> products = tmsPriceQuoteService.listAllBoundPackageProducts(customerCode, asOf);
Set<String> codes = new HashSet<String>();
if (products != null)
{
if (p == null || StringUtils.isEmpty(p.getProductCode()))
for (PrcPriceSetProduct p : products)
{
continue;
}
String code = p.getProductCode().trim();
String upper = code.toUpperCase(Locale.ROOT);
if (!seen.add(upper))
{
continue;
}
boolean inLibrary = existsInLibrary(code, asOf);
ProductRow row = new ProductRow();
row.setCustomerCode(customerCode);
row.setProductCode(code);
row.setProductName(trim(p.getProductName()));
row.setInLibrary(inLibrary);
Integer oc = orderCountByKey.get(key(customerCode, upper));
row.setOrderCount(oc == null ? 0 : oc.intValue());
packageRows.add(row);
if (inLibrary)
{
matched++;
}
else
{
missingRows.add(row);
if (p == null || StringUtils.isEmpty(p.getProductCode()))
{
continue;
}
if (!isSalesProduct(p))
{
continue;
}
String code = p.getProductCode().trim();
String upper = code.toUpperCase(Locale.ROOT);
if (!codes.add(upper))
{
continue;
}
PackageProductRow pr = new PackageProductRow();
pr.setCustomerCode(customerCode);
pr.setProductCode(code);
pr.setProductName(trim(p.getProductName()));
packageRows.add(pr);
}
}
packageCodeByCustomer.put(customerCode, codes);
}
packageRows.sort(Comparator
.comparing(PackageProductRow::getCustomerCode, nullSafe())
.thenComparing(PackageProductRow::getProductCode, nullSafe()));
List<OrderProductRow> orderProducts = new ArrayList<OrderProductRow>();
List<OrderProductRow> missingProducts = new ArrayList<OrderProductRow>();
int matched = 0;
for (Map<String, Object> g : groups)
{
String customerCode = trim(str(g, "customer_code"));
String productCode = trim(str(g, "product_code"));
if (StringUtils.isEmpty(customerCode) || StringUtils.isEmpty(productCode))
{
continue;
}
Set<String> pkg = packageCodeByCustomer.get(customerCode);
if (pkg == null)
{
pkg = Collections.emptySet();
}
boolean inPackage = pkg.contains(productCode.toUpperCase(Locale.ROOT));
String mappedCode = resolveMappedIfDifferent(productCode);
boolean mappedInPackage = false;
if (StringUtils.isNotEmpty(mappedCode))
{
mappedInPackage = pkg.contains(mappedCode.toUpperCase(Locale.ROOT));
}
boolean covered = inPackage || mappedInPackage;
OrderProductRow row = new OrderProductRow();
row.setCustomerCode(customerCode);
row.setUpstreamCode(productCode);
row.setProductName(trim(str(g, "product_name")));
row.setMappedCode(mappedCode);
row.setInPackage(inPackage);
row.setMappedInPackage(mappedInPackage);
row.setCovered(covered);
row.setOrderCount((int) Math.min(Integer.MAX_VALUE, longValue(g, "order_count")));
orderProducts.add(row);
if (covered)
{
matched++;
}
else
{
missingProducts.add(row);
}
}
packageRows.sort(Comparator
.comparing(ProductRow::getCustomerCode, nullSafe())
.thenComparing(ProductRow::getProductCode, nullSafe()));
missingRows.sort(Comparator
.comparing(ProductRow::getCustomerCode, nullSafe())
.thenComparing(ProductRow::getProductCode, nullSafe()));
orderProducts.sort(Comparator
.comparing(OrderProductRow::isCovered)
.thenComparing(OrderProductRow::getCustomerCode, nullSafe())
.thenComparing(OrderProductRow::getUpstreamCode, nullSafe()));
missingProducts.sort(Comparator
.comparing(OrderProductRow::getCustomerCode, nullSafe())
.thenComparing(OrderProductRow::getUpstreamCode, nullSafe()));
result.setOrderTotal(orderTotal);
result.setDistinctOrderProducts(orderProducts.size());
result.setPackageProductCount(packageRows.size());
result.setMatchedCount(matched);
result.setMissingCount(missingRows.size());
result.setMissingCount(missingProducts.size());
result.setPackageProducts(packageRows);
result.setMissingProducts(missingRows);
result.setOrderProducts(orderProducts);
result.setMissingProducts(missingProducts);
return result;
}
@@ -136,32 +189,28 @@ public class OrderBillProductCheckService
return rows == null ? new ArrayList<PrcOrderBill>() : rows;
}
private Map<String, Integer> loadOrderCounts(PrcOrderBill query)
private String resolveMappedIfDifferent(String upstreamCode)
{
List<Map<String, Object>> groups = orderBillMapper.selectDistinctProductGroups(query);
Map<String, Integer> map = new HashMap<String, Integer>();
if (groups == null)
if (productCodeMappingService == null || StringUtils.isEmpty(upstreamCode))
{
return map;
return null;
}
for (Map<String, Object> g : groups)
String mapped = productCodeMappingService.resolveBmsProductCode(upstreamCode);
if (StringUtils.isEmpty(mapped) || mapped.equalsIgnoreCase(upstreamCode.trim()))
{
String customerCode = trim(str(g, "customer_code"));
String productCode = trim(str(g, "product_code"));
if (StringUtils.isEmpty(customerCode) || StringUtils.isEmpty(productCode))
{
continue;
}
map.put(key(customerCode, productCode.toUpperCase(Locale.ROOT)),
Integer.valueOf((int) Math.min(Integer.MAX_VALUE, longValue(g, "order_count"))));
return null;
}
return map;
return mapped.trim();
}
private boolean existsInLibrary(String productCode, Date asOf)
private static boolean isSalesProduct(PrcPriceSetProduct p)
{
BmsProduct hit = productMapper.selectEffectiveBmsProductByCode(productCode, asOf);
return hit != null && StringUtils.isNotEmpty(hit.getProductCode());
if (p == null)
{
return false;
}
String type = p.getPriceType();
return StringUtils.isEmpty(type) || "SALES".equalsIgnoreCase(type.trim());
}
private void validate(PrcOrderBill query)
@@ -248,11 +297,6 @@ public class OrderBillProductCheckService
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(asOf);
}
private static String key(String customerCode, String productUpper)
{
return customerCode + "|" + productUpper;
}
private static String trim(String s)
{
return StringUtils.isEmpty(s) ? null : s.trim();
@@ -1571,7 +1571,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
bill.setCustomerPricesetId(result.getCustomerPricesetId());
bill.setPsvId(result.getPsvId());
bill.setPsdId(result.getPsdId());
bill.setProductCountryId(result.getProductCountryId());
bill.setWeightMin(result.getWeightMin());
bill.setWeightMax(result.getWeightMax());
bill.setWeightLabel(result.getWeightLabel());
@@ -2119,7 +2118,6 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
r.setProductName(bill.getProductName());
r.setCountryCode(bill.getCountryCode());
r.setCountryName(bill.getCountryName());
r.setProductCountryId(bill.getProductCountryId());
r.setWeightMin(bill.getWeightMin());
r.setWeightMax(bill.getWeightMax());
r.setWeightLabel(bill.getWeightLabel());
@@ -359,6 +359,7 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
}
PrcPriceSetProduct q = new PrcPriceSetProduct();
q.setPsvId(psvId);
q.setPriceType("SALES");
List<PrcPriceSetProduct> rows = setProductMapper.selectPrcPriceSetProductList(q);
if (rows == null || rows.isEmpty())
{
@@ -1656,6 +1657,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
to.setSetType(from.getSetType());
to.setBindPriority(from.getBindPriority());
to.setCustomerPricesetId(from.getCustomerPricesetId());
to.setPsvId(from.getPsvId());
to.setVersionNo(from.getVersionNo());
to.setPsdId(from.getPsdId());
to.setProductCode(from.getProductCode());
to.setProductName(from.getProductName());
to.setCountryCode(from.getCountryCode());
@@ -185,33 +185,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</select>
<!-- Distinct product codes under the same filters (no pagination). -->
<!-- Distinct LINE_CODE under the same filters (product check; alias keeps Java keys stable). -->
<select id="selectTabOrderProductCodes" resultType="java.util.HashMap">
SELECT o.CUSTOMER_CODE AS CUSTOMER_CODE,
o.PRODUCT_CODE AS PRODUCT_CODE,
MAX(o.PRODUCT_NAME) AS PRODUCT_NAME,
o.LINE_CODE AS PRODUCT_CODE,
MAX(o.LINE_NAME) AS PRODUCT_NAME,
COUNT(1) AS ORDER_COUNT
FROM ${orderTable} o
WHERE
<include refid="tabOrderMonitorWhere"/>
AND o.PRODUCT_CODE IS NOT NULL
GROUP BY o.CUSTOMER_CODE, o.PRODUCT_CODE
ORDER BY o.CUSTOMER_CODE, o.PRODUCT_CODE
AND o.LINE_CODE IS NOT NULL
GROUP BY o.CUSTOMER_CODE, o.LINE_CODE
ORDER BY o.CUSTOMER_CODE, o.LINE_CODE
</select>
<!-- Order numbers for one upstream product under the same filters. -->
<!-- Order numbers for one upstream LINE_CODE under the same filters. -->
<select id="selectTabOrderIdsByProduct" resultType="java.util.HashMap">
SELECT o.ORDER_ID AS ORDER_ID,
o.ORG_ORDER_ID AS ORG_ORDER_ID,
o.TRANSFER_ORDER_ID AS TRANSFER_ORDER_ID,
o.CUSTOMER_CODE AS CUSTOMER_CODE,
o.PRODUCT_CODE AS PRODUCT_CODE,
o.PRODUCT_NAME AS PRODUCT_NAME,
o.LINE_CODE AS PRODUCT_CODE,
o.LINE_NAME AS PRODUCT_NAME,
o.PICKUP_DATE AS PICKUP_DATE
FROM ${orderTable} o
WHERE
<include refid="tabOrderMonitorWhere"/>
AND o.PRODUCT_CODE = #{query.productCode}
AND o.LINE_CODE = #{query.productCode}
ORDER BY o.PICKUP_DATE DESC, o.ORDER_ID DESC
</select>
@@ -52,7 +52,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="customerPricesetId" column="customer_priceset_id" />
<result property="psvId" column="psv_id" />
<result property="psdId" column="psd_id" />
<result property="productCountryId" column="product_country_id" />
<result property="weightMin" column="weight_min" />
<result property="weightMax" column="weight_max" />
<result property="weightLabel" column="weight_label" />
@@ -95,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_remark,
product_code, product_name, country_code, country_name, weight, biz_date, tms_id,
match_source, match_message, price_set_id, price_set_code, price_set_name,
set_type, bind_priority, customer_priceset_id, psv_id, psd_id, product_country_id,
set_type, bind_priority, customer_priceset_id, psv_id, psd_id,
weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, income_total, pay_total, currency, ar_bill_status,
@@ -114,7 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.shipper_name, p.consignee_name, p.dest_postcode, p.warehouse_code, p.order_time, p.order_status, p.bl_pickup, p.pickup_date, p.order_remark,
p.product_code, p.product_name, p.country_code, p.country_name, p.weight, p.biz_date, p.tms_id,
p.match_source, p.match_message, p.price_set_id, p.price_set_code, p.price_set_name,
p.set_type, p.bind_priority, p.customer_priceset_id, p.psv_id, p.psd_id, p.product_country_id,
p.set_type, p.bind_priority, p.customer_priceset_id, p.psv_id, p.psd_id,
p.weight_min, p.weight_max, p.weight_label, p.effective_date, p.charge_weight,
p.freight_rate, p.base_freight_rate, p.discount_percent, p.registration_fee,
p.freight_amount, p.surcharge_amount,
@@ -784,7 +783,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
shipper_name, consignee_name, dest_postcode, warehouse_code, order_time, order_status, bl_pickup, pickup_date, order_remark,
product_code, product_name, country_code, country_name, weight, biz_date, tms_id,
match_source, match_message, price_set_id, price_set_code, price_set_name,
set_type, bind_priority, customer_priceset_id, psv_id, psd_id, product_country_id,
set_type, bind_priority, customer_priceset_id, psv_id, psd_id,
weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, income_total, pay_total, currency, ar_bill_status,
@@ -798,7 +797,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{shipperName}, #{consigneeName}, #{destPostcode}, #{warehouseCode}, #{orderTime}, #{orderStatus}, #{blPickup}, #{pickupDate}, #{orderRemark},
#{productCode}, #{productName}, #{countryCode}, #{countryName}, #{weight}, #{bizDate}, #{tmsId},
#{matchSource}, #{matchMessage}, #{priceSetId}, #{priceSetCode}, #{priceSetName},
#{setType}, #{bindPriority}, #{customerPricesetId}, #{psvId}, #{psdId}, #{productCountryId},
#{setType}, #{bindPriority}, #{customerPricesetId}, #{psvId}, #{psdId},
#{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight},
#{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee},
#{freightAmount}, #{surchargeAmount}, #{incomeTotal}, #{payTotal}, #{currency}, #{arBillStatus},
@@ -857,7 +856,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
customer_priceset_id = #{customerPricesetId},
psv_id = #{psvId},
psd_id = #{psdId},
product_country_id = #{productCountryId},
weight_min = #{weightMin},
weight_max = #{weightMax},
weight_label = #{weightLabel},
-1
View File
@@ -944,7 +944,6 @@ CREATE TABLE `prc_order_bill` (
`customer_priceset_id` bigint(20) DEFAULT NULL COMMENT '客户套餐绑定ID',
`psv_id` bigint(20) DEFAULT NULL COMMENT '套餐版本ID,对应 prc_price_set_version.psv_id',
`psd_id` bigint(20) DEFAULT NULL COMMENT '套餐明细ID,对应 prc_price_set_detail.psd_id',
`product_country_id` bigint(20) DEFAULT NULL COMMENT '关联 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 '重量段展示',
@@ -0,0 +1,11 @@
-- prc_order_bill: drop unused product_country_id
SET @db = DATABASE();
SET @sql = (
SELECT IF(COUNT(*) > 0,
'ALTER TABLE prc_order_bill DROP COLUMN product_country_id',
'SELECT 1')
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'prc_order_bill' AND COLUMN_NAME = 'product_country_id'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
@@ -1,5 +1,5 @@
<template>
<el-drawer v-model="visible" size="920px" title="产品库比对(套餐销售价)" append-to-body destroy-on-close>
<el-drawer v-model="visible" size="920px" title="产品套餐比对" append-to-body destroy-on-close>
<div v-loading="loading">
<el-empty v-if="!loading && !result" description="暂无结果" />
<template v-else-if="result">
@@ -7,7 +7,8 @@
<el-descriptions-item label="筛选订单数">{{ result.orderTotal ?? 0 }}</el-descriptions-item>
<el-descriptions-item label="套餐截止时间">{{ result.asOfTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="套餐产品数">{{ result.packageProductCount ?? 0 }}</el-descriptions-item>
<el-descriptions-item label="库内/缺失">
<el-descriptions-item label="订单产品数">{{ result.distinctOrderProducts ?? 0 }}</el-descriptions-item>
<el-descriptions-item label="命中/缺失">
<el-tag type="success" size="small">{{ result.matchedCount ?? 0 }}</el-tag>
<span class="sep">/</span>
<el-tag type="danger" size="small">{{ result.missingCount ?? 0 }}</el-tag>
@@ -18,33 +19,49 @@
<el-tab-pane :label="missingTabLabel" name="missing">
<el-table :data="result.missingProducts || []" border size="small" max-height="520">
<el-table-column prop="customerCode" label="客户代码" min-width="110" show-overflow-tooltip />
<el-table-column prop="productCode" label="套餐产品代码" min-width="130" show-overflow-tooltip />
<el-table-column prop="upstreamCode" label="上游产品代码" min-width="120" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="140" show-overflow-tooltip />
<el-table-column prop="mappedCode" label="映射后代码" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ row.mappedCode || '-' }}</template>
</el-table-column>
<el-table-column prop="orderCount" label="订单数" width="100" align="center">
<template #default="{ row }">
<el-button link type="primary" :title="'点击查订单'" @click="openOrders(row)">{{ row.orderCount ?? 0 }}</el-button>
</template>
</el-table-column>
</el-table>
<el-empty v-if="!(result.missingProducts || []).length" description="未发现产品库缺失" />
<el-empty v-if="!(result.missingProducts || []).length" description="未发现缺失产品" />
</el-tab-pane>
<el-tab-pane :label="packageTabLabel" name="package">
<el-table :data="result.packageProducts || []" border size="small" max-height="520">
<el-tab-pane label="全部比对" name="all">
<el-table :data="result.orderProducts || []" border size="small" max-height="520">
<el-table-column prop="customerCode" label="客户代码" min-width="110" show-overflow-tooltip />
<el-table-column prop="productCode" label="套餐产品代码" min-width="130" show-overflow-tooltip />
<el-table-column prop="upstreamCode" label="上游产品代码" min-width="120" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="140" show-overflow-tooltip />
<el-table-column label="产品库" width="110" align="center">
<el-table-column prop="mappedCode" label="映射后代码" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ row.mappedCode || '-' }}</template>
</el-table-column>
<el-table-column label="是否在套餐" width="120" align="center">
<template #default="{ row }">
<el-tag v-if="row.inLibrary" size="small" type="success">在库</el-tag>
<el-tag v-else size="small" type="danger">不在库</el-tag>
<el-tag v-if="row.covered" size="small" type="success">在套餐</el-tag>
<el-tag v-else size="small" type="danger">不在套餐</el-tag>
</template>
</el-table-column>
<el-table-column label="命中方式" min-width="140" show-overflow-tooltip>
<template #default="{ row }">{{ hitText(row) }}</template>
</el-table-column>
<el-table-column prop="orderCount" label="订单数" width="100" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="openOrders(row)">{{ row.orderCount ?? 0 }}</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane :label="packageTabLabel" name="package">
<el-table :data="result.packageProducts || []" border size="small" max-height="520">
<el-table-column prop="customerCode" label="客户代码" min-width="110" show-overflow-tooltip />
<el-table-column prop="productCode" label="套餐产品代码" min-width="130" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
</el-table>
<el-empty v-if="!(result.packageProducts || []).length" description="客户未绑定套餐产品" />
</el-tab-pane>
</el-tabs>
@@ -87,17 +104,25 @@ const packageTabLabel = computed(() => {
return '套餐产品 (' + n + ')'
})
function hitText(row) {
if (!row) return '-'
if (row.inPackage) return '直接命中'
if (row.mappedInPackage) return '映射后命中'
if (row.mappedCode) return '有映射但仍不在套餐'
return '无映射'
}
function openOrders(row) {
if (!row || !row.productCode || !lastQuery.value) {
if (!row || !row.upstreamCode || !lastQuery.value) {
ElMessage.warning('请先选择客户并选择计费时间')
return
}
const q = {
...lastQuery.value,
customerCodes: row.customerCode ? [row.customerCode] : lastQuery.value.customerCodes,
productCode: row.productCode
productCode: row.upstreamCode
}
orderDialogTitle.value = '产品订单: ' + row.productCode
orderDialogTitle.value = '产品订单: ' + row.upstreamCode
orderDialogVisible.value = true
orderRows.value = []
orderLoading.value = true
@@ -128,7 +153,7 @@ function open(query) {
if ((result.value?.missingCount || 0) > 0) {
activeTab.value = 'missing'
} else {
activeTab.value = 'package'
activeTab.value = 'all'
}
}).catch(() => {
result.value = null