后端:完成退款逻辑

This commit is contained in:
YunaiV
2019-04-27 01:52:24 +08:00
parent 1be40cb195
commit 207fdc1d55
27 changed files with 446 additions and 335 deletions

View File

@@ -1,6 +1,6 @@
<?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="cn.iocoder.mall.pay.biz.dao.PayTransactionNotifyLogMapper">
<mapper namespace="cn.iocoder.mall.pay.biz.dao.PayNotifyLogMapper">
<!--<sql id="FIELDS">-->
<!--id, transaction_id, transaction_extension_id, app_id, order_id,-->
@@ -9,7 +9,7 @@
<!--</sql>-->
<insert id="insert" parameterType="PayNotifyLogDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO transaction_notify_log (
INSERT INTO notify_log (
notify_id, request, response, status
) VALUES (
#{notifyId}, #{request}, #{response}, #{status}

View File

@@ -1,25 +1,37 @@
<?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="cn.iocoder.mall.pay.biz.dao.PayTransactionNotifyTaskMapper">
<mapper namespace="cn.iocoder.mall.pay.biz.dao.PayNotifyTaskMapper">
<sql id="FIELDS">
id, transaction_id, transaction_extension_id, app_id, order_id,
id, app_id, type,
status, next_notify_time, last_execute_time, notify_times, max_notify_times,
create_time
</sql>
<resultMap id="PayNotifyTaskResultMap" type="PayNotifyTaskDO">
<result property="transaction" column="transaction"
javaType="cn.iocoder.mall.pay.biz.dataobject.PayNotifyTaskDO$Transaction"
typeHandler="cn.iocoder.common.framework.mybatis.JSONTypeHandler"/>
<result property="refund" column="refund"
javaType="cn.iocoder.mall.pay.biz.dataobject.PayNotifyTaskDO$Refund"
typeHandler="cn.iocoder.common.framework.mybatis.JSONTypeHandler"/>
</resultMap>
<insert id="insert" parameterType="PayNotifyTaskDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO transaction_notify_task (
transaction_id, transaction_extension_id, app_id, order_id,
status, next_notify_time, notify_times, max_notify_times
INSERT INTO notify_task (
app_id, type,
status, next_notify_time, notify_times, max_notify_times,
`transaction`, refund
) VALUES (
#{transactionId}, #{transactionExtensionId}, #{appId}, #{orderId},
#{status}, #{nextNotifyTime}, #{notifyTimes}, #{maxNotifyTimes}
#{appId}, #{type},
#{status}, #{nextNotifyTime}, #{notifyTimes}, #{maxNotifyTimes},
#{transaction, typeHandler=cn.iocoder.common.framework.mybatis.JSONTypeHandler},
#{refund, typeHandler=cn.iocoder.common.framework.mybatis.JSONTypeHandler}
)
</insert>
<update id="update" parameterType="PayNotifyTaskDO">
UPDATE transaction_notify_task
UPDATE notify_task
<set>
<if test="status != null">
, status = #{status}
@@ -37,10 +49,10 @@
WHERE id = #{id}
</update>
<select id="selectByNotify" resultType="PayNotifyTaskDO">
<select id="selectByNotify" resultMap="PayNotifyTaskResultMap">
SELECT
<include refid="FIELDS"/>
FROM transaction_notify_task
FROM notify_task
WHERE status IN (1, 4, 5)
AND next_notify_time <![CDATA[ <= ]]> NOW()
AND last_execute_time > next_notify_time

View File

@@ -3,7 +3,7 @@
<mapper namespace="cn.iocoder.mall.pay.biz.dao.PayRefundMapper">
<sql id="FIELDS">
id, transaction_id, refund_cod, app_id, create_ip, order_id,
id, transaction_id, refund_code, app_id, create_ip, order_id,
order_description, price, status,
finish_time, notify_url, extension_data, refund_channel, refund_time, notify_time,
trade_no, create_time

View File

@@ -56,8 +56,8 @@
<update id="updateForRefundTotal">
UPDATE `transaction`
SET refundTotal = refundTotal + ${refundTotalIncr}
WHERE price >= refundTotal + ${refundTotalIncr}
SET refund_total = refund_total + ${refundTotalIncr}
WHERE price >= refund_total + ${refundTotalIncr}
</update>
<select id="selectByAppIdAndOrderId" resultType="PayTransactionDO">