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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?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.KeyOrderMapper"> 
  <resultMap id="BaseResultMap" type="com.taoke.autopay.entity.KeyOrder"> 
    <id column="id" property="id" jdbcType="VARCHAR"/>  
    <result column="uid" property="uid" jdbcType="BIGINT"/>  
    <result column="key" property="key" jdbcType="VARCHAR"/>  
    <result column="order_type" property="orderType" jdbcType="INTEGER"/>  
    <result column="order_no" property="orderNo" jdbcType="VARCHAR"/>  
    <result column="order_state" property="orderState" jdbcType="INTEGER"/>  
    <result column="state" property="state" jdbcType="INTEGER"/>  
    <result column="state_desc" property="stateDesc" jdbcType="VARCHAR"/>  
    <result column="distribute_client_uid" property="distributeClientUid" jdbcType="BIGINT"/>  
    <result column="distribute_time" property="distributeTime" jdbcType="TIMESTAMP"/>  
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>  
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>  
    <result column="excute_pay_time" property="excutePayTime" jdbcType="TIMESTAMP"/>  
    <result column="pay_time" property="payTime" jdbcType="TIMESTAMP"/>  
    <result column="order_money" property="orderMoney" jdbcType="DECIMAL"/>  
    <result column="order_channel" property="orderChannel" jdbcType="VARCHAR"/>  
    <result column="pay_type" property="payType" jdbcType="INTEGER"/>  
    <result column="agent_id" property="agentId" jdbcType="BIGINT"/>  
    <result column="pay_merchant" property="payMerchant" jdbcType="VARCHAR"/>  
    <result column="ip" property="ip" jdbcType="VARCHAR"/>  
    <result column="ip_info" property="ipInfo" jdbcType="VARCHAR"/>  
    <result column="`ignore`" property="ignore" jdbcType="BOOLEAN"/>
    <result column="sub_state" property="subState" jdbcType="INTEGER"/>
    <association property="user" javaType="com.taoke.autopay.entity.WxUserInfo"> 
      <id column="uid" property="id" jdbcType="BIGINT"/>  
      <result column="nick_name" property="nickName" jdbcType="VARCHAR"/>  
      <result column="portrait" property="portrait" jdbcType="VARCHAR"/> 
    </association>
 
  </resultMap>
  <resultMap id="DistributeResultMap" type="com.taoke.autopay.entity.OrderDistributeCountInfo"> 
    <result column="uid" property="uid" jdbcType="BIGINT"/>  
    <result column="count" property="count" jdbcType="INTEGER"/> 
  </resultMap>  
  <resultMap id="ChannelOrderStatisticMap" type="com.taoke.autopay.dto.ChannelOrderStatistic"> 
    <result column="order_channel" property="orderChannel" jdbcType="VARCHAR"/>  
    <result column="count" property="count" jdbcType="BIGINT"/>  
    <result column="money" property="money" jdbcType="DECIMAL"/> 
  </resultMap>  
  <sql id="Base_Column_List">id ,uid,`key`,order_type,order_no,order_state,state,state_desc,distribute_client_uid,distribute_time,create_time,update_time,excute_pay_time,pay_time,order_money,order_channel,pay_type,agent_id,pay_merchant,ip,ip_info,`ignore`,sub_state</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select 
    <include refid="Base_Column_List"/> from table_order where id = #{id,jdbcType=BIGINT}
  </select>  
  <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.String">select 
    <include refid="Base_Column_List"/> from table_order where id = #{id,jdbcType=VARCHAR} for update
  </select>  
  <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.String">select 
    <include refid="Base_Column_List"/> from table_order where id = #{id,jdbcType=VARCHAR}
  </select>  
  <sql id="listWhereSQL"> 
    <if test="query.id!=null">AND id = #{query.id}</if>  
    <if test="query.key!=null">AND `key` = #{query.key}</if>  
    <if test="query.uid!=null">AND uid = #{query.uid}</if>  
    <if test="query.orderType!=null">AND order_type = #{query.orderType}</if>  
    <if test="query.orderNo!=null">AND order_no = #{query.orderNo}</if>  
    <if test="query.orderState!=null">AND order_state = #{query.orderState}</if>  
    <if test="query.state!=null">AND state = #{query.state}</if>  
    <if test="query.hasPayTime!=null">AND pay_time is not null</if>  
    <if test="query.hasAgentId!=null">AND agent_id is not null</if>  
    <if test="query.agentId!=null">AND agent_id = #{query.agentId}</if>  
    <if test="query.orderChannel!=null">AND order_channel = #{query.orderChannel}</if>  
    <if test="query.stateList!=null"> 
      <foreach collection="query.stateList" item="state" separator=" or " open=" AND (" close=") ">state = #{state}</foreach> 
    </if>  
    <if test="query.stateDesc!=null">AND state_desc = #{query.stateDesc}</if>  
    <if test="query.distributeClientUid!=null">AND distribute_client_uid = #{query.distributeClientUid}</if>  
    <if test="query.minDistributeTime!=null">AND distribute_time &gt;= #{query.minDistributeTime}</if>  
    <if test="query.maxDistributeTime!=null">AND #{query.maxDistributeTime} &gt; distribute_time</if>  
    <if test="query.minCreateTime!=null">AND create_time &gt;= #{query.minCreateTime}</if>  
    <if test="query.maxCreateTime!=null">AND #{query.maxCreateTime} &gt; create_time</if>  
    <if test="query.oMinCreateTime!=null">AND o.create_time &gt;= #{query.oMinCreateTime}</if>  
    <if test="query.oMaxCreateTime!=null">AND #{query.oMaxCreateTime} &gt; o.create_time</if>  
    <if test="query.minUpdateTime!=null">AND update_time &gt;= #{query.minUpdateTime}</if>  
    <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} &gt; update_time</if>  
    <if test="query.nickName!=null">AND u.nick_name like '%${query.nickName}%'</if>  
    <if test="query.ignore!=null">AND `ignore` =#{query.ignore}</if>
  </sql>  
  <select id="list" resultMap="BaseResultMap">select 
    <include refid="Base_Column_List"/> from table_order 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="listWithUser" resultMap="BaseResultMap">select o.*, u.portrait, u.nick_name from table_order o left join table_wx_user u on u.id = o.uid 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="count" resultType="java.lang.Long">select count(*) from table_order where 1=1 
    <include refid="listWhereSQL"/> 
  </select>  
  <select id="countWithUser" resultType="java.lang.Long">select count(*) from table_order o left join table_wx_user u on u.id = o.uid where 1=1 
    <include refid="listWhereSQL"/> 
  </select>  
  <select id="countUser" resultType="java.lang.Long">select count(distinct(u.id)) from table_order o left join table_wx_user u on u.id = o.uid where 1=1 
    <include refid="listWhereSQL"/> 
  </select>  
  <select id="statisticChannelOrders" resultMap="ChannelOrderStatisticMap">select order_channel, count(o.id) as count, sum(order_money) as money from table_order o left join table_wx_user u on u.id = o.uid where 1=1 
    <include refid="listWhereSQL"/> group by order_channel
  </select>  
  <select id="listAgentId" resultType="java.lang.Long">select distinct(agent_id) from table_order o 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="countAgentId" resultType="java.lang.Long">select count(distinct(agent_id)) from table_order o where 1=1 
    <include refid="listWhereSQL"/>  
    <if test="query.sortList!=null"> 
      <foreach collection="query.sortList" item="item" open=" order by " separator=",">${item}</foreach> 
    </if> 
  </select>  
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from table_order where id = #{id,jdbcType=BIGINT}</delete>  
  <insert id="insert" parameterType="com.taoke.autopay.entity.KeyOrder" useGeneratedKeys="true" keyProperty="id">insert into table_order (id, uid, key, order_type, order_no, order_state, state, state_desc, distribute_client_uid, distribute_time, create_time, update_time, id, excute_pay_time, pay_time, order_money, order_channel, pay_type, agent_id,pay_merchant,`key`,ip,ip_info,`ignore`,sub_state) values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=BIGINT}, #{key,jdbcType=VARCHAR}, #{orderType,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{orderState,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{stateDesc,jdbcType=VARCHAR}, #{distributeClientUid,jdbcType=BIGINT}, #{distributeTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{id,jdbcType=VARCHAR}, #{excutePayTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, #{orderMoney,jdbcType=DECIMAL}, #{orderChannel,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, #{agentId,jdbcType=BIGINT},#{payMerchant, jdbcType=VARCHAR},#{key,jdbcType=VARCHAR},#{ip,jdbcType=VARCHAR},#{ipInfo,jdbcType=VARCHAR},#{ignore,jdbcType=BOOLEAN},#{subState,jdbcType=INTEGER})</insert>
  <insert id="insertSelective" parameterType="com.taoke.autopay.entity.KeyOrder" useGeneratedKeys="true" keyProperty="id">insert into table_order 
    <trim prefix="(" suffix=")" suffixOverrides=","> 
      <if test="id != null">id,</if>  
      <if test="uid != null">uid,</if>  
      <if test="key != null">`key`,</if>  
      <if test="orderType != null">order_type,</if>  
      <if test="orderNo != null">order_no,</if>  
      <if test="orderState != null">order_state,</if>  
      <if test="state != null">state,</if>  
      <if test="stateDesc != null">state_desc,</if>  
      <if test="distributeClientUid != null">distribute_client_uid,</if>  
      <if test="distributeTime != null">distribute_time,</if>  
      <if test="createTime != null">create_time,</if>  
      <if test="updateTime != null">update_time,</if>  
      <if test="excutePayTime != null">excute_pay_time,</if>  
      <if test="payTime != null">pay_time,</if>  
      <if test="orderMoney != null">order_money,</if>  
      <if test="orderChannel != null">order_channel,</if>  
      <if test="payType != null">pay_type,</if>  
      <if test="agentId != null">agent_id,</if>  
      <if test="payMerchant!=null">pay_merchant,</if>  
      <if test="ip!=null">ip,</if>  
      <if test="ipInfo!=null">ip_info,</if>  
      <if test="ignore != null">`ignore`,</if>
      <if test="subState != null">sub_state,</if>  
    </trim> values
    <trim prefix="(" suffix=")" suffixOverrides=","> 
      <if test="id != null">#{id,jdbcType=VARCHAR},</if>  
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>  
      <if test="key != null">#{key,jdbcType=VARCHAR},</if>  
      <if test="orderType != null">#{orderType,jdbcType=INTEGER},</if>  
      <if test="orderNo != null">#{orderNo,jdbcType=VARCHAR},</if>  
      <if test="orderState != null">#{orderState,jdbcType=INTEGER},</if>  
      <if test="state != null">#{state,jdbcType=INTEGER},</if>  
      <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if>  
      <if test="distributeClientUid != null">#{distributeClientUid,jdbcType=BIGINT},</if>  
      <if test="distributeTime != null">#{distributeTime,jdbcType=TIMESTAMP},</if>  
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>  
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>  
      <if test="excutePayTime != null">#{excutePayTime,jdbcType=TIMESTAMP},</if>  
      <if test="payTime != null">#{payTime,jdbcType=TIMESTAMP},</if>  
      <if test="orderMoney != null">#{orderMoney,jdbcType=DECIMAL},</if>  
      <if test="orderChannel != null">#{orderChannel,jdbcType=VARCHAR},</if>  
      <if test="payType != null">#{payType,jdbcType=INTEGER},</if>  
      <if test="agentId != null">#{agentId,jdbcType=BIGINT},</if>  
      <if test="payMerchant != null">#{payMerchant,jdbcType=VARCHAR},</if>  
      <if test="ip != null">#{ip,jdbcType=VARCHAR},</if>  
      <if test="ipInfo != null">#{ipInfo,jdbcType=VARCHAR},</if>  
      <if test="ignore != null">#{ignore,jdbcType=BOOLEAN}</if>  
      <if test="subState != null">#{subState,jdbcType=INTEGER}</if>  
    </trim>
  </insert>  
  <update id="updateByPrimaryKey" parameterType="com.taoke.autopay.entity.KeyOrder">update table_order set uid = #{uid,jdbcType=BIGINT}, `key` = #{key,jdbcType=VARCHAR}, order_type = #{orderType,jdbcType=INTEGER}, order_no = #{orderNo,jdbcType=VARCHAR}, order_state = #{orderState,jdbcType=INTEGER}, state = #{state,jdbcType=INTEGER}, state_desc = #{stateDesc,jdbcType=VARCHAR}, distribute_client_uid = #{distributeClientUid,jdbcType=BIGINT}, distribute_time = #{distributeTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, excute_pay_time =#{excutePayTime,jdbcType=TIMESTAMP}, pay_time =#{payTime,jdbcType=TIMESTAMP}, order_money =#{orderMoney,jdbcType=DECIMAL}, order_channel =#{orderChannel,jdbcType=VARCHAR}, pay_type =#{payType,jdbcType=INTEGER}, agent_id =#{agentId,jdbcType=BIGINT}, pay_merchant =#{payMerchant,jdbcType=VARCHAR}, ip =#{ip,jdbcType=VARCHAR}, ip_info =#{ipInfo,jdbcType=VARCHAR}, ignore =#{ignore,jdbcType=BOOLEAN}, sub_state =#{subState,jdbcType=INTEGER}, where id = #{id,jdbcType=VARCHAR}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.taoke.autopay.entity.KeyOrder">update table_order 
    <set> 
      <if test="uid != null">uid=#{uid,jdbcType=BIGINT},</if>  
      <if test="key != null">`key`=#{key,jdbcType=VARCHAR},</if>  
      <if test="orderType != null">order_type=#{orderType,jdbcType=INTEGER},</if>  
      <if test="orderNo != null">order_no=#{orderNo,jdbcType=VARCHAR},</if>  
      <if test="orderState != null">order_state=#{orderState,jdbcType=INTEGER},</if>  
      <if test="state != null">state=#{state,jdbcType=INTEGER},</if>  
      <if test="stateDesc != null">state_desc=#{stateDesc,jdbcType=VARCHAR},</if>  
      <if test="distributeClientUid != null">distribute_client_uid=#{distributeClientUid,jdbcType=BIGINT},</if>  
      <if test="distributeTime != null">distribute_time=#{distributeTime,jdbcType=TIMESTAMP},</if>  
      <if test="createTime != null">create_time=#{createTime,jdbcType=TIMESTAMP},</if>  
      <if test="updateTime != null">update_time=#{updateTime,jdbcType=TIMESTAMP},</if>  
      <if test="excutePayTime !=null">excute_pay_time =#{excutePayTime,jdbcType=TIMESTAMP},</if>  
      <if test="payTime !=null">pay_time =#{payTime,jdbcType=TIMESTAMP},</if>  
      <if test="orderMoney !=null">order_money =#{orderMoney,jdbcType=DECIMAL},</if>  
      <if test="orderChannel !=null">order_channel =#{orderChannel,jdbcType=VARCHAR},</if>  
      <if test="payType !=null">pay_type =#{payType,jdbcType=INTEGER},</if>  
      <if test="agentId !=null">agent_id =#{agentId,jdbcType=BIGINT},</if>  
      <if test="payMerchant !=null">pay_merchant =#{payMerchant,jdbcType=VARCHAR},</if>  
      <if test="ip !=null">ip =#{ip,jdbcType=VARCHAR},</if>  
      <if test="ipInfo !=null">ip_info =#{ipInfo,jdbcType=VARCHAR},</if>  
      <if test="ignore !=null">`ignore` =#{ignore,jdbcType=BOOLEAN},</if>
      <if test="subState !=null">sub_state =#{subState,jdbcType=INTEGER},</if>  
    </set> where id = #{id,jdbcType=VARCHAR}
  </update>  
  <select id="listDistributeUids" resultMap="DistributeResultMap">SELECT u.`id` as uid, IF( a.count IS NULL,0,a.count) AS `count` FROM `table_user` u LEFT JOIN (SELECT o.`distribute_client_uid` AS uid,COUNT(*) AS `count` FROM `table_order` o WHERE o.`state` = 0 and create_time &gt; #{minKeyOrderCreateTime} GROUP BY o.`distribute_client_uid`) a ON a.uid = u.`id` WHERE rule=0  and client_type=0
    <if test="minActiveTime!=null">and active_time &gt;=#{minActiveTime}</if> 
  </select>  
  <select id="listNotDistributed" resultMap="BaseResultMap">select 
    <include refid="Base_Column_List"/> from table_order where distribute_client_uid is null and state=0 limit #{start},#{count}
  </select>  
  <delete id="deleteAll" parameterType="java.util.Date">delete from table_order where #{maxCreateTime} &gt;= create_time</delete>  
  <update id="removeDistributedClient" parameterType="java.lang.String">update table_order set distribute_client_uid = null, distribute_time = null where id = #{0}</update> 
</mapper>