fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java
@@ -107,6 +107,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserRankService; import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; import com.yeshi.fanli.service.inter.user.invite.UserInviteService; @@ -253,6 +254,11 @@ @Resource private UserInviteService userInviteService; @Resource private TeamFansInfoService teamFansInfoService; private static final String EXTRACT_MIN_MONEY = ConfigKeyEnum.extractMoneyMin.getKey(); private static final String EXTRACT_MAX_MONEY = ConfigKeyEnum.extractMoneyMAX.getKey(); @@ -1890,6 +1896,11 @@ return; } int type = 1; if (threeSale.getBoss().getId() != uid) { type = 2; } ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, worker.getId()); if (extraInfo == null) { extraInfo = new ThreeSaleExtraInfo(); @@ -1913,6 +1924,10 @@ updateInfo.setUpdateTime(new Date()); threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(updateInfo); } // 更新粉丝记录信息 teamFansInfoService.updateMemoName(worker.getId(), type, memoName); out.print(JsonUtil.loadTrueResult("保存成功")); } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/DynamicControllerV2.java
@@ -265,7 +265,7 @@ list.add(map.get(TYPE_FAQUAN)); list.add(map.get(TYPE_HUODONG)); // list.add(map.get(TYPE_XUEYUAN)); // list.add(map.get(TYPE_SUCAI)); list.add(map.get(TYPE_SUCAI)); } else if (VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) { // 2.0.6返回热销+活动+推荐+学院+邀请 list.add(map.get(TYPE_REXIAO)); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -1247,6 +1247,7 @@ threeSaleExtraInfoSerivce.insertSelective(saleExtraInfo); } // 更新粉丝记录信息 teamFansInfoService.updateTags(workerId, type, tags); out.print(JsonUtil.loadTrueResult("保存成功")); } fanli/src/main/java/com/yeshi/fanli/dao/user/invite/TeamFansInfoDao.java
@@ -1,181 +1,74 @@ 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.dao.MongodbBaseDao; 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 { public class TeamFansInfoDao extends MongodbBaseDao<TeamFansInfo> { @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 = ""; } public void updateSelective(TeamFansInfo record) { Query query = new Query(); query.addCriteria(Criteria.where("workerId").is(workerId)); query.addCriteria(Criteria.where("id").is(record.getId())); Update update = null; if (type == 1) { update = Update.update("memoName", memoName); } else { update = Update.update("memoNameSup", memoName); } mongoTemplate.updateFirst(query, update, TeamFansInfo.class); 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.getWeixinBind() != null) update.set("weixinBind", record.getWeixinBind()); if (record.getWeixinId() != null) update.set("weixinId", record.getWeixinId()); 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); } /** * 更新标签 * * @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); } /** * 统计 * @@ -196,7 +89,7 @@ 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 findList(query); } /** @@ -206,7 +99,7 @@ */ public long count(int type, Long uid, ThreeSaleFocusDTO focusDTO) { Query query = createQuery(type, uid, focusDTO); return mongoTemplate.count(query, TeamFansInfo.class); return count(query); } private Query createQuery(int type, Long uid, ThreeSaleFocusDTO focusDTO) { @@ -264,6 +157,15 @@ 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 { @@ -273,6 +175,15 @@ 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))))); } @@ -280,7 +191,6 @@ } if (list.size() > 0) { Criteria[] cas = new Criteria[list.size()]; for (int i = 0; i < list.size(); i++) cas[i] = list.get(i); fanli/src/main/java/com/yeshi/fanli/entity/bus/user/TeamFansInfo.java
@@ -9,67 +9,77 @@ import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; @Document(collection = "team_fans_info") @Document(collection = "teamFansInfo") public class TeamFansInfo { @Id @Field("id") @Field private String id; @Field("bossId") @Field private Long bossId; // 上级id @Field("bossSuperId") @Field private Long bossSuperId; // 上上级id @Field("workerId") @Field private Long workerId; // 下级id @Field("nickName") @Field private String nickName; // 昵称 @Field("level") @Field private UserLevelEnum level; // 当前等级 @Field("stateValid") @Field private Boolean stateValid; // 有效粉丝 @Field("taobaoBind") @Field private Boolean taobaoBind; // 绑定淘宝 @Field("weixinBind") @Field private Boolean weixinBind; // 绑定微信 @Field("activeTime") @Field private String weixinId; // 微信号 @Field private String phone; // 电话号码 @Field private Boolean phoneOpen; // 电话号码公开 @Field private String inviteCode; // 邀请码 @Field private Date activeTime; // 活跃时间 @Field("fansNum") @Field private Integer fansNum; // 粉丝数量 @Field("income") @Field private BigDecimal income; // 账户收入 @Field("incomeTime") @Field private Date incomeTime; // 账户收入统计时间 @Field("joinTime") @Field private Date joinTime; // 邀请成功时间 @Field("memoName") @Field private String memoName; // 直接上级备注名 @Field("tags") @Field private String tags; // 直接上级标签 @Field("memoNameSup") @Field private String memoNameSup; // 间接上级备注名 @Field("tagsSup") @Field private String tagsSup; // 间接上级标签 @Field("updateTime") @Field private Date updateTime; // 更新时间 public String getId() { @@ -224,4 +234,36 @@ this.level = level; } public String getWeixinId() { return weixinId; } public void setWeixinId(String weixinId) { this.weixinId = weixinId; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public Boolean getPhoneOpen() { return phoneOpen; } public void setPhoneOpen(Boolean phoneOpen) { this.phoneOpen = phoneOpen; } public String getInviteCode() { return inviteCode; } public void setInviteCode(String inviteCode) { this.inviteCode = inviteCode; } } fanli/src/main/java/com/yeshi/fanli/entity/bus/user/invite/TeamDailyRecord.java
@@ -50,7 +50,7 @@ @Field private Integer beyondSuperVIP; @Field private String updateTime; private Date updateTime; public TeamDailyRecord() {} @@ -190,11 +190,11 @@ this.beyondSuperVIP = beyondSuperVIP; } public String getUpdateTime() { public Date getUpdateTime() { return updateTime; } public void setUpdateTime(String updateTime) { public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamDailyRecordServiceImpl.java
@@ -48,7 +48,7 @@ // 初始化数据 initData(record); record.setUpdateTime(new Date()); teamDailyRecordDao.save(record); } } fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/TeamFansInfoServiceImpl.java
@@ -11,8 +11,10 @@ import com.yeshi.fanli.dao.user.invite.TeamFansInfoDao; import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO; import com.yeshi.fanli.entity.bus.user.TeamFansInfo; import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService; import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; import com.yeshi.fanli.util.StringUtil; @Service public class TeamFansInfoServiceImpl implements TeamFansInfoService { @@ -25,60 +27,187 @@ @Override public void save(TeamFansInfo record) { teamFansInfoDao.save(record); if (record == null || record.getWorkerId() == null ) { return; } record.setId(record.getWorkerId().toString()); TeamFansInfo teamFansInfo = teamFansInfoDao.get(record.getId()); if (teamFansInfo != null) { teamFansInfoDao.updateSelective(record); } else { initData(record); record.setUpdateTime(new Date()); teamFansInfoDao.save(record); } } /** * 初始化数据 * @param record */ private void initData(TeamFansInfo record) { if (StringUtil.isNullOrEmpty(record.getNickName())) record.setNickName(""); if (record.getLevel() == null) record.setLevel(UserLevelEnum.daRen); if (record.getStateValid() == null) record.setStateValid(false); if (record.getTaobaoBind() == null) record.setTaobaoBind(false); if (record.getWeixinBind() == null) record.setWeixinBind(false); if (record.getWeixinId() == null) record.setWeixinId(""); if (record.getPhone() == null) record.setPhone(""); if (record.getPhoneOpen() == null) record.setPhoneOpen(true); if (record.getInviteCode() == null) record.setInviteCode(""); if (record.getActiveTime() == null) record.setActiveTime(new Date()); if (record.getFansNum() == null) record.setFansNum(0); if (record.getIncome() != null) record.setIncome(BigDecimal.ZERO); if (record.getIncomeTime() == null) record.setIncomeTime(new Date()); if (record.getMemoName() == null) record.setMemoName(""); if (record.getTags() != null) record.setTags(""); if (record.getMemoNameSup() == null) record.setMemoNameSup(""); if (record.getTagsSup() == null) record.setTagsSup(""); } @Override public void updateMemoName(Long workerId, int type, String memoName) { teamFansInfoDao.updateMemoName(workerId, type, memoName); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); if (type == 1) { teamFansInfo.setMemoName(memoName); } else { teamFansInfo.setMemoNameSup(memoName); } save(teamFansInfo); } @Override public void updateTags(Long workerId, int type, String tags) { teamFansInfoDao.updateTags(workerId, type, tags); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); if (type == 1) { teamFansInfo.setTags(tags); } else { teamFansInfo.setTagsSup(tags); } save(teamFansInfo); } @Override public void updateNickName(Long workerId, String nickName) { teamFansInfoDao.updateNickName(workerId, nickName); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setNickName(nickName); save(teamFansInfo); } @Override public void updateStateValid(Long workerId, boolean stateValid) { teamFansInfoDao.updateStateValid(workerId, stateValid); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setStateValid(stateValid); save(teamFansInfo); } @Override public void updateTaobaoBind(Long workerId, boolean taobaoBind) { teamFansInfoDao.updateTaobaoBind(workerId, taobaoBind); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setTaobaoBind(taobaoBind); save(teamFansInfo); } @Override public void updateWeixinBind(Long workerId, boolean weixinBind) { teamFansInfoDao.updateWeixinBind(workerId, weixinBind); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setWeixinBind(weixinBind); save(teamFansInfo); } @Override public void updateActiveTime(Long workerId, Date activeTime) { teamFansInfoDao.updateActiveTime(workerId, activeTime); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setActiveTime(activeTime); save(teamFansInfo); } @Override public void updateWeixinId(Long workerId, String weixinId) { TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setWeixinId(weixinId); save(teamFansInfo); } @Override public void updateInviteCode(Long workerId, String inviteCode) { TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setInviteCode(inviteCode); save(teamFansInfo); } @Override public void updatePhone(Long workerId, String phone) { TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setPhone(phone); save(teamFansInfo); } @Override public void updatePhoneOpen(Long workerId, boolean phoneOpen) { TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setPhoneOpen(phoneOpen); save(teamFansInfo); } @Override public void updateIncome(Long workerId, BigDecimal income) { TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setIncome(income); teamFansInfo.setIncomeTime(new Date()); save(teamFansInfo); } @Override public void updateFansNum(Long workerId) { long firstTeam = threeSaleSerivce.countFirstTeam(workerId); long secondTeam = threeSaleSerivce.countSecondTeam(workerId); int fansNum = (int) (firstTeam + secondTeam); teamFansInfoDao.updateFansNum(workerId, fansNum); } @Override public void updateIncome(Long workerId, BigDecimal income) { teamFansInfoDao.updateIncome(workerId, income); TeamFansInfo teamFansInfo = new TeamFansInfo(); teamFansInfo.setWorkerId(workerId); teamFansInfo.setFansNum(fansNum); save(teamFansInfo); } @Override public List<TeamFansInfo> query(int start, int count, int type, Long uid, ThreeSaleFocusDTO focusDTO) { return teamFansInfoDao.query(start, count, type, uid, focusDTO); fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/TeamFansInfoService.java
@@ -29,28 +29,103 @@ */ public TeamFansInfo getbyWorkerId(Long workerId); public void updateMemoName(Long workerId, int type, String memoName); public void updateTags(Long workerId, int type, String tags); public void updateNickName(Long workerId, String nickName); public void updateStateValid(Long workerId, boolean stateValid); public void updateTaobaoBind(Long workerId, boolean taobaoBind); public void updateWeixinBind(Long workerId, boolean weixinBind); public void updateActiveTime(Long workerId, Date activeTime); public void updateFansNum(Long workerId); public void updateIncome(Long workerId, BigDecimal income); /** * 添加 * @param record */ public void save(TeamFansInfo record); /** * 更新粉丝数量 * @param workerId */ public void updateFansNum(Long workerId); /** * 更新标签 * @param workerId * @param type * @param tags */ public void updateTags(Long workerId, int type, String tags); /** * 更新粉丝备注名 * @param workerId * @param type * @param memoName */ public void updateMemoName(Long workerId, int type, String memoName); /** * 更新昵称 * @param workerId * @param nickName */ public void updateNickName(Long workerId, String nickName); /** * 更新有效状态 * @param workerId * @param stateValid */ public void updateStateValid(Long workerId, boolean stateValid); /** * 更新淘宝绑定 * @param workerId * @param taobaoBind */ public void updateTaobaoBind(Long workerId, boolean taobaoBind); /** * 更新微信绑定 * @param workerId * @param weixinBind */ public void updateWeixinBind(Long workerId, boolean weixinBind); /** * 更新活跃时间 * @param workerId * @param activeTime */ public void updateActiveTime(Long workerId, Date activeTime); /** * 更新60天收入 * @param workerId * @param income */ public void updateIncome(Long workerId, BigDecimal income); /** * 更新微信号 * @param workerId * @param weixinId */ public void updateWeixinId(Long workerId, String weixinId); /** * 更新邀请码 * * @param workerId * @param inviteCode */ public void updateInviteCode(Long workerId, String inviteCode); /** * 更新电话号 * @param workerId * @param phone */ public void updatePhone(Long workerId, String phone); /** * 更新手机号公开 * @param workerId * @param phoneOpen */ public void updatePhoneOpen(Long workerId, boolean phoneOpen); }