| | |
| | | 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.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | |
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
|
| | | import com.yeshi.fanli.util.annotation.redpack.RedPackGetVersionLimit;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | |
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | | |
| | |
|
| | | @Override
|
| | | public List<RedPackWinInvite> getRewardList(int start, int count, Long uid) {
|
| | |
| | | return redPackWinInviteMapper.countRewardRecord(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getRewardMoney(Long uid) {
|
| | | return redPackWinInviteMapper.getRewardMoney(uid);
|
| | | }
|
| | | |
| | | |
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | // 上一级的奖励
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss != null) {
|
| | | firstReward(uid, source, orderNo);
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | if (activeLog == null) |
| | | return;
|
| | | |
| | | // 小于2.0.2版本不增加
|
| | | if (!VersionUtil.greaterThan_2_0_2("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | | |
| | | bossReward(boss.getId(), uid, source, orderNo);
|
| | | }
|
| | | }
|
| | |
| | | firstSharedOrderRewardToBoss(uid, teamUid, source, orderNo);
|
| | | firstSharedOrderRewardTheMonthToBoss(uid, teamUid, source, orderNo);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 被邀请人下首单返利(下单就给):
|
| | | * 完成首笔订单 (已到账) 首单=不限制金额、不限制商品、不限制数量、不限制订单类型)
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param orderNo
|
| | | * @param bossId
|
| | | */
|
| | | @Transactional
|
| | | private void firstReward(Long uid, Integer source, String orderNo) throws Exception{
|
| | | // 奖励一次
|
| | | long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.newUserReward.name());
|
| | | if (total > 0)
|
| | | return;
|
| | | |
| | | // 1、判断是否用户首个订单
|
| | | CommonOrderVO order = commonOrderService.firstValidOrderByUid(uid);
|
| | | if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo())) |
| | | return;
|
| | | |
| | | // 金额
|
| | | BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("new_user_first_order"));
|
| | | |
| | | // 3、获得红包记录
|
| | | RedPackWinInvite winInvite = new RedPackWinInvite();
|
| | | winInvite.setCreateTime(new Date());
|
| | | winInvite.setUpdateTime(new Date());
|
| | | winInvite.setType(RedPackWinInviteTypeEnum.newUserReward);
|
| | | winInvite.setUid(uid);
|
| | | winInvite.setTeamUid(null);
|
| | | winInvite.setMoney(money);
|
| | | winInvite.setSource(source);
|
| | | winInvite.setOrderNo(orderNo);
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | | |
| | | // 4、增加红包
|
| | | redPackBalanceService.addRedPack(uid, money, RedPackDetailFactory.createNewUserReward(winInvite));
|
| | | |
| | | //消息
|
| | | MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
|
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackNewUserReward, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 上级奖励:被邀请人完成首笔分享订单 (已到账)
|
| | |
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackFirstSharedOrder, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackFirstSharedOrder, |
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | |
|
| | |
|
| | |
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(uid).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackMonthSharedOrder, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackMonthSharedOrder,
|
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | |
|
| | |
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Override
|
| | | @Transactional
|
| | | @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)
|
| | | return;
|
| | |
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | if (activeLog == null)
|
| | | return;
|
| | | |
| | | // 小于2.0.2版本不增加
|
| | | if (!VersionUtil.greaterThan_2_0_2("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | |
|
| | | // 同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | if (totalReward > 0)
|
| | |
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(boss.getId()).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(boss.getId(), MsgTypeMoneyTypeEnum.redPackInviteSucceed, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | userMoneyMsgNotificationService.redPackMsg(boss.getId(), MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | | }
|
| | |
|