admin
2020-06-10 271ae63c20fcbe28d29c47f1881138ff6551a2a1
fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java
@@ -16,6 +16,7 @@
import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO;
import com.yeshi.fanli.entity.bus.user.TeamFansInfo;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TimeUtil;
@Repository
public class TeamFansInfoDao extends MongodbBaseDao<TeamFansInfo> {
@@ -89,7 +90,7 @@
   public List<TeamFansInfo> query(int start, int count, int type, Long uid, ThreeSaleFocusDTO focusDTO) {
      Query query = createQuery(type, uid, focusDTO);
      query.skip(start).limit(count);
      query.with(new Sort(Sort.Direction.DESC, "weight"));
      query.with(new Sort(Sort.Direction.DESC, "joinTime"));
      return findList(query);
   }
@@ -104,9 +105,7 @@
   }
   private Query createQuery(int type, Long uid, ThreeSaleFocusDTO focusDTO) {
      Query query = new Query();
      List<Criteria> list = new ArrayList<Criteria>();
      if (type == 1) {
         list.add(Criteria.where("bossId").is(uid));
      } else {
@@ -132,21 +131,9 @@
         if (focusDTO.getMaxFansNum() != null)
            list.add(Criteria.where("fansNum").lte(focusDTO.getMaxFansNum()));
         if (!StringUtil.isNullOrEmpty(focusDTO.getMinJoinTime()))
            list.add(Criteria.where("joinTime").gte(focusDTO.getMinJoinTime()));
         if (!StringUtil.isNullOrEmpty(focusDTO.getMaxJoinTime()))
            list.add(Criteria.where("joinTime").lte(focusDTO.getMaxJoinTime()));
         if (!StringUtil.isNullOrEmpty(focusDTO.getMinActiveTime()))
            list.add(Criteria.where("activeTime").gte(focusDTO.getMinActiveTime()));
         if (!StringUtil.isNullOrEmpty(focusDTO.getMaxActiveTime()))
            list.add(Criteria.where("activeTime").lte(focusDTO.getMaxActiveTime()));
         if (focusDTO.getMinIncome() != null) {
            int income = focusDTO.getMinIncome().multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN).intValue();
            list.add(Criteria.where("income").lte(income));
            list.add(Criteria.where("income").gte(income));
         }
         if (focusDTO.getMaxIncome() != null) {
@@ -154,6 +141,25 @@
            list.add(Criteria.where("income").lte(income));
         }
         
         if (!StringUtil.isNullOrEmpty(focusDTO.getMinJoinTime())) {
            Date date = TimeUtil.parseDotYYYYMMDD(focusDTO.getMinJoinTime());
            list.add(Criteria.where("joinTime").gte(date));
         }
         if (!StringUtil.isNullOrEmpty(focusDTO.getMaxJoinTime())) {
            Date date = TimeUtil.parseDotCommon(focusDTO.getMaxJoinTime() + " 23:59:59");
            list.add(Criteria.where("joinTime").lte(date));
         }
         if (!StringUtil.isNullOrEmpty(focusDTO.getMinActiveTime())) {
            Date date = TimeUtil.parseDotYYYYMMDD(focusDTO.getMinActiveTime());
            list.add(Criteria.where("activeTime").gte(date));
         }
         if (!StringUtil.isNullOrEmpty(focusDTO.getMaxActiveTime())) {
            Date date = TimeUtil.parseDotCommon(focusDTO.getMaxActiveTime() + " 23:59:59");
            list.add(Criteria.where("activeTime").lte(date));
         }
         if (!StringUtil.isNullOrEmpty(focusDTO.getKey())) {
            if (type == 1) {
@@ -196,6 +202,7 @@
         }
      }
      Query query = new Query();
      if (list.size() > 0) {
         Criteria[] cas = new Criteria[list.size()];
         for (int i = 0; i < list.size(); i++)
@@ -206,4 +213,34 @@
      return query;
   }
   /**
    * 根据用户信息匹配
    * @param key
    * @return
    */
   public List<TeamFansInfo> queryByUserInfo(String key) {
      if (StringUtil.isNullOrEmpty(key))
         return null;
      Long workerId = null;
      try {
         workerId = Long.parseLong(key);
      } catch (Exception e) {
      }
      Criteria criteria = null;
      if (workerId == null) {
         criteria = new Criteria().orOperator(Criteria.where("phone").is(key),
               new Criteria().orOperator(Criteria.where("inviteCode").is(key)));
      } else {
         criteria = new Criteria().orOperator(Criteria.where("phone").is(key),
               new Criteria().orOperator(Criteria.where("inviteCode").is(key)),
               new Criteria().orOperator(Criteria.where("workerId").is(workerId)));
      }
      Query query = new Query(criteria);
      return findList(query);
   }
}