yujian
2019-07-31 f4548a3ee46afe45da4ee2a42dc169c575deee9f
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponServiceImpl.java
@@ -609,7 +609,7 @@
   @Transactional
   @Override
   public void useGoodsCoupon(Long uid, Long id, Long goodId) throws UserSystemCouponException, Exception {
   public void useGoodsCoupon(Long uid, Long id, Long goodId, Integer sourceType) throws UserSystemCouponException, Exception {
      if (uid == null) {
         throw new UserSystemCouponException(1, "用户未登录");
      }
@@ -660,7 +660,7 @@
      // 插入使用券记录
      UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
      couponRecord.setGoodId(goodId);
      couponRecord.setGoodSource(Constant.SOURCE_TYPE_TAOBAO); // 默认淘宝
      couponRecord.setGoodSource(sourceType); // 默认淘宝
      couponRecord.setState(UserSystemCouponRecord.STATE_WAIT); // 正在匹配
      couponRecord.setUserSystemCoupon(userSystemCoupon);
      couponRecord.setCouponType(baseCoupon.getType().name());
@@ -684,12 +684,16 @@
   @Transactional
   @Override
   public void useOrderCoupon(Long uid, Long id, String orderNo, Integer goodsType) throws UserSystemCouponException, Exception {
   public void useOrderCoupon(Long uid, Long id, String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
      if (id == null) {
         throw new UserSystemCouponException(1, "券id不存在");
      }
      if (sourceType == null) {
         sourceType = Constant.SOURCE_TYPE_TAOBAO;
      }
      // 用户券
      UserSystemCoupon userSystemCoupon = selectByPrimaryKey(id);
      if (userSystemCoupon == null) {
@@ -724,7 +728,7 @@
      }
      // 订单
      CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS);
      CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(uid, orderNo, CommonOrder.STATE_JS, sourceType);
      if (orderVO == null) {
         throw new UserSystemCouponException(1, "订单信息获取失败");
      }
@@ -738,7 +742,7 @@
      // 条件: A:必须是返利订单 、B:必须已经处于已到账状态
      if (HongBaoV2.TYPE_ZIGOU == hongBaoType && HongBaoV2.STATE_YILINGQU == hongBaoState || hongBao != null) {
         Order order = orderService.findOrderByOrderIdAndType(orderNo, goodsType);
         Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
         if (order == null)
            return;
@@ -766,14 +770,14 @@
         // 2.插入关联
         orderHongBaoMapService.addOrderHongBaoMap(hongBaoV2, order);
         // 3.插入资金明细,用户余额 // TODO
         UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo,goodsType, money,
         // 3.插入资金明细,用户余额
         UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createOrderReward(orderNo, sourceType, money,
               new UserInfo(uid));
         userMoneyDetailService.addUserMoneyDetail(userMoneyDetail);
         userInfoService.addMoney(new UserInfo(uid), money);
         // 插入资金通知
         userMoneyMsgNotificationService.orderReward(uid, orderNo,goodsType, money,
         userMoneyMsgNotificationService.orderReward(uid, orderNo, sourceType, money,
               userInfoService.selectByPKey(uid).getMyHongBao());
         /* 用户券信息状态及记录处理 */
@@ -788,7 +792,7 @@
         // 插入使用券记录
         UserSystemCouponRecord couponRecord = new UserSystemCouponRecord();
         couponRecord.setState(UserSystemCouponRecord.STATE_SUCCESS);
         couponRecord.setGoodSource(goodsType);
         couponRecord.setGoodSource(sourceType);
         couponRecord.setOrderNo(orderNo);
         couponRecord.setUserSystemCoupon(userSystemCoupon);
         couponRecord.setCouponType(systemCoupon.getType().name());
@@ -807,7 +811,7 @@
   }
   @Override
   public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
   public UserSystemCouponRecordVO getRewardCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
      if (orderNo == null || orderNo.trim().length() == 0) {
         throw new UserSystemCouponException(1, "订单号不存在");
@@ -843,7 +847,7 @@
      Long uid = userSystemCoupon.getUid();
      CommonOrderVO commonOrderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo,
            CommonOrder.STATE_JS);
            CommonOrder.STATE_JS, sourceType);
      if (commonOrderVO == null) {
         throw new UserSystemCouponException(1, "订单信息获取失败");
@@ -885,7 +889,7 @@
   }
   @Override
   public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo) throws UserSystemCouponException, Exception {
   public UserSystemCouponRecordVO getFreeCouponRecord(String orderNo, Integer sourceType) throws UserSystemCouponException, Exception {
      if (orderNo == null || orderNo.trim().length() == 0) {
         throw new UserSystemCouponException(1, "订单号不存在");
@@ -913,7 +917,7 @@
      }
      // 订单
      CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null);
      CommonOrderVO orderVO = commonOrderService.getCommonOrderByOrderNo(userSystemCoupon.getUid(), orderNo, null, sourceType);
      if (orderVO == null) {
         throw new UserSystemCouponException(1, "订单信息获取失败");
      }