yujian
2019-07-31 f4548a3ee46afe45da4ee2a42dc169c575deee9f
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -25,7 +25,6 @@
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.dto.HongBaoDTO;
import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
@@ -48,7 +47,6 @@
import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserNotificationService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
@@ -95,9 +93,6 @@
   @Resource
   private ThreeSaleSerivce threeSaleSerivce;
   @Resource
   private UserNotificationService userNotificationService;
   @Resource
   private UserOrderMsgNotificationService userOrderMsgNotificationService;
@@ -152,6 +147,8 @@
   public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
      Set<Integer> stateSet = new HashSet<>();// 订单状态Set
      if (commonOrderList != null && commonOrderList.size() > 0) {
         int orderType = commonOrderList.get(0).getSourceType();
         Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
         int goodsCount = 0;
         boolean hasAdd = false;
@@ -183,30 +180,27 @@
               BigDecimal money = notify.getMoney();
               switch (t) {
               case HongBaoV2.TYPE_ZIGOU:
                  userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,commonOrder.getPayment(),
                        money, goodsCount, state);
                  break;
               case HongBaoV2.TYPE_SHARE_GOODS:
                  userNotificationService.orderShareStatisticed(uid, orderId, goodsCount, MsgOrderDetail.STATE_FK,
                        null, money);
                  userOrderMsgNotificationService.orderShareStatistic(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderShareStatistic(uid, orderId,orderType, commonOrder.getPayment(),
                        money, goodsCount, state);
                  break;
               case HongBaoV2.TYPE_YIJI:
                  userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
                        MsgOrderDetail.STATE_FK, null, money);
                  userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, commonOrder.getPayment(),
                        money, goodsCount, state);
                  break;
               case HongBaoV2.TYPE_ERJI:
                  userNotificationService.orderInviteStatisticed(uid, orderId, goodsCount,
                        MsgOrderDetail.STATE_FK, null, money);
                  userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderInviteStatistic(uid, orderId,orderType, commonOrder.getPayment(),
                        money, goodsCount, state);
                  break;
               case HongBaoV2.TYPE_SHARE_YIJI:
                  userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,
                  userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId,orderType,
                        commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
                  break;
               }
@@ -226,23 +220,23 @@
               BigDecimal money = notify.getMoney();
               switch (t) {
               case HongBaoV2.TYPE_ZIGOU:
                  userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
                        money, state);
                  break;
               case HongBaoV2.TYPE_SHARE_GOODS:
                  userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderShareStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
                        money, state);
                  break;
               case HongBaoV2.TYPE_YIJI:
                  userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
                        money, state);
                  break;
               case HongBaoV2.TYPE_ERJI:
                  userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, commonOrder.getPayment(),
                  userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId,orderType, commonOrder.getPayment(),
                        money, state);
                  break;
               case HongBaoV2.TYPE_SHARE_YIJI:
                  userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,
                  userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId,orderType,
                        commonOrder.getPayment(), money, state);
               }
            }
@@ -272,7 +266,7 @@
      HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBaoOrder.getHongBaoV2().getId());
      if (oldHongBao == null)
         throw new HongBaoException(10, "红包对象不存在");
      // 已经失效或者已经领取的红包不做处理
      // 已经失效,已经领取,新老状态一致的红包不做处理
      if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
         return;
@@ -288,7 +282,8 @@
               payMent = commonOrder.getSettlement();
            if (payMent.compareTo(new BigDecimal(10)) < 0) {
               mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo());
               mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getSourceType(),
                     commonOrder.getOrderNo());
            }
         }
@@ -312,6 +307,14 @@
         } else if (commonOrder.getState() == CommonOrder.STATE_SX) {
            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
            hongBao.setMoney(new BigDecimal(0));
         }
         // 新老红包状态一致不处理
         if (oldHongBao.getState().intValue() == hongBao.getState())
            return;
         if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
            if (mianDan) {
               try {
                  userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
@@ -321,6 +324,7 @@
               }
            }
         }
         hongBaoV2Mapper.updateByPrimaryKeySelective(hongBao);
         // 加入通知
@@ -952,7 +956,7 @@
         hb.setMoney(hongBao.getMoney());
         try {
            userShareGoodsGroupService.updateOrderRecord(hb);
            userShareGoodsGroupService.updateOrderRecord(hb,commonOrder.getSourceType());
         } catch (UserShareGoodsRecordException e) {
            try {
               LogHelper.errorDetailInfo(e);