yujian
2019-01-22 88b54772dbcf5ecab1e2316e4e4626ac901b8908
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
<?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.msg.MsgMoneyDetailMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail">
        <id column="mm_id" property="id" jdbcType="BIGINT" />
        <result column="mm_type" property="msgType"
            typeHandler="com.yeshi.fanli.util.mybatishandler.msg.MsgTypeMoneyTypeEnumHandler" />
        <result column="mm_order_count" property="orderCount" jdbcType="INTEGER" />
        <result column="mm_goods_count" property="goodsCount" jdbcType="INTEGER" />
        <result column="mm_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="mm_money" property="money" jdbcType="DECIMAL" />
        <result column="mm_balance" property="balance" jdbcType="DECIMAL" />
        <result column="mm_state_desc" property="stateDesc" jdbcType="VARCHAR" />
        <result column="mm_beizhu" property="beiZhu" jdbcType="VARCHAR" />
        <result column="mm_create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="mm_update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="mm_read" property="read" jdbcType="BOOLEAN" />
        <association property="user" column="mm_uid"  javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="mm_uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="extract" column="mm_source_id_extract"
            select="com.yeshi.fanli.dao.mybatis.ExtractMapper.selectByPrimaryKey">
        </association>
        <association property="alipayAccountValid" column="mm_source_id_alipayvalid"
            select="com.yeshi.fanli.dao.mybatis.AlipayAccountValidNormalHistoryMapper.selectByPrimaryKey">
        </association>
    </resultMap>
    <sql id="Base_Column_List">mm_id,mm_uid,mm_type,mm_order_count,mm_goods_count,mm_order_id,mm_source_id,mm_money,mm_balance,mm_state_desc,mm_beizhu,mm_create_time,mm_update_time,mm_read
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_msg_money where mm_id = #{id,jdbcType=BIGINT}
    </select>
 
 
    <select id="selectBySourceIdAndMsgType" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_msg_money where mm_source_id =
        #{sourceId,jdbcType=BIGINT} and mm_type=#{type}
    </select>
 
 
    <select id="listByUid" resultMap="BaseResultMap" >
        select
        <include refid="Base_Column_List" />,
        mm_source_id as mm_source_id_extract,
        mm_source_id as mm_source_id_alipayvalid
        from yeshi_ec_msg_money where mm_uid = #{uid,jdbcType=BIGINT} order by
        mm_update_time desc limit #{start},#{count}
    </select>
 
 
    <select id="countByUid" resultType="java.lang.Long"
        parameterType="java.lang.Long">
        select
        count(mm_id)
        from yeshi_ec_msg_money where mm_uid =
        #{uid,jdbcType=BIGINT}
    </select>
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_msg_money where mm_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_msg_money
        (mm_id,mm_uid,mm_type,mm_order_count,mm_goods_count,mm_order_id,mm_source_id,mm_money,mm_balance,mm_state_desc,mm_beizhu,mm_create_time,mm_update_time,mm_read)
        values
        (#{id,jdbcType=BIGINT},#{user.id,jdbcType=BIGINT},#{msgType,jdbcType=VARCHAR},#{orderCount,jdbcType=INTEGER},#{goodsCount,jdbcType=INTEGER},#{orderId,jdbcType=VARCHAR},#{extract.id,jdbcType=BIGINT},#{money,jdbcType=DECIMAL},#{balance,jdbcType=DECIMAL},#{stateDesc,jdbcType=VARCHAR},#{beiZhu,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP},#{read,jdbcType=BOOLEAN})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_msg_money
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">mm_id,</if>
            <if test="user != null">mm_uid,</if>
            <if test="msgType != null">mm_type,</if>
            <if test="orderCount != null">mm_order_count,</if>
            <if test="goodsCount != null">mm_goods_count,</if>
            <if test="orderId != null">mm_order_id,</if>
            <if test="extract != null">mm_source_id,</if>
            <if test="alipayAccountValid != null">mm_source_id,</if>
            <if test="money != null">mm_money,</if>
            <if test="balance != null">mm_balance,</if>
            <if test="stateDesc != null">mm_state_desc,</if>
            <if test="beiZhu != null">mm_beizhu,</if>
            <if test="createTime != null">mm_create_time,</if>
            <if test="updateTime != null">mm_update_time,</if>
            <if test="read != null">mm_read,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="user != null">#{user.id,jdbcType=BIGINT},</if>
            <if test="msgType != null">#{msgType,jdbcType=VARCHAR},</if>
            <if test="orderCount != null">#{orderCount,jdbcType=INTEGER},</if>
            <if test="goodsCount != null">#{goodsCount,jdbcType=INTEGER},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="extract != null">#{extract.id,jdbcType=BIGINT},</if>
            <if test="alipayAccountValid != null">#{alipayAccountValid.id,jdbcType=BIGINT},</if>
            <if test="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="balance != null">#{balance,jdbcType=DECIMAL},</if>
            <if test="stateDesc != null">#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="beiZhu != null">#{beiZhu,jdbcType=VARCHAR},</if>
            <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="read != null">#{read,jdbcType=BOOLEAN},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail">update
        yeshi_ec_msg_money set mm_uid = #{user.id,jdbcType=BIGINT},mm_type =
        #{msgType,jdbcType=VARCHAR},mm_order_count =
        #{orderCount,jdbcType=INTEGER},mm_goods_count =
        #{goodsCount,jdbcType=INTEGER},mm_order_id =
        #{orderId,jdbcType=VARCHAR},mm_source_id =
        #{extract.id,jdbcType=BIGINT},mm_money =
        #{money,jdbcType=DECIMAL},mm_balance =
        #{balance,jdbcType=DECIMAL},mm_state_desc =
        #{stateDesc,jdbcType=VARCHAR},mm_beizhu =
        #{beiZhu,jdbcType=VARCHAR},mm_create_time =
        #{createTime,jdbcType=TIMESTAMP},mm_update_time =
        #{updateTime,jdbcType=TIMESTAMP},mm_read = #{read,jdbcType=BOOLEAN}
        where mm_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail">
        update yeshi_ec_msg_money
        <set>
            <if test="user != null">mm_uid=#{user.id,jdbcType=BIGINT},</if>
            <if test="msgType != null">mm_type=#{msgType,jdbcType=VARCHAR},</if>
            <if test="orderCount != null">mm_order_count=#{orderCount,jdbcType=INTEGER},</if>
            <if test="goodsCount != null">mm_goods_count=#{goodsCount,jdbcType=INTEGER},</if>
            <if test="orderId != null">mm_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="extract != null">mm_source_id=#{extract.id,jdbcType=BIGINT},</if>
            <if test="alipayAccountValid != null">mm_source_id=#{alipayAccountValid.id,jdbcType=BIGINT},
            </if>
            <if test="money != null">mm_money=#{money,jdbcType=DECIMAL},</if>
            <if test="balance != null">mm_balance=#{balance,jdbcType=DECIMAL},</if>
            <if test="stateDesc != null">mm_state_desc=#{stateDesc,jdbcType=VARCHAR},</if>
            <if test="beiZhu != null">mm_beizhu=#{beiZhu,jdbcType=VARCHAR},</if>
            <if test="createTime != null">mm_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">mm_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
            <if test="read != null">mm_read=#{read,jdbcType=BOOLEAN},</if>
        </set>
        where mm_id = #{id,jdbcType=BIGINT}
    </update>
    
    
    <update id="setMsgReadByUid" parameterType="java.lang.Long">
        update
        yeshi_ec_msg_money set mm_read=1 where mm_uid=#{0}
    </update>
    
</mapper>