OrderDetailMapper.xml
6.57 KB
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
<?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.soss.system.mapper.OrderDetailMapper">
<resultMap type="OrderDetail" id="OrderDetailResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="goodsId" column="goods_id" />
<result property="goodsName" column="goods_name" />
<result property="machineId" column="machine_id" />
<result property="num" column="num" />
<result property="amount" column="amount" />
<result property="realAmount" column="real_amount" />
<result property="specRuleDetail" column="spec_rule_detail" />
<result property="specRuleIds" column="spec_rule_ids" />
<result property="skuId" column="sku_id" />
<result property="goodsCategory" column="goods_category" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
</resultMap>
<sql id="selectOrderDetailVo">
select id, order_id, goods_id, goods_name, machine_id, num, amount, real_amount, spec_rule_detail, spec_rule_ids, sku_id, goods_category, created_at, updated_at from order_detail
</sql>
<select id="selectOrderDetailList" parameterType="OrderDetail" resultMap="OrderDetailResult">
<include refid="selectOrderDetailVo"/>
<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="goodsName != null and goodsName != ''"> and goods_name like concat('%', #{goodsName}, '%')</if>
<if test="machineId != null and machineId != ''"> and machine_id = #{machineId}</if>
<if test="num != null and num != ''"> and num = #{num}</if>
<if test="amount != null "> and amount = #{amount}</if>
<if test="realAmount != null "> and real_amount = #{realAmount}</if>
<if test="specRuleDetail != null and specRuleDetail != ''"> and spec_rule_detail = #{specRuleDetail}</if>
<if test="specRuleIds != null and specRuleIds != ''"> and spec_rule_ids = #{specRuleIds}</if>
<if test="skuId != null and skuId != ''"> and sku_id = #{skuId}</if>
<if test="goodsCategory != null and goodsCategory != ''"> and goods_category = #{goodsCategory}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
</where>
</select>
<select id="selectOrderDetailById" parameterType="String" resultMap="OrderDetailResult">
<include refid="selectOrderDetailVo"/>
where id = #{id}
</select>
<insert id="insertOrderDetail" parameterType="OrderDetail" useGeneratedKeys="true" keyProperty="id">
insert into order_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderId != null and orderId != ''">order_id,</if>
<if test="goodsId != null and goodsId != ''">goods_id,</if>
<if test="goodsName != null and goodsName != ''">goods_name,</if>
<if test="machineId != null and machineId != ''">machine_id,</if>
<if test="num != null and num != ''">num,</if>
<if test="amount != null">amount,</if>
<if test="realAmount != null">real_amount,</if>
<if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail,</if>
<if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids,</if>
<if test="skuId != null and skuId != ''">sku_id,</if>
<if test="goodsCategory != null">goods_category,</if>
<if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null and orderId != ''">#{orderId},</if>
<if test="goodsId != null and goodsId != ''">#{goodsId},</if>
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
<if test="machineId != null and machineId != ''">#{machineId},</if>
<if test="num != null and num != ''">#{num},</if>
<if test="amount != null">#{amount},</if>
<if test="realAmount != null">#{realAmount},</if>
<if test="specRuleDetail != null and specRuleDetail != ''">#{specRuleDetail},</if>
<if test="specRuleIds != null and specRuleIds != ''">#{specRuleIds},</if>
<if test="skuId != null and skuId != ''">#{skuId},</if>
<if test="goodsCategory != null">#{goodsCategory},</if>
<if test="createdAt != null">#{createdAt},</if>
<if test="updatedAt != null">#{updatedAt},</if>
</trim>
</insert>
<update id="updateOrderDetail" parameterType="OrderDetail">
update order_detail
<trim prefix="SET" suffixOverrides=",">
<if test="orderId != null and orderId != ''">order_id = #{orderId},</if>
<if test="goodsId != null and goodsId != ''">goods_id = #{goodsId},</if>
<if test="goodsName != null and goodsName != ''">goods_name = #{goodsName},</if>
<if test="machineId != null and machineId != ''">machine_id = #{machineId},</if>
<if test="num != null and num != ''">num = #{num},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="realAmount != null">real_amount = #{realAmount},</if>
<if test="specRuleDetail != null and specRuleDetail != ''">spec_rule_detail = #{specRuleDetail},</if>
<if test="specRuleIds != null and specRuleIds != ''">spec_rule_ids = #{specRuleIds},</if>
<if test="skuId != null and skuId != ''">sku_id = #{skuId},</if>
<if test="goodsCategory != null">goods_category = #{goodsCategory},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteOrderDetailById" parameterType="String">
delete from order_detail where id = #{id}
</delete>
<delete id="deleteOrderDetailByIds" parameterType="String">
delete from order_detail where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>