修改类型
This commit is contained in:
@@ -25,6 +25,9 @@ public class PaySurcharge
|
||||
|
||||
private String feeName;
|
||||
|
||||
/** 附加费配置ID,对应 prc_surcharge.sc_id */
|
||||
private Long scId;
|
||||
|
||||
private String zoneName;
|
||||
|
||||
/** 收费标准原文 */
|
||||
|
||||
@@ -442,6 +442,7 @@ public class PayWorkbookParser
|
||||
PaySurcharge copy = new PaySurcharge();
|
||||
copy.setSectionName(fee.getSectionName());
|
||||
copy.setFeeName(fee.getFeeName());
|
||||
copy.setScId(fee.getScId());
|
||||
copy.setZoneName(fee.getZoneName());
|
||||
copy.setChargeText(fee.getChargeText());
|
||||
copy.setAmount(fee.getAmount());
|
||||
@@ -1189,7 +1190,12 @@ public class PayWorkbookParser
|
||||
{
|
||||
detectedCurrency = product.getCurrency();
|
||||
}
|
||||
if (detectedCurrency == null || detectedCurrency.isBlank())
|
||||
{
|
||||
detectedCurrency = "EUR";
|
||||
}
|
||||
product.setCurrency(detectedCurrency);
|
||||
fillSurchargeCurrency(product, detectedCurrency);
|
||||
product.setWeightCount(product.getWeightBands().size());
|
||||
product.setSurchargeCount(product.getSurcharges().size());
|
||||
product.setExtraCount(product.getExtraLines().size());
|
||||
@@ -3294,11 +3300,37 @@ public class PayWorkbookParser
|
||||
fee.setCurrency("");
|
||||
fee.setPriceUnit("");
|
||||
}
|
||||
if (fee.getCurrency() == null || fee.getCurrency().isBlank())
|
||||
{
|
||||
String cardCurrency = product.getCurrency();
|
||||
fee.setCurrency(cardCurrency == null || cardCurrency.isBlank() ? "EUR" : cardCurrency.trim().toUpperCase(Locale.ROOT));
|
||||
}
|
||||
fee.setSortNo(product.getSurcharges().size() + 1);
|
||||
PaySurchargeRules.apply(fee);
|
||||
product.getSurcharges().add(fee);
|
||||
}
|
||||
|
||||
/** 附加费币种为空时取价卡币种,价卡也没有则默认 EUR。 */
|
||||
private static void fillSurchargeCurrency(PayProduct product, String cardCurrency)
|
||||
{
|
||||
if (product == null || product.getSurcharges() == null || product.getSurcharges().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
String fallback = cardCurrency == null || cardCurrency.isBlank() ? "EUR" : cardCurrency.trim().toUpperCase(Locale.ROOT);
|
||||
for (PaySurcharge fee : product.getSurcharges())
|
||||
{
|
||||
if (fee == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (fee.getCurrency() == null || fee.getCurrency().isBlank())
|
||||
{
|
||||
fee.setCurrency(fallback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 燃油、去碳列是整张表的包含说明,只记一条,不跟每个重量段重复。 */
|
||||
private void readFuelMark(ExcelGrid grid, PayProduct product)
|
||||
{
|
||||
|
||||
+111
@@ -37,12 +37,14 @@ import com.bms.price.domain.PaySaveCommand;
|
||||
import com.bms.price.domain.PaySurcharge;
|
||||
import com.bms.price.domain.PayWeightBand;
|
||||
import com.bms.price.domain.PrcPriceSet;
|
||||
import com.bms.price.domain.PrcSurcharge;
|
||||
import com.bms.masterdata.domain.ServiceChannel;
|
||||
import com.bms.masterdata.mapper.ServiceChannelMapper;
|
||||
import com.bms.price.mapper.ChannelProductMapMapper;
|
||||
import com.bms.price.mapper.PayProductMapper;
|
||||
import com.bms.price.mapper.PayProductTermMapper;
|
||||
import com.bms.price.mapper.PrcPriceSetMapper;
|
||||
import com.bms.price.mapper.PrcSurchargeMapper;
|
||||
import com.bms.price.pay.PayParseProgressListener;
|
||||
import com.bms.price.pay.PayWorkbookParser;
|
||||
import com.bms.price.service.IPayProductService;
|
||||
@@ -69,9 +71,14 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
|
||||
private static final String TERM_EXPIRED = "2";
|
||||
|
||||
private static final String DEFAULT_CURRENCY = "EUR";
|
||||
|
||||
@Autowired
|
||||
private PayProductMapper payProductMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcSurchargeMapper prcSurchargeMapper;
|
||||
|
||||
@Autowired
|
||||
private ChannelProductMapMapper channelProductMapMapper;
|
||||
|
||||
@@ -1383,6 +1390,7 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
{
|
||||
return;
|
||||
}
|
||||
prepareSurcharges(product);
|
||||
for (PaySurcharge row : rows)
|
||||
{
|
||||
row.setProductId(product.getProductId());
|
||||
@@ -1395,6 +1403,105 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按附加费名称映射 prc_surcharge.sc_id;币种不能为空:附加费 -> 价卡 -> EUR。
|
||||
*/
|
||||
private void prepareSurcharges(PayProduct product)
|
||||
{
|
||||
List<PaySurcharge> rows = product.getSurcharges();
|
||||
if (rows == null || rows.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (isBlank(product.getCurrency()))
|
||||
{
|
||||
product.setCurrency(DEFAULT_CURRENCY);
|
||||
}
|
||||
String productCurrency = product.getCurrency().trim().toUpperCase(Locale.ROOT);
|
||||
Map<String, Long> nameToScId = surchargeNameMap();
|
||||
for (PaySurcharge fee : rows)
|
||||
{
|
||||
if (fee.getScId() == null && !isBlank(fee.getFeeName()))
|
||||
{
|
||||
Long scId = nameToScId.get(fee.getFeeName().trim());
|
||||
if (scId != null)
|
||||
{
|
||||
fee.setScId(scId);
|
||||
}
|
||||
}
|
||||
String currency = firstCurrency(fee.getCurrency(), currencyFromUnit(fee.getPriceUnit()), productCurrency);
|
||||
fee.setCurrency(currency);
|
||||
if (isBlank(fee.getPriceUnit()) || "%".equals(fee.getPriceUnit().trim()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String unit = fee.getPriceUnit().trim();
|
||||
if (!unit.contains("/") && !"%".equals(unit) && !unit.toUpperCase(Locale.ROOT).startsWith(currency))
|
||||
{
|
||||
fee.setPriceUnit(currency + "/" + unit.toUpperCase(Locale.ROOT));
|
||||
}
|
||||
else if (unit.matches("(?i)^[A-Za-z]{3}$"))
|
||||
{
|
||||
fee.setPriceUnit(currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Long> surchargeNameMap()
|
||||
{
|
||||
Map<String, Long> map = new LinkedHashMap<String, Long>();
|
||||
List<PrcSurcharge> list = prcSurchargeMapper.selectPrcSurchargeList(new PrcSurcharge());
|
||||
if (list == null)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
for (PrcSurcharge item : list)
|
||||
{
|
||||
if (item == null || item.getScId() == null || isBlank(item.getScName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String key = item.getScName().trim();
|
||||
if (!map.containsKey(key))
|
||||
{
|
||||
map.put(key, item.getScId());
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private static String currencyFromUnit(String priceUnit)
|
||||
{
|
||||
if (isBlank(priceUnit) || "%".equals(priceUnit.trim()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = priceUnit.trim();
|
||||
int slash = text.indexOf('/');
|
||||
String head = slash > 0 ? text.substring(0, slash) : text;
|
||||
if (head.matches("(?i)^[A-Za-z]{3}$"))
|
||||
{
|
||||
return head.toUpperCase(Locale.ROOT);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String firstCurrency(String... values)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
return DEFAULT_CURRENCY;
|
||||
}
|
||||
for (String value : values)
|
||||
{
|
||||
if (!isBlank(value))
|
||||
{
|
||||
return value.trim().toUpperCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
return DEFAULT_CURRENCY;
|
||||
}
|
||||
|
||||
private void insertExtras(PayProduct product)
|
||||
{
|
||||
List<PayExtraLine> rows = product.getExtraLines();
|
||||
@@ -1438,6 +1545,10 @@ public class PayProductServiceImpl implements IPayProductService
|
||||
product.setSourceFile(cut(product.getSourceFile(), 500));
|
||||
product.setFilePath(cut(product.getFilePath(), 500));
|
||||
product.setSupplierName(cut(product.getSupplierName(), 100));
|
||||
if (isBlank(product.getCurrency()))
|
||||
{
|
||||
product.setCurrency(DEFAULT_CURRENCY);
|
||||
}
|
||||
product.setCurrency(cut(product.getCurrency(), 20));
|
||||
product.setServiceNote(cut(product.getServiceNote(), 4000));
|
||||
product.setParseStatus(cut(product.getParseStatus(), 20));
|
||||
|
||||
@@ -326,11 +326,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertSurcharges">
|
||||
insert into pay_surcharge (
|
||||
product_id, term_id, version_no, section_name, fee_name, zone_name, charge_text, amount, currency, price_unit, fee_desc, period_text,
|
||||
product_id, term_id, version_no, section_name, fee_name, sc_id, zone_name, charge_text, amount, currency, price_unit, fee_desc, period_text,
|
||||
effective_start, effective_end, charge_timing, calc_rule, calc_param, weight_min, weight_max, postcode_param, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.feeName}, #{row.zoneName}, #{row.chargeText}, #{row.amount},
|
||||
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.feeName}, #{row.scId}, #{row.zoneName}, #{row.chargeText}, #{row.amount},
|
||||
#{row.currency}, #{row.priceUnit}, #{row.feeDesc}, #{row.periodText}, #{row.effectiveStart}, #{row.effectiveEnd},
|
||||
#{row.chargeTiming}, ifnull(#{row.calcRule}, 'MANUAL'), #{row.calcParam}, #{row.weightMin}, #{row.weightMax},
|
||||
#{row.postcodeParam}, #{row.sortNo})
|
||||
@@ -366,7 +366,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectSurcharges" resultType="com.bms.price.domain.PaySurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
sc_id as scId, zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
|
||||
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam,
|
||||
weight_min as weightMin, weight_max as weightMax, postcode_param as postcodeParam, sort_no as sortNo
|
||||
@@ -378,7 +378,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectSurchargesByTerm" resultType="com.bms.price.domain.PaySurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
sc_id as scId, zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
|
||||
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam,
|
||||
weight_min as weightMin, weight_max as weightMax, postcode_param as postcodeParam, sort_no as sortNo
|
||||
|
||||
Reference in New Issue
Block a user