yujian
2020-06-08 b3da9f82b7740d39742fef1a81a56c22fe1c8b9c
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
<?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.yeshi.fanli.dao.mybatis.user.cloud.UserCloudMapper">
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.cloud.UserCloud">
    <id column="uc_id" property="id" jdbcType="BIGINT"/>
    <result column="uc_uid" property="uid" jdbcType="BIGINT"/>
    <result column="uc_order_id" property="orderId" jdbcType="BIGINT"/>
    <result column="uc_group_num" property="groupNum" jdbcType="INTEGER"/>
    <result column="uc_start_time" property="startTime" jdbcType="TIMESTAMP"/>
    <result column="uc_end_time" property="endTime" jdbcType="TIMESTAMP"/>
    <result column="uc_wx_id" property="wxId" jdbcType="VARCHAR"/>
    <result column="uc_wx_name" property="wxName" jdbcType="VARCHAR"/>
    <result column="uc_wx_portrait" property="wxPortrait" jdbcType="VARCHAR"/>
    <result column="uc_robot_id" property="robotId" jdbcType="INTEGER"/>
    <result column="uc_robot_type" property="robotType" jdbcType="INTEGER"/>
    <result column="uc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="uc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">uc_id,uc_uid,uc_order_id,uc_group_num,uc_start_time,uc_end_time,uc_wx_id,uc_wx_name,uc_wx_portrait,uc_robot_id,uc_robot_type,uc_create_time,uc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_user_cloud where uc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_user_cloud where uc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloud" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_cloud (uc_id,uc_uid,uc_order_id,uc_group_num,uc_start_time,uc_end_time,uc_wx_id,uc_wx_name,uc_wx_portrait,uc_robot_id,uc_robot_type,uc_create_time,uc_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{orderId,jdbcType=BIGINT},#{groupNum,jdbcType=INTEGER},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP},#{wxId,jdbcType=VARCHAR},#{wxName,jdbcType=VARCHAR},#{wxPortrait,jdbcType=VARCHAR},#{robotId,jdbcType=INTEGER},#{robotType,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloud" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_cloud
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">uc_id,</if>
      <if test="uid != null">uc_uid,</if>
      <if test="orderId != null">uc_order_id,</if>
      <if test="groupNum != null">uc_group_num,</if>
      <if test="startTime != null">uc_start_time,</if>
      <if test="endTime != null">uc_end_time,</if>
      <if test="wxId != null">uc_wx_id,</if>
      <if test="wxName != null">uc_wx_name,</if>
      <if test="wxPortrait != null">uc_wx_portrait,</if>
      <if test="robotId != null">uc_robot_id,</if>
      <if test="robotType != null">uc_robot_type,</if>
      <if test="createTime != null">uc_create_time,</if>
      <if test="updateTime != null">uc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="uid != null">#{uid,jdbcType=BIGINT},</if>
      <if test="orderId != null">#{orderId,jdbcType=BIGINT},</if>
      <if test="groupNum != null">#{groupNum,jdbcType=INTEGER},</if>
      <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="wxId != null">#{wxId,jdbcType=VARCHAR},</if>
      <if test="wxName != null">#{wxName,jdbcType=VARCHAR},</if>
      <if test="wxPortrait != null">#{wxPortrait,jdbcType=VARCHAR},</if>
      <if test="robotId != null">#{robotId,jdbcType=INTEGER},</if>
      <if test="robotType != null">#{robotType,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloud">update yeshi_ec_user_cloud set uc_uid = #{uid,jdbcType=BIGINT},uc_order_id = #{orderId,jdbcType=BIGINT},uc_group_num = #{groupNum,jdbcType=INTEGER},uc_start_time = #{startTime,jdbcType=TIMESTAMP},uc_end_time = #{endTime,jdbcType=TIMESTAMP},uc_wx_id = #{wxId,jdbcType=VARCHAR},uc_wx_name = #{wxName,jdbcType=VARCHAR},uc_wx_portrait = #{wxPortrait,jdbcType=VARCHAR},uc_robot_id = #{robotId,jdbcType=INTEGER},uc_robot_type = #{robotType,jdbcType=INTEGER},uc_create_time = #{createTime,jdbcType=TIMESTAMP},uc_update_time = #{updateTime,jdbcType=TIMESTAMP} where uc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloud">update yeshi_ec_user_cloud
    <set>
      <if test="uid != null">uc_uid=#{uid,jdbcType=BIGINT},</if>
      <if test="orderId != null">uc_order_id=#{orderId,jdbcType=BIGINT},</if>
      <if test="groupNum != null">uc_group_num=#{groupNum,jdbcType=INTEGER},</if>
      <if test="startTime != null">uc_start_time=#{startTime,jdbcType=TIMESTAMP},</if>
      <if test="endTime != null">uc_end_time=#{endTime,jdbcType=TIMESTAMP},</if>
      <if test="wxId != null">uc_wx_id=#{wxId,jdbcType=VARCHAR},</if>
      <if test="wxName != null">uc_wx_name=#{wxName,jdbcType=VARCHAR},</if>
      <if test="wxPortrait != null">uc_wx_portrait=#{wxPortrait,jdbcType=VARCHAR},</if>
      <if test="robotId != null">uc_robot_id=#{robotId,jdbcType=INTEGER},</if>
      <if test="robotType != null">uc_robot_type=#{robotType,jdbcType=INTEGER},</if>
      <if test="createTime != null">uc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">uc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where uc_id = #{id,jdbcType=BIGINT}
  </update>
  
   <select id="getLastByUid" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_cloud d
    WHERE d.`uc_uid` = #{uid}
    ORDER BY d.uc_id DESC
    LIMIT 1
  </select>
  
  <select id="getValidByUid" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_cloud d
    WHERE d.`uc_uid` = #{uid}  AND  d.`uc_end_time` > NOW()
    LIMIT 1
  </select>
  
  <select id="countByUid" resultType="Long">
      SELECT COUNT(uc_id) FROM yeshi_ec_user_cloud d
    WHERE d.`uc_uid` = #{uid}
  </select>
  
  <select id="getByOrderId" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_cloud d
    WHERE d.`uc_order_id` = #{orderId}
  </select>
  
  
  <select id="listValidUid" resultType="Long">
    SELECT * FROM (SELECT DISTINCT d.`uc_uid` FROM yeshi_ec_user_cloud d
    WHERE d.`uc_end_time` > NOW() AND d.uc_wx_id IS NOT NULL)A
    LIMIT #{start},{count}
  </select>
  
  <select id="query" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_user_cloud d
    WHERE 1=1
        <if test="key != null  and key !=''"> AND d.`uc_uid` LIKE '%#{key}%' </if>
        <if test="state == 0">AND d.`uc_end_time`<![CDATA[<=]]>NOW()</if>
        <if test="state == 1">AND d.`uc_end_time` > NOW()</if>
    ORDER BY d.`uc_id` DESC
    LIMIT #{start},#{count}
  </select>
  
  <select id="count" resultType="Long">
      SELECT count(d.`uc_id`) FROM yeshi_ec_user_cloud d
    WHERE 1=1
         <if test="key != null  and key !=''"> AND d.`uc_uid` LIKE '%#{key}%' </if>
        <if test="state == 0">AND d.`uc_end_time`<![CDATA[<=]]>NOW()</if>
        <if test="state == 1">AND d.`uc_end_time` > NOW()</if>
  </select>
  
  
</mapper>