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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?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.system.mapper.SysEnvironmentalInfoMapper">
    <resultMap id="SysEnvironmentalInfoMap" type="com.xzx.gc.model.system.SysEnvironmentalInfoVo">
        <id column="id" property="id" />
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="item_type" jdbcType="VARCHAR" property="itemType"/>
        <result column="price" jdbcType="VARCHAR" property="price"/>
        <result column="second_price" jdbcType="VARCHAR" property="secondPrice"/>
        <result column="create_time" jdbcType="VARCHAR" property="createTime"/>
        <result column="create_user_id" jdbcType="VARCHAR" property="createUserId"/>
        <result column="picture"  property="picture"/>
        <result column="top_flag"  property="topFlag"/>
        <result column="parent_id"  property="parentId"/>
        <result column="sort" property="sort"/>
        <result column="put_storage_price"  property="putStoragePrice"/>
        <result column="item_unit"  property="itemUnit"/>
        <result column="del_flag"  property="delFlag"/>
        <result column="partner_id"  property="partnerId"/>
        <result column="city_id"  property="cityId"/>
        <result column="show_flag"  property="showFlag"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,title,item_type,price,create_time,create_user_id,picture,top_flag,parent_id,sort,put_storage_price,item_unit,del_flag,second_price
        ,partner_id,city_id,show_flag
    </sql>
    <!-- 新增环保资讯-->
    <insert id="addSysEnvironmentalInfo" parameterType="java.util.Map">
        insert into xzx_sys_environmental_info(title,item_type,price,create_time,create_user_id
        <if test="secondPrice!=null and secondPrice!=''">
            ,second_price
        </if>
        )
        values (#{title},#{itemType},#{price},#{createTime},#{createUserId}
        <if test="secondPrice!=null and secondPrice!=''">
            ,#{secondPrice}
        </if>
        )
    </insert>
 
 
    <!-- 环保资讯列表查询 -->
    <select id="getSysEnvironmentalInfoListWithMap" parameterType="java.util.Map" resultMap="SysEnvironmentalInfoMap">
        select <include refid="Base_Column_List"/> from xzx_sys_environmental_info
        where del_flag=0
        <if test="type==1">
            and  parent_id is null
        </if>
        <if test="cityId!=null and cityId!=''">
            and  city_id=#{cityId}
        </if>
        <if test="type==2">
            <if test="parentId!=null">
                and  parent_id=#{parentId}
            </if>
        </if>
        order by sort
    </select>
 
    <!-- 环保资讯详情查询 -->
    <select id="getSysEnvironmentalInfoById" parameterType="java.util.Map" resultMap="SysEnvironmentalInfoMap">
        select <include refid="Base_Column_List"/> from xzx_sys_environmental_info
        where id = #{id} and del_flag=0
    </select>
 
    <!-- 环保资讯编辑-->
    <update id="editSysEnvironmentalInfo" parameterType="java.util.Map">
        update xzx_sys_environmental_info
        set price = #{price}
            <if test="secondPrice!=null and secondPrice!=''">
                ,second_price=#{secondPrice}
            </if>
        where id = #{id}
    </update>
 
 
    <select id="queryOperaIteml" parameterType="com.xzx.gc.model.admin.ItemModel"
            resultType="com.xzx.gc.model.admin.ItemModel">
        select a.id,a.title,a.del_flag as delFlag,a.show_flag as showFlag,a.item_unit as itemUnit,
        (select b.title from xzx_sys_environmental_info b where b.id=a.parent_id) as type,
        a.price as price,a.second_price as secondPrice,IFNULL(a.put_storage_price,0.00) as putStoragePrice,a.sort as
        sort,
        a.picture as picture,a.parent_id,
        (select c.partner_name from xzx_city_partner c where c.id=a.partner_id) as partnerName
        from xzx_sys_environmental_info a where  a.parent_id is not null and a.del_flag=0
        <if test="title!= null">
            AND title like concat("%",#{title},"%")
        </if>
        <if test="parentId!=null">
            AND parent_id=#{parentId}
        </if>
        <if test="id!= null and id != ''">
            AND id=#{id}
        </if>
        <if test="partnerIds!= null and partnerIds.size() != 0">
            AND partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="cityId!= null">
            AND city_id =#{cityId}
        </if>
        <if test="townIdList!= null">
            AND city_id in
            <foreach collection="townIdList" index="index" item="tid" open="(" separator="," close=")">
                #{tid}
            </foreach>
        </if>
        order by sort
    </select>
 
 
    <select id="queryOperateItemList" parameterType="com.xzx.gc.model.admin.ItemModel"
            resultType="com.xzx.gc.model.admin.ItemModel">
        select a.id,a.title,a.sort,a.item_type,a.city_id,a.partner_id,a.del_flag,
        (select b.partner_name from xzx_city_partner b where a.partner_id=b.id) as partnerName
        from xzx_sys_environmental_info a where 1=1
        <if test="id!= null and id != ''">
            AND a.id=#{id}
        </if>
        <if test="cityId!= null">
            AND a.city_id=#{cityId}
        </if>
        <if test="townIdList!= null">
            AND a.city_id in
            <foreach collection="townIdList" index="index" item="tid" open="(" separator="," close=")">
                #{tid}
            </foreach>
        </if>
        <choose>
            <when test="partnerId !=null and partnerId != ''">
                AND a.partnerId=#{partnerId}
            </when>
        </choose>
 
        and a.parent_id is null
    </select>
 
 
    <select id="queryOperateItemChildren" parameterType="com.xzx.gc.model.admin.ItemModel" resultType="com.xzx.gc.model.admin.ItemModel">
        select a.id,a.title,a.sort,a.item_type,a.city_id from xzx_sys_environmental_info a where a.del_flag=0 and
        a.parent_id is not null
        <if test="id!= null and id != ''">
            AND parent_id=#{id}
        </if>
    </select>
 
    <update id="updateItem">
        UPDATE `xzx_sys_environmental_info`
        <trim prefix="set" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="picture != null and picture != ''">`picture` = #{picture},</if>
            <if test="price != null and price != ''">`price` = #{price},</if>
            <if test="putStoragePrice != null and putStoragePrice != ''">`put_storage_price` = #{putStoragePrice},</if>
            <if test="secondPrice != null and secondPrice != ''">`second_price` = #{secondPrice},</if>
            <if test="sort != null and sort != ''">`sort` = #{sort},</if>
            <if test="showFlag != null">`show_flag` = #{showFlag},</if>
            <if test="itemUnit != null and itemUnit != ''">`item_unit` = #{itemUnit},</if>
            <if test="minPrice != null and minPrice != ''">`min_price` = #{minPrice} ,</if>
            <if test="maxPrice != null and maxPrice != ''">`max_price` = #{maxPrice} ,</if>
        </trim>
 
        <if test="cityId != null and cityId != ''">
            ,`city_id` = #{cityId}
        </if>
 
        <if test="partnerId != null and partnerId != ''">
            , `partner_id` = #{partnerId}
        </if>
        WHERE `id` = #{id}
    </update>
 
    <select id="querIteml" resultType="com.xzx.gc.model.admin.ItemModel">
        select * from `xzx_sys_environmental_info` where del_flag=0
        <if test="itemType != null">
            AND item_type=#{itemType}
        </if>
        <if test="title != null">
            AND title=#{title}
        </if>
        <if test="delFlag != null">
            AND del_flag=#{delFlag}
        </if>
        <if test="topFlag != null">
            AND top_flag=#{topFlag}
        </if>
        <if test="parentId!=null and parentId != ''">
            AND parent_id=#{parentId}
        </if>
        <if test="partnerId==null or partnerId == ''">
            AND partner_id is NULL
        </if>
        <if test="id != null">
            AND id=#{id}
        </if>
        order by sort
    </select>
 
    <insert id="insertItemOperate">
        INSERT INTO `xzx_sys_environmental_info`
        (`item_type`, `title`, `picture`, `price`, `put_storage_price`, `parent_id`, `sort`, `create_time`, `item_unit`, `second_price`, `partner_id`, `city_id`,show_flag,min_price,max_price)
        VALUES
            (#{itemType}, #{title}, #{picture}, #{price}, #{putStoragePrice}, #{parentId}, #{sort}, #{createTime},
                          #{itemUnit}, #{secondPrice}, #{partnerId}, #{cityId},#{showFlag} ,#{minPrice} ,#{maxPrice} )
    </insert>
    <select id="queryByTitle" resultType="java.lang.String">
        select id from xzx_sys_environmental_info where del_flag=0 and parent_id is not null
        <if test="title!= null">
            AND title like  concat("%",#{title} ,"%")
        </if>
        <if test="townIds!= null">
            AND city_id in
            <foreach collection="townIds" index="index" item="tid" open="(" separator="," close=")">
                #{tid}
            </foreach>
        </if>
    </select>
 
    <update id="updateByIds">
        update xzx_sys_environmental_info set del_flag=0 where del_flag=1 and parent_id is not null
        and id in
        <foreach collection="list" index="index" item="tid" open="(" separator="," close=")">
            #{tid}
        </foreach>
    </update>
 
    <delete id="delItem">
        update `xzx_sys_environmental_info`
        set del_flag = 1
        where id = #{id}
    </delete>
 
    <select id="queryOperaIteml1" parameterType="com.xzx.gc.model.admin.ItemModel"
            resultType="com.xzx.gc.model.admin.ItemModel">
        select a.id,a.title,
        a.price as price,a.second_price as secondPrice,IFNULL(a.put_storage_price,0.00) as putStoragePrice,a.sort as
        sort,a.del_flag as delFlag,
        a.picture as picture,a.parent_id
        from xzx_package_goods_info a
        left join xzx_city_partner b on a.package_id=b.id
        where  a.parent_id is not null and a.del_flag=0
        <if test="title!= null and title != ''">
            AND a.title like
            concat("%",#{title},"%")
        </if>
        <if test="parentId!= null and parentId != ''">
            AND a.parent_id=#{parentId}
        </if>
        <if test="id!= null and id != ''">
            AND a.id=#{id}
        </if>
        <if test="partnerIds!= null and partnerIds.size() != 0">
            AND a.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="cityId!= null and cityId != ''">
            AND a.city_id =#{cityId}
        </if>
        <if test="packageId!= null and packageId != ''">
            AND a.package_id=#{packageId}
        </if>
        <if test="partnerId!= null and partnerId != ''">
            AND b.packing_station =#{partnerId}
        </if>
        order by sort
    </select>
 
    <select id="findPage" resultType="com.xzx.gc.entity.SysEnvironmentalInfo">
        SELECT
        a.title,
        a.id,
        a.del_flag "delFlag",
        a.item_type "itemType",
        a.partner_id "partnerId",
        b.partner_name "partnerName",
        c.title "parentName"
        FROM
        xzx_sys_environmental_info a
        inner  join xzx_sys_environmental_info c on a.parent_id=c.id
        INNER JOIN xzx_city_partner b ON a.partner_id = b.id
        WHERE
        a.parent_id IS NOT NULL
        <if test="delFlag != null and delFlag != ''">
            and a.del_flag=#{delFlag}
        </if>
        <if test="parentId != null and parentId != ''">
            and a.parent_id=#{parentId}
        </if>
        <if test="partnerId != null and partnerId != ''">
            and a.partner_id=#{partnerId}
        </if>
        <if test="typeName != null and typeName != ''">
            and a.title like concat("%",#{typeName} ,"%")
        </if>
    </select>
</mapper>