yujian
2019-03-01 857eb5eaf379f7df6686bd838ee561d1ddfb8043
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -215,11 +215,11 @@
      
      // 消息推送
      try {
         if (coupon.getType() != CouponTypeEnum.welfareFreeCoupon) {
         if (coupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
            userOtherMsgNotificationService.welfareCouponGet(userCoupon);
         } else if (coupon.getType() != CouponTypeEnum.freeCoupon) {
         } else if (coupon.getType() == CouponTypeEnum.freeCoupon) {
            userOtherMsgNotificationService.freeSheetCouponGet(userCoupon);
         } else if (coupon.getType() != CouponTypeEnum.rebatePercentCoupon) {
         } else if (coupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
            userOtherMsgNotificationService.rewardCouponGet(userCoupon,coupon.getPercent().intValue());
         }
         
@@ -618,10 +618,10 @@
      
      // 消息推送
      try {
         if (baseCoupon.getType() != CouponTypeEnum.welfareFreeCoupon) {
//            userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,order);
         } else if (baseCoupon.getType() != CouponTypeEnum.freeCoupon) {
//            userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon);
         if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
            //userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,order.get);
         } else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
            //userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon);
         }
         
      } catch(Exception e) {
@@ -1082,7 +1082,7 @@
      userSystemCouponRecordService.updateByPrimaryKeySelective(record);
      
      // 券退回
      sendBackCoupon(record.getUserSystemCoupon());
      sendBackCoupon(record.getUserSystemCoupon(), record);
   }
   
   @Transactional
@@ -1102,6 +1102,13 @@
      record.setUpdateTime(new Date());
      record.setState(UserSystemCouponRecord.STATE_SUCCESS);
      userSystemCouponRecordService.updateByPrimaryKeySelective(record);
      // 消息推送
      if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
         userOtherMsgNotificationService.welfareCouponUsed(record.getUserSystemCoupon(), orderNo);
      } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
         userOtherMsgNotificationService.freeSheetCouponUsed(record.getUserSystemCoupon(), orderNo);
      }
   }
   @Transactional
@@ -1129,11 +1136,11 @@
         
         // 消息推送
         try {
            if (baseCoupon.getType() != CouponTypeEnum.welfareFreeCoupon) {
            if (baseCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
               userOtherMsgNotificationService.welfareCouponAlreadyOutOfDate(userSystemCoupon);
            } else if (baseCoupon.getType() != CouponTypeEnum.freeCoupon) {
            } else if (baseCoupon.getType() == CouponTypeEnum.freeCoupon) {
               userOtherMsgNotificationService.freeSheetCouponAlreadyOutOfDate(userSystemCoupon);
            } else if (baseCoupon.getType() != CouponTypeEnum.rebatePercentCoupon) {
            } else if (baseCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
               userOtherMsgNotificationService.rewardCouponAlreadyOutOfDate(userSystemCoupon);
            }
            
@@ -1238,7 +1245,7 @@
            userSystemCouponRecordService.updateByPrimaryKeySelective(record);
            
            // 退回券
            sendBackCoupon(userSystemCoupon);
            sendBackCoupon(userSystemCoupon, record);
            
         } else {
            // 免单匹配成功
@@ -1253,16 +1260,15 @@
            userSystemCoupon.setUpdateTime(new Date());
            userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
            
            SystemCoupon systemCoupon = userSystemCoupon.getSystemCoupon();
            String couponType = record.getCouponType();
            if (couponType == null || couponType.trim().length() == 0) {
               throw new Exception("券类型未被记录");
            }
            
            SystemCoupon baseCoupon = systemCouponService.selectByPrimaryKey(systemCoupon.getId());
            if (baseCoupon == null) {
               // 券已使用
               userOtherMsgNotificationService.freeSheetCouponUsed(userSystemCoupon, orderNo);
            } else    if (baseCoupon.getType() != CouponTypeEnum.welfareFreeCoupon) {
             if (CouponTypeEnum.welfareFreeCoupon.name().equals(couponType)) {
               userOtherMsgNotificationService.welfareCouponUsing(userSystemCoupon,orderNo,payment);
            } else if (baseCoupon.getType() != CouponTypeEnum.freeCoupon) {
               userOtherMsgNotificationService.freeSheetCouponUsed(userSystemCoupon,orderNo);
            } else if (CouponTypeEnum.freeCoupon.name().equals(couponType)) {
               userOtherMsgNotificationService.freeSheetCouponUsing(userSystemCoupon, orderNo, payment);
            } 
         }
      }
@@ -1274,7 +1280,7 @@
    * 退回券 初始数据
    * @param userSystemCoupon
    */
   public void sendBackCoupon(UserSystemCoupon userSystemCoupon) throws Exception{
   public void sendBackCoupon(UserSystemCoupon userSystemCoupon, UserSystemCouponRecord record) throws Exception{
      int expiryDay = 15;
@@ -1303,6 +1309,13 @@
      userSystemCoupon.setUpdateTime(new Date());
      
      userSystemCouponMapper.updateByPrimaryKey(userSystemCoupon);
      if (CouponTypeEnum.welfareFreeCoupon.name().equals(record.getCouponType())) {
         userOtherMsgNotificationService.welfareCouponDrawBack(userSystemCoupon, record.getOrderNo());
      } else if (CouponTypeEnum.freeCoupon.name().equals(record.getCouponType())) {
         userOtherMsgNotificationService.freeSheetCouponDrawBack(userSystemCoupon, record.getOrderNo());
      }
   }