jiangqs
2023-06-08 6cca89c41aea52ae6b23909bb9fbd2834f0094d5
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
<?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.ruoyi.order.mapper.order.OrderGoodsMapper">
 
    <resultMap type="OrderGoods" id="OrderGoodsResult">
        <result property="orderGoodsId"    column="order_goods_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="orderId"    column="order_id"    />
        <result property="goodsId"    column="goods_id"    />
        <result property="buyNum"    column="buy_num"    />
        <result property="couponId"    column="coupon_id"    />
        <result property="goodsPrice"    column="goods_price"    />
        <result property="goodsTotalMoney"    column="goods_total_money"    />
        <result property="goodsReceivableMoney"    column="goods_receivable_money"    />
        <result property="cycleNumFlag"    column="cycle_num_flag"    />
        <result property="serviceNum"    column="service_num"    />
        <result property="goodsType"    column="goods_type"    />
    </resultMap>
 
    <sql id="selectOrderGoodsVo">
        select order_goods_id, del_flag, order_id, goods_id, buy_num, coupon_id, goods_price, goods_total_money, goods_receivable_money, cycle_num_flag, service_num, goods_type from t_order_goods
    </sql>
 
    <select id="selectOrderGoodsList" parameterType="OrderGoods" resultMap="OrderGoodsResult">
        <include refid="selectOrderGoodsVo"/>
        <where>
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="goodsId != null  and goodsId != ''"> and goods_id = #{goodsId}</if>
            <if test="buyNum != null "> and buy_num = #{buyNum}</if>
            <if test="couponId != null  and couponId != ''"> and coupon_id = #{couponId}</if>
            <if test="goodsPrice != null "> and goods_price = #{goodsPrice}</if>
            <if test="goodsTotalMoney != null "> and goods_total_money = #{goodsTotalMoney}</if>
            <if test="goodsReceivableMoney != null "> and goods_receivable_money = #{goodsReceivableMoney}</if>
            <if test="cycleNumFlag != null "> and cycle_num_flag = #{cycleNumFlag}</if>
            <if test="serviceNum != null "> and service_num = #{serviceNum}</if>
            <if test="goodsType != null "> and goods_type = #{goodsType}</if>
        </where>
    </select>
 
    <select id="selectOrderGoodsByOrderGoodsId" parameterType="String" resultMap="OrderGoodsResult">
        <include refid="selectOrderGoodsVo"/>
        where order_goods_id = #{orderGoodsId}
    </select>
 
    <insert id="insertOrderGoods" parameterType="OrderGoods">
        insert into t_order_goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderGoodsId != null">order_goods_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="orderId != null">order_id,</if>
            <if test="goodsId != null">goods_id,</if>
            <if test="buyNum != null">buy_num,</if>
            <if test="couponId != null">coupon_id,</if>
            <if test="goodsPrice != null">goods_price,</if>
            <if test="goodsTotalMoney != null">goods_total_money,</if>
            <if test="goodsReceivableMoney != null">goods_receivable_money,</if>
            <if test="cycleNumFlag != null">cycle_num_flag,</if>
            <if test="serviceNum != null">service_num,</if>
            <if test="goodsType != null">goods_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderGoodsId != null">#{orderGoodsId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="goodsId != null">#{goodsId},</if>
            <if test="buyNum != null">#{buyNum},</if>
            <if test="couponId != null">#{couponId},</if>
            <if test="goodsPrice != null">#{goodsPrice},</if>
            <if test="goodsTotalMoney != null">#{goodsTotalMoney},</if>
            <if test="goodsReceivableMoney != null">#{goodsReceivableMoney},</if>
            <if test="cycleNumFlag != null">#{cycleNumFlag},</if>
            <if test="serviceNum != null">#{serviceNum},</if>
            <if test="goodsType != null">#{goodsType},</if>
        </trim>
    </insert>
 
    <update id="updateOrderGoods" parameterType="OrderGoods">
        update t_order_goods
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="goodsId != null">goods_id = #{goodsId},</if>
            <if test="buyNum != null">buy_num = #{buyNum},</if>
            <if test="couponId != null">coupon_id = #{couponId},</if>
            <if test="goodsPrice != null">goods_price = #{goodsPrice},</if>
            <if test="goodsTotalMoney != null">goods_total_money = #{goodsTotalMoney},</if>
            <if test="goodsReceivableMoney != null">goods_receivable_money = #{goodsReceivableMoney},</if>
            <if test="cycleNumFlag != null">cycle_num_flag = #{cycleNumFlag},</if>
            <if test="serviceNum != null">service_num = #{serviceNum},</if>
            <if test="goodsType != null">goods_type = #{goodsType},</if>
        </trim>
        where order_goods_id = #{orderGoodsId}
    </update>
 
    <delete id="deleteOrderGoodsByOrderGoodsId" parameterType="String">
        delete from t_order_goods where order_goods_id = #{orderGoodsId}
    </delete>
 
    <delete id="deleteOrderGoodsByOrderGoodsIds" parameterType="String">
        delete from t_order_goods where order_goods_id in
        <foreach item="orderGoodsId" collection="array" open="(" separator="," close=")">
            #{orderGoodsId}
        </foreach>
    </delete>
 
    <select id="listVoByOrderId" resultType="com.ruoyi.order.domain.vo.AppUserOrderGoodsPageVo">
        SELECT
        tog.order_goods_id orderGoodsId,
        tog.goods_id goodsId,
        tg.goods_name goodsName,
        tog.goods_type goodsType,
        tog.buy_num buyNum,
        tog.goods_price goodsPrice,
        tgf.file_url goodsPicture,
        tog.goods_total_money goodsRealPrice,
        tog.cycle_num_flag cycleNumFlag,
        tog.service_num serviceNum
        FROM t_order toc
        INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
        INNER JOIN t_goods tg ON tg.goods_id = tog.goods_id
        INNER JOIN t_goods_file tgf ON tgf.goods_id = tg.goods_id AND tgf.del_flag = 0 AND tgf.file_type = 1
        WHERE toc.del_flag = 0 AND toc.order_id = #{orderId}
 
    </select>
</mapper>