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 | 181 ++++++++++++++++++++++++++++++++++++++------- 1 files changed, 152 insertions(+), 29 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 ec1fa2b..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; @@ -15,7 +16,9 @@ import org.springframework.stereotype.Repository; 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 { @@ -35,11 +38,10 @@ mongoTemplate.save(record); } - /** * 鐘舵�佸垏鎹� - * - * @param record + * @param id + * @param state */ public void updateSatate(String id, int state) { Query query = new Query(); @@ -97,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)); @@ -108,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( @@ -125,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)); @@ -133,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)); @@ -155,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>(); @@ -167,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()]; @@ -182,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>(); @@ -194,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()]; @@ -207,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()]; @@ -229,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, Long 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)); @@ -258,9 +269,32 @@ /** * 鏌ヨ鏈夋晥 - * @param start - * @param count - * @param key + * @return + */ + 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)); + + 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)); + } + + return mongoTemplate.find(query, GoodsEvaluate.class); + } + + + /** + * 鏌ヨ鏈夋晥 * @return */ public List<GoodsEvaluate> queryOverdue() { @@ -271,12 +305,8 @@ return mongoTemplate.find(query, GoodsEvaluate.class); } - + /** - * 鏌ヨ鏈夋晥 - * @param start - * @param count - * @param key * @return */ public List<GoodsEvaluate> removeDownGoods() { @@ -303,10 +333,12 @@ */ public List<GoodsEvaluate> listByStartTime(Date date) { List<Criteria> list = new ArrayList<Criteria>(); - list.add(Criteria.where("startTime").gt(new Date())); - list.add(Criteria.where("startTime").lte(date)); + list.add(Criteria.where("dynamicType").is(1)); + list.add(Criteria.where("state").is(1)); + list.add(Criteria.where("startTime").gt(date)); + list.add(Criteria.where("startTime").lte(new Date())); list.add(new Criteria().orOperator(Criteria.where("type").is("single"), - new Criteria().andOperator(Criteria.where("type").is("single")))); + new Criteria().andOperator(Criteria.where("type").is("activity")))); Query query = new Query(); if (list.size() > 0) { @@ -315,8 +347,99 @@ cas[i] = list.get(i); query.addCriteria(new Criteria().andOperator(cas)); } + query.with(new Sort(Sort.Direction.DESC,"startTime")); + return mongoTemplate.find(query, GoodsEvaluate.class); } + /** + * 鏌ヨ鏈夋晥-鍊掑簭 + * @param start + * @param count + * @return + */ + public List<GoodsEvaluate> queryValidSortASC(int start, int count, EvaluateEnum tyepEnum, boolean sortDesc) { + Date now = new Date(); + Query query = new Query(); + List<Criteria> list = new ArrayList<Criteria>(); + + list.add(Criteria.where("type").is(tyepEnum.name())); + list.add(Criteria.where("dynamicType").is(1)); + list.add(Criteria.where("state").is(1)); + list.add(Criteria.where("startTime").lte(now)); + list.add(Criteria.where("endTime").gte(now)); + + 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); + + if (sortDesc) { + query.with(new Sort(Sort.Direction.DESC,"startTime")); + } else { + query.with(new Sort(Sort.Direction.ASC,"startTime")); + } + + return mongoTemplate.find(query, GoodsEvaluate.class); + } + + + /** + * + * @param goodsType + * @param goodsId + * @param limitTime + * @return + */ + public List<GoodsEvaluate> queryExistLimitTime(int goodsType, String goodsId, Date limitTime) { + 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.goodsId").is(goodsId)); + list.add(Criteria.where("goods.goodsType").is(goodsType)); + + // 闄愬埗鏃堕棿鍐� + list.add(Criteria.where("startTime").gte(limitTime)); + + 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)); + } + + 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