ProductPop.xml 24 KB
<?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.dili.titan.dao.ProductPopDao">

	<resultMap type="productPop" id="productPop">
		<result property="pid" javaType="Long" column="pid"/>
		<result property="name" javaType="String" column="name"/>
        <result property="quotationType" javaType="Integer" column="quotation_type"/>
		<result property="cateId" javaType="Integer" column="cate_id"/>
		<result property="userDefined" javaType="Integer" column="user_defined"/>
		<result property="cate" javaType="String" column="cate"/>
		<result property="status" javaType="Integer" column="status"/>
        <result property="hasSpecial" javaType="Integer" column="has_special"/>
		<result property="publishSettime" javaType="Date" column="publish_settime"/>
		<result property="publishTime" javaType="Date" column="publish_time"/>
		<result property="publishMode" javaType="Integer" column="publish_mode"/>
		<result property="prepareTime" javaType="Long" column="prepare_time"/>
		<result property="dropsTime" javaType="Date" column="drops_time"/>
		<result property="ctime" javaType="Date" column="ctime"/>
		<result property="utime" javaType="Date" column="utime"/>
		<result property="desc" javaType="String" column="desc"/>
		<result property="minPrice" javaType="Integer" column="minPrice"/>
		<result property="maxPrice" javaType="Integer" column="maxPrice"/>
		<result property="producingArea" javaType="Long" column="producing_area"/>
		<result property="localityArea" javaType="Long" column="locality_area"/>
		<result property="sellerName" javaType="String" column="seller_name"/>
        <result property="manualAuditType" javaType="Integer" column="manual_audit_type"/>
		<result property="seller" javaType="Long" column="seller"/>
		<result property="shop" javaType="Long" column="shop"/>
		<result property="shopName" javaType="String" column="shop_name"/>
		<result property="marketId" javaType="Long" column="market_id"/>
		<result property="marketName" javaType="String" column="market_name"/>
		<result property="indate" javaType="Integer" column="indate"/>
		<result property="defaultPic" javaType="String" column="img_url"/>
		<result property="foreignPid" javaType="String" column="foreign_pid"/>
		<result property="storeUnit" javaType="Integer" column="store_unit"/>
		<collection property="subCateList" javaType="ArrayList" ofType="category">
			<result property="id" column="id" javaType="Integer"/>
		</collection>
	</resultMap>
	
	<!-- 全部条件(更多功能可以通过queryData扩展实现) 为防止column名重复,查询时将product_pop表取别名为a-->
	<sql id="QUERY_WHERE_CLAUSE">
		<where>
			<if test="pid != null and pid != ''"><![CDATA[AND pid = #{pid}]]></if>
            <if test="manualAuditType != null and manualAuditType != ''"><![CDATA[AND manual_audit_type = #{manualAuditType}]]></if>
			<if test="name != null and name != ''"><![CDATA[AND a.name = #{name}]]></if>
			<if test="cateId != null and cateId != ''"><![CDATA[AND cate_id = #{cateId}]]></if>
		    <if test="userDefined != null and userDefined != ''"><![CDATA[AND user_defined = #{userDefined}]]></if>
			<if test="producingArea != null and producingArea != ''"><![CDATA[AND producing_area = #{producingArea}]]></if>
			<if test="seller != null and seller != ''"><![CDATA[AND seller = #{seller}]]></if>
			<if test="sellerName != null and sellerName != ''"><![CDATA[AND seller_name = #{sellerName}]]></if>
			<if test="shop != null and shop != ''"><![CDATA[AND shop = #{shop}]]></if>
			<if test="marketId != null and marketId != ''"><![CDATA[AND market_id = #{marketId}]]></if>
			<if test="publishMode != null and publishMode != ''"><![CDATA[AND publish_mode = #{publishMode}]]></if>
			<if test="publishTime != null and publishTime != ''"><![CDATA[AND publish_time = #{publishTime}]]></if>
			<if test="status != null and status != '' and status &lt; 4"><![CDATA[AND a.status = #{status}]]></if>
			<if test="userDefined !=null and userDefined !='' "><![CDATA[AND user_defined = #{userDefined}]]></if>
			<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
			<if test="startTime != null and endTime == null "><![CDATA[AND ctime > #{startTime}]]></if>
			<if test="startTime == null and endTime != null "><![CDATA[AND ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
			<if test="startTime != null and endTime != null  and startTime != '' and endTime!= '' "><![CDATA[AND ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
			<if test="utime != null and utime != ''"><![CDATA[AND utime = #{utime}]]></if>
			<![CDATA[AND a.status > 0]]>
		</where>
	</sql>

	<!-- 智能排序与分页 -->
	<sql id="QUERY_ORDER_LIMIT_CONDTION">
		<if test="orderField != null and orderField != '' and orderFieldType != null and orderFieldType != ''"><![CDATA[ORDER BY ${orderField} ${orderFieldType}]]></if>
		<if test="startIndex != null and startIndex &gt;= 0 and pageSize != null and pageSize &gt; 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
	</sql>
	
	<sql id="UPDATE_COLUMN_SET">
		<set>
			<if test="manualAuditType != null and manualAuditType != ''"><![CDATA[ manual_audit_type = #{manualAuditType},]]></if>
            <if test="name != null and name != ''"><![CDATA[ name = #{name},]]></if>
			<if test="cateId != null and cateId != ''"><![CDATA[cate_id = #{cateId},]]></if>
			<if test="producingArea != null and producingArea != ''"><![CDATA[ producing_area = #{producingArea},]]></if>
			<if test="seller != null and seller != ''"><![CDATA[ seller = #{seller},]]></if>
			<if test="shop != null and shop != ''"><![CDATA[ shop = #{shop},]]></if>
			<if test="localityArea != null and localityArea != ''"><![CDATA[ locality_area = #{localityArea},]]></if>
			<if test="publishMode != null and publishMode != '' and publishMode > 0 "><![CDATA[ publish_mode = #{publishMode},]]></if>
			<if test="publishTime != null and publishTime != ''"><![CDATA[ publish_time = #{publishTime},]]></if>
			<if test="publishSettime != null and publishSettime != ''"><![CDATA[ publish_settime = #{publishSettime},]]></if>
			<if test="prepareTime != null and prepareTime != ''"><![CDATA[ prepare_time = #{prepareTime},]]></if>
			<if test="dropsTime != null and dropsTime != ''"><![CDATA[ drops_time = #{dropsTime},]]></if>
			<if test="status != null and status != ''"><![CDATA[`status` = #{status},]]></if>
			<if test="foreignPid != null and foreignPid != ''"><![CDATA[ foreign_pid = #{foreignPid},]]></if>
			<if test="ctime != null and ctime != ''"><![CDATA[ ctime = #{ctime},]]></if>
			<![CDATA[ utime = now()]]>
		</set>
	</sql>



	<!-- 插入product_pop记录 -->
	<insert id="insertEntry" parameterType="productPop">
		<![CDATA[
			INSERT INTO product_pop (pid,name,has_special,quotation_type,cate_id,producing_area,seller,seller_name,shop,shop_name,market_id,market_name,indate,publish_mode,publish_settime,status,ctime,prepare_time,foreign_pid,store_unit,manual_audit_type)
			VALUES (#{pid},#{name},#{hasSpecial},#{quotationType},#{cateId},#{producingArea},#{seller},#{sellerName},#{shop},#{shopName},#{marketId},#{marketName},#{indate},#{publishMode},#{publishSettime},#{status},now(),#{prepareTime},#{foreignPid},#{storeUnit},#{manualAuditType})
		]]>
	</insert>

	<!-- 删除,通过条件 -->
	<update id="deleteByCondtion" parameterType="productPop">
		<![CDATA[DELETE FROM product_pop a]]>
		<include refid="QUERY_WHERE_CLAUSE" />
	</update>

	<!-- 修改记录通过主键 -->
	<update id="updateByKey" parameterType="productPop">
		<![CDATA[UPDATE product_pop]]>
		<include refid="UPDATE_COLUMN_SET"/>
		<![CDATA[WHERE pid = #{pid}]]>
	</update>

    <select id="searchEntryList" parameterType="com.dili.titan.domain.ProductPopQuery" resultMap="productPop">

        <if test="minPrice == null and maxPrice == null">
            <![CDATA[
              SELECT t.pid,t.name,t.cate_id,t.seller,t.seller_name,t.shop,t.shop_name,t.publish_time,t.status,t.desc,t.ctime,t.utime
              FROM product_pop t
            ]]>
        </if>
        <where>
            <if test="pid != null and pid != ''"><![CDATA[AND t.pid = #{pid}]]></if>
            <if test="name != null and name != ''"><![CDATA[AND t.name like CONCAT('%',#{name},'%')]]></if>
            <if test="sellerName != null and sellerName != ''"><![CDATA[AND t.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
			<if test="shopName != null and shopName != ''"><![CDATA[AND t.shop_name like CONCAT('%',#{shopName},'%')]]></if>
            <if test="status != null and status != '' and status == -1"><![CDATA[AND t.status >0 ]]></if>
            <if test="status != null and status != '' and status>0 and status&lt;3"><![CDATA[AND t.status =#{status} ]]></if>
            <if test="status != null and status != '' and status>=3"><![CDATA[AND t.status >= 3 AND t.status <= 7]]></if>
            <if test="startTime != null and endTime == null "><![CDATA[AND t.ctime > #{startTime}]]></if>
            <if test="startTime == null and endTime != null "><![CDATA[AND t.ctime < #{endTime}]]></if>
            <if test="startTime != null and endTime != null  and startTime != '' and endTime!= '' "><![CDATA[AND t.ctime between #{startTime} and #{endTime}]]></if>
            <if test="cateList != null and cateList != ''"><![CDATA[AND t.cate_id IN]]>
                <foreach collection="cateList" item="cate" open="(" separator="," close=")">
                    <![CDATA[#{cate}]]>
                </foreach>
            </if>
        </where>
        ORDER BY t.pid desc
        <if test="startIndex != null and startIndex &gt;= 0 and pageSize != null and pageSize &gt; 0"><![CDATA[LIMIT #{startIndex},#{pageSize}]]></if>
    </select>

    <select id="searchEntryListCount" parameterType="com.dili.titan.domain.ProductPopQuery" resultType="int">

        <if test="minPrice == null and maxPrice == null">
            <![CDATA[SELECT count(t.pid) FROM product_pop t]]>
        </if>
        <where>
            <if test="pid != null and pid != ''"><![CDATA[AND t.pid = #{pid}]]></if>
            <if test="name != null and name != ''"><![CDATA[AND t.name like CONCAT('%',#{name},'%')]]></if>
            <if test="sellerName != null and sellerName != ''"><![CDATA[AND t.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
			<if test="shopName != null and shopName != ''"><![CDATA[AND t.shop_name like CONCAT('%',#{shopName},'%')]]></if>
            <if test="status != null and status != '' and status == -1"><![CDATA[AND t.status >0 ]]></if>
            <if test="status != null and status != '' and status>0 and status&lt;4"><![CDATA[AND t.status =#{status} ]]></if>
            <if test="status != null and status != '' and status>=4"><![CDATA[AND t.status >= 4 AND t.status <= 7]]></if>
            <if test="startTime != null and endTime == null "><![CDATA[AND t.ctime > #{startTime}]]></if>
            <if test="startTime == null and endTime != null "><![CDATA[AND t.ctime < #{endTime}]]></if>
            <if test="startTime != null and endTime != null  and startTime != '' and endTime!= '' "><![CDATA[AND t.ctime between #{startTime} and #{endTime}]]></if>
            <if test="cateList != null and cateList != ''"><![CDATA[AND t.cate_id IN]]>
                <foreach collection="cateList" item="cate" open="(" separator="," close=")">
                    <![CDATA[#{cate}]]>
                </foreach>
            </if>
        </where>
    </select>

	<!-- 查询,通过主键IN(array) -->
	<select id="selectEntryArray" parameterType="java.lang.reflect.Array" resultType="productPop">
		<![CDATA[SELECT a.hasSpecial,a.pid,a.name,a.cateId,a.producingArea,a.seller,a.sellerName,a.shop,a.shopCityId,a.shopType,a.shopName,a.indate,a.dropsTime,a.publishMode,a.publishTime,a.publishSettime,a.status,a.desc,a.ctime,a.utime,b.name as cate,a.storeUnit from ]]>
		<![CDATA[(SELECT `has_special` AS hasSpecial,`pid`,`name`,`cate_id` AS cateId,`producing_area` AS producingArea,`seller`,`seller_name` AS sellerName,`shop`,`shop_city_id` AS shopCityId,`shop_type` AS shopType,`shop_name` AS shopName,`indate`,`drops_time` AS dropsTime,`publish_mode` AS publishMode,`publish_time` AS publishTime, publish_settime as publishSettime,`status`,`desc`,`ctime`,`utime`,store_unit as storeUnit  FROM product_pop]]>
		<![CDATA[WHERE pid IN]]>
		<foreach collection="array" item="pid" open="(" separator="," close=")">
			<![CDATA[#{pid}]]>
		</foreach>
		<![CDATA[) a left join category b on b.id = a.cateId]]>
	</select>

	<select id="selectEntryList" parameterType="productPop" resultMap="productPop">
		<![CDATA[SELECT g.deli_name,g.deli_type,g.deli_id,maxPrice,minPrice,f.pid,market_id,market_name,has_special,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,f.ctime,f.utime,f.storeUnit FROM ]]>
		<![CDATA[(SELECT maxPrice,minPrice,market_id,market_name,has_special,e.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,e.ctime,e.utime,e.storeUnit FROM]]>
		<![CDATA[(SELECT MAX(d.price) as maxPrice,MIN(d.price) as minPrice,market_id,market_name,has_special,c.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,c.status,c.ctime,c.utime,c.storeUnit FROM ]]>
		<![CDATA[(SELECT a.market_id,a.market_name,a.has_special,a.pid,a.`name`,a.cate_id ,b.`name` AS cate,publish_settime,indate,shop_name,shop,seller,seller_name,a.producing_area,a.`desc`,a.drops_time ,a.publish_mode,a.publish_time,a.`status`,a.ctime,a.utime,a.store_unit as storeUnit ]]>
		<![CDATA[FROM product_pop a LEFT JOIN category b on a.cate_id=b.id ]]>
		<where>
			<if test="pid != null and pid != ''"><![CDATA[AND a.pid = #{pid}]]></if>
			<if test="name != null and name != ''"><![CDATA[AND a.name like CONCAT('%',#{name},'%')]]></if>
            <if test="cateId != null and cateId != '' and cateId>0"><![CDATA[AND a.cate_id = #{cateId}]]></if>
			<if test="subCateList != null and subCateList != ''"><![CDATA[AND a.cate_id IN]]>
			<foreach collection="subCateList" item="cate" open="(" separator="," close=")">
				<![CDATA[#{cate.id}]]>
			</foreach></if>
			<if test="sellerName != null and sellerName != ''"><![CDATA[AND a.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
			<if test="status != null and status != '' and status &lt; 4"><![CDATA[AND a.status = #{status}]]></if>
			<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
			<if test="startTime != null and endTime == null "><![CDATA[AND a.ctime > #{startTime}]]></if>
			<if test="startTime == null and endTime != null "><![CDATA[AND a.ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
			<if test="startTime != null and endTime != null  and startTime != '' and endTime!= '' "><![CDATA[AND a.ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
            <if test="isExcludeFailure != null and isExcludeFailure == true "><![CDATA[AND a.status > 0]]></if>
			<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
		</where>
		<![CDATA[ )c LEFT JOIN  product_pop_sku d ON d.pid=c.pid GROUP BY pid)e ]]>
		<if test="minPrice != null and maxPrice == null"><![CDATA[WHERE minPrice>=#{minPrice} ]]> </if>
		<if test="minPrice == null and maxPrice != null"><![CDATA[WHERE maxPrice<=#{maxPrice} ]]> </if>
		<if test="minPrice != null and maxPrice != null "><![CDATA[WHERE (minPrice>=#{minPrice} and minPrice<=#{maxPrice}) or (maxPrice>=#{minPrice} and maxPrice<=#{maxPrice})]]> </if>
		<include refid="QUERY_ORDER_LIMIT_CONDTION" />
		<![CDATA[)f order by f.ctime desc,f.pid desc]]>
	</select>

	<!-- 总数查询,通过条件 -->
	<select id="selectEntryListCount" parameterType="productPop" resultType="int">
		<![CDATA[SELECT COUNT(pid) AS dataCount FROM]]>
		<![CDATA[(SELECT maxPrice,minPrice,e.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,`status`,e.ctime,e.utime,e.storeUnit FROM]]>
		<![CDATA[(SELECT MAX(d.price) as maxPrice,MIN(d.price) as minPrice,c.pid,`name`,cate_id,cate,publish_settime,indate,shop_name,shop,seller,seller_name,producing_area,`desc`,drops_time,publish_mode,publish_time,c.status,c.ctime,c.utime,c.storeUnit FROM ]]>
		<![CDATA[(SELECT a.pid,a.`name`,a.cate_id ,b.`name` AS cate,publish_settime,indate,shop_name,shop,seller,seller_name,a.producing_area,a.`desc`,a.drops_time ,a.publish_mode,a.publish_time,a.`status`,a.ctime,a.utime,a.store_unit as storeUnit ]]>
		<![CDATA[FROM product_pop a LEFT JOIN category b on a.cate_id=b.id ]]>
		<where>
			<if test="pid != null and pid != ''"><![CDATA[AND a.pid = #{pid}]]></if>
            <if test="cateId != null and cateId != '' and cateId>0"><![CDATA[AND a.cate_id = #{cateId}]]></if>
			<if test="name != null and name != ''"><![CDATA[AND a.name like CONCAT('%',#{name},'%')]]></if>
			<if test="subCateList != null and subCateList != ''"><![CDATA[AND a.cate_id IN]]>
			<foreach collection="subCateList" item="cate" open="(" separator="," close=")">
				<![CDATA[#{cate.id}]]>
			</foreach></if>
			<if test="sellerName != null and sellerName != ''"><![CDATA[AND a.seller_name like CONCAT('%',#{sellerName},'%')]]></if>
			<if test="status != null and status != '' and status &lt; 4"><![CDATA[AND a.status = #{status}]]></if>
			<if test="userDefined !=null and userDefined !='' "><![CDATA[AND a.user_defined = #{userDefined}]]></if>
			<if test="status != null and status != '' and status>=4"><![CDATA[AND a.status >3]]></if>
			<if test="startTime != null and endTime == null "><![CDATA[AND a.ctime > #{startTime}]]></if>
			<if test="startTime == null and endTime != null "><![CDATA[AND a.ctime < DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
			<if test="startTime != null and endTime != null  and startTime != '' and endTime!= '' "><![CDATA[AND a.ctime between #{startTime} and DATE_ADD(#{endTime},INTERVAL 1 DAY)]]></if>
            <if test="isExcludeFailure != null and isExcludeFailure == true "><![CDATA[AND a.status > 0]]></if>
			<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
		</where>
		<![CDATA[ )c LEFT JOIN  product_pop_sku d ON d.pid=c.pid GROUP BY pid)e ]]>
		<if test="minPrice != null and maxPrice == null"><![CDATA[WHERE minPrice>=#{minPrice} ]]> </if>
		<if test="minPrice == null and maxPrice != null"><![CDATA[WHERE maxPrice<=#{maxPrice} ]]> </if>
		<if test="minPrice != null and maxPrice != null "><![CDATA[WHERE (minPrice>=#{minPrice} and minPrice<=#{maxPrice}) or (maxPrice>=#{minPrice} and maxPrice<=#{maxPrice})]]> </if>
		<![CDATA[)f]]>
	</select>

    <update id="updateByKeyAndStatus" parameterType="java.util.HashMap" >
        <![CDATA[UPDATE product_pop]]>
        <![CDATA[SET status = #{status},]]>
        <if test="dropsTime != null"><![CDATA[drops_time = #{dropsTime},]]></if>
        utime=now()
        <![CDATA[WHERE status = #{whereStatus} AND pid in ]]>
        <foreach collection="list" item="s" open="(" separator="," close=")">
            <![CDATA[#{s}]]>
        </foreach>
        <if test="manualAuditType != null"><![CDATA[AND manual_audit_type = #{manualAuditType}]]></if>
    </update>
    
    <select id="selectPopList" parameterType="com.dili.titan.domain.ProductPopQuery" resultMap="productPop">
    	<![CDATA[select  d.market_id,d.pid,d.name,d.quotation_type,d.cate_id,d.user_defined,d.seller,d.seller_name,d.shop,d.shop_name,
              d.producing_area,d.country_area,d.foreign_city_name,d.locality_area,d.shop_city_id,d.shop_type,
              d.indate,d.publish_mode,d.publish_settime,d.publish_time,d.drops_time,d.status,d.prepare_time,
              d.desc,d.ctime,d.utime,d.store_unit,d.manual_audit_type,d.has_special,min(b.price) AS minPrice,MAX(b.price) AS maxPrice from(]]>
		<![CDATA[select  a.market_id,a.pid,a.name,a.quotation_type,a.cate_id,a.user_defined,a.seller,a.seller_name,a.shop,a.shop_name,
              a.producing_area,a.country_area,a.foreign_city_name,a.locality_area,a.shop_city_id,a.shop_type,
              a.indate,a.publish_mode,a.publish_settime,a.publish_time,a.drops_time,a.status,a.prepare_time,
              a.desc,a.ctime,a.utime,a.store_unit,a.manual_audit_type,a.has_special FROM product_pop a
				  where a.`status` =3 ]]>
		<if test="pids != null and pids != ''"><![CDATA[ AND a.pid not in]]>
			<foreach collection="pids" item="item" open="(" separator="," close=")">
				<![CDATA[#{item}]]>
			</foreach>
		</if>
        <if test="cateList != null and cateList != ''"><![CDATA[AND a.cate_id IN]]>
            <foreach collection="cateList" item="cate" open="(" separator="," close=")">
                <![CDATA[#{cate}]]>
            </foreach>
        </if>			
		<if test="pid != null and pid != ''"><![CDATA[ AND a.pid = #{pid}]]></if>
		<if test="name != null and name != ''"><![CDATA[ AND a.name like CONCAT('%',#{name},'%')]]></if>
		<if test="shopName != null and shopName != ''"><![CDATA[ AND a.shop_name like CONCAT('%',#{shopName},'%')]]></if>
		<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
		<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND a.shop_city_id IN]]>
			<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
				<![CDATA[#{cityid}]]>
			</foreach>
		</if>
		<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND a.shop_type IN]]>
			<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
				<![CDATA[#{shopType}]]>
			</foreach>
		</if>
		<include refid="QUERY_ORDER_LIMIT_CONDTION" />
		<![CDATA[ )d LEFT JOIN  product_pop_sku b on d.pid = b.pid GROUP BY b.pid ]]>
    </select>
    
    <select id="selectPopListCount" parameterType="com.dili.titan.domain.ProductPopQuery" resultType="int">
    	<![CDATA[ select count(1) FROM product_pop a where a.`status` =3 ]]>
		<if test="pids != null and pids != ''"><![CDATA[ AND a.pid not in]]>
			<foreach collection="pids" item="item" open="(" separator="," close=")">
				<![CDATA[#{item}]]>
			</foreach>
		</if>		
        <if test="cateList != null and cateList != ''"><![CDATA[AND a.cate_id IN]]>
            <foreach collection="cateList" item="cate" open="(" separator="," close=")">
                <![CDATA[#{cate}]]>
            </foreach>
        </if>		
		<if test="pid != null and pid != ''"><![CDATA[ AND a.pid = #{pid}]]></if>
		<if test="name != null and name != ''"><![CDATA[ AND a.name like CONCAT('%',#{name},'%')]]></if>
		<if test="shopName != null and shopName != ''"><![CDATA[ AND a.shop_name like CONCAT('%',#{shopName},'%')]]></if>
		<if test="marketId != null and marketId != ''"><![CDATA[AND a.market_id = #{marketId}]]></if>
		<if test="shopCityIds != null and shopCityIds != ''"><![CDATA[AND a.shop_city_id IN]]>
			<foreach collection="shopCityIds" item="cityid" open="(" separator="," close=")">
				<![CDATA[#{cityid}]]>
			</foreach>
		</if>
		<if test="shopTypes != null and shopTypes != ''"><![CDATA[AND a.shop_type IN]]>
			<foreach collection="shopTypes" item="shopType" open="(" separator="," close=")">
				<![CDATA[#{shopType}]]>
			</foreach>
		</if>
    </select>
    <!--todo 初始化 -->
    <select id="findShopId" parameterType="productPop" resultType="long">
        <![CDATA[ select shop FROM product_pop  group by shop]]>
    </select>
    <!--todo 初始化 -->
    <update id="setShopCityId" parameterType="java.util.Map">
        <![CDATA[UPDATE product_pop SET shop_city_id = #{cityId}, shop_type = #{shopType},shop_name= #{shopName}]]>
        <![CDATA[ WHERE  shop = #{shopId} ]]>
    </update>

	<!--todo 初始化 -->
	<update id="updateMarket" parameterType="java.util.Map">
		<![CDATA[UPDATE product_pop SET market_id = #{marketId}, market_name = #{marketName} ]]>
		<![CDATA[ WHERE  shop = #{shopId} ]]>
	</update>


    <!--todo 初始化 -->
    <select id="findByLocalityId" parameterType="productPop" resultType="productPop">
        <![CDATA[SELECT pid,shop from product_pop]]>
        <![CDATA[WHERE locality_area=0 OR locality_area IS NULL ]]>
    </select>
    <!--todo 初始化 -->
    <update id="updateLocalityId" parameterType="java.util.Map">
        <![CDATA[UPDATE product_pop SET locality_area = #{localityId}]]>
        <![CDATA[ WHERE  shop = #{shopId}  ]]>
    </update>
</mapper>