fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java
@@ -72,29 +72,7 @@ long queryCountMySecondTeamList(@Param("key") String key, @Param("bossId") Long bossId); /** * 长时间未邀请成功用户 * * @param daysNum * @return */ List<Long> queryLongTimeFailed(@Param("daysNum") int daysNum); /** * 长时间 邀请成功用户 * * @param daysNum * @return */ List<ThreeSale> queryLongTimeSuccess(@Param("daysNum") int daysNum); /** * 设置对应邀请过期 * * @param list * @return */ int updateExpire(List<Long> list); /** * 一级查询 fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -82,9 +82,7 @@ <!-- 根据邀请者ID查询关系 --> <select id="getByWorkerId" resultMap="BaseResultMap" parameterType="java.lang.Long"> select <include refid="Base_Column_List" /> from yeshi_ec_threeSale where worker_id = #{0} AND state=0 AND (expire = 0 OR expire IS NULL) ORDER BY createTime DESC LIMIT 1 where worker_id = #{0} AND state = 1 </select> <select id="selectLatestByWorkerIdAndState" resultMap="BaseResultMap"> @@ -231,32 +229,7 @@ )A </select> <select id="queryLongTimeFailed" resultType="java.lang.Long"> <!-- 长时间未邀请成功 --> SELECT h.`id` FROM `yeshi_ec_threesale` h WHERE h.`state` = 0 AND (h.expire = 0 OR h.expire IS NULL) <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]> </select> <select id="queryLongTimeSuccess" resultMap="BaseResultMap"> <!-- 长时间未邀请成功 --> SELECT * FROM `yeshi_ec_threesale` h WHERE h.`state` = 1 AND (h.expire = 0 OR h.expire IS NULL) <![CDATA[ AND DATE_SUB(CURDATE(), INTERVAL #{daysNum} DAY) > DATE(FROM_UNIXTIME(h.`createTime`/1000)) ]]> </select> <update id="updateExpire" parameterType="java.lang.Long"> update yeshi_ec_threeSale t set t.expire = 1, t.updateTime = <![CDATA[UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) * 1000]]> where t.`id` IN <foreach item="item" collection="list" open="(" separator="," close=")">#{item}</foreach> </update> <select id="listFirstTeamQuery" resultMap="AllResultMap"> SELECT * FROM `yeshi_ec_threesale` fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoExtraServiceImpl.java
@@ -358,48 +358,14 @@ throw new UserInfoExtraException(1, "已经激活, 无需再次激活"); inviteCode = inviteCode.toUpperCase(); // 邀请码对应用户信息 UserInfo inviter = userInfoService.getUserInfoByInviteCode(inviteCode); if (inviter == null || inviter.getState() != UserInfo.STATE_NORMAL) UserInfo boss = userInfoService.getUserInfoByInviteCode(inviteCode); if (boss == null || boss.getState() != UserInfo.STATE_NORMAL) throw new UserInfoExtraException(1, "上级邀请码不存在"); // 绑定关系 try { threeSaleSerivce.bindRelationshipByInviteCode(invitee, inviter); } catch (ThreeSaleException e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } throw new UserInfoExtraException(1, "激活失败"); } // 生成邀请码 String mycode = createInviteCode(uid); if (StringUtil.isNullOrEmpty(mycode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(invitee); userInfoExtra.setInviteCode(mycode); userInfoExtra.setUpdateTime(new Date()); if (extra != null) { userInfoExtra.setId(extra.getId()); userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra); } else { userInfoExtra.setCreateTime(new Date()); userInfoExtraMapper.insertSelective(userInfoExtra); } userActivedRecordService.add(new UserActivedRecord(uid)); if (!Constant.IS_TEST) { // 发送激活成功消息 Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive, new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date()))); producer.send(message); } return mycode; // 生成邀请关系 return inviteCodeActive(uid, boss.getId()); } @Override @@ -489,42 +455,8 @@ throw new UserInfoExtraException(1, "没有对应的邀请关系"); } // 绑定关系 try { threeSaleSerivce.bindRelationshipByWX(invitee, inviterId); } catch (ThreeSaleException e) { try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } throw new UserInfoExtraException(1, "关系绑定时失败"); } // 生成邀请码 String inviteCode = createInviteCode(uid); if (StringUtil.isNullOrEmpty(inviteCode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(invitee); userInfoExtra.setInviteCode(inviteCode); userInfoExtra.setUpdateTime(new Date()); if (extra != null) { userInfoExtra.setId(extra.getId()); userInfoExtraMapper.updateByPrimaryKeySelective(userInfoExtra); } else { userInfoExtra.setCreateTime(new Date()); userInfoExtraMapper.insertSelective(userInfoExtra); } userActivedRecordService.add(new UserActivedRecord(uid)); if (!Constant.IS_TEST) { // 发送激活成功消息 Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive, new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date()))); producer.send(message); } // 邀请码激活 inviteCodeActive(uid, boss.getId()); } @Override @@ -538,15 +470,6 @@ UserInfo invitee = userInfoService.selectByPKey(uid); if (invitee == null) { throw new UserInfoExtraException(1, "用户不存在"); } // 用户额外信息 UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid); if (extra != null) { String inviteCodeHas = extra.getInviteCode(); if (inviteCodeHas != null && inviteCodeHas.trim().length() > 0) { throw new UserInfoExtraException(1, "已经激活, 无需再次激活"); } } String wxUnionId = weiXinUser.getUnionid(); @@ -617,9 +540,27 @@ throw new UserInfoExtraException(1, "没有对应的邀请关系"); } // 邀请码激活 inviteCodeActive(uid, boss.getId()); } /** * 邀请关系生成激活码 * @param uid * @param bossId * @return * @throws UserInfoExtraException */ private String inviteCodeActive(Long uid, Long bossId) throws UserInfoExtraException{ UserInfoExtra extra = userInfoExtraMapper.getInfoExtraByUid(uid); if (extra != null && !StringUtil.isNullOrEmpty(extra.getInviteCode())) { throw new UserInfoExtraException(1, "已经激活, 无需再次激活"); } // 绑定关系 try { threeSaleSerivce.bindRelationshipByWX(invitee, inviterId); threeSaleSerivce.bindInviteRelationship(uid, bossId); } catch (ThreeSaleException e) { try { LogHelper.errorDetailInfo(e); @@ -631,12 +572,11 @@ // 生成邀请码 String inviteCode = createInviteCode(uid); ; if (StringUtil.isNullOrEmpty(inviteCode)) throw new UserInfoExtraException(1, "激活码生成失败"); UserInfoExtra userInfoExtra = new UserInfoExtra(); userInfoExtra.setUserInfo(invitee); userInfoExtra.setUserInfo(new UserInfo(uid)); userInfoExtra.setInviteCode(inviteCode); userInfoExtra.setUpdateTime(new Date()); if (extra != null) { @@ -654,8 +594,12 @@ new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date()))); producer.send(message); } return inviteCode; } @Override public void updateActiveTime(Long uid, Date date) { UserInfoExtra userInfoExtra = new UserInfoExtra(); fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -27,14 +27,10 @@ import com.yeshi.fanli.dao.mybatis.UserInfoMapper; import com.yeshi.fanli.dao.mybatis.UserShareGoodsHistoryMapper; import com.yeshi.fanli.dao.mybatis.share.ShareMapper; import com.yeshi.fanli.dto.user.UserInviteLevelEnum; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; import com.yeshi.fanli.entity.bus.user.WeiXinUser; import com.yeshi.fanli.entity.system.BusinessSystem; import com.yeshi.fanli.exception.user.ThreeSaleException; import com.yeshi.fanli.exception.user.UserInfoException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.count.HongBaoV2CountService; @@ -49,7 +45,6 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.ThreadUtil; import com.yeshi.fanli.util.account.UserUtil; import com.yeshi.fanli.util.wx.WXLoginUtil; import com.yeshi.fanli.vo.user.UserInfoVO; import net.coobird.thumbnailator.Thumbnails; @@ -204,43 +199,7 @@ return userInfoMapper.countAvaiableUser(); } @Transactional public boolean inviteWXUserInfo(String code, UserInfo inviter) { WeiXinUser weiXinUser = WXLoginUtil.getWeiXinWYUser(code); if (weiXinUser == null) { return false; } String wxUnionId = weiXinUser.getUnionid(); UserInfo find = getUserByLoginTypeAndOpenId(Constant.WEIXIN, wxUnionId, Constant.APPID); if (find == null) { find = new UserInfo(); find.setAppId(Constant.APPID); find.setWxUnionId(weiXinUser.getUnionid()); String wxHeadImg = COSManager.getInstance() .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()), FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString()) .getUrl(); find.setPortrait(wxHeadImg); find.setWxPic(wxHeadImg); find.setNickName(weiXinUser.getNickname()); find.setWxName(weiXinUser.getNickname()); find.setLoginType(Constant.WEIXIN); find.setRank(0); find.setWxOpenId(weiXinUser.getOpenid()); BusinessSystem system = new BusinessSystem(Constant.FANLI); system.setPlatform(1); find.setSystem(system); } try { threeSaleSerivce.bind(find, inviter); return true; } catch (ThreeSaleException e) { e.printStackTrace(); return false; } } @Transactional public void unBindUserInfo(UserInfo user, int type) { fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralGetServiceImpl.java
@@ -270,11 +270,11 @@ @Override public void addInviteLevelOne(Long uid, Long workerId) { try { // UserInfo boss = getBossByUid(uid); // if (boss != null) // addInviteLevelTwo(boss.getId()); UserInfo boss = getBossByUid(uid); if (boss != null) addInviteLevelTwo(boss.getId()); //addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelOne.name()); addEventStatistic(uid, TaskUniqueKeyEnum.inviteLevelOne.name()); } catch (Exception e) { // LogHelper.errorDetailInfo(e); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java
@@ -21,7 +21,6 @@ import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg; import com.yeshi.fanli.entity.bus.user.ThreeSale; import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.exception.user.ThreeSaleException; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; @@ -35,7 +34,6 @@ import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; import com.yeshi.fanli.util.rocketmq.MQTopicName; @@ -230,7 +228,7 @@ // if (inviter != null) // reComputeUserRank(inviter.getId()); // 添加到队列 inviteSuccess(oldSale.getBoss().getId(), worker); inviteSuccess(worker.getId(), oldSale.getBoss().getId()); } } @@ -269,20 +267,7 @@ return threeSaleMapper.deleteByPrimaryKey(id); } @Override public List<Long> queryLongTimeFailed(int daysNum) { return threeSaleMapper.queryLongTimeFailed(daysNum); } @Override public List<ThreeSale> queryLongTimeSuccess(int daysNum) { return threeSaleMapper.queryLongTimeSuccess(daysNum); } @Override public int updateExpire(List<Long> list) { return threeSaleMapper.updateExpire(list); } @Override public List<ThreeSale> listFirstTeamQuery(long start, int count, Long uid, Integer state, String startTime, @@ -491,35 +476,17 @@ return threeSaleMapper.getSuccessRelationshipNum(uid); } @Override @Transactional(rollbackFor = Exception.class) public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException { if (invitee == null || inviter == null) public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException { if (workerId == null || bossId == null) throw new ThreeSaleException(1, "用户信息为空"); // 新建立确定关系 ThreeSale threeSale = new ThreeSale(); threeSale.setBoss(inviter); threeSale.setWorker(invitee); threeSale.setState(true); threeSale.setExpire(ThreeSale.EXPIRE_NORMAL); threeSale.setSucceedTime(java.lang.System.currentTimeMillis()); threeSale.setCreateTime(java.lang.System.currentTimeMillis()); threeSale.setUpdateTime(java.lang.System.currentTimeMillis()); threeSaleMapper.insertSelective(threeSale); inviteSuccess(inviter.getId(), invitee); } @Override @Transactional(rollbackFor = Exception.class) public void bindRelationshipByWX(UserInfo invitee, Long inviterId) throws ThreeSaleException { if (invitee == null || inviterId == null) throw new ThreeSaleException(1, "用户信息为空"); // 新建立确定关系 ThreeSale threeSale = new ThreeSale(); threeSale.setBoss(new UserInfo(inviterId)); threeSale.setWorker(invitee); threeSale.setBoss(new UserInfo(bossId)); threeSale.setWorker(new UserInfo(workerId)); threeSale.setState(true); threeSale.setExpire(ThreeSale.EXPIRE_NORMAL); threeSale.setSucceedTime(java.lang.System.currentTimeMillis()); @@ -528,16 +495,16 @@ threeSaleMapper.insertSelective(threeSale); // 邀请成功:消息、相关处理 inviteSuccess(inviterId, invitee); inviteSuccess(workerId, bossId); } /** * 邀请成功 */ @Transactional private void inviteSuccess(Long bossId, UserInfo invitee) { private void inviteSuccess(Long workerId, Long bossId) { if (!Constant.IS_TEST) { UserInviteMQMsg msg = new UserInviteMQMsg(bossId, invitee.getId(), null, new Date(), UserInviteMQMsg.STATE_SUCCESS); UserInviteMQMsg msg = new UserInviteMQMsg(bossId, workerId, null, new Date(), UserInviteMQMsg.STATE_SUCCESS); Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteSuccess, msg); producer.send(message); } @@ -545,15 +512,15 @@ executor.execute(new Runnable() { @Override public void run() { try { // 邀请金币 integralGetService.addInviteLevelOne(bossId, invitee.getId()); try { // 邀请金币 integralGetService.addInviteLevelOne(bossId, workerId); } catch (Exception e) { e.printStackTrace(); } try { // 直接粉丝邀请成功 UserInfo invitee = userInfoService.selectByPKey(workerId); userInviteMsgNotificationService.directInviteSuccess(bossId, invitee.getNickName(), invitee.getPortrait(), new Date()); fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserInfoService.java
@@ -6,7 +6,6 @@ import org.springframework.web.multipart.MultipartFile; import com.yeshi.fanli.dto.user.UserInviteLevelEnum; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.exception.user.UserInfoException; import com.yeshi.fanli.vo.user.UserInfoVO; @@ -54,7 +53,6 @@ public long getUserCount(); public boolean inviteWXUserInfo(String code, UserInfo inviter); public void unBindUserInfo(UserInfo find, int type); fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/ThreeSaleSerivce.java
@@ -68,29 +68,7 @@ */ public int deleteByPrimaryKey(Long id); /** * 长时间未邀请成功用户 * * @param daysNum * @return */ public List<Long> queryLongTimeFailed(int daysNum); /** * 长时间 邀请成功用户 * * @param daysNum * @return */ public List<ThreeSale> queryLongTimeSuccess(int daysNum); /** * 设置对应邀请过期 * * @param list * @return */ public int updateExpire(List<Long> list); /** * 一级查询 @@ -212,14 +190,6 @@ */ public int getSuccessRelationshipNum(Long uid); /** * 邀请码生成上下级关系 * * @param invitee * @param inviter * @throws ThreeSaleException */ public void bindRelationshipByInviteCode(UserInfo invitee, UserInfo inviter) throws ThreeSaleException; /** * 统计邀请成功队员数量 @@ -244,7 +214,7 @@ * @param threeSaleOld * @throws ThreeSaleException */ public void bindRelationshipByWX(UserInfo invitee, Long inviterId) throws ThreeSaleException; public void bindInviteRelationship(Long workerId, Long bossId) throws ThreeSaleException; /** * 根据下级查找对象 fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgMoneyDetailFactory.java
@@ -384,7 +384,7 @@ listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("结算月度", ClientTextStyleVO.COLOR_TITLE), contentList)); listMsg.add(CommonMsgItemVOFactory.createMsgItemVO(new ClientTextStyleVO("到账类目", ClientTextStyleVO.COLOR_TITLE), new ClientTextStyleVO(teamName, ClientTextStyleVO.COLOR_CONTENT), true)); new ClientTextStyleVO(teamName, ClientTextStyleVO.COLOR_CONTENT))); List<ClientTextStyleVO> contentList2 = new ArrayList<>(); contentList2.add(new ClientTextStyleVO("¥" + money.setScale(2, BigDecimal.ROUND_DOWN), ClientTextStyleVO.COLOR_HIGHLIGHT_CONTENT));