| @@ -143,7 +143,7 @@ public class WxCouponOrderController extends BaseController { | |||||
| WxAppinfo appinfo = appinfoPageInfo.getList().get(0); | WxAppinfo appinfo = appinfoPageInfo.getList().get(0); | ||||
| if (appinfo != null) { | if (appinfo != null) { | ||||
| try { | try { | ||||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumPayType.PAY_ADMIN_REFUND, null); | |||||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumPayType.PAY_ADMIN_REFUND, null, true); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -5,11 +5,11 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.config.PayProperty; | import com.iformall.config.PayProperty; | ||||
| import com.iformall.domain.po.WxAppinfo; | |||||
| import com.iformall.domain.po.WxMerchantBUser; | |||||
| import com.iformall.domain.po.WxRefundOrder; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumPayType; | import com.iformall.enums.EnumPayType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxCouponOrderService; | |||||
| import com.iformall.service.WxOrderService; | |||||
| import com.iformall.service.WxRefundOrderService; | import com.iformall.service.WxRefundOrderService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -57,7 +57,7 @@ public class WxRefundOrderController extends BaseController { | |||||
| WxMerchantBUser bUser = getUser(); | WxMerchantBUser bUser = getUser(); | ||||
| WxAppinfo appinfo = getAppInfo(bUser.getAppId()); | WxAppinfo appinfo = getAppInfo(bUser.getAppId()); | ||||
| try { | try { | ||||
| ResultData rd = wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumPayType.PAY_B_REFUND, bUser.getId()); | |||||
| ResultData rd = wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, couponOrderId, EnumPayType.PAY_B_REFUND, bUser.getId(), true); | |||||
| return rd; | return rd; | ||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| @@ -85,7 +85,7 @@ public class CouponOrderExpiringSchedule { | |||||
| // 退款 | // 退款 | ||||
| try { | try { | ||||
| couponOrderExpireRefund(co); | |||||
| couponOrderExpireRefund(co, false); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| } | } | ||||
| @@ -115,7 +115,7 @@ public class CouponOrderExpiringSchedule { | |||||
| } | } | ||||
| } | } | ||||
| private void couponOrderExpireRefund(WxCouponOrder co) { | |||||
| private void couponOrderExpireRefund(WxCouponOrder co, boolean bStockBack) { | |||||
| // 非储值卡, 可以退款 | // 非储值卡, 可以退款 | ||||
| if(!co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode()) | if(!co.getCouponType().equals(EnumCouponType.CARD_MULTIMCH.getCode()) | ||||
| && !co.getAutoRefund().equals(EnumCouponAutoRefund.UNSUPPORTED.getCode())) { | && !co.getAutoRefund().equals(EnumCouponAutoRefund.UNSUPPORTED.getCode())) { | ||||
| @@ -125,7 +125,7 @@ public class CouponOrderExpiringSchedule { | |||||
| appinfo = wxAppinfoMapper.findList(appinfo).get(0); | appinfo = wxAppinfoMapper.findList(appinfo).get(0); | ||||
| try { | try { | ||||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumPayType.PAY_AUTO_REFUND, null); | |||||
| wxRefundOrderService.createRefundOrder(payProperty.isReal(), appinfo, co.getId(), EnumPayType.PAY_AUTO_REFUND, null, bStockBack); | |||||
| } catch (MallinkException e) { | } catch (MallinkException e) { | ||||
| logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId()); | logger.error("退款失败:"+e.getMessage()+"couponOrderId="+co.getId()); | ||||
| throw new MallinkException(e.getErrorCode(), e.getMessage()); | throw new MallinkException(e.getErrorCode(), e.getMessage()); | ||||
| @@ -21,7 +21,7 @@ public interface WxRefundOrderService { | |||||
| * @param bUserId b端退款Id,auto,admin,self可为null | * @param bUserId b端退款Id,auto,admin,self可为null | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumPayType payType, Long bUserId); | |||||
| ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumPayType payType, Long bUserId, boolean bStockBack); | |||||
| /** | /** | ||||
| * 创建退款订单 | * 创建退款订单 | ||||
| @@ -263,7 +263,7 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumPayType payType, Long bUserId) { | |||||
| public ResultData createRefundOrder(boolean isReal, WxAppinfo appInfo, Long couponOrderId, EnumPayType payType, Long bUserId, boolean bStockBack) { | |||||
| WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | WxCouponOrder wxCouponOrder = wxCouponOrderMapper.selectByPrimaryKey(couponOrderId); | ||||
| if (wxCouponOrder == null) { | if (wxCouponOrder == null) { | ||||
| logger.error("券ID不存在:" + couponOrderId); | logger.error("券ID不存在:" + couponOrderId); | ||||
| @@ -360,6 +360,11 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | ||||
| } | } | ||||
| // 退库存 | |||||
| if(bStockBack) { | |||||
| wxOrderService.stockBack(wxOrder); | |||||
| } | |||||
| // 查找支付订单 | // 查找支付订单 | ||||
| WxPayOrder payOrderQ = new WxPayOrder(); | WxPayOrder payOrderQ = new WxPayOrder(); | ||||
| payOrderQ.setTenantId(appInfo.getTenantId()); | payOrderQ.setTenantId(appInfo.getTenantId()); | ||||