yujian
2019-05-29 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3
fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
@@ -65,8 +65,7 @@
      </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" />
@@ -178,12 +177,28 @@
      </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
      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">
@@ -282,8 +297,7 @@
   <!-- 查询超过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
      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>
@@ -291,8 +305,7 @@
   <!-- 查询超过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
      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>
@@ -593,6 +606,16 @@
      <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
      WHERE sg_goods_id = ${auctionId}
      limit 1
   </select>
   <select id="queryCountByGoodsId" resultType="java.lang.Long">
      SELECT COUNT(sg_id)
@@ -622,8 +645,7 @@
   </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>
@@ -706,69 +728,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">
@@ -1152,23 +1112,12 @@
   <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} <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>
   <!-- 查询超过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
@@ -1376,5 +1325,62 @@
      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>
</mapper>