admin
2024-06-30 b6fdf185c7e8fb1f06da0e609e39aecaef6b66f5
src/main/resources/mapper/KeyOrderMapper.xml
@@ -1,138 +1,126 @@
<?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"/>
<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"/>
  </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</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <result column="excute_pay_time" property="excutePayTime" jdbcType="TIMESTAMP"/>
    <result column="pay_time" property="payTime" jdbcType="TIMESTAMP"/>
  </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</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
  </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
  </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.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 >= #{query.minDistributeTime}</if>
    <if test="query.maxDistributeTime!=null">AND #{query.maxDistributeTime} > distribute_time</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 where 1=1
    <include refid="listWhereSQL"/>
    <if test="query.sortList!=null">
      <foreach collection="query.sortList" item="item" open=" order by " separator=",">${item}</foreach>
  </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.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) 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})</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>
  </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) 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})</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>
    </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="excutePayTime != null">excute_pay_time,</if>
      <if test="payTime != null">pay_time,</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>
    </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} 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">#{excutePayTime,jdbcType=TIMESTAMP}</if>
      <if test="payTime != null">#{payTime,jdbcType=TIMESTAMP}</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} 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="excutePayTime !=null">pay_time =#{payTime,jdbcType=TIMESTAMP},</if>
    </set> where id = #{id,jdbcType=VARCHAR}
  </update>
  <select id="listDistributeUids" resultMap="DistributeResultMap" parameterType="java.util.Date">
     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 GROUP BY o.`distribute_client_uid`) a ON a.uid = u.`id` WHERE rule=0 <if test="minActiveTime!=null">
    and active_time >=#{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} >= create_time
  </delete>
  </update>
  <select id="listDistributeUids" resultMap="DistributeResultMap" parameterType="java.util.Date">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 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>
</mapper>