增加软删除
This commit is contained in:
+37
-2
@@ -174,6 +174,9 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
List<Long> deletableIds = new ArrayList<Long>();
|
||||
List<String> notPendingTips = new ArrayList<String>();
|
||||
List<BmsRedlineProduct> toReopen = new ArrayList<BmsRedlineProduct>();
|
||||
List<Long> relProductIds = new ArrayList<Long>();
|
||||
for (Long id : productIds)
|
||||
{
|
||||
@@ -182,19 +185,51 @@ public class BmsRedlineProductServiceImpl implements IBmsRedlineProductService
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String liveStatus = resolveStoredStatus(p.getEffectiveDate(), p.getExpireDate());
|
||||
if (!BmsRedlineProduct.STATUS_PENDING.equals(liveStatus))
|
||||
{
|
||||
String tip = p.getProductCode();
|
||||
if (p.getEffectiveDate() != null)
|
||||
{
|
||||
tip = tip + "(" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(p.getEffectiveDate()) + ")";
|
||||
}
|
||||
notPendingTips.add(tip);
|
||||
continue;
|
||||
}
|
||||
if (p.getProductId() != null)
|
||||
{
|
||||
countryMapper.deleteByProductId(p.getProductId());
|
||||
relProductIds.add(p.getProductId());
|
||||
}
|
||||
countryMapper.deleteByProductCodeAndEffectiveDate(p.getProductCode(), p.getEffectiveDate());
|
||||
deletableIds.add(p.getProductId());
|
||||
if (p.getEffectiveDate() != null)
|
||||
{
|
||||
toReopen.add(p);
|
||||
}
|
||||
}
|
||||
if (!notPendingTips.isEmpty())
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.redline.delete.pendingOnly",
|
||||
String.join("\u3001", notPendingTips)));
|
||||
}
|
||||
if (deletableIds.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!relProductIds.isEmpty())
|
||||
{
|
||||
// REDLINE rels bind redline_product.product_id (not shared with product catalog)
|
||||
surchargeRelMapper.deleteByProductIdsAndPriceType(relProductIds, PrcSurchargeRel.PRICE_TYPE_REDLINE);
|
||||
}
|
||||
return productMapper.deleteBmsRedlineProductByIds(productIds);
|
||||
int rows = productMapper.deleteBmsRedlineProductByIds(deletableIds.toArray(new Long[0]));
|
||||
for (BmsRedlineProduct p : toReopen)
|
||||
{
|
||||
productMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate());
|
||||
countryMapper.reopenExpiredByProductCodeAndExpireDate(p.getProductCode(), p.getEffectiveDate());
|
||||
}
|
||||
productMapper.refreshStatusByDates();
|
||||
countryMapper.refreshStatusByDates();
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user