xiaoyong931011
2021-07-23 4602ddaa6f8c408411aa6521b1f70ba3af629713
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
<?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.xzx.gc.pay.mapper.OrderMapper">
 
    <select id="findHistoryByReceiverWithMonth" resultType="com.xzx.gc.entity.OrderInfo">
        SELECT LEFT
               ( b.complete_time, 10 ) as completeTime,
              sum(cast(c.weight as DECIMAL(9,3))) as weight,
              sum(cast(c.money as DECIMAL(9,2))) as money
        FROM
            xzx_order_info a
            INNER JOIN xzx_order_detail_info b ON a.order_id = b.order_id
            INNER JOIN xzx_order_item_info c ON b.order_id = c.order_id
        WHERE
            a.order_status IN ( '4', '5', '7' )
            AND a.receiver = #{receiver}
        GROUP BY
            LEFT ( b.complete_time, 7 )
          <if test="yearMonth != null and yearMonth != ''">
              HAVING LEFT ( completeTime, 7 )=#{yearMonth}
          </if>
        ORDER BY b.complete_time desc
    </select>
 
    <select id="queryUserOrderList" parameterType="com.xzx.gc.model.admin.PayRequestInfoModel" resultType="com.xzx.gc.model.admin.PayRequestInfoModel">
        select a.order_id as orderId,c.complete_time as completeTime,
        sum(b.money) as money,sum(b.weight) as weight,
        a.create_time as createTime,a.rela_phone as phone from xzx_order_info a
        inner join xzx_order_detail_info c on a.order_id=c.order_id
        left join xzx_order_item_info b on a.order_id=b.order_id
        where a.del_flag=0
        and a.order_status in ('4','5','7')
        and a.order_id=c.order_id
        <if test="userId != null and userId != ''">
            and  a.create_user_id=#{userId}
        </if>
        <if test="otherUserId != null and otherUserId != ''">
            and  a.receiver=#{otherUserId}
        </if>
        group by a.order_id
    </select>
 
 
    <select id="queryUserOrderMoneyAndWeight" parameterType="com.xzx.gc.model.admin.PayRequestInfoModel" resultType="java.util.HashMap">
        select
        IFNULL(sum(b.money),0) as money,IFNULL(sum(b.weight),0) as weight
        from xzx_order_info a
        left join xzx_order_detail_info c on a.order_id=c.order_id
        left join xzx_order_item_info b on a.order_id=b.order_id
        where a.del_flag=0
        and a.order_status in ('4','5','7')
        and a.order_id=c.order_id
        <if test="userId != null and userId != ''">
            and  a.create_user_id=#{userId}
        </if>
        <if test="otherUserId != null and otherUserId != ''">
            and  a.receiver=#{otherUserId}
        </if>
        group by a.order_id
    </select>
 
    <select id="queryStorageMoneyDetailApi" resultType="com.xzx.gc.model.admin.PayRequestInfoModel">
        select a.order_id as orderId,c.complete_time as completeTime,
        sum(b.money) as money,sum(b.weight) as weight,
        a.create_time as createTime,a.rela_phone as phone from xzx_order_info a
        left join xzx_order_detail_info c on a.order_id=c.order_id
        left join xzx_order_item_info b on a.order_id=b.order_id
        where a.del_flag=0
        and a.order_status in (4,5)
        and a.order_id=c.order_id
        and a.order_id in
        <foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        group by a.order_id
    </select>
 
    <select id="queryMoneyAndWeightByOrderIds" resultType="java.util.HashMap" parameterType="java.util.List">
        select
        IFNULL(sum(b.money),0) as money,IFNULL(sum(b.weight),0) as weight
        from xzx_order_info a
        left join xzx_order_detail_info c on a.order_id=c.order_id
        left join xzx_order_item_info b on a.order_id=b.order_id
        where a.del_flag=0
        and a.order_status in (4,5)
        and a.order_id=c.order_id
        and a.order_id in
        <foreach collection="orderIds" index="index" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        group by a.order_id
    </select>
 
    <select id="quotaDetail" parameterType="com.xzx.gc.model.admin.StorageUserModel" resultType="com.xzx.gc.model.admin.StorageUserModel">
        select IFNULL(sum(c.money),0) as money,IFNULL(sum(c.weight),0) as weight,b.receive_time as storageTime from xzx_order_info a
        left join xzx_order_detail_info b on a.order_id=b.order_id
        left join xzx_order_item_info c on a.order_id=c.order_id
        where a.receiver=#{userId} and c.order_id is not null
        <if test="startTime!= null and startTime!=''">
            and b.receive_time<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime!= null and endTime!=''">
            and b.receive_time<![CDATA[<= ]]>#{endTime}
        </if>
        group by a.order_id
    </select>
</mapper>