admin
2025-08-20 f318c9c7c127b00f353bf45f273096d1dc4b424f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?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.taoke.autopay.dao.OrderTaskExecutionDetailMapper">
    <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.js2.OrderTaskExecutionDetail">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="task_id" property="taskId" jdbcType="BIGINT"/>
        <result column="client_id" property="clientId" jdbcType="BIGINT"/>
        <result column="execution_status" property="executionStatus" jdbcType="INTEGER"/>
        <result column="status_description" property="statusDescription" jdbcType="VARCHAR"/>
        <result column="order_no" property="orderNo" jdbcType="VARCHAR"/>
        <result column="product_name" property="productName" jdbcType="VARCHAR"/>
        <result column="shop_name" property="shopName" jdbcType="VARCHAR"/>
        <result column="coupon_code" property="couponCode" jdbcType="VARCHAR"/>
        <result column="order_time" property="orderTime" jdbcType="TIMESTAMP"/>
        <result column="receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
        <result column="review_time" property="reviewTime" jdbcType="TIMESTAMP"/>
        <result column="expected_review_time" property="expectedReviewTime" jdbcType="TIMESTAMP"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
 
    <resultMap id="ClientCountResultMap" type="com.taoke.autopay.dto.js2.ClientCountDTO">
 
        <result column="clientId" property="clientId" jdbcType="BIGINT"/>
        <result column="count" property="count" jdbcType="INTEGER"/>
 
    </resultMap>
 
    <sql id="Base_Column_List">id,task_id,client_id,execution_status,status_description,order_no,product_name,shop_name,coupon_code,order_time,receive_time,review_time,expected_review_time,create_time,update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">select
        <include refid="Base_Column_List"/>
        from table_order_task_execution_detail where id = #{id,jdbcType=VARCHAR}
    </select>
    <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.String">select
        <include refid="Base_Column_List"/>
        from table_order_task_execution_detail where id = #{id,jdbcType=VARCHAR} for update
    </select>
    <sql id="listWhereSQL">
        <if test="query.id!=null">AND id = #{query.id}</if>
        <if test="query.taskId!=null">AND task_id = #{query.taskId}</if>
        <if test="query.clientId!=null">AND client_id = #{query.clientId}</if>
        <if test="query.executionStatus!=null">AND execution_status = #{query.executionStatus}</if>
        <if test="query.statusDescription!=null">AND status_description = #{query.statusDescription}</if>
        <if test="query.orderNo!=null">AND order_no = #{query.orderNo}</if>
        <if test="query.productName!=null">AND product_name = #{query.productName}</if>
        <if test="query.shopName!=null">AND shop_name = #{query.shopName}</if>
        <if test="query.couponCode!=null">AND coupon_code = #{query.couponCode}</if>
        <if test="query.orderTime!=null">AND order_time = #{query.orderTime}</if>
        <if test="query.receiveTime!=null">AND receive_time = #{query.receiveTime}</if>
        <if test="query.reviewTime!=null">AND review_time = #{query.reviewTime}</if>
        <if test="query.expectedReviewTime!=null">AND expected_review_time = #{query.expectedReviewTime}</if>
        <if test="query.minCreateTime!=null">AND create_time >= #{query.minCreateTime}</if>
        <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} > create_time</if>
        <if test="query.minUpdateTime!=null">AND update_time >= #{query.minUpdateTime}</if>
        <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} > update_time</if>
    </sql>
    <select id="list" resultMap="BaseResultMap">select
        <include refid="Base_Column_List"/>
        from table_order_task_execution_detail where 1=1
        <include refid="listWhereSQL"/>
        <if test="query.sortList!=null">
            <foreach collection="query.sortList" item="item" open=" order by " separator=",">${item}</foreach>
        </if>
        limit #{query.start},#{query.count}
    </select>
 
 
    <select id="listByIds" resultMap="BaseResultMap" parameterType="java.lang.String">select
        <include refid="Base_Column_List"/>
        from table_order_task_execution_detail where 1=1
        <if test="ids!=null">
            <foreach collection="ids" item="item" open="and (" separator=" or " close=")">id=#{item}
            </foreach>
        </if>
    </select>
 
    <select id="count" resultType="java.lang.Long">select count(*) from table_order_task_execution_detail where 1=1
        <include refid="listWhereSQL"/>
    </select>
 
 
 
    <select id="listCanExcuteTaskDetail" resultMap="BaseResultMap" >
select
       d.*
        from `table_order_task_execution_detail` d LEFT JOIN `table_order_task` t ON t.`id`=d.`task_id`
        WHERE
        client_id = #{clientId}
        AND
        (
        (d.`execution_status`=0 AND d.`create_time` > #{minCreateTime})
        OR (d.`execution_status`=1 AND  UNIX_TIMESTAMP(NOW()) > UNIX_TIMESTAMP(d.`order_time`) + t.receive_cycle_minutes*60)
        OR (d.`execution_status`=2 AND d.expected_review_time is not null)
        ) order by d.create_time limit #{start},#{count}
    </select>
 
    <select id="countCanExcuteTaskDetail" resultType="java.lang.Long">select count(*) from
        `table_order_task_execution_detail` d LEFT JOIN `table_order_task` t ON t.`id`=d.`task_id`
        WHERE
        client_id = #{clientId}
        AND
        (
        (d.`execution_status`=0 AND d.`create_time` > #{minCreateTime})
        OR (d.`execution_status`=1 AND UNIX_TIMESTAMP(NOW()) > UNIX_TIMESTAMP(d.`order_time`) + t.receive_cycle_minutes*60)
        OR (d.`execution_status`=2 AND d.expected_review_time is not null)
        )
    </select>
 
 
 
    <select id="statisticClientIdsCountByStatus" resultMap="ClientCountResultMap">
        SELECT client_id as clientId,count(*) as count
        FROM table_order_task_execution_detail where
           <foreach collection="statusList" open="" separator=" or " item="status" >
               execution_status=#{status}
           </foreach>
        GROUP BY client_id
    </select>
    
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.String">delete from table_order_task_execution_detail where id = #{id,jdbcType=VARCHAR}</delete>
    <insert id="insert" parameterType="com.taoke.autopay.entity.js2.OrderTaskExecutionDetail" useGeneratedKeys="true"
            keyProperty="id">insert into table_order_task_execution_detail (id,task_id,client_id,execution_status,status_description,order_no,product_name,shop_name,coupon_code,order_time,receive_time,review_time,expected_review_time,create_time,update_time) values (#{id,jdbcType=VARCHAR},#{taskId,jdbcType=BIGINT},#{clientId,jdbcType=BIGINT},#{executionStatus,jdbcType=INTEGER},#{statusDescription,jdbcType=VARCHAR},#{orderNo,jdbcType=VARCHAR},#{productName,jdbcType=VARCHAR},#{shopName,jdbcType=VARCHAR},#{couponCode,jdbcType=VARCHAR},#{orderTime,jdbcType=TIMESTAMP},#{receiveTime,jdbcType=TIMESTAMP},#{reviewTime,jdbcType=TIMESTAMP},#{expectedReviewTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.taoke.autopay.entity.js2.OrderTaskExecutionDetail" useGeneratedKeys="true"
            keyProperty="id">insert into table_order_task_execution_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="taskId != null">task_id,</if>
            <if test="clientId != null">client_id,</if>
            <if test="executionStatus != null">execution_status,</if>
            <if test="statusDescription != null">status_description,</if>
            <if test="orderNo != null">order_no,</if>
            <if test="productName != null">product_name,</if>
            <if test="shopName != null">shop_name,</if>
            <if test="couponCode != null">coupon_code,</if>
            <if test="orderTime != null">order_time,</if>
            <if test="receiveTime != null">receive_time,</if>
            <if test="reviewTime != null">review_time,</if>
            <if test="expectedReviewTime != null">expected_review_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=VARCHAR},</if>
            <if test="taskId != null">#{taskId,jdbcType=BIGINT},</if>
            <if test="clientId != null">#{clientId,jdbcType=BIGINT},</if>
            <if test="executionStatus != null">#{executionStatus,jdbcType=INTEGER},</if>
            <if test="statusDescription != null">#{statusDescription,jdbcType=VARCHAR},</if>
                <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>
            <if test="productName != null">#{productName,jdbcType=VARCHAR},</if>
            <if test="shopName != null">#{shopName,jdbcType=VARCHAR},</if>
            <if test="couponCode != null">#{couponCode,jdbcType=VARCHAR},</if>
            <if test="orderTime != null">#{orderTime,jdbcType=TIMESTAMP},</if>
            <if test="receiveTime != null">#{receiveTime,jdbcType=TIMESTAMP},</if>
            <if test="reviewTime != null">#{reviewTime,jdbcType=TIMESTAMP},</if>
            <if test="expectedReviewTime != null">#{expectedReviewTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.taoke.autopay.entity.js2.OrderTaskExecutionDetail">update table_order_task_execution_detail set task_id = #{taskId,jdbcType=BIGINT},client_id = #{clientId,jdbcType=BIGINT},execution_status = #{executionStatus,jdbcType=INTEGER},status_description = #{statusDescription,jdbcType=VARCHAR},order_no = #{orderNo,jdbcType=VARCHAR},product_name = #{productName,jdbcType=VARCHAR},shop_name = #{shopName,jdbcType=VARCHAR},coupon_code = #{couponCode,jdbcType=VARCHAR},order_time = #{orderTime,jdbcType=TIMESTAMP},receive_time = #{receiveTime,jdbcType=TIMESTAMP},review_time = #{reviewTime,jdbcType=TIMESTAMP},expected_review_time = #{expectedReviewTime,jdbcType=TIMESTAMP},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where id = #{id,jdbcType=VARCHAR}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.js2.OrderTaskExecutionDetail">update table_order_task_execution_detail
        <set>
            <if test="taskId != null">task_id=#{taskId,jdbcType=BIGINT},</if>
            <if test="clientId != null">client_id=#{clientId,jdbcType=BIGINT},</if>
            <if test="executionStatus != null">execution_status=#{executionStatus,jdbcType=INTEGER},</if>
            <if test="statusDescription != null">status_description=#{statusDescription,jdbcType=VARCHAR},</if>
                <if test="orderNo != null">order_no=#{orderNo,jdbcType=VARCHAR},</if>
            <if test="productName != null">product_name=#{productName,jdbcType=VARCHAR},</if>
            <if test="shopName != null">shop_name=#{shopName,jdbcType=VARCHAR},</if>
            <if test="couponCode != null">coupon_code=#{couponCode,jdbcType=VARCHAR},</if>
            <if test="orderTime != null">order_time=#{orderTime,jdbcType=TIMESTAMP},</if>
            <if test="receiveTime != null">receive_time=#{receiveTime,jdbcType=TIMESTAMP},</if>
            <if test="reviewTime != null">review_time=#{reviewTime,jdbcType=TIMESTAMP},</if>
            <if test="expectedReviewTime != null">expected_review_time=#{expectedReviewTime,jdbcType=TIMESTAMP},</if>
            <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>
</mapper>