puzhibing
4 天以前 a0e03b646f2c444b0f09687d24e9995112b99017
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
<?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.ruoyi.account.mapper.TAppUserWhitelistMapper">
 
    <resultMap id="BaseResultMap" type="com.ruoyi.account.api.model.TAppUserWhitelist">
        <id column="id" property="id" />
        <result column="app_user_id" property="appUserId" />
        <result column="phone" property="phone" />
        <result column="name" property="name" />
        <result column="benefit_type" property="benefitType" />
        <result column="scope_type" property="scopeType" />
        <result column="partner_id" property="partnerId" />
        <result column="company_id" property="companyId" />
        <result column="fleet_id" property="fleetId" />
        <result column="balance" property="balance" />
        <result column="status" property="status" />
        <result column="create_by" property="createBy" />
        <result column="create_time" property="createTime" />
        <result column="update_by" property="updateBy" />
        <result column="remark" property="remark" />
        <result column="del_flag" property="delFlag" />
    </resultMap>
 
    <sql id="Base_Column_List">
        id, app_user_id, phone, name, benefit_type, scope_type, partner_id, company_id, fleet_id, balance, status, create_by, create_time, update_by, update_time, remark, del_flag
    </sql>
 
    <select id="selectValidByPhone" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_app_user_whitelist
        where phone = #{phone} and del_flag = 0
        limit 1
    </select>
 
    <update id="updateByIdIgnoreLogic">
        update t_app_user_whitelist
        <set>
            app_user_id = #{appUserId},
            phone = #{phone},
            name = #{name},
            benefit_type = #{benefitType},
            scope_type = #{scopeType},
            partner_id = #{partnerId},
            company_id = #{companyId},
            fleet_id = #{fleetId},
            balance = #{balance},
            status = #{status},
            update_by = #{updateBy},
            update_time = now(),
            remark = #{remark},
            del_flag = #{delFlag}
        </set>
        where id = #{id}
    </update>
 
    <update id="addBalance">
        update t_app_user_whitelist
        set balance = IFNULL(balance, 0) + #{amount}, update_time = now(), update_by = #{updateBy}
        where id = #{id} and del_flag = 0
    </update>
    <update id="clearBalance">
        update t_app_user_whitelist
        set balance = 0, update_time = now(), update_by = #{updateBy}
        where id = #{id} and del_flag = 0 and balance &gt; 0
    </update>
</mapper>