| | |
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackWinInviteMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
|
| | | if (uid == null || source == null || orderNo == null)
|
| | | if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo))
|
| | | return;
|
| | |
|
| | | // 上一级的奖励
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss != null) {
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
|
| | | if(threeSale == null)
|
| | | return;
|
| | | |
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | |
|
| | |
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | |
|
| | | bossReward(boss.getId(), uid, source, orderNo);
|
| | | }
|
| | | // 奖励上级
|
| | | bossReward(bossId, uid, source, orderNo);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | * @param orderNo
|
| | | * @throws Exception
|
| | | */
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @Transactional
|
| | | private void bossReward(Long uid, Long teamUid, Integer source, String orderNo) throws Exception {
|
| | | firstSharedOrderRewardToBoss(uid, teamUid, source, orderNo);
|
| | |
| | |
|
| | | // 第一次到账的次月开始连续15个月 自然月获得(已到账)
|
| | | int monthSpace = DateUtil.getMonthSpace( order.getAccountTime(), firstorder.getAccountTime());
|
| | | if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARd_MONTH) |
| | | if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARD_MONTH) |
| | | return;
|
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void inviteSucceedReward(Long uid) throws Exception{
|
| | | // 验证是否存在上级
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss == null) |
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
|
| | | if (threeSale == null)
|
| | | return;
|
| | | // 上级id
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | |
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | |
|
| | |
| | | return;
|
| | |
|
| | | // 同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | if (totalReward > 0)
|
| | | return;
|
| | |
|
| | |
| | | winInvite.setCreateTime(new Date());
|
| | | winInvite.setUpdateTime(new Date());
|
| | | winInvite.setType(RedPackWinInviteTypeEnum.inviteSucceed);
|
| | | winInvite.setUid(boss.getId());
|
| | | winInvite.setUid(bossId);
|
| | | winInvite.setTeamUid(uid);
|
| | | winInvite.setMoney(money);
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | |
|
| | | // 增加红包
|
| | | redPackBalanceService.addRedPack(boss.getId(), money, RedPackDetailFactory.createInvite(winInvite));
|
| | | redPackBalanceService.addRedPack(bossId, money, RedPackDetailFactory.createInvite(winInvite));
|
| | |
|
| | | // 消息
|
| | | MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
|
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(boss.getId()).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(boss.getId(), MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(bossId).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(bossId, MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | | }
|