修改计费文档,加上客户代码
This commit is contained in:
@@ -17,6 +17,8 @@ public class PrcBillingTask extends BaseEntity
|
||||
private String transferNo;
|
||||
private String trackingNo;
|
||||
private String orderNo;
|
||||
/** Customer code snapshot for filter / rebill */
|
||||
private String customerCode;
|
||||
/** PENDING / REBILL / REFUND */
|
||||
private String billType;
|
||||
/** WAITING / SUCCESS / FAILED */
|
||||
|
||||
+2
@@ -18,6 +18,8 @@ public class BillingTaskSubmitRequest implements Serializable
|
||||
private String transferNo;
|
||||
private String trackingNo;
|
||||
private String orderNo;
|
||||
/** Optional customer code; also filled from Oracle when task runs */
|
||||
private String customerCode;
|
||||
/** Billing time from mobile; persisted to prc_billing_task.bill_time */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date billTime;
|
||||
|
||||
+31
-2
@@ -86,6 +86,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
task.setTransferNo(transferNo);
|
||||
task.setTrackingNo(trackingNo);
|
||||
task.setOrderNo(orderNo);
|
||||
task.setCustomerCode(trim(request.getCustomerCode()));
|
||||
task.setBillTime(billTime);
|
||||
task.setBillType(type.getCode());
|
||||
task.setSuccessStatus(BillTaskSuccessStatus.WAITING.getCode());
|
||||
@@ -93,8 +94,8 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
billingTaskMapper.insertPrcBillingTask(task);
|
||||
|
||||
billingTaskMqPublisher.publish(new BillingTaskMessage(task.getTaskId()));
|
||||
log.info("billing task submitted taskId={} type={} billTime={} transferNo={} trackingNo={} orderNo={}",
|
||||
task.getTaskId(), task.getBillType(), billTime, transferNo, trackingNo, orderNo);
|
||||
log.info("billing task submitted taskId={} type={} billTime={} customerCode={} transferNo={} trackingNo={} orderNo={}",
|
||||
task.getTaskId(), task.getBillType(), billTime, task.getCustomerCode(), transferNo, trackingNo, orderNo);
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -130,6 +131,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
{
|
||||
String refundOrderNo = resolveRefundOrderNo(task);
|
||||
log.info("billing task REFUND path taskId={} orderNo={}", taskId, refundOrderNo);
|
||||
fillCustomerCodeFromBill(task, refundOrderNo);
|
||||
TmsPriceQuoteResult result = refundWithDbRetry(taskId, refundOrderNo);
|
||||
writeback(task, BillTaskSuccessStatus.SUCCESS, result == null ? null : result.getBillId(),
|
||||
null);
|
||||
@@ -175,6 +177,7 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
}
|
||||
// Billing date from task.bill_time (mobile), not Oracle CREATE_DATE.
|
||||
billReq.setBizDate(new SimpleDateFormat("yyyy-MM-dd").format(task.getBillTime()));
|
||||
task.setCustomerCode(billReq.getCustomerCode());
|
||||
|
||||
TmsPriceQuoteResult result = billWithDbRetry(taskId, billReq);
|
||||
writeback(task, BillTaskSuccessStatus.SUCCESS, result == null ? null : result.getBillId(),
|
||||
@@ -381,6 +384,28 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
}
|
||||
|
||||
/** Write back status/billId/failCode/error only; keep inbound transfer/tracking/order/billTime untouched. */
|
||||
/** Prefer existing bill customer when task has none (REFUND path). */
|
||||
private void fillCustomerCodeFromBill(PrcBillingTask task, String orderNo)
|
||||
{
|
||||
if (task == null || StringUtils.isNotEmpty(task.getCustomerCode()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PrcOrderBill bill = null;
|
||||
if (StringUtils.isNotEmpty(orderNo))
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillByOrderNo(orderNo.trim());
|
||||
}
|
||||
if (bill == null && StringUtils.isNotEmpty(task.getBillId()))
|
||||
{
|
||||
bill = orderBillMapper.selectPrcOrderBillById(task.getBillId());
|
||||
}
|
||||
if (bill != null && StringUtils.isNotEmpty(bill.getCustomerCode()))
|
||||
{
|
||||
task.setCustomerCode(bill.getCustomerCode().trim());
|
||||
}
|
||||
}
|
||||
|
||||
private void writeback(PrcBillingTask task, BillTaskSuccessStatus status, String billId,
|
||||
String errorMessage)
|
||||
{
|
||||
@@ -388,6 +413,10 @@ public class PrcBillingTaskServiceImpl implements IPrcBillingTaskService
|
||||
upd.setTaskId(task.getTaskId());
|
||||
upd.setSuccessStatus(status.getCode());
|
||||
upd.setBillId(billId);
|
||||
if (StringUtils.isNotEmpty(task.getCustomerCode()))
|
||||
{
|
||||
upd.setCustomerCode(task.getCustomerCode());
|
||||
}
|
||||
if (BillTaskSuccessStatus.FAILED == status)
|
||||
{
|
||||
upd.setFailCode(BillTaskFailCode.resolveCode(errorMessage));
|
||||
|
||||
@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="transferNo" column="transfer_no" />
|
||||
<result property="trackingNo" column="tracking_no" />
|
||||
<result property="orderNo" column="order_no" />
|
||||
<result property="customerCode" column="customer_code" />
|
||||
<result property="billType" column="bill_type" />
|
||||
<result property="successStatus" column="success_status" />
|
||||
<result property="billTime" column="bill_time" />
|
||||
@@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcBillingTaskVo">
|
||||
select task_id, transfer_no, tracking_no, order_no, bill_type, success_status,
|
||||
select task_id, transfer_no, tracking_no, order_no, customer_code, bill_type, success_status,
|
||||
bill_time, bill_id, fail_code, error_message, create_by, create_time, update_by, update_time
|
||||
from prc_billing_task
|
||||
</sql>
|
||||
@@ -44,6 +45,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
AND order_no like concat('%', #{orderNo}, '%')
|
||||
</if>
|
||||
<if test="customerCode != null and customerCode != ''">
|
||||
AND customer_code like concat('%', #{customerCode}, '%')
|
||||
</if>
|
||||
<if test="billType != null and billType != ''">
|
||||
AND bill_type = #{billType}
|
||||
</if>
|
||||
@@ -65,10 +69,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertPrcBillingTask" parameterType="PrcBillingTask" useGeneratedKeys="true" keyProperty="taskId">
|
||||
insert into prc_billing_task (
|
||||
transfer_no, tracking_no, order_no, bill_type, success_status,
|
||||
transfer_no, tracking_no, order_no, customer_code, bill_type, success_status,
|
||||
bill_time, bill_id, fail_code, error_message, create_by, create_time
|
||||
) values (
|
||||
#{transferNo}, #{trackingNo}, #{orderNo}, #{billType}, #{successStatus},
|
||||
#{transferNo}, #{trackingNo}, #{orderNo}, #{customerCode}, #{billType}, #{successStatus},
|
||||
#{billTime}, #{billId}, #{failCode}, #{errorMessage}, #{createBy}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
@@ -79,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="transferNo != null">transfer_no = #{transferNo},</if>
|
||||
<if test="trackingNo != null">tracking_no = #{trackingNo},</if>
|
||||
<if test="orderNo != null">order_no = #{orderNo},</if>
|
||||
<if test="customerCode != null">customer_code = #{customerCode},</if>
|
||||
<if test="billType != null">bill_type = #{billType},</if>
|
||||
<if test="successStatus != null">success_status = #{successStatus},</if>
|
||||
<if test="billTime != null">bill_time = #{billTime},</if>
|
||||
@@ -91,13 +96,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
<!-- Keep inbound transfer/tracking/order/bill_time; only write status result. -->
|
||||
<!-- Keep inbound identity keys/bill_time; write status + optional customer_code snapshot. -->
|
||||
<update id="updateBillingResult" parameterType="PrcBillingTask">
|
||||
update prc_billing_task
|
||||
set success_status = #{successStatus},
|
||||
bill_id = #{billId},
|
||||
fail_code = #{failCode},
|
||||
error_message = #{errorMessage},
|
||||
<if test="customerCode != null">
|
||||
customer_code = #{customerCode},
|
||||
</if>
|
||||
update_time = sysdate()
|
||||
where task_id = #{taskId}
|
||||
</update>
|
||||
|
||||
Reference in New Issue
Block a user