| <?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> |