✨ 应收账单快照保存产品价和红线价
This commit is contained in:
@@ -80,8 +80,10 @@ import com.bms.common.utils.StringUtils;
|
||||
import com.bms.common.utils.file.FileUtils;
|
||||
import com.bms.common.utils.file.FileUploadUtils;
|
||||
import com.bms.common.utils.uuid.IdUtils;
|
||||
import com.bms.price.domain.PrcIncomeBill;
|
||||
import com.bms.price.domain.PrcIncomeBillFee;
|
||||
import com.bms.price.domain.PrcOrderBill;
|
||||
import com.bms.price.mapper.PrcIncomeBillMapper;
|
||||
import com.bms.price.mapper.PrcIncomeBillFeeMapper;
|
||||
import com.bms.price.mapper.PrcOrderBillMapper;
|
||||
|
||||
@@ -174,6 +176,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
@Autowired
|
||||
private PrcIncomeBillFeeMapper sourceFeeMapper;
|
||||
@Autowired
|
||||
private PrcIncomeBillMapper sourceIncomeBillMapper;
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
/**
|
||||
@@ -665,6 +669,14 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, PrcIncomeBill> sourceIncomeBillsByBillId = new HashMap<>();
|
||||
List<PrcIncomeBill> sourceIncomeBills = sourceIncomeBillMapper.selectByBillIds(currentSourceBillIds);
|
||||
if (sourceIncomeBills != null) {
|
||||
for (PrcIncomeBill sourceIncomeBill : sourceIncomeBills) {
|
||||
sourceIncomeBillsByBillId.put(sourceIncomeBill.getBillId(), sourceIncomeBill);
|
||||
}
|
||||
}
|
||||
|
||||
// 先抓取本批次的未出账费用快照,后续只更新和复制这些费用,避免把同订单已有 BILLED 费用重复带入新账单。
|
||||
List<PrcIncomeBillFee> sourceFees = sourceFeeMapper.selectUnbilledByBillIds(
|
||||
currentSourceBillIds, ArIncomeBillFeeStatus.UNBILLED.getCode());
|
||||
@@ -698,7 +710,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
int detailNo = (task.getProcessedCount() == null ? 0 : task.getProcessedCount()) + 1;
|
||||
List<ArBillDetail> details = new ArrayList<>(sources.size());
|
||||
for (PrcOrderBill source : sources) {
|
||||
details.add(toDetail(bill, source, detailNo++, task.getCreateBy()));
|
||||
details.add(toDetail(bill, source, sourceIncomeBillsByBillId.get(source.getBillId()),
|
||||
detailNo++, task.getCreateBy()));
|
||||
}
|
||||
detailMapper.insertBatch(details);
|
||||
|
||||
@@ -1137,7 +1150,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
return !details.isEmpty() && detailTotal.compareTo(nvl(billTotal)) == 0;
|
||||
}
|
||||
|
||||
private ArBillDetail toDetail(ArBill bill, PrcOrderBill source, int detailNo, String operator) {
|
||||
private ArBillDetail toDetail(ArBill bill, PrcOrderBill source, PrcIncomeBill sourceIncomeBill,
|
||||
int detailNo, String operator) {
|
||||
ArBillDetail detail = new ArBillDetail();
|
||||
detail.setArBillId(bill.getArBillId());
|
||||
detail.setPrcOrderBillId(source.getBillId());
|
||||
@@ -1162,6 +1176,10 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
detail.setPkgHeight(source.getPkgHeight());
|
||||
detail.setCurrency(source.getCurrency() == null ? bill.getCurrency() : source.getCurrency());
|
||||
detail.setTotalAmount(nvl(source.getIncomeTotal()));
|
||||
if (sourceIncomeBill != null) {
|
||||
detail.setProductAmount(sourceIncomeBill.getProductAmount());
|
||||
detail.setRedlineAmount(sourceIncomeBill.getRedlineAmount());
|
||||
}
|
||||
detail.setRemark(source.getOrderRemark());
|
||||
detail.setCreateBy(operator);
|
||||
return detail;
|
||||
@@ -1176,6 +1194,8 @@ public class ArBillServiceImpl implements IArBillService {
|
||||
fee.setFeeName(source.getFeeName());
|
||||
fee.setScId(source.getScId());
|
||||
fee.setAmount(nvl(source.getAmount()));
|
||||
fee.setProductAmount(source.getProductAmount());
|
||||
fee.setRedlineAmount(source.getRedlineAmount());
|
||||
fee.setCurrency(source.getCurrency() == null ? detail.getCurrency() : source.getCurrency());
|
||||
fee.setRoundMode(source.getRoundMode());
|
||||
fee.setRemark(source.getRemark());
|
||||
|
||||
Reference in New Issue
Block a user