admin
2022-08-25 c9db68e33f90231b064b8864fc69ccf7d25f5e0b
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
<?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.ks.lijin.mapper.LiJinExpendRecordMapper">
    <resultMap id="BaseResultMap" type="com.ks.lijin.pojo.DO.LiJinExpendRecord">
        <id column="rd_id" property="id" jdbcType="BIGINT"/>
        <result column="rd_uid" property="uid" jdbcType="VARCHAR"/>
        <result column="rd_account_id" property="accountId" jdbcType="BIGINT"/>
        <result column="rd_goods_id" property="goodsId" jdbcType="VARCHAR"/>
        <result column="rd_money" property="money" jdbcType="DECIMAL"/>
        <result column="rd_num" property="num" jdbcType="INTEGER"/>
        <result column="rd_title" property="title" jdbcType="VARCHAR"/>
        <result column="rd_rights_id" property="rightsId" jdbcType="VARCHAR"/>
        <result column="rd_send_url" property="sendUrl" jdbcType="VARCHAR"/>
        <result column="rd_unfreeze_amount" property="unfreezeAmount" jdbcType="DECIMAL"/>
        <result column="rd_unfreeze_num" property="unfreezeNum" jdbcType="INTEGER"/>
        <result column="rd_refund_amount" property="refundAmount" jdbcType="DECIMAL"/>
        <result column="rd_refund_num" property="refundNum" jdbcType="INTEGER"/>
        <result column="rd_alipay_amount" property="alipayAmount" jdbcType="DECIMAL"/>
        <result column="rd_use_amount" property="useAmount" jdbcType="DECIMAL"/>
        <result column="rd_use_num" property="useNum" jdbcType="INTEGER"/>
        <result column="rd_win_amount" property="winAmount" jdbcType="DECIMAL"/>
        <result column="rd_win_num" property="winNum" jdbcType="INTEGER"/>
        <result column="rd_pre_commission_amount" property="preCommissionAmount" jdbcType="DECIMAL"/>
        <result column="rd_create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="rd_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">rd_id,rd_uid,rd_account_id,rd_goods_id,rd_money,rd_num,rd_title,rd_rights_id,rd_send_url,rd_unfreeze_amount,rd_unfreeze_num,rd_refund_amount,rd_refund_num,rd_alipay_amount,rd_use_amount,rd_use_num,rd_win_amount,rd_win_num,rd_pre_commission_amount,rd_create_time,rd_update_time</sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
        <include refid="Base_Column_List"/>from tlj_expend_record where rd_id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="java.lang.Long">delete from tlj_expend_record where rd_id = #{id,jdbcType=BIGINT}</delete>
    <insert id="insert" parameterType="com.ks.lijin.pojo.DO.LiJinExpendRecord" useGeneratedKeys="true"
            keyProperty="id">insert into tlj_expend_record (rd_id, rd_uid, rd_account_id, rd_goods_id, rd_money, rd_num, rd_title, rd_rights_id, rd_send_url, rd_unfreeze_amount, rd_unfreeze_num, rd_refund_amount, rd_refund_num, rd_alipay_amount, rd_use_amount, rd_use_num, rd_win_amount, rd_win_num, rd_pre_commission_amount, rd_create_time, rd_update_time)values (#{id,jdbcType=BIGINT}, #{uid,jdbcType=VARCHAR}, #{accountId,jdbcType=BIGINT}, #{goodsId,jdbcType=VARCHAR}, #{money,jdbcType=DECIMAL}, #{num,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{rightsId,jdbcType=VARCHAR}, #{sendUrl,jdbcType=VARCHAR}, #{unfreezeAmount,jdbcType=DECIMAL}, #{unfreezeNum,jdbcType=INTEGER}, #{refundAmount,jdbcType=DECIMAL}, #{refundNum,jdbcType=INTEGER}, #{alipayAmount,jdbcType=DECIMAL}, #{useAmount,jdbcType=DECIMAL}, #{useNum,jdbcType=INTEGER}, #{winAmount,jdbcType=DECIMAL}, #{winNum,jdbcType=INTEGER}, #{preCommissionAmount,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})</insert>
    <insert id="insertSelective" parameterType="com.ks.lijin.pojo.DO.LiJinExpendRecord" useGeneratedKeys="true"
            keyProperty="id">insert into tlj_expend_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">rd_id,</if>
            <if test="uid != null">rd_uid,</if>
            <if test="accountId != null">rd_account_id,</if>
            <if test="goodsId != null">rd_goods_id,</if>
            <if test="money != null">rd_money,</if>
            <if test="num != null">rd_num,</if>
            <if test="title != null">rd_title,</if>
            <if test="rightsId != null">rd_rights_id,</if>
            <if test="sendUrl != null">rd_send_url,</if>
            <if test="unfreezeAmount != null">rd_unfreeze_amount,</if>
            <if test="unfreezeNum != null">rd_unfreeze_num,</if>
            <if test="refundAmount != null">rd_refund_amount,</if>
            <if test="refundNum != null">rd_refund_num,</if>
            <if test="alipayAmount != null">rd_alipay_amount,</if>
            <if test="useAmount != null">rd_use_amount,</if>
            <if test="useNum != null">rd_use_num,</if>
            <if test="winAmount != null">rd_win_amount,</if>
            <if test="winNum != null">rd_win_num,</if>
            <if test="preCommissionAmount != null">rd_pre_commission_amount,</if>
            <if test="createTime != null">rd_create_time,</if>
            <if test="updateTime != null">rd_update_time,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="uid != null">#{uid,jdbcType=VARCHAR},</if>
            <if test="accountId != null">#{accountId,jdbcType=BIGINT},</if>
            <if test="goodsId != null">#{goodsId,jdbcType=VARCHAR},</if>
            <if test="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="num != null">#{num,jdbcType=INTEGER},</if>
            <if test="title != null">#{title,jdbcType=VARCHAR},</if>
            <if test="rightsId != null">#{rightsId,jdbcType=VARCHAR},</if>
            <if test="sendUrl != null">#{sendUrl,jdbcType=VARCHAR},</if>
            <if test="unfreezeAmount != null">#{unfreezeAmount,jdbcType=DECIMAL},</if>
            <if test="unfreezeNum != null">#{unfreezeNum,jdbcType=INTEGER},</if>
            <if test="refundAmount != null">#{refundAmount,jdbcType=DECIMAL},</if>
            <if test="refundNum != null">#{refundNum,jdbcType=INTEGER},</if>
            <if test="alipayAmount != null">#{alipayAmount,jdbcType=DECIMAL},</if>
            <if test="useAmount != null">#{useAmount,jdbcType=DECIMAL},</if>
            <if test="useNum != null">#{useNum,jdbcType=INTEGER},</if>
            <if test="winAmount != null">#{winAmount,jdbcType=DECIMAL},</if>
            <if test="winNum != null">#{winNum,jdbcType=INTEGER},</if>
            <if test="preCommissionAmount != null">#{preCommissionAmount,jdbcType=DECIMAL},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey"
            parameterType="com.ks.lijin.pojo.DO.LiJinExpendRecord">update tlj_expend_record set rd_uid = #{uid,jdbcType=VARCHAR},rd_account_id = #{accountId,jdbcType=BIGINT},rd_goods_id = #{goodsId,jdbcType=VARCHAR},rd_money = #{money,jdbcType=DECIMAL},rd_num = #{num,jdbcType=INTEGER},rd_title = #{title,jdbcType=VARCHAR},rd_rights_id = #{rightsId,jdbcType=VARCHAR},rd_send_url = #{sendUrl,jdbcType=VARCHAR},rd_unfreeze_amount = #{unfreezeAmount,jdbcType=DECIMAL},rd_unfreeze_num = #{unfreezeNum,jdbcType=INTEGER},rd_refund_amount = #{refundAmount,jdbcType=DECIMAL},rd_refund_num = #{refundNum,jdbcType=INTEGER},rd_alipay_amount = #{alipayAmount,jdbcType=DECIMAL},rd_use_amount = #{useAmount,jdbcType=DECIMAL},rd_use_num = #{useNum,jdbcType=INTEGER},rd_win_amount = #{winAmount,jdbcType=DECIMAL},rd_win_num = #{winNum,jdbcType=INTEGER},rd_pre_commission_amount = #{preCommissionAmount,jdbcType=DECIMAL},rd_create_time = #{createTime,jdbcType=TIMESTAMP},rd_update_time = #{updateTime,jdbcType=TIMESTAMP}where rd_id = #{id,jdbcType=BIGINT}</update>
    <update id="updateByPrimaryKeySelective" parameterType="com.ks.lijin.pojo.DO.LiJinExpendRecord">update
        tlj_expend_record
        <set>
            <if test="uid != null">rd_uid=#{uid,jdbcType=VARCHAR},</if>
            <if test="accountId != null">rd_account_id=#{accountId,jdbcType=BIGINT},</if>
            <if test="goodsId != null">rd_goods_id=#{goodsId,jdbcType=VARCHAR},</if>
            <if test="money != null">rd_money=#{money,jdbcType=DECIMAL},</if>
            <if test="num != null">rd_num=#{num,jdbcType=INTEGER},</if>
            <if test="title != null">rd_title=#{title,jdbcType=VARCHAR},</if>
            <if test="rightsId != null">rd_rights_id=#{rightsId,jdbcType=VARCHAR},</if>
            <if test="sendUrl != null">rd_send_url=#{sendUrl,jdbcType=VARCHAR},</if>
            <if test="unfreezeAmount != null">rd_unfreeze_amount=#{unfreezeAmount,jdbcType=DECIMAL},</if>
            <if test="unfreezeNum != null">rd_unfreeze_num=#{unfreezeNum,jdbcType=INTEGER},</if>
            <if test="refundAmount != null">rd_refund_amount=#{refundAmount,jdbcType=DECIMAL},</if>
            <if test="refundNum != null">rd_refund_num=#{refundNum,jdbcType=INTEGER},</if>
            <if test="alipayAmount != null">rd_alipay_amount=#{alipayAmount,jdbcType=DECIMAL},</if>
            <if test="useAmount != null">rd_use_amount=#{useAmount,jdbcType=DECIMAL},</if>
            <if test="useNum != null">rd_use_num=#{useNum,jdbcType=INTEGER},</if>
            <if test="winAmount != null">rd_win_amount=#{winAmount,jdbcType=DECIMAL},</if>
            <if test="winNum != null">rd_win_num=#{winNum,jdbcType=INTEGER},</if>
            <if test="preCommissionAmount != null">rd_pre_commission_amount=#{preCommissionAmount,jdbcType=DECIMAL},
            </if>
            <if test="createTime != null">rd_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">rd_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where rd_id = #{id,jdbcType=BIGINT}
    </update>
 
    <!-- 非模板 -->
    <sql id="listWhere">
        <if test="query.uid!=null">and rd_uid=#{query.uid}</if>
        <if test="query.accountId!=null">and rd_account_id=#{query.accountId}</if>
        <if test="query.goodsId!=null">and rd_goods_id=#{query.goodsId}</if>
        <if test="query.money!=null">and rd_money=#{query.money}</if>
        <if test="query.num!=null">and rd_num=#{query.num}</if>
        <if test="query.title!=null">and rd_title=#{query.title}</if>
        <if test="query.rightsId!=null">and rd_rights_id=#{query.rightsId}</if>
    </sql>
 
 
    <select id="listByPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tlj_expend_record
        where 1=1
        <include refid="listWhere"/>
        limit #{query.start},#{query.count}
    </select>
 
    <select id="count" resultType="java.lang.Long">
        select IFNULL(count(*),0) from tlj_expend_record
        where 1=1
        <include refid="listWhere"/>
    </select>
 
    <select id="countTodayNumByExpend" resultType="Integer">
    select  IFNULL(count(*),0) from tlj_expend_record
    where rd_uid=#{uid}  and date(rd_create_time) = curdate();
  </select>
 
    <select id="countTodayMoneyByExpend" resultType="BigDecimal">
    select  IFNULL(SUM(rd_money),0) from tlj_expend_record
    where rd_uid=#{uid}  and date(rd_create_time) = curdate();
  </select>
 
 
    <select id="getMaxMoneyRecord" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tlj_expend_record
        where rd_goods_id=#{goodsId} AND rd_create_time>=#{minCreatetime} and #{maxCreatetime}>rd_create_time order by
        rd_money desc limit 1
    </select>
 
    <select id="listOnGoingLijin" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tlj_expend_record
        where (rd_win_num=0 || rd_win_num IS NULL || rd_use_num=0 || rd_use_num IS NULL) AND (rd_refund_num=0 ||
        rd_refund_num IS NULL)
        <if test="minCreateTime!=null">
            AND rd_create_time>=#{minCreateTime}
        </if>
        <if test="maxCreateTime!=null">
            AND #{maxCreateTime}>rd_create_time
        </if>
        limit #{start},#{count}
    </select>
 
 
    <select id="countOnGoingLijin" resultType="java.lang.Long">
        select count(*) from tlj_expend_record
        where (rd_win_num=0 || rd_win_num IS NULL || rd_use_num=0 || rd_use_num IS NULL) AND (rd_refund_num=0 ||
        rd_refund_num IS NULL)
        <if test="minCreateTime!=null">
            AND rd_create_time>=#{minCreateTime}
        </if>
        <if test="maxCreateTime!=null">
            AND #{maxCreateTime}>rd_create_time
        </if>
    </select>
 
</mapper>