增加代码检测,和映射
This commit is contained in:
@@ -36,4 +36,11 @@ public interface ITmsPriceQuoteService
|
||||
* @param bizDate optional; default today (same as-of window as quote)
|
||||
*/
|
||||
List<PrcPriceSetProduct> listBoundPackageProducts(String customerCode, Date bizDate);
|
||||
|
||||
/**
|
||||
* Union of products from all effective bound packages (for order-source product check).
|
||||
* @param customerCode required
|
||||
* @param bizDate optional; default today
|
||||
*/
|
||||
List<PrcPriceSetProduct> listAllBoundPackageProducts(String customerCode, Date bizDate);
|
||||
}
|
||||
|
||||
+87
@@ -9,6 +9,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -57,6 +58,7 @@ import com.bms.price.search.EsBizLogSupport;
|
||||
import com.bms.price.search.EsLogType;
|
||||
import com.bms.price.search.IBillSearchStore;
|
||||
import com.bms.price.service.ITmsPriceQuoteService;
|
||||
import com.bms.system.service.IBmsProductCodeMappingService;
|
||||
|
||||
/**
|
||||
* Shared quote/bill calc: customer bind + package version by bizDate (version effective_time).
|
||||
@@ -103,6 +105,9 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
@Autowired
|
||||
private BmsProductMapper productMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private IBmsProductCodeMappingService productCodeMappingService;
|
||||
|
||||
@Autowired
|
||||
private PrcSurchargeRelMapper surchargeRelMapper;
|
||||
|
||||
@@ -261,6 +266,52 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PrcPriceSetProduct> listAllBoundPackageProducts(String customerCode, Date bizDate)
|
||||
{
|
||||
if (StringUtils.isEmpty(customerCode))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PrcCustomerPriceSet> binds = customerPriceSetMapper.selectEffectiveByCustomerCode(customerCode.trim());
|
||||
if (binds == null || binds.isEmpty())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Date asOf = bizDate != null ? bizDate : new Date();
|
||||
Map<String, PrcPriceSetProduct> byCode = new LinkedHashMap<String, PrcPriceSetProduct>();
|
||||
for (PrcCustomerPriceSet bind : binds)
|
||||
{
|
||||
if (bind == null || bind.getPriceSetId() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PrcPriceSet set = priceSetMapper.selectPrcPriceSetHeaderById(bind.getPriceSetId());
|
||||
if (set == null || !"E".equals(set.getStatus()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<PrcPriceSetProduct> products = loadProductsForPackage(set.getPriceSetId(), asOf);
|
||||
if (products == null || products.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (PrcPriceSetProduct p : products)
|
||||
{
|
||||
if (p == null || StringUtils.isEmpty(p.getProductCode()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String key = p.getProductCode().trim().toUpperCase(Locale.ROOT);
|
||||
if (!byCode.containsKey(key))
|
||||
{
|
||||
byCode.put(key, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<PrcPriceSetProduct>(byCode.values());
|
||||
}
|
||||
|
||||
/** Prefer version active at asOf; else latest version that has set-product rows. */
|
||||
private List<PrcPriceSetProduct> loadProductsForPackage(Long priceSetId, Date asOf)
|
||||
{
|
||||
@@ -373,6 +424,25 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
|
||||
PrcPriceSetProduct setProduct = resolveSetProduct(version.getPsvId(), productCode);
|
||||
if (setProduct == null)
|
||||
{
|
||||
// Package has no this product: try product_code_mapping (upstream -> BMS).
|
||||
String mappedCode = resolveMappedProductCode(productCode);
|
||||
if (mappedCode != null)
|
||||
{
|
||||
setProduct = resolveSetProduct(version.getPsvId(), mappedCode);
|
||||
if (setProduct != null)
|
||||
{
|
||||
productCode = mappedCode;
|
||||
request.setProductCode(mappedCode);
|
||||
String mappedName = resolveProductName(mappedCode, bizDate);
|
||||
if (StringUtils.isNotEmpty(mappedName))
|
||||
{
|
||||
productName = mappedName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (setProduct == null)
|
||||
{
|
||||
PrcPriceSetProduct probe = new PrcPriceSetProduct();
|
||||
probe.setPsvId(version.getPsvId());
|
||||
@@ -470,6 +540,23 @@ public class TmsPriceQuoteServiceImpl implements ITmsPriceQuoteService
|
||||
return setProductMapper.selectByPsvIdAndCode(psvId, productCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return mapped BMS product code only when mapping exists and differs from upstream code.
|
||||
*/
|
||||
private String resolveMappedProductCode(String upstreamCode)
|
||||
{
|
||||
if (productCodeMappingService == null || StringUtils.isEmpty(upstreamCode))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String mapped = productCodeMappingService.resolveBmsProductCode(upstreamCode);
|
||||
if (StringUtils.isEmpty(mapped) || mapped.equalsIgnoreCase(upstreamCode.trim()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return mapped.trim();
|
||||
}
|
||||
|
||||
private static final class ZoneResolve
|
||||
{
|
||||
private boolean required;
|
||||
|
||||
Reference in New Issue
Block a user