mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?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.panzhihua.service_community.dao.ComBatteryCommodityOrderBargainMapper">
 
    <resultMap type="com.panzhihua.service_community.entity.ComBatteryCommodityOrderBargain"
               id="ComBatteryCommodityOrderBargainMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="userId" column="user_id" jdbcType="INTEGER"/>
        <result property="commodityId" column="commodity_id" jdbcType="INTEGER"/>
        <result property="activityId" column="activity_id" jdbcType="INTEGER"/>
        <result property="orderId" column="order_id" jdbcType="INTEGER"/>
        <result property="orderNo" column="order_no" jdbcType="VARCHAR"/>
        <result property="originalPrice" column="original_price" jdbcType="VARCHAR"/>
        <result property="targetPrice" column="target_price" jdbcType="VARCHAR"/>
        <result property="currentPrice" column="current_price" jdbcType="VARCHAR"/>
        <result property="count" column="count" jdbcType="INTEGER"/>
        <result property="createAt" column="create_at" jdbcType="TIMESTAMP"/>
        <result property="createBy" column="create_by" jdbcType="INTEGER"/>
    </resultMap>
 
    <!--查询单个-->
    <select id="queryById" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityOrderBargainVo">
        SELECT
            cbcob.id,
            cbcob.user_id,
            cbcob.commodity_id,
            cbcob.activity_id,
            cbcob.order_id,
            cbcob.order_no,
            cbcob.original_price,
            cbcob.target_price,
            cbcob.current_price,
            cbcob.count,
            cbcob.create_at,
            cbcob.create_by,
            su.nick_name as nickName,
            su.image_url as imageUrl,
            cbc.`name` as commodityName,
            cbc.images as commodityImages,
            cbco.bargain_status
        FROM
            com_battery_commodity_order_bargain as cbcob
            left join com_battery_commodity_order as cbco on cbco.id = cbcob.order_id
            left join com_battery_commodity as cbc on cbc.id = cbco.commodity_id
            left join sys_user as su on su.user_id = cbcob.user_id
        where cbcob.id = #{id}
    </select>
 
    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityOrderBargainVo">
        select
        id, user_id, commodity_id, activity_id, order_id, order_no, original_price, target_price, current_price, count,
        create_at, create_by
        from com_battery_commodity_order_bargain
        <where>
            <if test="dto.id != null">
                and id = #{dto.id}
            </if>
            <if test="dto.userId != null">
                and user_id = #{dto.userId}
            </if>
            <if test="dto.commodityId != null">
                and commodity_id = #{dto.commodityId}
            </if>
            <if test="dto.activityId != null">
                and activity_id = #{dto.activityId}
            </if>
            <if test="dto.orderId != null">
                and order_id = #{dto.orderId}
            </if>
            <if test="dto.orderNo != null and dto.orderNo != ''">
                and order_no = #{dto.orderNo}
            </if>
            <if test="dto.originalPrice != null">
                and original_price = #{dto.originalPrice}
            </if>
            <if test="dto.targetPrice != null">
                and target_price = #{dto.targetPrice}
            </if>
            <if test="dto.currentPrice != null">
                and current_price = #{dto.currentPrice}
            </if>
            <if test="dto.count != null">
                and count = #{dto.count}
            </if>
            <if test="dto.createAt != null">
                and create_at = #{dto.createAt}
            </if>
            <if test="dto.createBy != null">
                and create_by = #{dto.createBy}
            </if>
        </where>
        order by create_at desc
    </select>
 
    <!--查询所有数据-->
    <select id="queryAllByList" resultType="com.panzhihua.common.model.vos.common.ComBatteryCommodityOrderBargainVo">
        select
        id, user_id, commodity_id, activity_id, order_id, order_no, original_price, target_price, current_price, count,
        create_at, create_by
        from com_battery_commodity_order_bargain
        <where>
            <if test="dto.id != null">
                and id = #{dto.id}
            </if>
            <if test="dto.userId != null">
                and user_id = #{dto.userId}
            </if>
            <if test="dto.commodityId != null">
                and commodity_id = #{dto.commodityId}
            </if>
            <if test="dto.activityId != null">
                and activity_id = #{dto.activityId}
            </if>
            <if test="dto.orderId != null">
                and order_id = #{dto.orderId}
            </if>
            <if test="dto.orderNo != null and dto.orderNo != ''">
                and order_no = #{dto.orderNo}
            </if>
            <if test="dto.originalPrice != null">
                and original_price = #{dto.originalPrice}
            </if>
            <if test="dto.targetPrice != null">
                and target_price = #{dto.targetPrice}
            </if>
            <if test="dto.currentPrice != null">
                and current_price = #{dto.currentPrice}
            </if>
            <if test="dto.count != null">
                and count = #{dto.count}
            </if>
            <if test="dto.createAt != null">
                and create_at = #{dto.createAt}
            </if>
            <if test="dto.createBy != null">
                and create_by = #{dto.createBy}
            </if>
        </where>
        order by create_at desc
    </select>
 
</mapper>