admin
2020-06-10 271ae63c20fcbe28d29c47f1881138ff6551a2a1
fanli/src/main/java/com/yeshi/fanli/dao/dynamic/GoodsEvaluateDao.java
@@ -263,6 +263,33 @@
    * @param key
    * @return
    */
   public List<GoodsEvaluate> queryExistSingle(int goodsType, String goodsId) {
      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"));
      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);
   }
   /**
    * 查询有效
    * @param start
    * @param count
    * @param key
    * @return
    */
   public List<GoodsEvaluate> queryOverdue() {
      Date now = new Date();
      Query query = new Query();
@@ -303,10 +330,12 @@
    */
   public List<GoodsEvaluate> listByStartTime(Date date) {
      List<Criteria> list = new ArrayList<Criteria>();
      list.add(Criteria.where("dynamicType").is(1));
      list.add(Criteria.where("state").is(1));
      list.add(Criteria.where("startTime").gt(new Date()));
      list.add(Criteria.where("startTime").lte(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,6 +344,8 @@
            cas[i] = list.get(i);
         query.addCriteria(new Criteria().andOperator(cas));
      }
      query.with(new Sort(Sort.Direction.ASC,"startTime"));
      return mongoTemplate.find(query, GoodsEvaluate.class);
   }