| | |
| | | package com.yeshi.fanli.dao.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.regex.Pattern;
|
| | |
| | | mongoTemplate.save(record);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 更新标签
|
| | | *
|
| | |
| | | if (memoName == null) {
|
| | | memoName = "";
|
| | | }
|
| | | |
| | |
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | |
| | |
|
| | | Update update = null;
|
| | | if (type == 1) {
|
| | | update = Update.update("memoName", memoName);
|
| | |
| | | if (tags == null) {
|
| | | tags = "";
|
| | | }
|
| | | |
| | |
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | |
| | |
|
| | | Update update = null;
|
| | | if (type == 1) {
|
| | | update = Update.update("tags", tags);
|
| | |
| | | }
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 更新昵称
|
| | | * |
| | | * @param workerId
|
| | | * @param nickName
|
| | | */
|
| | |
| | | if (nickName == null) {
|
| | | nickName = "";
|
| | | }
|
| | | |
| | |
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("nickName", nickName);
|
| | | Update update = Update.update("nickName", nickName);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 更新是否有效粉丝
|
| | | * |
| | | * @param workerId
|
| | | * @param stateValid
|
| | | */
|
| | | public void updateStateValid(Long workerId, boolean stateValid) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("stateValid", stateValid);
|
| | | Update update = Update.update("stateValid", stateValid);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 更新淘宝绑定
|
| | | * |
| | | * @param workerId
|
| | | * @param taobaoBind
|
| | | */
|
| | | public void updateTaobaoBind(Long workerId, boolean taobaoBind) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("taobaoBind", taobaoBind);
|
| | | Update update = Update.update("taobaoBind", taobaoBind);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 更新微信绑定
|
| | | * |
| | | * @param workerId
|
| | | * @param weixinBind
|
| | | */
|
| | | public void updateWeixinBind(Long workerId, boolean weixinBind) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("weixinBind", weixinBind);
|
| | | Update update = Update.update("weixinBind", weixinBind);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新活跃时间
|
| | | * |
| | | * @param workerId
|
| | | * @param activeTime
|
| | | */
|
| | | public void updateActiveTime(Long workerId, Date activeTime) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("activeTime", activeTime);
|
| | | Update update = Update.update("activeTime", activeTime);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新粉丝数量
|
| | | * |
| | | * @param workerId
|
| | | * @param fansNum
|
| | | */
|
| | | public void updateFansNum(Long workerId, int fansNum) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("fansNum", fansNum);
|
| | | Update update = Update.update("fansNum", fansNum);
|
| | | mongoTemplate.updateFirst(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 更新收入
|
| | | * |
| | | * @param workerId
|
| | | * @param income
|
| | | */
|
| | | public void updateIncome(Long workerId, BigDecimal income) {
|
| | | Query query = new Query();
|
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | Update update = Update.update("income", income).set("incomeTime", new Date());
|
| | | Update update = Update.update("income", income).set("incomeTime", new Date());
|
| | | mongoTemplate.updateMulti(query, update, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 统计
|
| | | * |
| | | * @return
|
| | | */
|
| | | public ThreeSaleFocusInfo getbyWorkerId(Long workerId) {
|
| | |
| | | query.addCriteria(Criteria.where("workerId").is(workerId));
|
| | | return mongoTemplate.findOne(query, ThreeSaleFocusInfo.class);
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 查询
|
| | | *
|
| | |
| | | public List<ThreeSaleFocusInfo> 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, "weight"));
|
| | | return mongoTemplate.find(query, ThreeSaleFocusInfo.class);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计
|
| | | * |
| | | * @return
|
| | | */
|
| | | public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) {
|
| | |
| | | return mongoTemplate.count(query, ThreeSaleFocusInfo.class);
|
| | | }
|
| | |
|
| | | |
| | | private Query createQuery(int type, Long uid, ThreeSaleFocusDTO focusDTO) {
|
| | | Query query = new Query();
|
| | | List<Criteria> list = new ArrayList<Criteria>();
|
| | |
|
| | | if (type == 1) {
|
| | | query.addCriteria(Criteria.where("bossId").is(uid));
|
| | | list.add(Criteria.where("bossId").is(uid));
|
| | | } else {
|
| | | query.addCriteria(Criteria.where("bossSuperId").is(uid));
|
| | | list.add(Criteria.where("bossSuperId").is(uid));
|
| | | }
|
| | | |
| | | if (focusDTO == null) {
|
| | | return query;
|
| | | }
|
| | | |
| | | if (focusDTO.getStateValid() != null)
|
| | | query.addCriteria(Criteria.where("stateValid").is(focusDTO.getStateValid()));
|
| | | |
| | | if (focusDTO.getTaobaoBind() != null)
|
| | | query.addCriteria(Criteria.where("taobaoBind").is(focusDTO.getTaobaoBind()));
|
| | | |
| | | if (focusDTO.getWeixinBind() != null)
|
| | | query.addCriteria(Criteria.where("weixinBind").is(focusDTO.getWeixinBind()));
|
| | | |
| | | if (focusDTO.getMinFansNum() != null)
|
| | | query.addCriteria(Criteria.where("fansNum").lte(focusDTO.getMinFansNum()));
|
| | | |
| | | if (focusDTO.getMinFansNum() != null)
|
| | | query.addCriteria(Criteria.where("fansNum").gte(focusDTO.getMinFansNum()));
|
| | | |
| | | if (focusDTO.getMinActiveTime() != null)
|
| | | query.addCriteria(Criteria.where("activeTime").lte(focusDTO.getMinActiveTime()));
|
| | | |
| | | if (focusDTO.getMaxActiveTime() != null)
|
| | | query.addCriteria(Criteria.where("activeTime").gte(focusDTO.getMaxActiveTime()));
|
| | | |
| | | if (focusDTO.getMinIncome() != null)
|
| | | query.addCriteria(Criteria.where("income").lte(focusDTO.getMinIncome()));
|
| | | |
| | | if (focusDTO.getMaxIncome() != null)
|
| | | query.addCriteria(Criteria.where("income").gte(focusDTO.getMaxIncome()));
|
| | | |
| | | |
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getKey())) {
|
| | | if (type == 1) {
|
| | | query.addCriteria(new Criteria().orOperator(
|
| | | Criteria.where("nickName").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)),
|
| | | new Criteria().andOperator(Criteria.where("memoName").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE))),
|
| | | new Criteria().andOperator(Criteria.where("tags").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)))
|
| | | ));
|
| | | } else {
|
| | | query.addCriteria(new Criteria().orOperator(
|
| | | Criteria.where("nickName").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)),
|
| | | new Criteria().andOperator(Criteria.where("memoNameSup").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE))),
|
| | | new Criteria().andOperator(Criteria.where("tagsSup").regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)))
|
| | | ));
|
| | |
|
| | | if (focusDTO != null) {
|
| | | if (focusDTO.getStateValid() != null)
|
| | | list.add(Criteria.where("stateValid").is(focusDTO.getStateValid()));
|
| | |
|
| | | if (focusDTO.getTaobaoBind() != null)
|
| | | list.add(Criteria.where("taobaoBind").is(focusDTO.getTaobaoBind()));
|
| | |
|
| | | if (focusDTO.getWeixinBind() != null)
|
| | | list.add(Criteria.where("weixinBind").is(focusDTO.getWeixinBind()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getLevel()))
|
| | | list.add(Criteria.where("level").is(focusDTO.getLevel()));
|
| | |
|
| | | if (focusDTO.getMinFansNum() != null)
|
| | | list.add(Criteria.where("fansNum").lte(focusDTO.getMinFansNum()));
|
| | |
|
| | | if (focusDTO.getMaxFansNum() != null)
|
| | | list.add(Criteria.where("fansNum").gte(focusDTO.getMaxFansNum()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getMinJoinTime()))
|
| | | list.add(Criteria.where("joinTime").lte(focusDTO.getMinJoinTime()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getMaxJoinTime()))
|
| | | list.add(Criteria.where("joinTime").gte(focusDTO.getMaxJoinTime()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getMinActiveTime()))
|
| | | list.add(Criteria.where("activeTime").lte(focusDTO.getMinActiveTime()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getMaxActiveTime()))
|
| | | list.add(Criteria.where("activeTime").gte(focusDTO.getMaxActiveTime()));
|
| | |
|
| | | if (focusDTO.getMinIncome() != null)
|
| | | list.add(Criteria.where("income").lte(focusDTO.getMinIncome()));
|
| | |
|
| | | if (focusDTO.getMaxIncome() != null)
|
| | | list.add(Criteria.where("income").gte(focusDTO.getMaxIncome()));
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(focusDTO.getKey())) {
|
| | | if (type == 1) {
|
| | | list.add(new Criteria().orOperator( Criteria.where("nickName")
|
| | | .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$",
|
| | | Pattern.CASE_INSENSITIVE)),
|
| | | new Criteria().andOperator(Criteria.where("memoName")
|
| | | .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$",
|
| | | Pattern.CASE_INSENSITIVE))),
|
| | | new Criteria().andOperator(Criteria.where("tags").regex(Pattern
|
| | | .compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)))));
|
| | | } else {
|
| | | list.add(new Criteria().orOperator(Criteria.where("nickName")
|
| | | .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$",
|
| | | Pattern.CASE_INSENSITIVE)),
|
| | | new Criteria().andOperator(Criteria.where("memoNameSup")
|
| | | .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$",
|
| | | Pattern.CASE_INSENSITIVE))),
|
| | | new Criteria().andOperator(Criteria.where("tagsSup").regex(Pattern
|
| | | .compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE)))));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | 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 query;
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | }
|