yujian
2019-03-27 cdcbed9af813b2a02cdc01eefa24db8bec6b51a9
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
<?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.taobao.TaoBaoWeiQuanOrderMapper">
    <resultMap id="BaseResultMap"
        type="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">
        <id column="tmo_id" property="id" jdbcType="BIGINT" />
        <result column="tmo_order_id" property="orderId" jdbcType="VARCHAR" />
        <result column="tmo_order_item_id" property="orderItemId"
            jdbcType="VARCHAR" />
        <result column="tmo_goods_name" property="goodsName" jdbcType="VARCHAR" />
        <result column="tmo_money" property="money" jdbcType="DECIMAL" />
        <result column="tmo_fan_money" property="fanMoney" jdbcType="DECIMAL" />
        <result column="tmo_state" property="state" jdbcType="VARCHAR" />
        <result column="tmo_jiesuan_time" property="jieSuanTime"
            jdbcType="TIMESTAMP" />
        <result column="tmo_weiquan_time" property="weiQuanTime"
            jdbcType="TIMESTAMP" />
        <result column="tmo_weiquan_finish_time" property="weiQuanFinishTime"
            jdbcType="TIMESTAMP" />
        <result column="tmo_createtime" property="createTime" jdbcType="TIMESTAMP" />
        <result column="tmo_updatetime" property="updateTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="Base_Column_List">tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_weiqaun_order where tmo_id =
        #{id,jdbcType=BIGINT}
    </select>
 
 
    <select id="selectByOrderIdAndOrderItemId" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and
        tmo_order_item_id=#{orderItemId}
    </select>
 
    <select id="selectListByOrderIdAndState" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from yeshi_ec_taobao_weiqaun_order where tmo_order_id =#{orderId} and
        tmo_state=#{state}
    </select>
 
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_taobao_weiqaun_order where tmo_id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insert" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"
        useGeneratedKeys="true" keyProperty="id">insert into
        yeshi_ec_taobao_weiqaun_order
        (tmo_id,tmo_order_id,tmo_order_item_id,tmo_goods_name,tmo_money,tmo_fan_money,tmo_state,tmo_jiesuan_time,tmo_weiquan_time,tmo_weiquan_finish_time,tmo_createtime,tmo_updatetime)
        values
        (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{orderItemId,jdbcType=VARCHAR},#{goodsName,jdbcType=VARCHAR},#{money,jdbcType=DECIMAL},#{fanMoney,jdbcType=DECIMAL},#{state,jdbcType=VARCHAR},#{jieSuanTime,jdbcType=TIMESTAMP},#{weiQuanTime,jdbcType=TIMESTAMP},#{weiQuanFinishTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_taobao_weiqaun_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">tmo_id,</if>
            <if test="orderId != null">tmo_order_id,</if>
            <if test="orderItemId != null">tmo_order_item_id,</if>
            <if test="goodsName != null">tmo_goods_name,</if>
            <if test="money != null">tmo_money,</if>
            <if test="fanMoney != null">tmo_fan_money,</if>
            <if test="state != null">tmo_state,</if>
            <if test="jieSuanTime != null">tmo_jiesuan_time,</if>
            <if test="weiQuanTime != null">tmo_weiquan_time,</if>
            <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time,</if>
            <if test="createTime != null">tmo_createtime,</if>
            <if test="updateTime != null">tmo_updatetime,</if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=BIGINT},</if>
            <if test="orderId != null">#{orderId,jdbcType=VARCHAR},</if>
            <if test="orderItemId != null">#{orderItemId,jdbcType=VARCHAR},</if>
            <if test="goodsName != null">#{goodsName,jdbcType=VARCHAR},</if>
            <if test="money != null">#{money,jdbcType=DECIMAL},</if>
            <if test="fanMoney != null">#{fanMoney,jdbcType=DECIMAL},</if>
            <if test="state != null">#{state,jdbcType=VARCHAR},</if>
            <if test="jieSuanTime != null">#{jieSuanTime,jdbcType=TIMESTAMP},</if>
            <if test="weiQuanTime != null">#{weiQuanTime,jdbcType=TIMESTAMP},</if>
            <if test="weiQuanFinishTime != null">#{weiQuanFinishTime,jdbcType=TIMESTAMP},</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.taobao.TaoBaoWeiQuanOrder">update
        yeshi_ec_taobao_weiqaun_order set tmo_order_id =
        #{orderId,jdbcType=VARCHAR},tmo_order_item_id =
        #{orderItemId,jdbcType=VARCHAR},tmo_goods_name =
        #{goodsName,jdbcType=VARCHAR},tmo_money =
        #{money,jdbcType=DECIMAL},tmo_fan_money =
        #{fanMoney,jdbcType=DECIMAL},tmo_state =
        #{state,jdbcType=VARCHAR},tmo_jiesuan_time =
        #{jieSuanTime,jdbcType=TIMESTAMP},tmo_weiquan_time =
        #{weiQuanTime,jdbcType=TIMESTAMP},tmo_weiquan_finish_time =
        #{weiQuanFinishTime,jdbcType=TIMESTAMP},tmo_createtime =
        #{createTime,jdbcType=TIMESTAMP},tmo_updatetime =
        #{updateTime,jdbcType=TIMESTAMP} where tmo_id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder">
        update yeshi_ec_taobao_weiqaun_order
        <set>
            <if test="orderId != null">tmo_order_id=#{orderId,jdbcType=VARCHAR},</if>
            <if test="orderItemId != null">tmo_order_item_id=#{orderItemId,jdbcType=VARCHAR},</if>
            <if test="goodsName != null">tmo_goods_name=#{goodsName,jdbcType=VARCHAR},</if>
            <if test="money != null">tmo_money=#{money,jdbcType=DECIMAL},</if>
            <if test="fanMoney != null">tmo_fan_money=#{fanMoney,jdbcType=DECIMAL},</if>
            <if test="state != null">tmo_state=#{state,jdbcType=VARCHAR},</if>
            <if test="jieSuanTime != null">tmo_jiesuan_time=#{jieSuanTime,jdbcType=TIMESTAMP},</if>
            <if test="weiQuanTime != null">tmo_weiquan_time=#{weiQuanTime,jdbcType=TIMESTAMP},</if>
            <if test="weiQuanFinishTime != null">tmo_weiquan_finish_time=#{weiQuanFinishTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createTime != null">tmo_createtime=#{createTime,jdbcType=TIMESTAMP},</if>
            <if test="updateTime != null">tmo_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if>
        </set>
        where tmo_id = #{id,jdbcType=BIGINT}
    </update>
    
    
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`tmo_createtime`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`tmo_createtime`,'%Y') AS 'showDate'
        </if>
    </sql>
 
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y') = '${year}'
        </if>
    </sql>
 
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y')
        </if>
    </sql>
    <select id="countWeiQaunOrderNumber" resultType="java.util.HashMap">
        SELECT  IFNULL(COUNT(t.`tmo_id`),0) AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_taobao_weiqaun_order t
        WHERE t.`tmo_createtime`IS NOT NULL  <include refid="Count_Select_DateType"/> 
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
    </select>
    
    <select id="countWeiQaunOrderMoney" resultType="java.util.HashMap">
        SELECT  CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_taobao_weiqaun_order t
        WHERE  t.`tmo_createtime` IS NOT NULL  <include refid="Count_Select_DateType"/> 
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
    </select>
</mapper>