| | |
| | | |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public boolean wxRefund(WithdrawalOrders withdrawalOrders,Orders orders) { |
| | | // 发送退款请求 |
| | | withdrawalOrders.setCreateTime(new Date()); |
| | | withdrawalOrdersMapper.insert(withdrawalOrders); |
| | | CreateRequest request = new CreateRequest(); |
| | | request.setOutTradeNo(orders.getOutTradeNo()); |
| | | request.setOutRefundNo(withdrawalOrders.getId().toString()); |
| | | request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId()); |
| | | request.setNotifyUrl(WxMiniConfig.wxProperties.getRefundNotifyUrl()); |
| | | AmountReq amountReq = new AmountReq(); |
| | | amountReq.setTotal(1L);//withdrawalOrders.getAmount()); |
| | | amountReq.setRefund(1L);//withdrawalOrders.getAmount()); |
| | | amountReq.setCurrency("CNY"); |
| | | request.setAmount(amountReq); |
| | | try { |
| | | log.error("=============="+JSONObject.toJSONString(request)); |
| | | com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.refundService.create(request); |
| | | log.error("=============="+JSONObject.toJSONString(response)); |
| | | if ("SUCCESS".equals(response.getStatus().name()) |
| | | || "PROCESSING".equals(response.getStatus().name()) ) { |
| | | return true; |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败哦!"); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败!"); |
| | | } |
| | | // // 发送退款请求 |
| | | // withdrawalOrders.setCreateTime(new Date()); |
| | | // withdrawalOrdersMapper.insert(withdrawalOrders); |
| | | // CreateRequest request = new CreateRequest(); |
| | | // request.setOutTradeNo(orders.getOutTradeNo()); |
| | | // request.setOutRefundNo(withdrawalOrders.getId().toString()); |
| | | // request.setSubMchid(WxMiniConfig.wxProperties.getSubMchId()); |
| | | // request.setNotifyUrl(WxMiniConfig.wxProperties.getRefundNotifyUrl()); |
| | | // AmountReq amountReq = new AmountReq(); |
| | | // amountReq.setTotal(1L);//withdrawalOrders.getAmount()); |
| | | // amountReq.setRefund(1L);//withdrawalOrders.getAmount()); |
| | | // amountReq.setCurrency("CNY"); |
| | | // request.setAmount(amountReq); |
| | | // try { |
| | | // log.error("=============="+JSONObject.toJSONString(request)); |
| | | // com.wechat.pay.java.service.refund.model.Refund response = WxMiniConfig.wxPayService.refund(request); |
| | | // log.error("=============="+JSONObject.toJSONString(response)); |
| | | // if ("SUCCESS".equals(response.getStatus().name()) |
| | | // || "PROCESSING".equals(response.getStatus().name()) ) { |
| | | // return true; |
| | | // }else{ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败哦!"); |
| | | // } |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,退款申请失败!"); |
| | | // } |
| | | return false; |
| | | } |
| | | |
| | | |