增加套餐产品红线价修改内容日志

This commit is contained in:
wuweihua
2026-10-21 15:08:13 +08:00
parent 1e8a449dda
commit b8e2a8e31a
10 changed files with 731 additions and 5 deletions
@@ -39,10 +39,14 @@ import com.bms.price.domain.BmsProductCountry;
import com.bms.price.domain.BmsProductImportTask;
import com.bms.price.domain.CatalogPreviewApplyRequest;
import com.bms.price.domain.PrcZone;
import com.bms.price.domain.PrcPriceSetDetail;
import com.bms.price.mapper.BmsProductCountryMapper;
import com.bms.price.mapper.BmsProductMapper;
import com.bms.price.mapper.PrcPriceSetDetailMapper;
import com.bms.price.mapper.PrcZoneMapper;
import com.bms.price.domain.PrcPriceExcelFile;
import com.bms.price.search.IBillSearchStore;
import com.bms.price.search.PriceChangeEsLog;
import com.bms.price.service.IBmsProductService;
import com.bms.price.service.IPrcPriceExcelFileService;
import com.bms.price.service.IPrcSurchargeRelService;
@@ -106,6 +110,12 @@ public class BmsProductServiceImpl implements IBmsProductService
@Autowired
private IPrcPriceExcelFileService priceExcelFileService;
@Autowired
private PrcPriceSetDetailMapper detailMapper;
@Autowired
private IBillSearchStore billSearchStore;
@Override
public BmsProduct selectBmsProductById(Long productId)
{
@@ -164,13 +174,36 @@ public class BmsProductServiceImpl implements IBmsProductService
{
if (country == null || country.getDetailId() == null)
{
throw new ServiceException("明细行主键缺失,无法修改");
throw new ServiceException("\u660e\u7ec6\u884c\u4e3b\u952e\u7f3a\u5931\uff0c\u65e0\u6cd5\u4fee\u6539");
}
PrcPriceSetDetail old = detailMapper.selectPrcPriceSetDetailById(country.getDetailId());
int rows = countryMapper.updateBmsProductCountry(country);
if (rows > 0)
{
// 生效/失效日期可能变化,状态按日期重算
// Recalc status when effective/expire dates change
countryMapper.refreshStatusByDates();
List<Map<String, String>> changes = PriceChangeEsLog.diffCatalogPrice(
old == null ? null : old.getFvValue(),
old == null ? null : old.getFvRegistrationFee(),
country.getFreightPrice(),
country.getRegistrationFee());
if (!changes.isEmpty())
{
Map<String, Object> keys = new LinkedHashMap<String, Object>();
keys.put("detailId", country.getDetailId());
keys.put("productCode", country.getProductCode() != null ? country.getProductCode()
: (old == null ? null : old.getProductCode()));
keys.put("countryCode", country.getCountryCode() != null ? country.getCountryCode()
: (old == null ? null : old.getCountryCode()));
keys.put("zoneCode", country.getZoneCode() != null ? country.getZoneCode()
: (old == null ? null : old.getZoneCode()));
keys.put("weightMin", country.getWeightMin() != null ? country.getWeightMin()
: (old == null ? null : old.getWeightMin()));
keys.put("weightMax", country.getWeightMax() != null ? country.getWeightMax()
: (old == null ? null : old.getWeightMax()));
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdProduct(country.getDetailId()),
PriceChangeEsLog.KIND_PRODUCT, PriceChangeEsLog.ACTION_UPDATE, keys, changes);
}
}
return rows;
}
@@ -40,11 +40,15 @@ import com.bms.price.domain.BmsRedlineProductImportTask;
import com.bms.price.domain.RedlineCatalogPreviewApplyRequest;
import com.bms.price.domain.PrcZone;
import com.bms.price.domain.PrcSurchargeRel;
import com.bms.price.domain.PrcPriceSetDetail;
import com.bms.price.mapper.BmsRedlineProductCountryMapper;
import com.bms.price.mapper.BmsRedlineProductMapper;
import com.bms.price.mapper.PrcPriceSetDetailMapper;
import com.bms.price.mapper.PrcSurchargeRelMapper;
import com.bms.price.mapper.PrcZoneMapper;
import com.bms.price.domain.PrcPriceExcelFile;
import com.bms.price.search.IBillSearchStore;
import com.bms.price.search.PriceChangeEsLog;
import com.bms.price.service.IBmsRedlineProductService;
import com.bms.price.service.IPrcPriceExcelFileService;
import com.bms.price.domain.PriceType;
@@ -107,6 +111,12 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
@Autowired
private IPrcPriceExcelFileService priceExcelFileService;
@Autowired
private PrcPriceSetDetailMapper detailMapper;
@Autowired
private IBillSearchStore billSearchStore;
@Override
public BmsRedlineProduct selectBmsRedlineProductById(Long productId)
{
@@ -165,13 +175,36 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
{
if (country == null || country.getDetailId() == null)
{
throw new ServiceException("明细行主键缺失,无法修改");
throw new ServiceException("\u660e\u7ec6\u884c\u4e3b\u952e\u7f3a\u5931\uff0c\u65e0\u6cd5\u4fee\u6539");
}
PrcPriceSetDetail old = detailMapper.selectPrcPriceSetDetailById(country.getDetailId());
int rows = countryMapper.updateBmsRedlineProductCountry(country);
if (rows > 0)
{
// 生效/失效日期可能变化,状态按日期重算
// Recalc status when effective/expire dates change
countryMapper.refreshStatusByDates();
List<Map<String, String>> changes = PriceChangeEsLog.diffCatalogPrice(
old == null ? null : old.getFvValue(),
old == null ? null : old.getFvRegistrationFee(),
country.getFreightPrice(),
country.getRegistrationFee());
if (!changes.isEmpty())
{
Map<String, Object> keys = new LinkedHashMap<String, Object>();
keys.put("detailId", country.getDetailId());
keys.put("productCode", country.getProductCode() != null ? country.getProductCode()
: (old == null ? null : old.getProductCode()));
keys.put("countryCode", country.getCountryCode() != null ? country.getCountryCode()
: (old == null ? null : old.getCountryCode()));
keys.put("zoneCode", country.getZoneCode() != null ? country.getZoneCode()
: (old == null ? null : old.getZoneCode()));
keys.put("weightMin", country.getWeightMin() != null ? country.getWeightMin()
: (old == null ? null : old.getWeightMin()));
keys.put("weightMax", country.getWeightMax() != null ? country.getWeightMax()
: (old == null ? null : old.getWeightMax()));
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdRedline(country.getDetailId()),
PriceChangeEsLog.KIND_REDLINE, PriceChangeEsLog.ACTION_UPDATE, keys, changes);
}
}
return rows;
}
@@ -51,6 +51,8 @@ import com.bms.price.mapper.PrcSurchargeRelMapper;
import com.bms.common.core.domain.entity.SysUser;
import com.bms.system.mapper.SysUserMapper;
import com.bms.price.service.IBmsProductService;
import com.bms.price.search.IBillSearchStore;
import com.bms.price.search.PriceChangeEsLog;
import com.bms.price.service.IPrcPriceExcelFileService;
import com.bms.price.service.IPrcPriceSetService;
import com.bms.price.task.PrcPriceSetSaveAsyncRunner;
@@ -129,6 +131,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
@Autowired
private IPrcPriceExcelFileService priceExcelFileService;
@Autowired
private IBillSearchStore billSearchStore;
@Override
public PrcPriceSet selectPrcPriceSetById(Long priceSetId)
{
@@ -1505,8 +1510,27 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
}
if (!deleteIds.isEmpty())
{
Map<Long, PrcPriceSetDetail> beforeReplace = new HashMap<Long, PrcPriceSetDetail>();
for (PrcPriceSetDetail d : details)
{
if (d != null && d.getPsdId() != null && deleteIds.contains(d.getPsdId()))
{
beforeReplace.put(d.getPsdId(), d);
}
}
// Draft/pending: hard delete covered rows; effect/expired: soft delete.
deleteDetailRowsByIds(deleteIds, isDraftOrPendingVersionStatus(resolveVersionStatus(psvId)));
for (Long id : deleteIds)
{
PrcPriceSetDetail old = beforeReplace.get(id);
if (old == null)
{
continue;
}
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdSales(id),
PriceChangeEsLog.KIND_SALES, PriceChangeEsLog.ACTION_IMPORT,
PriceChangeEsLog.bizKeysSales(old), PriceChangeEsLog.diffSalesDetail(old, null));
}
}
removeDetailsByReplaceScopes(details, detailIndex, replaceScopes);
}
@@ -1573,6 +1597,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
{
continue;
}
BigDecimal oldFv = hit.getFvValue();
BigDecimal oldReg = hit.getFvRegistrationFee();
detailMapper.updateDetailPrices(hit.getPsdId(), freight, registration);
if (freight != null)
{
@@ -1582,6 +1608,14 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
{
hit.setFvRegistrationFee(registration);
}
List<Map<String, String>> changes = PriceChangeEsLog.diffSalesDetail(
buildPriceSnapshot(oldFv, oldReg), hit);
if (!changes.isEmpty())
{
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdSales(hit.getPsdId()),
PriceChangeEsLog.KIND_SALES, PriceChangeEsLog.ACTION_IMPORT,
PriceChangeEsLog.bizKeysSales(hit), changes);
}
touched.add(hit.getPsdId());
updated++;
}
@@ -1606,6 +1640,9 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
{
touched.add(created.getPsdId());
}
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdSales(created.getPsdId()),
PriceChangeEsLog.KIND_SALES, PriceChangeEsLog.ACTION_IMPORT,
PriceChangeEsLog.bizKeysSales(created), PriceChangeEsLog.diffSalesDetail(null, created));
inserted++;
}
}
@@ -2116,6 +2153,16 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
{
replaceSalesSurchargeRels(java.util.Collections.singletonList(detail));
}
if (rows > 0)
{
List<Map<String, String>> changes = PriceChangeEsLog.diffSalesDetail(old, detail);
if (!changes.isEmpty())
{
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdSales(old.getPsdId()),
PriceChangeEsLog.KIND_SALES, PriceChangeEsLog.ACTION_UPDATE,
PriceChangeEsLog.bizKeysSales(detail.getPsdId() != null ? detail : old), changes);
}
}
return rows;
}
@@ -2130,6 +2177,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
List<Long> softIds = new ArrayList<Long>();
Set<String> hardTouchKeys = new HashSet<String>();
Set<String> softTouchKeys = new HashSet<String>();
List<PrcPriceSetDetail> deletedSnapshots = new ArrayList<PrcPriceSetDetail>();
for (Long id : psdIds)
{
if (id == null)
@@ -2143,6 +2191,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
}
PrcPriceSet db = requireSet(resolvePriceSetIdByPsvId(old.getPsvId()));
assertChildEditable(db);
deletedSnapshots.add(old);
boolean hard = isDraftOrPendingVersionStatus(resolveVersionStatus(old.getPsvId()));
if (hard)
{
@@ -2172,6 +2221,13 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
rows += deleteDetailRowsByIds(softIds, false);
cleanupOrphanSetProducts(softTouchKeys, false);
}
for (PrcPriceSetDetail old : deletedSnapshots)
{
List<Map<String, String>> changes = PriceChangeEsLog.diffSalesDetail(old, null);
PriceChangeEsLog.save(billSearchStore, PriceChangeEsLog.bizIdSales(old.getPsdId()),
PriceChangeEsLog.KIND_SALES, PriceChangeEsLog.ACTION_DELETE,
PriceChangeEsLog.bizKeysSales(old), changes);
}
return rows;
}
@@ -2195,6 +2251,15 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
return detailMapper.deletePrcPriceSetDetailByIds(arr);
}
/** Snapshot freight/registration for import before-after log. */
private PrcPriceSetDetail buildPriceSnapshot(BigDecimal fvValue, BigDecimal registrationFee)
{
PrcPriceSetDetail snap = new PrcPriceSetDetail();
snap.setFvValue(fvValue);
snap.setFvRegistrationFee(registrationFee);
return snap;
}
/** Version status draft(0) / pending(3): hard delete children. */
private boolean isDraftOrPendingVersionStatus(String status)
{