Administrator
2018-12-18 d146e7bca73c7605af6b718b5df0b757e0034f0e
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
<?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" />
        <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.selectByPKey"/>
     
        <association property="order" column="oid" 
                 select="com.yeshi.fanli.dao.mybatis.order.OrderMapper.selectByPrimaryKey"> 
        </association>
    </resultMap>
 
    <select id="selectByOrderId" resultMap="BaseResultMap"
        parameterType="java.lang.String">
        select * from yeshi_ec_lost_order where orderId=#{0}
    </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>
        </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 != ""'>
                  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>
           
           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 != ""'>
                  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>
    </select>
      
      
</mapper>