admin
2024-07-27 65aaf1c05bd06cefa82ebc40cc3e01cf4ac233c0
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
<?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"/>
  </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>  
  <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</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.agentId!=null">AND agent_id = #{query.agentId}</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.minUpdateTime!=null">AND update_time &gt;= #{query.minUpdateTime}</if>  
    <if test="query.maxUpdateTime!=null">AND #{query.maxUpdateTime} &gt; update_time</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="count" resultType="java.lang.Long">select count(*) from table_order where 1=1 
    <include refid="listWhereSQL"/> 
  </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) 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})</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>
    </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>
    </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}, 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>
    </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 
    <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 where id=#{0}
  </update>
 
</mapper>