From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java | 462 ++++++++++++++++++++++++++++++--------------------------- 1 files changed, 246 insertions(+), 216 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java b/fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java index 0296a5a..6a48f4b 100644 --- a/fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java +++ b/fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java @@ -1,216 +1,246 @@ -package com.yeshi.fanli.dao.user.invite; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.regex.Pattern; - -import org.springframework.data.domain.Sort; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; -import org.springframework.data.mongodb.core.query.Update; -import org.springframework.stereotype.Repository; - -import com.yeshi.fanli.dao.MongodbBaseDao; -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> { - - - /** - * 閫夋嫨鎬ф洿鏂� - * @param record - */ - public void updateSelective(TeamFansInfo record) { - Query query = new Query(); - query.addCriteria(Criteria.where("id").is(record.getId())); - - Update update = new Update(); - if (record.getNickName() != null) - update.set("nickName", record.getNickName()); - if (record.getLevel() != null) - update.set("level", record.getLevel().name()); - if (record.getStateValid() != null) - update.set("stateValid", record.getStateValid()); - if (record.getTaobaoBind() != null) - update.set("taobaoBind", record.getTaobaoBind()); - 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) - update.set("phoneOpen", record.getPhoneOpen()); - if (record.getInviteCode() != null) - update.set("inviteCode", record.getInviteCode()); - if (record.getActiveTime() != null) - update.set("activeTime", record.getActiveTime()); - if (record.getFansNum() != null) - update.set("fansNum", record.getFansNum()); - if (record.getIncome() != null) - update.set("income", record.getIncome()); - if (record.getIncomeTime() != null) - update.set("incomeTime", record.getIncomeTime()); - if (record.getMemoName() != null) - update.set("memoName", record.getMemoName()); - if (record.getTags() != null) - update.set("tags", record.getTags()); - if (record.getMemoNameSup() != null) - update.set("memoNameSup", record.getMemoNameSup()); - if (record.getTagsSup() != null) - update.set("tagsSup", record.getTagsSup()); - update.set("updateTime", new Date()); - update(query, update); - } - - - - /** - * 缁熻 - * - * @return - */ - public TeamFansInfo getbyWorkerId(Long workerId) { - Query query = new Query(); - query.addCriteria(Criteria.where("workerId").is(workerId)); - return mongoTemplate.findOne(query, TeamFansInfo.class); - } - - /** - * 鏌ヨ - * - * @return - */ - 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")); - return findList(query); - } - - /** - * 缁熻 - * - * @return - */ - public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) { - Query query = createQuery(type, uid, focusDTO); - return count(query); - } - - private Query createQuery(int type, Long uid, ThreeSaleFocusDTO focusDTO) { - List<Criteria> list = new ArrayList<Criteria>(); - if (type == 1) { - list.add(Criteria.where("bossId").is(uid)); - } else { - list.add(Criteria.where("bossSuperId").is(uid)); - } - - 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("weixinIdExist").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").gte(focusDTO.getMinFansNum())); - - if (focusDTO.getMaxFansNum() != null) - list.add(Criteria.where("fansNum").lte(focusDTO.getMaxFansNum())); - - 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 (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.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) { - 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("weixinId") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE))), - new Criteria().andOperator(Criteria.where("inviteCode") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE))), - new Criteria().andOperator(Criteria.where("phone") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE)).andOperator(Criteria.where("phoneOpen").is(true))), - 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("weixinId") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE))), - new Criteria().andOperator(Criteria.where("inviteCode") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE))), - new Criteria().andOperator(Criteria.where("phone") - .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", - Pattern.CASE_INSENSITIVE)).andOperator(Criteria.where("phoneOpen").is(true))), - new Criteria().andOperator(Criteria.where("tagsSup").regex(Pattern - .compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE))))); - } - } - } - - Query query = new Query(); - 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; - } - -} +package com.yeshi.fanli.dao.user.invite; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.regex.Pattern; + +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.core.query.Update; +import org.springframework.stereotype.Repository; + +import com.yeshi.common.MongodbBaseDao; +import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO; +import com.yeshi.fanli.entity.bus.user.TeamFansInfo; +import com.yeshi.fanli.util.StringUtil; +import org.yeshi.utils.TimeUtil; + +@Repository +public class TeamFansInfoDao extends MongodbBaseDao<TeamFansInfo> { + + + /** + * 閫夋嫨鎬ф洿鏂� + * @param record + */ + public void updateSelective(TeamFansInfo record) { + Query query = new Query(); + query.addCriteria(Criteria.where("id").is(record.getId())); + + Update update = new Update(); + if (record.getNickName() != null) + update.set("nickName", record.getNickName()); + if (record.getLevel() != null) + update.set("level", record.getLevel().name()); + if (record.getStateValid() != null) + update.set("stateValid", record.getStateValid()); + if (record.getTaobaoBind() != null) + update.set("taobaoBind", record.getTaobaoBind()); + 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) + update.set("phoneOpen", record.getPhoneOpen()); + if (record.getInviteCode() != null) + update.set("inviteCode", record.getInviteCode()); + if (record.getActiveTime() != null) + update.set("activeTime", record.getActiveTime()); + if (record.getFansNum() != null) + update.set("fansNum", record.getFansNum()); + if (record.getIncome() != null) + update.set("income", record.getIncome()); + if (record.getIncomeTime() != null) + update.set("incomeTime", record.getIncomeTime()); + if (record.getMemoName() != null) + update.set("memoName", record.getMemoName()); + if (record.getTags() != null) + update.set("tags", record.getTags()); + if (record.getMemoNameSup() != null) + update.set("memoNameSup", record.getMemoNameSup()); + if (record.getTagsSup() != null) + update.set("tagsSup", record.getTagsSup()); + update.set("updateTime", new Date()); + update(query, update); + } + + + + /** + * 缁熻 + * + * @return + */ + public TeamFansInfo getbyWorkerId(Long workerId) { + Query query = new Query(); + query.addCriteria(Criteria.where("workerId").is(workerId)); + return mongoTemplate.findOne(query, TeamFansInfo.class); + } + + /** + * 鏌ヨ + * + * @return + */ + 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, "joinTime")); + return findList(query); + } + + /** + * 缁熻 + * + * @return + */ + public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) { + Query query = createQuery(type, uid, focusDTO); + return count(query); + } + + private Query createQuery(int type, Long uid, ThreeSaleFocusDTO focusDTO) { + List<Criteria> list = new ArrayList<Criteria>(); + if (type == 1) { + list.add(Criteria.where("bossId").is(uid)); + } else { + list.add(Criteria.where("bossSuperId").is(uid)); + } + + 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("weixinIdExist").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").gte(focusDTO.getMinFansNum())); + + if (focusDTO.getMaxFansNum() != null) + list.add(Criteria.where("fansNum").lte(focusDTO.getMaxFansNum())); + + 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 (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.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) { + 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("weixinId") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE))), + new Criteria().andOperator(Criteria.where("inviteCode") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE))), + new Criteria().andOperator(Criteria.where("phone") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE)).andOperator(Criteria.where("phoneOpen").is(true))), + 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("weixinId") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE))), + new Criteria().andOperator(Criteria.where("inviteCode") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE))), + new Criteria().andOperator(Criteria.where("phone") + .regex(Pattern.compile("^.*" + focusDTO.getKey() + ".*$", + Pattern.CASE_INSENSITIVE)).andOperator(Criteria.where("phoneOpen").is(true))), + new Criteria().andOperator(Criteria.where("tagsSup").regex(Pattern + .compile("^.*" + focusDTO.getKey() + ".*$", Pattern.CASE_INSENSITIVE))))); + } + } + } + + Query query = new Query(); + 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; + } + + + /** + * 鏍规嵁鐢ㄦ埛淇℃伅鍖归厤 + * @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); + } + +} -- Gitblit v1.8.0