admin
2020-04-14 036fc28606e5fcb2203cbc7c4736c99512a522f7
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/UserOrderControllerV2.java
@@ -20,7 +20,6 @@
import com.yeshi.fanli.entity.accept.AcceptData;
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.UserSystemCouponRecord;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
@@ -42,6 +41,7 @@
import com.yeshi.fanli.service.inter.order.ESOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
@@ -58,6 +58,7 @@
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.user.UserLevelUtil;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.order.CommonOrderVO;
import com.yeshi.fanli.vo.order.CurrentBonusVO;
import com.yeshi.fanli.vo.order.GoodsRebateVO;
@@ -127,6 +128,9 @@
   
   @Resource
   private ThreeSaleSerivce threeSaleSerivce;
   @Resource
   private OrderHongBaoMapService orderHongBaoMapService;
   /**
    * 订单列表
@@ -727,7 +731,7 @@
            BigDecimal weiQuanMoney = commonOrderService.getWeiQuanMoney(listWQ, sourceType, uid);
            
            orderRebateVO.setWq(true);
            orderRebateVO.setWqMoney("-¥"+ weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN));
            orderRebateVO.setWqMoney("¥"+ weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN));
            if (hongBao.compareTo(weiQuanMoney) > 0) {
               orderRebateVO.setWqDesc("部分售后退回");
            } else {
@@ -745,7 +749,7 @@
      if (userLevel == null)
         userLevel = UserLevelEnum.daRen;
      UserLevelEnum upperLevel =  UserLevelEnum.superVIP;
      BigDecimal upperTotalMoney = new BigDecimal(0);
      List<GoodsRebateVO> voList = new ArrayList<>();
      for (HongBaoOrder hongBaoOrder : hoList) {
@@ -768,7 +772,6 @@
         if (payment == null)
            payment = new BigDecimal(0);
         goodsVO.setActualPay("¥" + payment.setScale(2));
         
         BigDecimal commission = orderHongBaoMoneyComputeService.computeBaseFanliMoney(commonOrder);
         if (type == 3) { // 奖金
@@ -779,7 +782,7 @@
         
         // 平台补贴
         BigDecimal vipFanli = hongBaoOrder.getHongBaoV2().getMoney();
         goodsVO.setSubsidy(vipFanli.subtract(commission).setScale(2) + "");
         goodsVO.setSubsidy("¥" + vipFanli.subtract(commission).setScale(2));
         //  达人补贴
         if (userLevel != UserLevelEnum.daRen) {
            BigDecimal darenFanli = orderHongBaoMoneyComputeService.computeFanliMoney(commonOrder, UserLevelEnum.daRen);
@@ -824,25 +827,80 @@
      orderRebateVO.setType(type);
      orderRebateVO.setStateDesc(stateDesc);
      orderRebateVO.setListGoods(voList);
      orderRebateVO.setUserLevel(userLevel.name());
      
      // 上级返利
      if (upperLevel != null) {
         orderRebateVO.setUpperFanLi("¥" + upperTotalMoney);
         orderRebateVO.setUserLevel(upperLevel.name());
         orderRebateVO.setJumpLink(upperLevel.getDetailLink());
      }
      // 奖励券使用
      Date accountTime = hongBaoCountVO.getAccountTime();
      if (accountTime != null) {
         boolean vip = userInviteService.verifyVIP(uid);
         Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
         long currentTime = java.lang.System.currentTimeMillis();
         if (endDay.getTime() > currentTime && !vip) {
            UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null);
            if (couponRecord == null
                  || (couponRecord.getCouponType() == CouponTypeEnum.rebatePercentCoupon.name() && couponRecord.getState() != UserSystemCouponRecord.STATE_SUCCESS)) {
               orderRebateVO.setCoupon(true);
      int freeState = 0;
      boolean rewardSuccess = false;
      List<String> listNo = new ArrayList<String>();
      listNo.add(orderNo);
      List<UserSystemCouponRecord> useRecord = userSystemCouponRecordService.getRecordByOrderNoList(sourceType, listNo);
      if (useRecord != null && useRecord.size() > 0) {
         for (UserSystemCouponRecord couponRecord : useRecord) {
            Integer state = couponRecord.getState();
            String cType = couponRecord.getCouponType();
            if (CouponTypeEnum.rebatePercentCoupon.name().equals(cType) && UserSystemCouponRecord.STATE_SUCCESS == state) {
               rewardSuccess = true;
               break;
            } else if (CouponTypeEnum.freeCoupon.name().equals(cType) || CouponTypeEnum.welfareFreeCoupon.name().equals(cType)
                  || CouponTypeEnum.freeCouponBuy.name().equals(cType)) {
               freeState = state;
               break;
            }
         }
      }
      if (rewardSuccess) {  // 已使用奖励券
         JSONObject params = new JSONObject();
         params.put("orderNo", orderNo);
         params.put("goodsType", sourceType + "");
         BigDecimal couponMoney = orderHongBaoMapService.getCouponHongbaoByOrderNo(orderNo, uid);
         if (couponMoney == null) {
            couponMoney = new BigDecimal(0);
         }
         orderRebateVO.setCouponType(1);
         orderRebateVO.setCouponUse(true);
         orderRebateVO.setCouponText("奖励成功");
         orderRebateVO.setCouponDesc("已再返¥" +couponMoney.setScale(2));
         orderRebateVO.setCouponParams(params.toString());
         orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("rewardCouponDetail"));
      } else if (freeState > 0) { // 已使用免单券
         JSONObject params = new JSONObject();
         params.put("orderNo", orderNo);
         params.put("goodsType", sourceType + "");
         orderRebateVO.setCouponType(2);
         orderRebateVO.setCouponUse(true);
         orderRebateVO.setCouponParams(params.toString());
         orderRebateVO.setCouponJumpDetail(jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
         if (UserSystemCouponRecord.STATE_FREE_ON == freeState) {
            orderRebateVO.setCouponText("免单中");
         } else if (UserSystemCouponRecord.STATE_SUCCESS == freeState) {
            orderRebateVO.setCouponText("免单成功");
         } else if (UserSystemCouponRecord.STATE_FAIL_RULE == freeState
               || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == freeState) {
            orderRebateVO.setCouponText("免单失败");
         }
      } else {
         Date accountTime = hongBaoV2.getGetTime();
         if (accountTime != null) {
            boolean vip = userInviteService.verifyVIP(uid);
            Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime);
            long currentTime = java.lang.System.currentTimeMillis();
            if (endDay.getTime() > currentTime && !vip) {
               UserSystemCouponRecord couponRecord = userSystemCouponRecordService.getRecordByOrderNo(orderNo, null);
               if (couponRecord == null
                     || (couponRecord.getCouponType() == CouponTypeEnum.rebatePercentCoupon.name() && couponRecord.getState() != UserSystemCouponRecord.STATE_SUCCESS)) {
                  orderRebateVO.setCoupon(true);
                  orderRebateVO.setCouponType(1);
                  orderRebateVO.setCouponText("立即使用");
                  orderRebateVO.setCouponDesc("返利再返");
               }
            }
         }
      }