Helius
2021-06-16 4e51778362c2130598a4c73ec4cebe6629dbc53f
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
<?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.order.mapper.OrderItemInfoMapper">
    <select id="findByOrderIdAndTypes" resultType="com.xzx.gc.entity.OrderItemInfo">
            SELECT
                DISTINCT b.item_type "itemType",b.amount,b.money
            FROM
                xzx_order_detail_info a
                INNER JOIN xzx_order_item_info b ON a.order_id = b.order_id
            WHERE
                a.order_id = #{orderId}  and CAST(b.money as DECIMAL(9,2))>0
                and b.item_type in
            <foreach collection="childItemTypeByType" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
 
    </select>
    <select id="findByUserIdAndTypesWithComplete" resultType="com.xzx.gc.entity.OrderItemInfo">
        SELECT
            DISTINCT b.item_type "itemType",b.amount,b.money
        FROM
            xzx_order_info a
            INNER JOIN xzx_order_item_info b ON a.order_id = b.order_id
        WHERE
            CAST(b.money as DECIMAL(9,2))>0 and a.create_user_id=#{userId}  and a.order_status in('4','5','7')
            and b.item_type in
            <foreach collection="childItemTypeByType" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
    </select>
    <select id="findByTypeAndPartnerAndTime" resultType="com.xzx.gc.model.order.ItemDto">
        SELECT
            sum( ifnull( a.weight, 0 ) ) "weight",
            sum( ifnull( a.money, 0 ) ) "money",
            sum( ifnull( a.amount, 0 ) ) "amount"
        FROM
            xzx_order_item_info a
            INNER JOIN xzx_order_info b ON a.order_id = b.order_id
            INNER JOIN xzx_order_detail_info e ON b.order_id = e.order_id
            INNER JOIN xzx_partner_fence c ON b.town_id = c.fence_id
                                              AND c.del_flag = 0
        WHERE
            a.item_type = #{itemType}
            AND c.partner_id = #{partnerId}
            <if test="startTime != null and startTime != ''">
                AND e.complete_time >= #{startTime}
            </if>
              <if test="endTime != null and endTime != ''">
                  and e.complete_time&lt;=#{endTime}
              </if>
    </select>
 
    <insert id="addOrderItem">
        INSERT INTO `xzx_order_item_info` (`order_id`, `item_type`, `weight`,
        `amount`, `money`)
        VALUES
        <foreach collection="list" index="index" item="info" separator=",">
 
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{info.orderId}, #{info.itemType}, null, null, null
            </trim>
        </foreach>
 
    </insert>
</mapper>