From a7454d8a6325566753358b37ffabfae2faa0ca7f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 28 四月 2021 19:46:49 +0800
Subject: [PATCH] 拼多多授权调整,支持小程序跳转

---
 fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java |  101 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 65 insertions(+), 36 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java b/fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
index 8f1fb45..40ae84d 100644
--- a/fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
+++ b/fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
@@ -7,6 +7,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.entity.SystemEnum;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
@@ -17,6 +18,7 @@
 import com.yeshi.fanli.entity.dynamic.GoodsEvaluate;
 import com.yeshi.fanli.entity.dynamic.GoodsEvaluate.EvaluateEnum;
 import com.yeshi.fanli.util.StringUtil;
+import org.yeshi.utils.TimeUtil;
 
 @Repository
 public class GoodsEvaluateDao {
@@ -36,11 +38,10 @@
 		mongoTemplate.save(record);
 	}
 
-	
 	/**
 	 * 鐘舵�佸垏鎹�
-	 * 
-	 * @param record
+	 * @param id
+	 * @param state
 	 */
 	public void updateSatate(String id, int state) {
 		Query query = new Query();
@@ -98,7 +99,7 @@
 	 * 
 	 * @return
 	 */
-	public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType, String typeEnum) {
+	public List<GoodsEvaluate> query(int start, int count, String key, Integer state, int dynamicType, String typeEnum, SystemEnum system) {
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
 		list.add(Criteria.where("dynamicType").is(dynamicType));
@@ -109,6 +110,9 @@
 		
 		if (!StringUtil.isNullOrEmpty(typeEnum))
 			list.add(Criteria.where("type").is(typeEnum));
+
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		
 		if (!StringUtil.isNullOrEmpty(key))
 			list.add(new Criteria().orOperator(
@@ -126,7 +130,7 @@
 		return mongoTemplate.find(query, GoodsEvaluate.class);
 	}
 
-	public long count(String key, Integer state, int dynamicType, String typeEnum) {
+	public long count(String key, Integer state, int dynamicType, String typeEnum, SystemEnum system) {
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
 		list.add(Criteria.where("dynamicType").is(dynamicType));
@@ -134,6 +138,9 @@
 		if (state != null) {
 			list.add(Criteria.where("state").is(state));
 		}
+
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		
 		if (!StringUtil.isNullOrEmpty(typeEnum))
 			list.add(Criteria.where("type").is(typeEnum));
@@ -156,10 +163,9 @@
 	 * 鏌ヨ鏈夋晥
 	 * @param start
 	 * @param count
-	 * @param key
 	 * @return
 	 */
-	public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType) {
+	public List<GoodsEvaluate> queryValid(int start, int count, int dynamicType,SystemEnum system) {
 		Date now = new Date();
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
@@ -168,6 +174,8 @@
 		list.add(Criteria.where("state").is(1));
 		list.add(Criteria.where("startTime").lte(now));
 		list.add(Criteria.where("endTime").gte(now));
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		
 		if (list.size() > 0) {
 			Criteria[] cas = new Criteria[list.size()];
@@ -183,10 +191,9 @@
 
 	/**
 	 * 缁熻鏈夋晥
-	 * @param key
 	 * @return
 	 */
-	public long countValid(int dynamicType) {
+	public long countValid(int dynamicType,SystemEnum system) {
 		Date now = new Date();
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
@@ -195,6 +202,8 @@
 		list.add(Criteria.where("state").is(1));
 		list.add(Criteria.where("startTime").lte(now));
 		list.add(Criteria.where("endTime").gte(now));
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		
 		if (list.size() > 0) {
 			Criteria[] cas = new Criteria[list.size()];
@@ -208,18 +217,17 @@
 	
 	/**
 	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
 	 * @return
 	 */
-	public List<GoodsEvaluate> querySingleExist() {
+	public List<GoodsEvaluate> querySingleExist(SystemEnum system) {
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
 		
 		list.add(Criteria.where("dynamicType").is(1));
 		list.add(Criteria.where("state").is(1));
 		list.add(Criteria.where("goods.goodsType").is(1));
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		
 		if (list.size() > 0) {
 			Criteria[] cas = new Criteria[list.size()];
@@ -230,19 +238,21 @@
 		return mongoTemplate.find(query, GoodsEvaluate.class);
 	}
 	
-	
+
 	/**
 	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
+	 * @param goodsType
+	 * @param goodsId
+	 * @param system
 	 * @return
 	 */
-	public List<GoodsEvaluate> queryExist(int goodsType, String goodsId) {
+	public List<GoodsEvaluate> queryExist(int goodsType, String goodsId,SystemEnum system) {
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
 		list.add(Criteria.where("dynamicType").is(1));
 		list.add(Criteria.where("state").is(1));
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		list.add(Criteria.where("imgList.goods.goodsId").is(goodsId));
 		list.add(Criteria.where("imgList.goods.goodsType").is(goodsType));
 		
@@ -259,17 +269,16 @@
 	
 	/**
 	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
 	 * @return
 	 */
-	public List<GoodsEvaluate> queryExistSingle(int goodsType, String goodsId) {
+	public List<GoodsEvaluate> queryExistSingle(int goodsType, String goodsId,SystemEnum system) {
 		Query query = new Query();
 		List<Criteria> list = new ArrayList<Criteria>();
 		list.add(Criteria.where("dynamicType").is(1));
 		list.add(Criteria.where("state").is(1));
 		list.add(Criteria.where("type").is("single"));
+		if(system!=null)
+			list.add(Criteria.where("system").is(system));
 		list.add(Criteria.where("imgList.goods.goodsId").is(goodsId));
 		list.add(Criteria.where("imgList.goods.goodsType").is(goodsType));
 		
@@ -286,9 +295,6 @@
 	
 	/**
 	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
 	 * @return
 	 */
 	public List<GoodsEvaluate> queryOverdue() {
@@ -299,12 +305,8 @@
 		return mongoTemplate.find(query, GoodsEvaluate.class);
 	}
 	
-	
+
 	/**
-	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
 	 * @return
 	 */
 	public List<GoodsEvaluate> removeDownGoods() {
@@ -354,7 +356,6 @@
 	 * 鏌ヨ鏈夋晥-鍊掑簭
 	 * @param start
 	 * @param count
-	 * @param key
 	 * @return
 	 */
 	public List<GoodsEvaluate> queryValidSortASC(int start, int count, EvaluateEnum tyepEnum, boolean sortDesc) {
@@ -385,12 +386,12 @@
 		return mongoTemplate.find(query, GoodsEvaluate.class);
 	}
 
-	
+
 	/**
-	 * 鏌ヨ鏈夋晥
-	 * @param start
-	 * @param count
-	 * @param key
+	 *
+	 * @param goodsType
+	 * @param goodsId
+	 * @param limitTime
 	 * @return
 	 */
 	public List<GoodsEvaluate> queryExistLimitTime(int goodsType, String goodsId, Date limitTime) {
@@ -400,6 +401,7 @@
 		list.add(Criteria.where("state").is(1));
 		list.add(Criteria.where("goods.goodsId").is(goodsId));
 		list.add(Criteria.where("goods.goodsType").is(goodsType));
+		
 		// 闄愬埗鏃堕棿鍐�
 		list.add(Criteria.where("startTime").gte(limitTime));
 		
@@ -413,4 +415,31 @@
 		return mongoTemplate.find(query, GoodsEvaluate.class);
 	}
 	 
+	
+	 
+	public List<GoodsEvaluate> queryValidZeroPoint(int start, int count) {
+		// 浠婃棩22鐐瑰彂鍦� 锛�0鐐逛笅鍗�
+		Date now = new Date();
+		Date startTime = TimeUtil.parseYYYYMMDD_HHMM(TimeUtil.getGernalTime(now) + " 22:00");
+		
+		Query query = new Query();
+		List<Criteria> list = new ArrayList<Criteria>();
+		
+		list.add(Criteria.where("zeroPoint").is(1));
+		list.add(Criteria.where("dynamicType").is(1));
+		list.add(Criteria.where("state").is(1));
+		list.add(Criteria.where("startTime").is(startTime));
+		list.add(new Criteria().orOperator(Criteria.where("type").is("single"),
+				new Criteria().andOperator(Criteria.where("type").is("activity"))));
+		
+		if (list.size() > 0) {
+			Criteria[] cas = new Criteria[list.size()];
+			for (int i = 0; i < list.size(); i++)
+				cas[i] = list.get(i);
+			query.addCriteria(new Criteria().andOperator(cas));
+		}
+        query.skip(start).limit(count);
+		return mongoTemplate.find(query, GoodsEvaluate.class);
+	}
+
 }

--
Gitblit v1.8.0