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 | 539 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 246 insertions(+), 293 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 eff4236..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,293 +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 javax.annotation.Resource; - -import org.springframework.data.domain.Sort; -import org.springframework.data.mongodb.core.MongoTemplate; -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.dto.user.ThreeSaleFocusDTO; -import com.yeshi.fanli.entity.bus.user.TeamFansInfo; -import com.yeshi.fanli.util.StringUtil; - -@Repository -public class TeamFansInfoDao { - - @Resource - private MongoTemplate mongoTemplate; - - /** - * 鏂板 - * - * @param record - */ - public void save(TeamFansInfo record) { - if (record == null) { - return; - } - mongoTemplate.save(record); - } - - /** - * 鏇存柊鏍囩 - * - * @param record - */ - public void updateMemoName(Long workerId, int type, String memoName) { - 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); - } else { - update = Update.update("memoNameSup", memoName); - } - mongoTemplate.updateFirst(query, update, TeamFansInfo.class); - } - - /** - * 鏇存柊鏍囩 - * - * @param record - */ - public void updateTags(Long workerId, int type, String tags) { - 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); - } else { - update = Update.update("tagsSup", tags); - } - mongoTemplate.updateFirst(query, update, TeamFansInfo.class); - } - - /** - * 鏇存柊鏄电О - * - * @param workerId - * @param nickName - */ - public void updateNickName(Long workerId, String nickName) { - if (nickName == null) { - nickName = ""; - } - - Query query = new Query(); - query.addCriteria(Criteria.where("workerId").is(workerId)); - Update update = Update.update("nickName", nickName); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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); - mongoTemplate.updateFirst(query, update, TeamFansInfo.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()); - mongoTemplate.updateMulti(query, update, TeamFansInfo.class); - } - - /** - * 缁熻 - * - * @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 mongoTemplate.find(query, TeamFansInfo.class); - } - - /** - * 缁熻 - * - * @return - */ - public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) { - Query query = createQuery(type, uid, focusDTO); - return mongoTemplate.count(query, TeamFansInfo.class); - } - - 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("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("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").gte(focusDTO.getMinFansNum())); - - 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) - list.add(Criteria.where("income").gte(focusDTO.getMinIncome())); - - if (focusDTO.getMaxIncome() != null) - list.add(Criteria.where("income").lte(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; - } - -} +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