admin
2020-05-06 24a8d17e007545f7426c48352109aa1a9c6587ee
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?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.order.LostOrderMapper">
    <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.LostOrder">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="orderId" property="orderId" jdbcType="VARCHAR" />
        <result column="type" property="type" jdbcType="INTEGER" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="createTime" property="createTime" jdbcType="BIGINT" />
        <result column="handleTime" property="handleTime" jdbcType="BIGINT" />
        <result column="remake" property="remake" jdbcType="VARCHAR" />
        <result column="judge" property="judge" jdbcType="VARCHAR" />
        <result column="result_code" property="resultCode" jdbcType="INTEGER" />
        <result column="ip_info" property="ipInfo" jdbcType="VARCHAR" />
        <association property="userInfo" column="uid"
            javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
            <id column="uid" property="id" jdbcType="BIGINT" />
        </association>
        <association property="order" column="oid"
            javaType="com.yeshi.fanli.entity.bus.user.Order">
            <id column="oid" property="id" jdbcType="BIGINT" />
        </association>
    </resultMap>
    <resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.LostOrder">
        <id column="id" property="id" jdbcType="BIGINT" />
        <result column="orderId" property="orderId" jdbcType="VARCHAR" />
        <result column="type" property="type" jdbcType="INTEGER" />
        <result column="state" property="state" jdbcType="INTEGER" />
        <result column="createTime" property="createTime" jdbcType="BIGINT" />
        <result column="handleTime" property="handleTime" jdbcType="BIGINT" />
        <result column="remake" property="remake" jdbcType="VARCHAR" />
        <result column="judge" property="judge" jdbcType="VARCHAR" />
        <result column="result_code" property="resultCode" jdbcType="INTEGER" />
        <association property="userInfo" column="uid"
            select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPrimaryKey" />
        <association property="order" column="oid"
            select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey" />
    </resultMap>
    
    <resultMap id="ChartMap" type="com.yeshi.fanli.dto.ChartTDO">
        <result column="showDate" property="showDate" jdbcType="VARCHAR" />
        <result column="showValue" property="showValue" jdbcType="VARCHAR" />
    </resultMap>
    
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
        yeshi_ec_lost_order where id = #{id,jdbcType=BIGINT}
    </delete>
    <select id="selectByOrderIdAndType" resultMap="BaseResultMap">select * from
        yeshi_ec_lost_order where orderId=#{orderId} and `type`=#{type}
    </select>
 
 
    <select id="selectByPrimaryKey" resultMap="BaseResultMap"
        parameterType="java.lang.Long">select * from yeshi_ec_lost_order where id=#{0}</select>
    <select id="listByStateAndResultCode" resultMap="BaseResultMap">select * from
        yeshi_ec_lost_order where `state`=#{state} and
        `result_code`=#{resultCode} ORDER BY id DESC limit #{start},#{count}
    </select>
    <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder">
        update yeshi_ec_lost_order
        <set>
            <if test="orderId != null">orderId=#{orderId,jdbcType=VARCHAR},</if>
            <if test="type != null">type=#{type,jdbcType=INTEGER},</if>
            <if test="state != null">state=#{state,jdbcType=INTEGER},</if>
            <if test="createTime != null">createTime=#{createTime,jdbcType=BIGINT},</if>
            <if test="handleTime != null">handleTime=#{handleTime,jdbcType=BIGINT},</if>
            <if test="userInfo != null">uid=#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="order != null">oid=#{order.id,jdbcType=BIGINT},</if>
            <if test="remake != null">remake=#{remake,jdbcType=VARCHAR},</if>
            <if test="judge != null">judge=#{judge,jdbcType=VARCHAR},</if>
            <if test="resultCode != null">result_code=#{resultCode,jdbcType=INTEGER},</if>
            <if test="ipInfo !=null">ip_info =#{ipInfo,jdbcType=VARCHAR},</if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <select id="countByUid" resultType="java.util.HashMap">SELECT IFNULL(COUNT(id), 0)
        AS total,IFNULL(SUM(CASE WHEN state = 1 THEN 1 ELSE 0 END),0) AS
        totalPass, IFNULL(SUM(CASE WHEN state = 2 THEN 1 ELSE 0 END),0) AS
        totalReject FROM yeshi_ec_lost_order WHERE uid = #{uid};
    </select>
    <select id="listQuery" resultMap="AllResultMap">
        SELECT d.* FROM yeshi_ec_lost_order d left join yeshi_ec_user u on
        d.uid = u.id WHERE 1=1
        <if test="key != null and key != &quot;&quot;">AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
            u.nick_name like '%${key}%')</if>
        <if test="state != null">AND d.state = #{state}</if>
        <if test="handleType != null and handleType == 0">AND d.state = 0</if>
        <if test="handleType != null and handleType != 0">AND (d.state = 1 or d.state = 2)</if>
        <if test="type != null">AND d.type = #{type}</if>
        ORDER BY d.createTime desc LIMIT ${start},${count}
    </select>
    <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(d.id),0) FROM yeshi_ec_lost_order d left join
        yeshi_ec_user u on d.uid = u.id WHERE 1=1
        <if test="key != null and key != &quot;&quot;">AND (d.orderId like '%${key}%' or d.uid like '%${key}%' or
            u.nick_name like '%${key}%')</if>
        <if test="state != null">AND d.state = #{state}</if>
        <if test="handleType != null and handleType == 0">AND d.state = 0</if>
        <if test="handleType != null and handleType != 0">AND (d.state = 1 or d.state = 2)</if>
        <if test="type != null">AND d.type = #{type}</if>
    </select>
    
    <select id="countLostOrderNum" resultType="Integer">
        SELECT COUNT(1) FROM (SELECT COUNT(t.`id`) FROM `yeshi_ec_lost_order` t 
            WHERE FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') = #{preDay}
                  AND t.result_code = #{resultCode}
            GROUP BY t.`orderId`,t.`orderType`)A
    </select>
    
    <select id="countAppealMoney" resultType="BigDecimal">
        SELECT SUM(IFNULL(co.`co_eIncome`,co.`co_estimate`)) FROM `yeshi_ec_lost_order` t 
        LEFT JOIN yeshi_ec_common_order co ON (co.`co_order_no` = t.`orderId` AND co.`co_source_type` = t.`orderType`)
        WHERE FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') = #{preDay} AND (co.`co_state`=1 OR co.`co_state`=2)  
    </select>
 
 
    <select id="listByMaxHandleTimeAndStateAndResultCode" resultMap="BaseResultMap">
        select * from yeshi_ec_lost_order lo where #{maxTime} >
        lo.`handleTime`
        <if test="state!=null"> and lo.`state`=#{state} and result_code=#{resultCode}
        </if>
 
        <if test="resultCode!=null"> and lo.`result_code`=#{resultCode}
        </if>
    </select>
 
 
    <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
        useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_lost_order
        (id,orderId,type,state,createTime,handleTime,uid,oid,remake,judge,result_code,id,ip_info)
        values
        (#{id,jdbcType=BIGINT},#{orderId,jdbcType=VARCHAR},#{type,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=BIGINT},#{handleTime,jdbcType=BIGINT},#{userInfo.id,jdbcType=BIGINT},#{order.id,jdbcType=BIGINT},#{remake,jdbcType=VARCHAR},#{judge,jdbcType=VARCHAR},#{resultCode,jdbcType=INTEGER},#{id,jdbcType=BIGINT},#{ipInfo,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder"
        useGeneratedKeys="true" keyProperty="id">
        insert into yeshi_ec_lost_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="orderId != null">orderId,</if>
            <if test="type != null">type,</if>
            <if test="state != null">state,</if>
            <if test="createTime != null">createTime,</if>
            <if test="handleTime != null">handleTime,</if>
            <if test="userInfo != null">uid,</if>
            <if test="order != null">oid,</if>
            <if test="remake != null">remake,</if>
            <if test="judge != null">judge,</if>
            <if test="resultCode != null">result_code,</if>
            <if test="ipInfo != null">ip_info,</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="type != null">#{type,jdbcType=INTEGER},</if>
            <if test="state != null">#{state,jdbcType=INTEGER},</if>
            <if test="createTime != null">#{createTime,jdbcType=BIGINT},</if>
            <if test="handleTime != null">#{handleTime,jdbcType=BIGINT},</if>
            <if test="userInfo != null">#{userInfo.id,jdbcType=BIGINT},</if>
            <if test="order != null">#{order.id,jdbcType=BIGINT},</if>
            <if test="remake != null">#{remake,jdbcType=VARCHAR},</if>
            <if test="judge != null">#{judge,jdbcType=VARCHAR},</if>
            <if test="resultCode != null">#{resultCode,jdbcType=INTEGER},</if>
            <if test="ipInfo != null">#{ipInfo,jdbcType=VARCHAR}</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.user.LostOrder">update
        yeshi_ec_lost_order set orderId = #{orderId,jdbcType=VARCHAR},type =
        #{type,jdbcType=INTEGER},state = #{state,jdbcType=INTEGER},createTime
        = #{createTime,jdbcType=BIGINT},handleTime =
        #{handleTime,jdbcType=BIGINT},uid = #{userInfo.id,jdbcType=BIGINT},oid
        = #{order.id,jdbcType=BIGINT},remake =
        #{remake,jdbcType=VARCHAR},judge =
        #{judge,jdbcType=VARCHAR},result_code = #{resultCode,jdbcType=INTEGER}
        ,ip_info =#{ipInfo,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT}
    </update>
    <delete id="deleteByUid" parameterType="java.lang.Long">delete from
        yeshi_ec_lost_order where uid = #{0}
    </delete>
    <select id="listByUidOrderByCreateTimeDesc" resultMap="BaseResultMap">select *
        from yeshi_ec_lost_order where uid=#{uid} order by id desc limit
        #{start},#{count}
    </select>
    <select id="countAllByUid" resultType="java.lang.Long">select count(id) from
        yeshi_ec_lost_order where uid=#{0}
    </select>
    <select id="listByOrderIdAndTypeAndState" resultMap="BaseResultMap">
        select * from yeshi_ec_lost_order where orderId=#{orderId}
        <if test="type!=null">and type=#{type}</if>
        <if test="stateList!=null">
            <foreach collection="stateList" item="state" open="and ("
                close=")" separator=" or ">state=#{state}</foreach>
        </if>
    </select>
    <update id="processFail">UPDATE `yeshi_ec_lost_order` lo SET
        lo.`result_code`=3 WHERE lo.`state`=1 AND lo.`result_code`=1 AND
        UNIX_TIMESTAMP()*1000- lo.`handleTime`&gt;1000* 60 * 60 * 24 * 3
    </update>
 
    <select id="countTodayAppeal" resultType="java.lang.Long">
        SELECT
        IFNULL(COUNT(t.`id`),0) FROM yeshi_ec_lost_order t
        WHERE t.`uid` =
        #{uid}
        AND FROM_UNIXTIME(t.`createTime`/1000, '%Y-%m-%d')
        =DATE_FORMAT(NOW(),'%Y-%m-%d')
    </select>
 
</mapper>