admin
2019-11-23 51a4ff5d777028d52a19c314a99f796334cb7b51
fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
@@ -179,15 +179,31 @@
      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
      DELETE FROM yeshi_ec_quality_factory WHERE sg_id in
      <foreach collection="list" item="item" open="(" close=")"
         separator=",">#{item}</foreach>
   </delete>
   <delete id="deleteBatchByGoodsId" parameterType="java.util.List">
      DELETE FROM yeshi_ec_quality_factory WHERE sg_goods_id in
      <foreach collection="list" item="item" open="(" close=")"
         separator=",">#{item}</foreach>
   </delete>
   <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" />
      )
@@ -279,27 +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
@@ -460,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
@@ -594,6 +595,17 @@
      FROM yeshi_ec_quality_factory WHERE sg_goods_id = ${goodsId}
   </select>
   <!--查询精选商品信息 -->
   <select id="getByAuctionId" resultMap="BaseResultMap">
      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)
      FROM yeshi_ec_quality_factory WHERE sg_goods_id =
@@ -706,69 +718,7 @@
   </select>
   <select id="listQueryEverydayRob" resultMap="BaseResultMap">
      <!-- 移动查询每日必抢 -->
      SELECT * FROM `yeshi_ec_quality_factory` h
      LEFT JOIN
      `yeshi_ec_label_goods` g ON h.`sg_goods_id` = g.`lg_goods_id`
      LEFT JOIN
      yeshi_ec_taobao_goods tb ON h.`sg_goods_id`= tb.`id`
      WHERE
      g.`lg_label_id`= #{labId} AND TO_DAYS(h.`sg_updatetime`) =
      TO_DAYS(NOW())
      <!-- 分类id -->
      <if test="systemCid != null">
         AND h.`sg_class_id` = #{systemCid}
      </if>
      <if test="startCouponAmount != null">
         <![CDATA[ AND tb.couponAmount > #{startCouponAmount} ]]>
      </if>
      <if test="endCouponAmount != null">
         <![CDATA[ AND tb.couponAmount <= #{endCouponAmount}]]>
      </if>
      ORDER BY
      <if test="sortField == 1">
         h.sg_createtime,
      </if>
      <if test="sortField == 2">
         h.sg_createtime desc,
      </if>
      <if test="sortField == 3">
         h.sg_updatetime,
      </if>
      <if test="sortField == 4">
         h.sg_updatetime desc,
      </if>
      h.sg_weight 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
      LEFT JOIN `yeshi_ec_label_goods` g ON h.`sg_goods_id` =
      g.`lg_goods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb ON h.`sg_goods_id`=
      tb.`id`
      WHERE g.`lg_label_id`= #{labId} AND TO_DAYS(h.`sg_updatetime`)
      =
      TO_DAYS(NOW())
      <if test="systemCid != null">
         AND h.`sg_class_id` = #{systemCid}
      </if>
      <if test="startCouponAmount != null">
         <![CDATA[ AND tb.couponAmount > #{startCouponAmount} ]]>
      </if>
      <if test="endCouponAmount != null">
         <![CDATA[ AND tb.couponAmount <= #{endCouponAmount}]]>
      </if>
   </select>
   <delete id="removeStorageGoods" parameterType="java.lang.Long">
@@ -936,13 +886,11 @@
   <select id="listQueryByFlashSale" resultMap="BaseResultMap">
      SELECT
      <include refid="Base_Column_List" />
      FROM yeshi_ec_quality_factory h
      RIGHT JOIN yeshi_ec_quality_flash_sale
      s ON h.`sg_id` = s.`fs_qfgoods_id`
      LEFT JOIN yeshi_ec_taobao_goods tb
      ON h.`sg_goods_id`= tb.`id`
      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 ]]>
@@ -953,8 +901,7 @@
   <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_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
@@ -966,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_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>
@@ -1152,23 +1102,13 @@
   <select id="getAuctionIdbyClassId" resultType="java.lang.Long">
      SELECT tb.`id` FROM `yeshi_ec_quality_factory` h
      LEFT JOIN
      `yeshi_ec_taobao_goods` tb ON h.`sg_goods_id` = tb.`id`
      WHERE
      h.`sg_class_id` = #{systemCid} AND h.`sg_goods_source` =
      #{goodsSource}
      AND <![CDATA[h.`sg_createtime` < '${beforeTime}']]>
      AND NOT EXISTS(SELECT lg_goods_id FROM `yeshi_ec_label_goods` lb WHERE
      lb.`lg_goods_id` = tb.`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>
   <!-- 查询超过4个小时未更新商品,进行更新 -->
   <select 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} ]]>
   </select>
   <select id="listRecommendToIndex" resultMap="BaseResultMap">
      SELECT
@@ -1341,40 +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>
      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
      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>
   </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}
      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
      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}
   </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>