| | |
| | | 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;
|
| | | 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;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | |
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | | |
| | |
|
| | | @Override
|
| | | public List<RedPackWinInvite> getRewardList(int start, int count, Long uid) {
|
| | |
| | | return redPackWinInviteMapper.countRewardRecord(uid);
|
| | | }
|
| | |
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @Override
|
| | | public BigDecimal getRewardMoney(Long uid) {
|
| | | return redPackWinInviteMapper.getRewardMoney(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) {
|
| | | bossReward(boss.getId(), uid, source, orderNo);
|
| | | }
|
| | | 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;
|
| | | |
| | | // 小于2.0.2版本不增加
|
| | | if (!VersionUtil.greaterThan_2_1("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | | |
| | | // 奖励上级
|
| | | 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);
|
| | |
| | | */
|
| | | @Transactional
|
| | | private void firstSharedOrderRewardToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
|
| | | // 同一队员奖励一次
|
| | | // 1、同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(uid, inviteeUid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
|
| | | if (totalReward > 0)
|
| | | return;
|
| | |
|
| | | // 1、判断是否是改用户首个分享订单
|
| | | CommonOrderVO order = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
|
| | | if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo())) |
| | | // 2、是否下级的首个分享订单
|
| | | CommonOrder commonOrder = commonOrderService.getFirstShareOrderByUid(inviteeUid);
|
| | | if (commonOrder == null || !orderNo.equals(commonOrder.getOrderNo()) || source != commonOrder.getSourceType()) |
| | | return ;
|
| | | |
| | | // 3、到账奖励金额 是否大于5
|
| | | BigDecimal totalRewardMoney = commonOrderService.getTotalRewardMoneyByOrderNoAndSourceType(orderNo, source);
|
| | | if (totalRewardMoney == null || totalRewardMoney.compareTo(Constant.RED_PACK_ORDER_REWARD_MIN) < 0)
|
| | | return;
|
| | |
|
| | | // 2、判断是第几个人
|
| | | long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
|
| | | |
| | |
|
| | | // 计算应增加红包金额
|
| | | BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("first_shared_order"));
|
| | |
| | | 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), "请到“我的-红包”中查看");
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 上级奖励:次月开始产生满足条件的分享订单(分享订单实付款≥10元) 连续15个月 自然月获得(已到账)每月最高2元
|
| | | * @param uid
|
| | |
| | | */
|
| | | @Transactional
|
| | | private void firstSharedOrderRewardTheMonthToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
|
| | | |
| | | // 1、判断是否是上个月首单
|
| | | CommonOrderVO order = commonOrderService.firstValidOrderLastMonthByUidAndType(inviteeUid, 2);
|
| | | if (order == null || source != order.getSourceType() || !orderNo.equals(order.getOrderNo()) ||
|
| | |
| | | if (order.getPayment() == null || order.getPayment().compareTo(Constant.RED_PACK_PAY_MIN) < 0)
|
| | | return;
|
| | |
|
| | | // 查询首单奖励时间
|
| | | CommonOrderVO firstorder = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
|
| | | if (firstorder == null || firstorder.getAccountTime() == null) |
| | | return;
|
| | | // 2、是否下级的首个分享订单
|
| | | // CommonOrder firstorder = commonOrderService.getFirstShareOrderByUid(inviteeUid);
|
| | | // if (firstorder == null || (orderNo.equals(firstorder.getOrderNo()) && source == firstorder.getSourceType()));
|
| | | // return;
|
| | |
|
| | | // 第一次到账的次月开始连续15个月 自然月获得(已到账)
|
| | | int monthSpace = DateUtil.getMonthSpace( order.getAccountTime(), firstorder.getAccountTime());
|
| | | if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARd_MONTH) |
| | | return;
|
| | | // int monthSpace = DateUtil.getMonthSpace(order.getThirdCreateTime(), firstorder.getThirdCreateTime());
|
| | | // if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARD_MONTH) |
| | | // return;
|
| | |
|
| | |
|
| | | // 计算随机奖励
|
| | |
| | | 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
|
| | | @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(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | |
|
| | | // 小于2.0.2版本不增加
|
| | | if (!VersionUtil.greaterThan_2_1("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode()))
|
| | | 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, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(bossId).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(bossId, MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | | }
|
| | |
|