PayNotifyTaskMapper.xml 2.4 KB
Newer Older
1 2
<?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">
3
<mapper namespace="cn.iocoder.mall.pay.biz.dao.PayNotifyTaskMapper">
4 5

    <sql id="FIELDS">
6
        id, app_id, type,
YunaiV's avatar
YunaiV committed
7 8
        status, next_notify_time, last_execute_time, notify_times, max_notify_times,
        create_time
9 10
    </sql>

11 12 13
    <resultMap id="PayNotifyTaskResultMap" type="PayNotifyTaskDO">
        <result property="transaction" column="transaction"
                javaType="cn.iocoder.mall.pay.biz.dataobject.PayNotifyTaskDO$Transaction"
14
                typeHandler="cn.iocoder.mall.mybatis.type.JSONTypeHandler"/>
15 16
        <result property="refund" column="refund"
                javaType="cn.iocoder.mall.pay.biz.dataobject.PayNotifyTaskDO$Refund"
17
                typeHandler="cn.iocoder.mall.mybatis.type.JSONTypeHandler"/>
18 19
    </resultMap>

20
    <insert id="insert" parameterType="PayNotifyTaskDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
21 22 23 24
        INSERT INTO notify_task (
            app_id, type,
            status, next_notify_time, notify_times, max_notify_times,
            `transaction`, refund
25
        ) VALUES (
26 27 28 29
            #{appId}, #{type},
            #{status}, #{nextNotifyTime}, #{notifyTimes}, #{maxNotifyTimes},
            #{transaction, typeHandler=cn.iocoder.common.framework.mybatis.JSONTypeHandler},
            #{refund, typeHandler=cn.iocoder.common.framework.mybatis.JSONTypeHandler}
30 31 32
        )
    </insert>

33
    <update id="update" parameterType="PayNotifyTaskDO">
34
        UPDATE notify_task
35 36 37 38
        <set>
            <if test="status != null">
                , status = #{status}
            </if>
YunaiV's avatar
YunaiV committed
39 40 41 42 43
            <if test="nextNotifyTime != null">
                , next_notify_time = #{nextNotifyTime}
            </if>
            <if test="lastExecuteTime != null">
                , last_execute_time = #{lastExecuteTime}
44 45 46 47 48 49 50 51
            </if>
            <if test="notifyTimes != null">
                , notify_times = #{notifyTimes}
            </if>
        </set>
        WHERE id = #{id}
    </update>

52
    <select id="selectByNotify" resultMap="PayNotifyTaskResultMap">
YunaiV's avatar
YunaiV committed
53 54
        SELECT
            <include refid="FIELDS"/>
55
        FROM notify_task
56
        WHERE status IN (1, 4, 5)
YunaiV's avatar
YunaiV committed
57 58 59
        AND next_notify_time <![CDATA[ <= ]]> NOW()
        AND last_execute_time > next_notify_time
    </select>
60

61
</mapper>