admin
2019-11-23 51a4ff5d777028d52a19c314a99f796334cb7b51
fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
@@ -65,7 +65,8 @@
      </association>
   </resultMap>
   <resultMap id="GoodsResultMap"   type="com.yeshi.fanli.entity.bus.lable.QualityFactory">
   <resultMap id="GoodsResultMap"
      type="com.yeshi.fanli.entity.bus.lable.QualityFactory">
      <id column="sg_id" property="id" jdbcType="BIGINT" />
      <result column="sg_class_id" property="systemCid" jdbcType="BIGINT" />
      <result column="sg_entry_mode" property="entryMode" jdbcType="INTEGER" />
@@ -177,15 +178,15 @@
      </set>
      where sg_id = #{id,jdbcType=BIGINT}
   </update>
   <!-- 查询超过4个小时未更新商品,进行更新 -->
   <update id="updateWeight">
      UPDATE yeshi_ec_quality_factory SET sg_weight = #{weight}
      WHERE <![CDATA[TO_DAYS(`sg_updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(`sg_updatetime`)) >= #{time} ]]>
   </update>
   <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
      DELETE FROM yeshi_ec_quality_factory WHERE sg_id in
@@ -202,7 +203,7 @@
   <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id"
      parameterType="java.util.List">
      insert into yeshi_ec_quality_factory
      INSERT IGNORE yeshi_ec_quality_factory
      (
      <include refid="Base_Column_List" />
      )
@@ -294,25 +295,11 @@
   </select>
   <!-- 查询超过hour个小时未更新商品,进行更新 -->
   <select id="queryNeedUpdate" resultType="java.lang.Long">
      SELECT h.sg_goods_id FROM `yeshi_ec_quality_factory` h
      LEFT JOIN `yeshi_ec_taobao_goods` tb ON h.`sg_goods_id` = tb.id
      WHERE <![CDATA[TO_DAYS(tb.`updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(tb.`updatetime`)) >=  #{hour}]]>
      order by h.`sg_updatetime` LIMIT ${start},${count}
   </select>
   <!-- 查询超过5个小时未更新商品,进行更新 -->
   <select id="countQueryNeedUpdate" resultType="java.lang.Long">
      SELECT count(sg_id) FROM `yeshi_ec_quality_factory` h
      LEFT JOIN `yeshi_ec_taobao_goods` tb ON h.`sg_goods_id` = tb.id
      WHERE <![CDATA[TO_DAYS(tb.`updatetime`) < TO_DAYS(NOW()) OR (HOUR(NOW()) -HOUR(tb.`updatetime`)) >= 4]]>
   </select>
   <!-- 查询精选商品信息 -->
   <select id="query" parameterType="com.yeshi.fanli.vo.quality.QualityFactoryVO" resultMap="ResultMap">
   <select id="query" parameterType="com.yeshi.fanli.vo.quality.QualityFactoryVO"
      resultMap="ResultMap">
      SELECT ts.* FROM (
      SELECT DISTINCT( tt.`sg_id`) AS id FROM
      yeshi_ec_quality_factory tt
@@ -473,7 +460,8 @@
   </select>
   <select id="queryCount" parameterType="com.yeshi.fanli.vo.quality.QualityFactoryVO"  resultType="java.lang.Long">
   <select id="queryCount" parameterType="com.yeshi.fanli.vo.quality.QualityFactoryVO"
      resultType="java.lang.Long">
      <!-- 根据条件统计所有标签数量 -->
      SELECT count(ts.sg_id) FROM (
      SELECT DISTINCT( tt.`sg_id`) AS id FROM
@@ -606,16 +594,17 @@
      <include refid="Base_Column_List" />
      FROM yeshi_ec_quality_factory WHERE sg_goods_id = ${goodsId}
   </select>
   <!--查询精选商品信息 -->
   <select id="getByAuctionId" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_quality_factory
      SELECT * FROM
      yeshi_ec_quality_factory
      WHERE sg_goods_id = ${auctionId}
      limit 1
   </select>
   <select id="queryCountByGoodsId" resultType="java.lang.Long">
      SELECT COUNT(sg_id)
@@ -645,7 +634,8 @@
   </select>
   <delete id="deleteByGoodsId" parameterType="java.lang.Long">
      delete from  yeshi_ec_quality_factory where sg_goods_id =
      delete from
      yeshi_ec_quality_factory where sg_goods_id =
      #{goodsId,jdbcType=BIGINT}
   </delete>
@@ -728,7 +718,7 @@
   </select>
   <delete id="removeStorageGoods" parameterType="java.lang.Long">
@@ -894,9 +884,13 @@
   </select>
   <select id="listQueryByFlashSale" resultMap="BaseResultMap">
      SELECT    <include refid="Base_Column_List" /> FROM yeshi_ec_quality_flash_sale s
      LEFT JOIN yeshi_ec_quality_factory h ON  h.`sg_goods_id` = s.`fs_qfgoods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb    ON h.`sg_goods_id`= tb.`id`
      SELECT
      <include refid="Base_Column_List" />
      FROM yeshi_ec_quality_flash_sale s
      LEFT JOIN yeshi_ec_quality_factory h ON h.`sg_goods_id` =
      s.`fs_qfgoods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb ON
      h.`sg_goods_id`= tb.`id`
      WHERE <![CDATA[ tb.`couponTotalCount` > 0 AND tb.couponLeftCount<tb.couponTotalCount ]]>
@@ -907,9 +901,11 @@
   <select id="countQueryByFlashSale" resultType="java.lang.Long">
      SELECT IFNULL(COUNT( h.`sg_id`),0) FROM yeshi_ec_quality_factory h
      RIGHT JOIN yeshi_ec_quality_flash_sale s ON h.`sg_goods_id` =   s.`fs_qfgoods_id`
      RIGHT JOIN yeshi_ec_quality_flash_sale s ON h.`sg_goods_id` =
      s.`fs_qfgoods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb ON   h.`sg_goods_id`= tb.`id`
      LEFT JOIN yeshi_ec_taobao_goods tb ON
      h.`sg_goods_id`= tb.`id`
      WHERE <![CDATA[ tb.`couponTotalCount` > 0  AND tb.couponLeftCount<tb.couponTotalCount]]>
   </select>
@@ -917,12 +913,15 @@
   <select id="listFlashSaleRandGoods" resultMap="GoodsResultMap">
      SELECT h.*, tb.* FROM yeshi_ec_quality_factory h
      RIGHT JOIN yeshi_ec_quality_flash_sale s ON h.`sg_goods_id` = s.`fs_qfgoods_id`
      RIGHT JOIN
      yeshi_ec_quality_flash_sale s ON h.`sg_goods_id` = s.`fs_qfgoods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE  s.`fs_id` IS NOT NULL AND tb.`biz30day` <![CDATA[>=]]> 10000
           AND tb.`couponTotalCount` <![CDATA[>]]>10
           AND tb.couponLeftCount <![CDATA[<]]> tb.couponTotalCount
      WHERE s.`fs_id` IS NOT NULL AND tb.`biz30day` <![CDATA[>=]]>
      10000
      AND tb.`couponTotalCount` <![CDATA[>]]>10
      AND tb.couponLeftCount <![CDATA[<]]>
      tb.couponTotalCount
      ORDER BY RAND()
      LIMIT 3
   </select>
@@ -1103,10 +1102,11 @@
   <select id="getAuctionIdbyClassId" resultType="java.lang.Long">
      SELECT h.`sg_goods_id` FROM `yeshi_ec_quality_factory` h
      WHERE  h.`sg_goods_source` = #{goodsSource} <if test="systemCid != null">AND h.`sg_class_id` = #{systemCid}</if>
         AND h.`sg_updatetime` <![CDATA[<]]> #{beforeTime}
         AND NOT EXISTS(SELECT lg_goods_id FROM `yeshi_ec_label_goods` lb WHERE lb.`lg_goods_id` = h.`sg_goods_id`)
      SELECT h.`sg_goods_id` FROM `yeshi_ec_quality_factory` h
      WHERE h.`sg_goods_source` = #{goodsSource}
      AND h.`sg_updatetime` <![CDATA[<]]>
      #{beforeTime}
      <if test="systemCid != null">AND h.`sg_class_id` = #{systemCid}</if>
   </select>
@@ -1281,97 +1281,146 @@
      #{start},#{count}
   </select>
   <select id="listFreeGoods" resultMap="GoodsResultMap">
      SELECT * FROM `yeshi_ec_quality_factory` f
      LEFT JOIN `yeshi_ec_taobao_goods` tg ON tg.`id` = f.`sg_goods_id`
      LEFT JOIN `yeshi_ec_label_goods` g ON g.`lg_goods_id` = f.`sg_goods_id`
      LEFT JOIN `yeshi_ec_label` lab ON lab.`lab_id` = g.`lg_label_id`
      WHERE lab.`lab_title` = #{lableName}
          <![CDATA[AND tg.`tkRate` >= #{tkRate}]]>
      ORDER BY f.`sg_createtime` DESC
      limit #{start},#{count}
   </select>
   <select id="countFreeGoods" resultType="java.lang.Long">
      SELECT ifnull(count(sg_id),0) FROM `yeshi_ec_quality_factory` f
      LEFT JOIN `yeshi_ec_taobao_goods` tg ON tg.`id` = f.`sg_goods_id`
      LEFT JOIN `yeshi_ec_label_goods` g ON g.`lg_goods_id` = f.`sg_goods_id`
      LEFT JOIN `yeshi_ec_label` lab ON lab.`lab_id` = g.`lg_label_id`
      WHERE lab.`lab_title` = #{lableName}
          <![CDATA[AND tg.`tkRate` >= #{tkRate}]]>
   </select>
   <select id="listByShopId" resultMap="GoodsResultMap">
      SELECT * FROM  yeshi_ec_quality_factory q
      LEFT JOIN `yeshi_ec_taobao_goods` t ON q.`sg_goods_id` = t.`id`
      SELECT * FROM
      yeshi_ec_quality_factory q
      LEFT JOIN `yeshi_ec_taobao_goods` t ON
      q.`sg_goods_id` = t.`id`
      WHERE t.`sellerId` = #{shopId}
      ORDER BY q.`sg_weight` DESC
      ORDER BY
      q.`sg_weight` DESC
      LIMIT #{start},#{count}
   </select>
    <select id="countByShopId" resultType="java.lang.Long">
      SELECT  ifnull(count(sg_id),0) FROM  yeshi_ec_quality_factory q
      LEFT JOIN `yeshi_ec_taobao_goods` t ON q.`sg_goods_id` = t.`id`
      WHERE t.`sellerId` = #{shopId}
    </select>
   <select id="countByShopId" resultType="java.lang.Long">
      SELECT
      ifnull(count(sg_id),0) FROM yeshi_ec_quality_factory q
      LEFT JOIN
      `yeshi_ec_taobao_goods` t ON q.`sg_goods_id` = t.`id`
      WHERE
      t.`sellerId` = #{shopId}
   </select>
   <select id="get9k9ClassGoods" resultMap="GoodsResultMap">
      SELECT * FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
          AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
          AND tb.`zkPrice` <![CDATA[<=]]> #{zkPrice}
          AND tb.`biz30day` <![CDATA[>=]]> #{biz30day}
          <!--  券后价范围 -->
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]> #{minQuanPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]> #{maxQuanPrice}
          <!-- 多个分类id -->
         <if test='cids != null and cids != ""'>
            AND h.`sg_class_id` in (${cids})
         </if>
      LEFT JOIN
      yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE
      tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
      AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
      AND tb.`zkPrice` <![CDATA[<=]]>
      #{zkPrice}
      AND tb.`biz30day` <![CDATA[>=]]>
      #{biz30day}
      <!-- 券后价范围 -->
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]>
      #{minQuanPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]>
      #{maxQuanPrice}
      <!-- 多个分类id -->
      <if test='cids != null and cids != ""'>
         AND h.`sg_class_id` in (${cids})
      </if>
      ORDER BY h.sg_weight desc,tb.`biz30day`desc
      LIMIT ${start},${count}
   </select>
   <select id="count9k9ClassGoods" resultType="java.lang.Long">
      SELECT IFNULL(COUNT( h.`sg_id`),0) FROM `yeshi_ec_quality_factory` h
      SELECT IFNULL(COUNT(h.`sg_id`),0) FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
          AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
          AND tb.`zkPrice` <![CDATA[<=]]> #{zkPrice}
          AND tb.`biz30day` <![CDATA[>=]]> #{biz30day}
          <!--  券后价范围 -->
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]> #{minQuanPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]> #{maxQuanPrice}
          <!-- 多个分类id -->
         <if test='cids != null and cids != ""'>
            AND h.`sg_class_id` in (${cids})
         </if>
      WHERE
      tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
      AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
      AND tb.`zkPrice` <![CDATA[<=]]>
      #{zkPrice}
      AND tb.`biz30day` <![CDATA[>=]]>
      #{biz30day}
      <!-- 券后价范围 -->
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]>
      #{minQuanPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]>
      #{maxQuanPrice}
      <!-- 多个分类id -->
      <if test='cids != null and cids != ""'>
         AND h.`sg_class_id` in (${cids})
      </if>
   </select>
   <!-- 每日必抢 -->
   <select id="listQueryEverydayRob" resultMap="GoodsResultMap">
      SELECT * FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE tb.`couponTotalCount` > 0  AND tb.couponAmount <![CDATA[>]]> 1 AND tb.couponAmount <![CDATA[<=]]> 50
          AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
          AND tb.`zkPrice` <![CDATA[<=]]> #{zkPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]> #{minQuanPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<=]]> #{maxQuanPrice}
      LEFT JOIN
      yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE
      tb.`couponTotalCount` > 0 AND tb.couponAmount <![CDATA[>]]>
      1 AND tb.couponAmount <![CDATA[<=]]>
      50
      AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
      AND tb.`zkPrice` <![CDATA[<=]]>
      #{zkPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]>
      #{minQuanPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<=]]>
      #{maxQuanPrice}
      ORDER BY h.sg_createtime desc
      LIMIT ${start},${count}
   </select>
   <select id="countQueryEverydayRob" resultType="java.lang.Long">
      SELECT IFNULL(COUNT( h.`sg_id`),0) FROM `yeshi_ec_quality_factory` h
      SELECT IFNULL(COUNT(h.`sg_id`),0) FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE tb.`couponTotalCount` > 0  AND tb.couponAmount <![CDATA[>]]> 1 AND tb.couponAmount <![CDATA[<=]]> 50
          AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
          AND tb.`zkPrice` <![CDATA[<=]]> #{zkPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]> #{minQuanPrice}
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<=]]> #{maxQuanPrice}
      WHERE
      tb.`couponTotalCount` > 0 AND tb.couponAmount <![CDATA[>]]>
      1 AND tb.couponAmount <![CDATA[<=]]>
      50
      AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
      AND tb.`zkPrice` <![CDATA[<=]]>
      #{zkPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]>
      #{minQuanPrice}
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<=]]>
      #{maxQuanPrice}
   </select>
   <select id="listFreeGoods" resultMap="GoodsResultMap">
       SELECT * FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
          AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
          <!-- 在售价  209.9 -->
          AND tb.`zkPrice` <![CDATA[<=]]> 209.9
          <!--  券后价范围  0~9.9 -->
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]> 0
          AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]> 9.9
          <!-- 比例  20 -->
          AND  tb.`tkRate` <![CDATA[>=]]> 20
      ORDER BY h.sg_weight desc
      LIMIT ${start},${count}
   </select>
   <select id="countFreeGoods" resultType="java.lang.Long">
      SELECT IFNULL(COUNT(h.`sg_id`),0) FROM `yeshi_ec_quality_factory` h
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE
      tb.`couponAmount` > 0 AND tb.`couponTotalCount` > 0
      AND IF(tb.`zkPrice` - tb.`couponStartFee`>=0, TRUE, FALSE)
      <!-- 在售价 209.9 -->
      AND tb.`zkPrice` <![CDATA[<=]]>
      209.9
      <!-- 券后价范围 0~9.9 -->
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[>]]>
      0
      AND (tb.`zkPrice` - tb.`couponAmount`) <![CDATA[<= ]]>
      9.9
      <!-- 比例 20 -->
      AND tb.`tkRate` <![CDATA[>=]]>
      20
   </select>
</mapper>