From 0588d6be74335f41c79a8d8e32dbd1c3d3e47fa3 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 29 五月 2019 17:20:50 +0800
Subject: [PATCH] 精选库商品入库及更新调整 + 9k9类商品查询取消标签查询

---
 fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml |  180 +++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 93 insertions(+), 87 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
index 3fc7009..ac4a720 100644
--- a/fanli/src/main/java/com/yeshi/fanli/mapping/lable/QualityFactoryMapper.xml
+++ b/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>

--
Gitblit v1.8.0