| | |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.CommonOrderGoods;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | /**
|
| | | * 添加红包信息
|
| | | *
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | if (hasAdd) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | throw new HongBaoException(201, "添加补贴出错");
|
| | | } catch (CommonOrderException e) {
|
| | | throw new HongBaoException(202, "添加补贴出错");
|
| | | }
|
| | | }
|
| | |
|
| | | int state = getOrderState(stateSet);
|
| | |
|
| | | if (hasAdd || hasUpdate) {
|
| | | // 补贴失效
|
| | | if (state == CommonOrder.STATE_SX)
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(orderId, orderType);
|
| | | else
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(orderId, orderType);
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | } catch (CommonOrderException e) {
|
| | | LogHelper.errorDetailInfo(e, "淘宝订单补贴更新失败", orderId);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通知用户的返利情况
|
| | |
| | | CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
|
| | | Long uid = notify.getUserInfo().getId();
|
| | |
|
| | | List<InviteOrderSubsidy> subsidyList = inviteOrderSubsidyService.listByOrderNoAndTypeAndUid(orderId,
|
| | | orderType, uid);
|
| | | BigDecimal subsidy = new BigDecimal(0);
|
| | | if (subsidyList != null)
|
| | | for (InviteOrderSubsidy s : subsidyList) {
|
| | | if (s.getState() != InviteOrderSubsidy.STATE_INVALID)
|
| | | subsidy = subsidy.add(s.getOriginalMoney());
|
| | | }
|
| | |
|
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | |
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | |
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, subsidy, goodsCount, state,
|
| | | commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, state,
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
| | | List<Long> uidList = new ArrayList<Long>();
|
| | | for (ThreeSale ts : threeSales)
|
| | | uidList.add(ts.getBoss().getId());
|
| | | List<TeamUserLevelStatistic> levelList = teamUserLevelStatisticService.listByUids(uidList);
|
| | | if (levelList != null)
|
| | | for (TeamUserLevelStatistic s : levelList) {
|
| | | resultList.add(new UserTeamLevel(s.getId(), s.getLevel()));
|
| | | }
|
| | |
|
| | | for (Long bossUid : uidList) {
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(bossUid);
|
| | | resultList.add(new UserTeamLevel(bossUid, level));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | return resultList;
|
| | | }
|
| | |
|
| | | private List<UserTeamLevel> getBossList(List<HongBaoV2> children) {
|
| | | List<UserTeamLevel> resultList = new ArrayList<>();
|
| | | for (HongBaoV2 v2 : children) {
|
| | |
|
| | | UserLevelEnum level = UserLevelUtil.getByOrderRank(v2.getUrank());
|
| | | if (level == null)
|
| | | level = UserLevelEnum.daRen;
|
| | | UserTeamLevel teamLevel = new UserTeamLevel(v2.getUserInfo().getId(), level);
|
| | |
|
| | | if (v2.getType() == HongBaoV2.TYPE_YIJI || v2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {
|
| | | resultList.add(0, teamLevel);
|
| | | } else {
|
| | | resultList.add(teamLevel);
|
| | | }
|
| | | }
|
| | | return resultList;
|
| | | }
|
| | |
|
| | |
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null && children.size() > 0) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | | List<UserTeamLevel> bossList = getBossList(children);
|
| | |
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | |
| | | }
|
| | |
|
| | | if (boss != null) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | | List<UserTeamLevel> bossList = getBossList(oldHongBao.getUserInfo().getId(), 2);
|
| | |
|
| | | // 插入一级子红包
|
| | | money = orderHongBaoMoneyComputeService.computeFirstInviteMoney(commonOrder, buyerLevel,
|
| | |
| | | // 获取子红包
|
| | | List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
|
| | | if (children != null && children.size() > 0) {
|
| | | List<UserTeamLevel> bossList = getBossList(hongBao.getUserInfo().getId(), 2);
|
| | | List<UserTeamLevel> bossList = getBossList(children);
|
| | | for (HongBaoV2 child : children) {
|
| | | if (child.getState() == HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|