| | |
| | | package com.yeshi.fanli.dao.user.invite;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | 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> {
|
| | |
| | | update.set("stateValid", record.getStateValid());
|
| | | if (record.getTaobaoBind() != null)
|
| | | update.set("taobaoBind", record.getTaobaoBind());
|
| | | if (record.getWeixinBind() != null)
|
| | | update.set("weixinBind", record.getWeixinBind());
|
| | | if (record.getWeixinId() != null)
|
| | | update.set("weixinId", record.getWeixinId());
|
| | | if (record.getWeixinIdExist() != null)
|
| | | update.set("weixinIdExist", record.getWeixinIdExist());
|
| | | if (record.getPhone() != null)
|
| | | update.set("phone", record.getPhone());
|
| | | if (record.getPhoneOpen() != null)
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | 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 {
|
| | |
| | | list.add(Criteria.where("taobaoBind").is(focusDTO.getTaobaoBind()));
|
| | |
|
| | | if (focusDTO.getWeixinBind() != null)
|
| | | list.add(Criteria.where("weixinBind").is(focusDTO.getWeixinBind()));
|
| | | list.add(Criteria.where("weixinIdExist").is(focusDTO.getWeixinBind()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getLevel()))
|
| | | list.add(Criteria.where("level").is(focusDTO.getLevel()));
|
| | |
| | | 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 (focusDTO.getMinIncome() != null) {
|
| | | int income = focusDTO.getMinIncome().multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN).intValue();
|
| | | list.add(Criteria.where("income").gte(income));
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getMaxJoinTime()))
|
| | | list.add(Criteria.where("joinTime").lte(focusDTO.getMaxJoinTime()));
|
| | | if (focusDTO.getMaxIncome() != null) {
|
| | | int income = focusDTO.getMaxIncome().multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_DOWN).intValue();
|
| | | 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.getMinActiveTime()))
|
| | | list.add(Criteria.where("activeTime").gte(focusDTO.getMinActiveTime()));
|
| | | 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()))
|
| | | list.add(Criteria.where("activeTime").lte(focusDTO.getMaxActiveTime()));
|
| | |
|
| | | if (focusDTO.getMinIncome() != null)
|
| | | list.add(Criteria.where("income").gte(focusDTO.getMinIncome()));
|
| | |
|
| | | if (focusDTO.getMaxIncome() != null)
|
| | | list.add(Criteria.where("income").lte(focusDTO.getMaxIncome()));
|
| | | 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) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | Query query = new Query();
|
| | | if (list.size() > 0) {
|
| | | Criteria[] cas = new Criteria[list.size()];
|
| | | for (int i = 0; i < list.size(); i++)
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | }
|