增加应收应付中间表
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应收主表 prc_income_bill(与 prc_order_bill 一对一) */
|
||||
@Data
|
||||
public class PrcIncomeBill implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 应收主表ID */
|
||||
private String incomeBillId;
|
||||
/** 计费订单ID */
|
||||
private String billId;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 产品价合计 */
|
||||
private BigDecimal productAmount;
|
||||
/** 红线价合计 */
|
||||
private BigDecimal redlineAmount;
|
||||
/** 销售价合计(当前计费结果) */
|
||||
private BigDecimal salesAmount;
|
||||
/** 应收合计(当前等于销售价) */
|
||||
private BigDecimal incomeTotal;
|
||||
/** 业务员/销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
private String belongSalerCode;
|
||||
/** 结算员 */
|
||||
private String settlementMan;
|
||||
/** 结算员编码 */
|
||||
private String settlementManCode;
|
||||
private String createBy;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** receivable fee detail prc_income_bill_fee */
|
||||
/** 应收费用明细 prc_income_bill_fee */
|
||||
@Data
|
||||
public class PrcIncomeBillFee implements Serializable
|
||||
{
|
||||
@@ -14,6 +14,8 @@ public class PrcIncomeBillFee implements Serializable
|
||||
|
||||
private String feeId;
|
||||
private String billId;
|
||||
/** 应收主表ID */
|
||||
private String incomeBillId;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
private Long scId;
|
||||
|
||||
@@ -29,8 +29,12 @@ public class PrcOrderBill extends BaseEntity
|
||||
private List<String> transferNos;
|
||||
/** 所属销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
private String belongSalerCode;
|
||||
/** 结算员 */
|
||||
private String settlementMan;
|
||||
/** 结算员编码 */
|
||||
private String settlementManCode;
|
||||
/** 客服员 */
|
||||
private String serviceMan;
|
||||
private Long customerId;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ruoyi.price.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** 应付主表 prc_pay_bill(与 prc_order_bill 一对一) */
|
||||
@Data
|
||||
public class PrcPayBill implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
/** 计费订单ID */
|
||||
private String billId;
|
||||
/** 币种 */
|
||||
private String currency;
|
||||
/** 产品价合计 */
|
||||
private BigDecimal productAmount;
|
||||
/** 红线价合计 */
|
||||
private BigDecimal redlineAmount;
|
||||
/** 成本价合计(当前计费结果) */
|
||||
private BigDecimal costAmount;
|
||||
/** 应付合计(当前等于成本价) */
|
||||
private BigDecimal payTotal;
|
||||
/** 业务员/销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
private String belongSalerCode;
|
||||
/** 结算员 */
|
||||
private String settlementMan;
|
||||
/** 结算员编码 */
|
||||
private String settlementManCode;
|
||||
private String createBy;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/** payable fee detail prc_pay_bill_fee */
|
||||
/** 应付费用明细 prc_pay_bill_fee */
|
||||
@Data
|
||||
public class PrcPayBillFee implements Serializable
|
||||
{
|
||||
@@ -14,6 +14,8 @@ public class PrcPayBillFee implements Serializable
|
||||
|
||||
private String feeId;
|
||||
private String billId;
|
||||
/** 应付主表ID */
|
||||
private String payBillId;
|
||||
private String feeType;
|
||||
private String feeName;
|
||||
private Long scId;
|
||||
|
||||
@@ -25,8 +25,12 @@ public class TmsPriceBillRequest extends TmsPriceQuoteRequest
|
||||
private String transferNo;
|
||||
/** 所属销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
private String belongSalerCode;
|
||||
/** 结算员 */
|
||||
private String settlementMan;
|
||||
/** 结算员编码 */
|
||||
private String settlementManCode;
|
||||
/** 客服员 */
|
||||
private String serviceMan;
|
||||
private String customerName;
|
||||
|
||||
@@ -77,8 +77,12 @@ public class TmsPriceQuoteResult implements Serializable
|
||||
private String transferNo;
|
||||
/** 所属销售员 */
|
||||
private String belongSaler;
|
||||
/** 销售员编码 */
|
||||
private String belongSalerCode;
|
||||
/** 结算员 */
|
||||
private String settlementMan;
|
||||
/** 结算员编码 */
|
||||
private String settlementManCode;
|
||||
/** 客服员 */
|
||||
private String serviceMan;
|
||||
private String customerCode;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import com.ruoyi.price.domain.PrcIncomeBill;
|
||||
|
||||
/** prc_income_bill mapper */
|
||||
public interface PrcIncomeBillMapper
|
||||
{
|
||||
PrcIncomeBill selectByBillId(String billId);
|
||||
|
||||
PrcIncomeBill selectByIncomeBillId(String incomeBillId);
|
||||
|
||||
int insertPrcIncomeBill(PrcIncomeBill row);
|
||||
|
||||
int updatePrcIncomeBill(PrcIncomeBill row);
|
||||
|
||||
int upsertPrcIncomeBill(PrcIncomeBill row);
|
||||
|
||||
int deleteByBillId(String billId);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.price.mapper;
|
||||
|
||||
import com.ruoyi.price.domain.PrcPayBill;
|
||||
|
||||
/** prc_pay_bill mapper */
|
||||
public interface PrcPayBillMapper
|
||||
{
|
||||
PrcPayBill selectByBillId(String billId);
|
||||
|
||||
PrcPayBill selectByPayBillId(String payBillId);
|
||||
|
||||
int insertPrcPayBill(PrcPayBill row);
|
||||
|
||||
int updatePrcPayBill(PrcPayBill row);
|
||||
|
||||
int upsertPrcPayBill(PrcPayBill row);
|
||||
|
||||
int deleteByBillId(String billId);
|
||||
}
|
||||
@@ -27,7 +27,9 @@ public class OracleOrderBillMapper
|
||||
req.setTrackingNo(firstStr(row, "ORG_ORDER_ID", "TRACK_ID", "BARCODE_NUMBER", "CUSTOMER_TRACK_ID"));
|
||||
req.setTransferNo(firstStr(row, "TRANSFER_ORDER_ID"));
|
||||
req.setBelongSaler(firstStr(row, "BELONG_SALER_OLD"));
|
||||
req.setBelongSalerCode(firstStr(row, "BELONG_SALER_CODE", "SALER_CODE"));
|
||||
req.setSettlementMan(firstStr(row, "SETTLEMENT_MAN_OLD"));
|
||||
req.setSettlementManCode(firstStr(row, "SETTLEMENT_MAN_CODE", "SETTLEMENT_CODE"));
|
||||
req.setServiceMan(firstStr(row, "SERVICE_MAN_OLD"));
|
||||
req.setUpstreamRow(row);
|
||||
req.setCustomerCode(firstStr(row, "CUSTOMER_CODE"));
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.ruoyi.price.domain.PrcOrderBill;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
|
||||
/** Order billing: persist prc_order_bill + prc_income_bill_fee. Same price match as quote. */
|
||||
/** 订单计费:落库 prc_order_bill + prc_income_bill/+fee + prc_pay_bill/+fee。 */
|
||||
public interface IPrcOrderBillService
|
||||
{
|
||||
TmsPriceQuoteResult bill(TmsPriceBillRequest request);
|
||||
|
||||
+128
-5
@@ -20,9 +20,11 @@ import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.sign.Md5Utils;
|
||||
import com.ruoyi.price.domain.PrcIncomeBill;
|
||||
import com.ruoyi.price.domain.PrcIncomeBillFee;
|
||||
import com.ruoyi.price.domain.PrcOrderBill;
|
||||
import com.ruoyi.price.domain.PrcOrderBillExt;
|
||||
import com.ruoyi.price.domain.PrcPayBill;
|
||||
import com.ruoyi.price.domain.PrcPayBillFee;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
|
||||
@@ -30,9 +32,11 @@ import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||
import com.ruoyi.price.enums.BillCreditArrearsStatus;
|
||||
import com.ruoyi.price.enums.BillCustomerActiveStatus;
|
||||
import com.ruoyi.price.mapper.PrcIncomeBillFeeMapper;
|
||||
import com.ruoyi.price.mapper.PrcIncomeBillMapper;
|
||||
import com.ruoyi.price.mapper.PrcOrderBillExtMapper;
|
||||
import com.ruoyi.price.mapper.PrcOrderBillMapper;
|
||||
import com.ruoyi.price.mapper.PrcPayBillFeeMapper;
|
||||
import com.ruoyi.price.mapper.PrcPayBillMapper;
|
||||
import com.ruoyi.price.oracle.OracleOrderBillExtFiller;
|
||||
import com.ruoyi.price.search.EsBizLogSupport;
|
||||
import com.ruoyi.price.search.EsLogType;
|
||||
@@ -59,9 +63,15 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
@Autowired
|
||||
private PrcIncomeBillFeeMapper incomeBillFeeMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcIncomeBillMapper incomeBillMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPayBillFeeMapper payBillFeeMapper;
|
||||
|
||||
@Autowired
|
||||
private PrcPayBillMapper payBillMapper;
|
||||
|
||||
@Autowired
|
||||
private IBillSearchStore billSearchStore;
|
||||
|
||||
@@ -220,7 +230,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
bill.setTrackingNo(request.getTrackingNo());
|
||||
bill.setTransferNo(request.getTransferNo());
|
||||
bill.setBelongSaler(request.getBelongSaler());
|
||||
bill.setBelongSalerCode(request.getBelongSalerCode());
|
||||
bill.setSettlementMan(request.getSettlementMan());
|
||||
bill.setSettlementManCode(request.getSettlementManCode());
|
||||
bill.setServiceMan(request.getServiceMan());
|
||||
String customerActiveStatus = result == null ? null : result.getCustomerActiveStatus();
|
||||
if (StringUtils.isEmpty(customerActiveStatus))
|
||||
@@ -296,16 +308,26 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
{
|
||||
orderBillMapper.updatePrcOrderBill(bill);
|
||||
incomeBillFeeMapper.deleteByBillId(bill.getBillId());
|
||||
payBillFeeMapper.deleteByBillId(bill.getBillId());
|
||||
}
|
||||
List<PrcIncomeBillFee> fees = toFeeRows(bill.getBillId(), result);
|
||||
PrcIncomeBill incomeBill = persistIncomeBill(bill);
|
||||
List<PrcIncomeBillFee> fees = toFeeRows(bill.getBillId(),
|
||||
incomeBill == null ? null : incomeBill.getIncomeBillId(), result);
|
||||
if (!fees.isEmpty())
|
||||
{
|
||||
incomeBillFeeMapper.insertBatch(fees);
|
||||
}
|
||||
String syncJson = toRequestJson(request);
|
||||
PrcPayBill payBill = persistPayBill(bill);
|
||||
List<PrcPayBillFee> payFees = toPayFeeRows(bill.getBillId(),
|
||||
payBill == null ? null : payBill.getPayBillId(), result);
|
||||
if (!payFees.isEmpty())
|
||||
{
|
||||
payBillFeeMapper.insertBatch(payFees);
|
||||
}
|
||||
String requestJson = toRequestJson(request);
|
||||
persistBillExt(bill, request.getUpstreamRow());
|
||||
result.setRequestJson(syncJson);
|
||||
billSearchStore.save(EsLogType.BILL, orderNo, syncJson, toResponseJson(result));
|
||||
result.setRequestJson(requestJson);
|
||||
billSearchStore.save(EsLogType.BILL, orderNo, requestJson, toResponseJson(result));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -472,7 +494,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return v == null ? BigDecimal.ZERO : v;
|
||||
}
|
||||
|
||||
private List<PrcIncomeBillFee> toFeeRows(String billId, TmsPriceQuoteResult result)
|
||||
private List<PrcIncomeBillFee> toFeeRows(String billId, String incomeBillId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcIncomeBillFee> fees = new ArrayList<PrcIncomeBillFee>();
|
||||
if (result.getFeeDetails() == null)
|
||||
@@ -484,6 +506,7 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
PrcIncomeBillFee fee = new PrcIncomeBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setIncomeBillId(incomeBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
fee.setFeeName(line.getFeeName());
|
||||
fee.setScId(line.getScId() == null ? 0L : line.getScId());
|
||||
@@ -496,6 +519,104 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
return fees;
|
||||
}
|
||||
|
||||
/** 应收主表与订单计费一对一落库;当前写入销售价/应收合计,产品价/红线价预留。 */
|
||||
private PrcIncomeBill persistIncomeBill(PrcOrderBill bill)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal sales = nz(bill.getIncomeTotal());
|
||||
PrcIncomeBill existed = incomeBillMapper.selectByBillId(bill.getBillId());
|
||||
PrcIncomeBill row = existed == null ? new PrcIncomeBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
row.setIncomeBillId(UUID.randomUUID().toString());
|
||||
row.setBillId(bill.getBillId());
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
|
||||
// 产品价/红线价预留
|
||||
row.setSalesAmount(sales);
|
||||
row.setIncomeTotal(sales);
|
||||
row.setBelongSaler(bill.getBelongSaler());
|
||||
row.setBelongSalerCode(bill.getBelongSalerCode());
|
||||
row.setSettlementMan(bill.getSettlementMan());
|
||||
row.setSettlementManCode(bill.getSettlementManCode());
|
||||
row.setUpdateBy(bill.getUpdateBy());
|
||||
if (existed == null)
|
||||
{
|
||||
incomeBillMapper.insertPrcIncomeBill(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
incomeBillMapper.updatePrcIncomeBill(row);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
private List<PrcPayBillFee> toPayFeeRows(String billId, String payBillId, TmsPriceQuoteResult result)
|
||||
{
|
||||
List<PrcPayBillFee> fees = new ArrayList<PrcPayBillFee>();
|
||||
if (result.getPayFeeDetails() == null)
|
||||
{
|
||||
return fees;
|
||||
}
|
||||
for (TmsPriceQuoteFeeLine line : result.getPayFeeDetails())
|
||||
{
|
||||
PrcPayBillFee fee = new PrcPayBillFee();
|
||||
fee.setFeeId(UUID.randomUUID().toString());
|
||||
fee.setBillId(billId);
|
||||
fee.setPayBillId(payBillId);
|
||||
fee.setFeeType(line.getFeeType());
|
||||
fee.setFeeName(line.getFeeName());
|
||||
fee.setScId(line.getScId() == null ? 0L : line.getScId());
|
||||
fee.setAmount(line.getAmount() == null ? BigDecimal.ZERO : line.getAmount());
|
||||
fee.setCurrency(line.getCurrency());
|
||||
fee.setRoundMode(line.getRoundMode());
|
||||
fee.setRemark(line.getRemark());
|
||||
fees.add(fee);
|
||||
}
|
||||
return fees;
|
||||
}
|
||||
|
||||
/** 应付主表与订单计费一对一落库;当前写入成本价/应付合计,产品价/红线价预留。 */
|
||||
private PrcPayBill persistPayBill(PrcOrderBill bill)
|
||||
{
|
||||
if (bill == null || StringUtils.isEmpty(bill.getBillId()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BigDecimal pay = nz(bill.getPayTotal());
|
||||
PrcPayBill existed = payBillMapper.selectByBillId(bill.getBillId());
|
||||
PrcPayBill row = existed == null ? new PrcPayBill() : existed;
|
||||
if (existed == null)
|
||||
{
|
||||
row.setPayBillId(UUID.randomUUID().toString());
|
||||
row.setBillId(bill.getBillId());
|
||||
row.setCreateBy(bill.getCreateBy());
|
||||
}
|
||||
row.setCurrency(StringUtils.isEmpty(bill.getCurrency()) ? "CNY" : bill.getCurrency());
|
||||
// 产品价/红线价预留
|
||||
row.setCostAmount(pay);
|
||||
row.setPayTotal(pay);
|
||||
row.setBelongSaler(bill.getBelongSaler());
|
||||
row.setBelongSalerCode(bill.getBelongSalerCode());
|
||||
row.setSettlementMan(bill.getSettlementMan());
|
||||
row.setSettlementManCode(bill.getSettlementManCode());
|
||||
row.setUpdateBy(bill.getUpdateBy());
|
||||
if (existed == null)
|
||||
{
|
||||
payBillMapper.insertPrcPayBill(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
payBillMapper.updatePrcPayBill(row);
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
private TmsPriceQuoteResult toResult(PrcOrderBill bill, List<PrcIncomeBillFee> incomeFees,
|
||||
List<PrcPayBillFee> payFees)
|
||||
{
|
||||
@@ -609,7 +730,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
||||
r.setTrackingNo(bill.getTrackingNo());
|
||||
r.setTransferNo(bill.getTransferNo());
|
||||
r.setBelongSaler(bill.getBelongSaler());
|
||||
r.setBelongSalerCode(bill.getBelongSalerCode());
|
||||
r.setSettlementMan(bill.getSettlementMan());
|
||||
r.setSettlementManCode(bill.getSettlementManCode());
|
||||
r.setServiceMan(bill.getServiceMan());
|
||||
r.setCustomerName(bill.getCustomerName());
|
||||
r.setCustomerActiveStatus(bill.getCustomerActiveStatus());
|
||||
|
||||
Reference in New Issue
Block a user