增加扩展表
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.price.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** Extension of prc_order_bill: upstream sync payload snapshot. */
|
||||||
|
@Data
|
||||||
|
public class PrcOrderBillExt implements Serializable
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** prc_order_bill.bill_id */
|
||||||
|
private String billId;
|
||||||
|
/** business order no */
|
||||||
|
private String orderNo;
|
||||||
|
/** upstream request JSON after prc_order_bill persist success */
|
||||||
|
private String syncJson;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
+1
-1
@@ -90,7 +90,7 @@ public class TmsPriceQuoteResult implements Serializable
|
|||||||
private String orderRemark;
|
private String orderRemark;
|
||||||
/** true=hit stored quote */
|
/** true=hit stored quote */
|
||||||
private Boolean fromCache;
|
private Boolean fromCache;
|
||||||
/** original TMS sync request JSON from Elasticsearch */
|
/** original TMS sync request JSON from prc_order_bill_ext */
|
||||||
private String requestJson;
|
private String requestJson;
|
||||||
/** original billing response JSON from Elasticsearch */
|
/** original billing response JSON from Elasticsearch */
|
||||||
private String responseJson;
|
private String responseJson;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.price.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.price.domain.PrcOrderBillExt;
|
||||||
|
|
||||||
|
/** prc_order_bill_ext mapper */
|
||||||
|
public interface PrcOrderBillExtMapper
|
||||||
|
{
|
||||||
|
public PrcOrderBillExt selectByBillId(String billId);
|
||||||
|
|
||||||
|
public PrcOrderBillExt selectByOrderNo(String orderNo);
|
||||||
|
|
||||||
|
public int insertPrcOrderBillExt(PrcOrderBillExt ext);
|
||||||
|
|
||||||
|
public int upsertPrcOrderBillExt(PrcOrderBillExt ext);
|
||||||
|
}
|
||||||
+37
-1
@@ -22,11 +22,13 @@ import com.ruoyi.common.utils.StringUtils;
|
|||||||
import com.ruoyi.common.utils.sign.Md5Utils;
|
import com.ruoyi.common.utils.sign.Md5Utils;
|
||||||
import com.ruoyi.price.domain.PrcIncomeBillFee;
|
import com.ruoyi.price.domain.PrcIncomeBillFee;
|
||||||
import com.ruoyi.price.domain.PrcOrderBill;
|
import com.ruoyi.price.domain.PrcOrderBill;
|
||||||
|
import com.ruoyi.price.domain.PrcOrderBillExt;
|
||||||
import com.ruoyi.price.domain.PrcPayBillFee;
|
import com.ruoyi.price.domain.PrcPayBillFee;
|
||||||
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
import com.ruoyi.price.domain.vo.TmsPriceBillRequest;
|
||||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
|
import com.ruoyi.price.domain.vo.TmsPriceQuoteFeeLine;
|
||||||
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
import com.ruoyi.price.domain.vo.TmsPriceQuoteResult;
|
||||||
import com.ruoyi.price.mapper.PrcIncomeBillFeeMapper;
|
import com.ruoyi.price.mapper.PrcIncomeBillFeeMapper;
|
||||||
|
import com.ruoyi.price.mapper.PrcOrderBillExtMapper;
|
||||||
import com.ruoyi.price.mapper.PrcOrderBillMapper;
|
import com.ruoyi.price.mapper.PrcOrderBillMapper;
|
||||||
import com.ruoyi.price.mapper.PrcPayBillFeeMapper;
|
import com.ruoyi.price.mapper.PrcPayBillFeeMapper;
|
||||||
import com.ruoyi.price.search.EsBizLogSupport;
|
import com.ruoyi.price.search.EsBizLogSupport;
|
||||||
@@ -47,6 +49,9 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PrcOrderBillMapper orderBillMapper;
|
private PrcOrderBillMapper orderBillMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PrcOrderBillExtMapper orderBillExtMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PrcIncomeBillFeeMapper incomeBillFeeMapper;
|
private PrcIncomeBillFeeMapper incomeBillFeeMapper;
|
||||||
|
|
||||||
@@ -255,8 +260,11 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
|||||||
{
|
{
|
||||||
incomeBillFeeMapper.insertBatch(fees);
|
incomeBillFeeMapper.insertBatch(fees);
|
||||||
}
|
}
|
||||||
|
String syncJson = toRequestJson(request);
|
||||||
|
persistBillExt(bill, syncJson);
|
||||||
|
result.setRequestJson(syncJson);
|
||||||
syncOrderCredit(bill, previousIncome);
|
syncOrderCredit(bill, previousIncome);
|
||||||
billSearchStore.save(EsLogType.BILL, orderNo, toRequestJson(request), toResponseJson(result));
|
billSearchStore.save(EsLogType.BILL, orderNo, syncJson, toResponseJson(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -443,9 +451,37 @@ public class PrcOrderBillServiceImpl implements IPrcOrderBillService
|
|||||||
r.setBizDate(bill.getBizDate());
|
r.setBizDate(bill.getBizDate());
|
||||||
r.setFeeDetails(toIncomeFeeLines(incomeFees));
|
r.setFeeDetails(toIncomeFeeLines(incomeFees));
|
||||||
r.setPayFeeDetails(toPayFeeLines(payFees));
|
r.setPayFeeDetails(toPayFeeLines(payFees));
|
||||||
|
fillSyncJson(r, bill.getBillId());
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Persist upstream request JSON after prc_order_bill insert/update succeeds. */
|
||||||
|
private void persistBillExt(PrcOrderBill bill, String syncJson)
|
||||||
|
{
|
||||||
|
if (bill == null || StringUtils.isEmpty(bill.getBillId()) || StringUtils.isEmpty(syncJson))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PrcOrderBillExt ext = new PrcOrderBillExt();
|
||||||
|
ext.setBillId(bill.getBillId());
|
||||||
|
ext.setOrderNo(bill.getOrderNo());
|
||||||
|
ext.setSyncJson(syncJson);
|
||||||
|
orderBillExtMapper.upsertPrcOrderBillExt(ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillSyncJson(TmsPriceQuoteResult result, String billId)
|
||||||
|
{
|
||||||
|
if (result == null || StringUtils.isEmpty(billId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PrcOrderBillExt ext = orderBillExtMapper.selectByBillId(billId);
|
||||||
|
if (ext != null)
|
||||||
|
{
|
||||||
|
result.setRequestJson(ext.getSyncJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<TmsPriceQuoteFeeLine> toIncomeFeeLines(List<PrcIncomeBillFee> fees)
|
private List<TmsPriceQuoteFeeLine> toIncomeFeeLines(List<PrcIncomeBillFee> fees)
|
||||||
{
|
{
|
||||||
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
|
List<TmsPriceQuoteFeeLine> lines = new ArrayList<TmsPriceQuoteFeeLine>();
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.price.mapper.PrcOrderBillExtMapper">
|
||||||
|
|
||||||
|
<resultMap type="PrcOrderBillExt" id="PrcOrderBillExtResult">
|
||||||
|
<id property="billId" column="bill_id" />
|
||||||
|
<result property="orderNo" column="order_no" />
|
||||||
|
<result property="syncJson" column="sync_json" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectPrcOrderBillExtVo">
|
||||||
|
select bill_id, order_no, sync_json, create_time, update_time
|
||||||
|
from prc_order_bill_ext
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByBillId" parameterType="String" resultMap="PrcOrderBillExtResult">
|
||||||
|
<include refid="selectPrcOrderBillExtVo"/>
|
||||||
|
where bill_id = #{billId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByOrderNo" parameterType="String" resultMap="PrcOrderBillExtResult">
|
||||||
|
<include refid="selectPrcOrderBillExtVo"/>
|
||||||
|
where order_no = #{orderNo}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertPrcOrderBillExt" parameterType="PrcOrderBillExt">
|
||||||
|
insert into prc_order_bill_ext (
|
||||||
|
bill_id, order_no, sync_json, create_time, update_time
|
||||||
|
) values (
|
||||||
|
#{billId}, #{orderNo}, #{syncJson}, sysdate(), sysdate()
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="upsertPrcOrderBillExt" parameterType="PrcOrderBillExt">
|
||||||
|
insert into prc_order_bill_ext (
|
||||||
|
bill_id, order_no, sync_json, create_time, update_time
|
||||||
|
) values (
|
||||||
|
#{billId}, #{orderNo}, #{syncJson}, sysdate(), sysdate()
|
||||||
|
)
|
||||||
|
on duplicate key update
|
||||||
|
order_no = values(order_no),
|
||||||
|
sync_json = values(sync_json),
|
||||||
|
update_time = sysdate()
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
-- prc_order_bill_ext: snapshot of upstream sync payload after prc_order_bill persist success
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS prc_order_bill_ext (
|
||||||
|
bill_id VARCHAR(36) NOT NULL COMMENT '计费订单ID,对应 prc_order_bill.bill_id',
|
||||||
|
order_no VARCHAR(64) NOT NULL COMMENT '订单号',
|
||||||
|
sync_json LONGTEXT NOT NULL COMMENT '上游同步成功写入 prc_order_bill 时的请求JSON',
|
||||||
|
create_time DATETIME NOT NULL COMMENT '创建时间',
|
||||||
|
update_time DATETIME DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (bill_id),
|
||||||
|
UNIQUE KEY uk_order_bill_ext_order (order_no),
|
||||||
|
CONSTRAINT fk_order_bill_ext_bill FOREIGN KEY (bill_id) REFERENCES prc_order_bill (bill_id) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='订单计费扩展表';
|
||||||
Reference in New Issue
Block a user