| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | | @Resource
|
| | | private UserInviteMsgNotificationService userInviteMsgNotificationService;
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | | @Override
|
| | | @RequestSerializableByKeyService(key = "#orderUid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void winRedPackByOrder(Long orderUid, String orderNo, Integer source, Date downTime) {
|
| | | public void winRedPackByOrder(Long orderUid, String orderNo, Integer source) {
|
| | | if (orderUid == null || StringUtil.isNullOrEmpty(orderNo)) {
|
| | | return;
|
| | | }
|
| | | // 验证是否未首单
|
| | | CommonOrder firstOrder = commonOrderService.getFirstOrder(orderUid);
|
| | | if (!firstOrder.getOrderNo().equals(orderNo) || firstOrder.getSourceType() != source)
|
| | | return;
|
| | |
|
| | | Date downTime = firstOrder.getThirdCreateTime();
|
| | | // 注册时间
|
| | | UserInfoRegister register = userInfoRegisterService.selectByPrimaryKey(orderUid);
|
| | | if (register == null)
|
| | | return;
|
| | | // 注册48小时 以内 :新人
|
| | | long registerTime = register.getCreateTime().getTime();
|
| | | // 48小时限制
|
| | | if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
|
| | | // 注册48小时内下单限制
|
| | | if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48L)
|
| | | return;
|
| | | |
| | | |
| | | // 是否存在上下级关系
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(orderUid);
|
| | | if (threeSale == null)
|
| | |
| | | if (bossId == null)
|
| | | return;
|
| | |
|
| | | // 该邀请是否已添加
|
| | | RedPackWinInvite threeStage = redPackWinInviteMapper.getByUidAndTeamUid(bossId, orderUid);
|
| | | if (threeStage != null)
|
| | | return;
|
| | | |
| | | // 小于2.1.3版本不增加
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | | if (!VersionUtil.greaterThan_2_1_3("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | | |
| | | // 该邀请是否已添加
|
| | | RedPackWinInvite threeStage = redPackWinInviteMapper.getByUidAndTeamUid(bossId, orderUid);
|
| | | if (threeStage != null)
|
| | | return;
|
| | |
|
| | | // 查询订单
|
| | |
| | | boolean satisfy = false;
|
| | | // 遍历是否存在符合相应商品
|
| | | for (CommonOrder commonOrder: list) {
|
| | | // 订单未结算
|
| | | if(commonOrder.getState() != CommonOrder.STATE_JS)
|
| | | continue;
|
| | | |
| | | // 邀请关系之后
|
| | | long thirdTime = commonOrder.getThirdCreateTime().getTime();
|
| | | if (thirdTime < threeSale.getCreateTime())
|
| | |
| | | if(eIncome == null || settlement == null) {
|
| | | continue;
|
| | | }
|
| | | BigDecimal rete = MoneyBigDecimalUtil.div(eIncome, settlement);
|
| | | BigDecimal rete =MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.div(eIncome, settlement), BigDecimal.valueOf(100)) ;
|
| | | if (rete.compareTo(limitRate) >= 0) {
|
| | | satisfy = true;
|
| | | break;
|
| | |
| | | winInvite.setType(RedPackWinInviteTypeEnum.inviteDownOrder);
|
| | | winInvite.setIdentifyCode(StringUtil.Md5(RedPackWinInviteTypeEnum.inviteDownOrder.name() + ":" + orderUid));
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | | |
| | | // 消息提醒
|
| | | UserInfo userInfo = userInfoService.selectByPKey(orderUid);
|
| | | userInviteMsgNotificationService.pullNewRedPack(bossId, userInfo.getNickName(), userInfo.getPortrait());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | // 注册48小时 以内:新人
|
| | | long registerTime = register.getCreateTime().getTime();
|
| | | // 48小时限制
|
| | | if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
|
| | | if (downTime.getTime() > registerTime || downTime.getTime() < registerTime + 1000*60*60*48)
|
| | | return satisfy;
|
| | |
|
| | | // 验证是否未首单
|
| | | CommonOrder firstOrder = commonOrderService.getFirstOrder(orderUid);
|
| | | if (!firstOrder.getOrderNo().equals(orderNo) || firstOrder.getSourceType() != source)
|
| | | return satisfy;
|
| | | |
| | | // 是否已奖励
|
| | | List<UserSystemCoupon> coupons = userSystemCouponService.getUserCouponBySource(orderUid, UserSystemCoupon.SOURCE_PULL_NEW);
|
| | | if (coupons != null && coupons.size() > 0) {
|
| | |
| | | long thirdTime = commonOrder.getThirdCreateTime().getTime();
|
| | | if (thirdTime < threeSale.getCreateTime())
|
| | | continue;
|
| | | // 订单失效
|
| | | if(commonOrder.getState() != CommonOrder.STATE_FK && commonOrder.getState() != CommonOrder.STATE_JS)
|
| | | continue;
|
| | | |
| | | // 付款金额限制
|
| | | BigDecimal payment = commonOrder.getPayment();
|
| | | if (payment == null || payment.compareTo(limitPayMent) < 0) |
| | | if (payment == null || payment.compareTo(limitPayMent) <= 0) |
| | | continue;
|
| | |
|
| | | // 商品佣金比例限制
|
| | |
| | | // 注册48小时 以内:新人
|
| | | long registerTime = register.getCreateTime().getTime();
|
| | | // 48小时限制
|
| | | if (downTime.getTime() < registerTime || downTime.getTime() > registerTime + 1000*60*60*48)
|
| | | if (downTime.getTime() > registerTime || downTime.getTime() < registerTime + 1000*60*60*48)
|
| | | return;
|
| | |
|
| | | // 是否已奖励
|
| | |
| | | boolean satisfy = false;
|
| | | // 遍历是否存在符合相应商品
|
| | | for (CommonOrder commonOrder: list) {
|
| | | // 订单失效
|
| | | if(commonOrder.getState() != CommonOrder.STATE_FK && commonOrder.getState() != CommonOrder.STATE_JS)
|
| | | continue;
|
| | | // 付款金额限制
|
| | | BigDecimal payment = commonOrder.getPayment();
|
| | | if (payment == null || payment.compareTo(limitPayMent) < 0) |
| | | if (payment == null || payment.compareTo(limitPayMent) <= 0) |
| | | continue;
|
| | |
|
| | | // 商品佣金比例限制
|
| | |
| | |
|
| | | // 赠送购买者一张免单券
|
| | | try {
|
| | | userSystemCouponService.freeCouponWinBySystem(orderUid, CouponTypeEnum.freeCouponBuy, |
| | | UserSystemCoupon.SOURCE_PULL_NEW, 1, true, 2);
|
| | | userSystemCouponService.freeCouponWinBySystem(orderUid, CouponTypeEnum.freeCoupon, |
| | | UserSystemCoupon.SOURCE_PULL_NEW, 1, true, 2, 1);
|
| | | } catch (UserSystemCouponException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|