| | |
| | | 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.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.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserLevelManager userLevelManager;
|
| | |
|
| | | /**
|
| | | * 添加红包信息
|
| | |
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | |
|
| | | userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | break;
|
| | |
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state);
|
| | | commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | case HongBaoV2.TYPE_SHARE_ERJI:
|
| | | |
| | | userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType, commonOrder.getPayment(), money,
|
| | | goodsCount, commonOrder.getState(), commonOrder.getThirdCreateTime());
|
| | |
|
| | | // 添加新版本通知
|
| | |
|
| | | if (!hasAdd) {
|
| | | Iterator<Integer> its = notificationMap.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | Integer t = its.next();
|
| | | HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
|
| | | CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
|
| | | String orderId = commonOrderList.get(0).getOrderNo();
|
| | | Long uid = notify.getUserInfo().getId();
|
| | | BigDecimal money = notify.getMoney();
|
| | | switch (t) {
|
| | | case HongBaoV2.TYPE_ZIGOU:
|
| | | userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_GOODS:
|
| | | userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_YIJI:
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_ERJI:
|
| | | userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break;
|
| | | case HongBaoV2.TYPE_SHARE_YIJI:
|
| | | userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId, orderType,
|
| | | commonOrder.getPayment(), money, state);
|
| | | break; |
| | | |
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | HongBaoV2 hongBao = createFanLiHongBao(commonOrder, fanliRate, mianDanMoney, vip);
|
| | | HongBaoV2 hongBao = createFanLiHongBao(commonOrder, fanliRate, mianDanMoney);
|
| | | if (hongBao == null)
|
| | | return;
|
| | | addFanLiOrShareHongBao(hongBao, commonOrder, notificationMap);
|
| | |
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | return null;
|
| | | boolean isVIP = userVIPInfoService.isVIP(uid);
|
| | |
|
| | | UserLevelEnum level = userLevelManager.getUserLevel(uid);
|
| | |
|
| | | HongBaoV2 child = new HongBaoV2();
|
| | | child.setParent(parent);
|
| | |
| | | }
|
| | |
|
| | | child.setUserInfo(user);
|
| | | child.setUrank(user.getRank());
|
| | | child.setUrank(level.getOrderRank());
|
| | | child.setVersion(2);
|
| | | child.setCreateTime(new Date());
|
| | | child.setOrderType(commonOrder.getSourceType());
|
| | | if (child.getMoney() == null)
|
| | | return null;
|
| | | if (child.getMoney().compareTo(new BigDecimal(0)) <= 0 && !isVIP)
|
| | | return null;
|
| | | return child;
|
| | | }
|
| | |
| | | * -返利比例
|
| | | * @param mianDanMoney
|
| | | * 免单金额
|
| | | * @param isVIP-是否为VIP订单
|
| | | * @return
|
| | | * @throws HongBaoException
|
| | | * @throws UserAccountException
|
| | | */
|
| | | private HongBaoV2 createFanLiHongBao(CommonOrder commonOrder, BigDecimal fanliRate, BigDecimal mianDanMoney,
|
| | | boolean isVIP) throws HongBaoException, UserAccountException {
|
| | | private HongBaoV2 createFanLiHongBao(CommonOrder commonOrder, BigDecimal fanliRate, BigDecimal mianDanMoney) throws HongBaoException, UserAccountException {
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setUserInfo(commonOrder.getUserInfo());
|
| | | hongBao.setCreateTime(new Date());
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | if (isVIP) {
|
| | | hongBao.setUrank(HongBaoV2.RANK_VIP);// VIP的等级设置为100
|
| | | } else {
|
| | | UserLevelEnum userLevel = userLevelManager.getUserLevel(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | if (userLevel != null)
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | else {
|
| | | hongBao.setUrank(user.getRank());
|
| | | }
|
| | | hongBao.setOrderType(commonOrder.getSourceType());
|
| | |
| | | UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
|
| | | if (user == null)
|
| | | throw new UserAccountException(1001, "用户不存在/被封禁");
|
| | | if (isVip)
|
| | | hongBao.setUrank(HongBaoV2.RANK_VIP);
|
| | | UserLevelEnum userLevel = userLevelManager.getUserLevel(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getThirdCreateTime());
|
| | | if (userLevel != null)
|
| | | hongBao.setUrank(userLevel.getOrderRank());
|
| | | else
|
| | | hongBao.setUrank(user.getRank());
|
| | | hongBao.setUserInfo(user);
|