admin
2024-10-16 62a447d89331aee1feae7724c7616aa1bb2cfe79
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
<?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.UserCloudOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder">
        <id column="crd_id" property="id" jdbcType="BIGINT"/>
        <result column="crd_uid" property="uid" jdbcType="BIGINT"/>
        <result column="crd_money" property="money" jdbcType="DECIMAL"/>
        <result column="crd_state" property="state" jdbcType="BOOLEAN"/>
        <result column="crd_desc" property="desc" jdbcType="VARCHAR"/>
        <result column="crd_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="crd_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="crd_type" property="type"
                typeHandler="com.yeshi.fanli.util.mybatishandler.CloudOrderMenuEnumHandler"/>
    </resultMap>
    <sql id="Base_Column_List">crd_id,crd_uid,crd_money,crd_type,crd_state,crd_desc,crd_create_time,crd_update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from yeshi_ec_user_cloud_order where crd_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from yeshi_ec_user_cloud_order where crd_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder" useGeneratedKeys="true"
            keyProperty="id">insert into yeshi_ec_user_cloud_order (crd_id,crd_uid,crd_money,crd_type,crd_state,crd_desc,crd_create_time,crd_update_time) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{type,jdbcType=VARCHAR},#{state,jdbcType=BOOLEAN},#{desc,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder"
            useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_user_cloud_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">crd_id,</if>
            <if test="uid != null">crd_uid,</if>
            <if test="money != null">crd_money,</if>
            <if test="type != null">crd_type,</if>
            <if test="state != null">crd_state,</if>
            <if test="desc != null">crd_desc,</if>
            <if test="createTime != null">crd_create_time,</if>
            <if test="updateTime != null">crd_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="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">#{type,jdbcType=VARCHAR},</if>
            <if test="state != null">#{state,jdbcType=BOOLEAN},</if>
            <if test="desc != null">#{desc,jdbcType=VARCHAR},</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.UserCloudOrder">update yeshi_ec_user_cloud_order set crd_uid = #{uid,jdbcType=BIGINT},crd_money = #{money,jdbcType=DECIMAL},crd_type = #{type,jdbcType=VARCHAR},crd_state = #{state,jdbcType=BOOLEAN},crd_desc = #{desc,jdbcType=VARCHAR},crd_create_time = #{createTime,jdbcType=TIMESTAMP},crd_update_time = #{updateTime,jdbcType=TIMESTAMP} where crd_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder">update
        yeshi_ec_user_cloud_order
        <set>
            <if test="uid != null">crd_uid=#{uid,jdbcType=BIGINT},</if>
            <if test="money != null">crd_money=#{money,jdbcType=DECIMAL},</if>
            <if test="type != null">crd_type=#{type,jdbcType=VARCHAR},</if>
            <if test="state != null">crd_state=#{state,jdbcType=BOOLEAN},</if>
            <if test="desc != null">crd_desc=#{desc,jdbcType=VARCHAR},</if>
            <if test="createTime != null">crd_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">crd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where crd_id = #{id,jdbcType=BIGINT}
    </update>
 
    <select id="selectForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Long">
       SELECT * from yeshi_ec_user_cloud_order where crd_id = #{id,jdbcType=BIGINT} FOR UPDATE
  </select>
 
    <select id="list" resultMap="BaseResultMap">
        SELECT * from yeshi_ec_user_cloud_order where 1=1
        <if test="type!=null">
 
            and crd_type=#{type}
        </if>
 
        <if test="uid!=null">
 
            and crd_uid=#{uid}
        </if>
 
        <if test="state!=null">
 
            and crd_state=#{state}
        </if>
 
    </select>
 
 
 
    <select id="getLastOrderByPayEnd" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_cloud_order d
    WHERE d.`crd_uid` = #{uid}  AND d.`crd_type` = #{type} AND crd_state = 1
    ORDER BY d.`crd_id` DESC
    LIMIT 1
  </select>
 
    <select id="getLastOrderByUnpaid" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM yeshi_ec_user_cloud_order d
        WHERE d.`crd_uid` = #{uid} AND d.`crd_type` = #{type} AND crd_state = 0
        ORDER BY d.`crd_id` DESC
        LIMIT 1
    </select>
 
    <select id="getOrderRecord" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_user_cloud_order d
        WHERE d.`crd_uid` = #{uid}
        <if test="state != null">and d.crd_state = #{state}</if>
        ORDER BY d.`crd_id` DESC
        LIMIT #{start},#{count}
    </select>
 
    <select id="countOrderRecord" resultType="Long">
        SELECT count(d.`crd_id`) FROM yeshi_ec_user_cloud_order d
        WHERE d.`crd_uid` = #{uid}
        <if test="state != null">and d.crd_state = #{state}</if>
    </select>
 
    <select id="getLasthourByUnpaid" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_user_cloud_order
    WHERE crd_state = 0 AND crd_update_time > DATE_SUB(NOW(),INTERVAL 2 HOUR)
  </select>
 
 
    <select id="query" resultMap="BaseResultMap">
        SELECT * FROM yeshi_ec_user_cloud_order d
        WHERE 1=1
        <if test="key != null  and key !=''">AND d.`crd_uid` LIKE '%#{key}%'</if>
        <if test="state != null">AND d.crd_state = #{state}</if>
        ORDER BY d.`crd_id` DESC
        LIMIT #{start},#{count}
    </select>
 
    <select id="count" resultType="Long">
        SELECT count(d.`crd_id`) FROM yeshi_ec_user_cloud_order d
        WHERE 1=1
        <if test="key != null and key !='' ">AND d.`crd_uid` LIKE '%#{key}%'</if>
        <if test="state != null">AND d.crd_state = #{state}</if>
    </select>
 
</mapper>