Commit 218abbba by gonglei

修改保证金支付流程

1 parent 0b7a825e
package com.glsx.usedcar.web.rest.finance; package com.glsx.usedcar.web.rest.finance;
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.glsx.usedcar.export.DepositBean; import com.glsx.usedcar.export.DepositBean;
import com.glsx.usedcar.export.ExcelExporter; import com.glsx.usedcar.export.ExcelExporter;
import com.glsx.usedcar.export.WithdrawBean; import com.glsx.usedcar.export.WithdrawBean;
...@@ -18,6 +23,7 @@ import jakarta.persistence.criteria.JoinType; ...@@ -18,6 +23,7 @@ import jakarta.persistence.criteria.JoinType;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.summerframework.orm.paging.Pagination; import org.summerframework.orm.paging.Pagination;
...@@ -44,6 +50,12 @@ public class DepositController { ...@@ -44,6 +50,12 @@ public class DepositController {
@Resource @Resource
private WithdrawService withdrawService; private WithdrawService withdrawService;
@Resource
private WxPayService wxService;
@Value("${wx.pay.notifyUrl}")
private String notifyUrl;
/** /**
* 分页查询保证金规则 * 分页查询保证金规则
* *
...@@ -175,4 +187,28 @@ public class DepositController { ...@@ -175,4 +187,28 @@ public class DepositController {
return depositService.getFreezeAmountByAccount(accountId); return depositService.getFreezeAmountByAccount(accountId);
} }
/**
* <pre>
* 微信支付-申请退款
* 详见 https://pay.weixin.qq.com/doc/v3/merchant/4012791862
* </pre>
*
* @param request 请求对象
* @return 退款操作结果
*/
@PostMapping("refund")
public WxPayRefundV3Result refund(@RequestBody int depositId ) throws WxPayException {
Deposit deposit = depositService.getDepositDetailById(depositId);
WxPayRefundV3Request request=new WxPayRefundV3Request();
WxPayRefundV3Request.Amount amount = new WxPayRefundV3Request.Amount();
amount.setCurrency("CNY");
amount.setTotal((int) (deposit.getTransaction().getAmount() * 100));
amount.setRefund((int) (deposit.getAmount() * 100));
request.setAmount(amount);
request.setOutTradeNo(deposit.getOutTradeNo());
request.setTransactionId(deposit.getTransactionId());
request.setNotifyUrl(notifyUrl);
return this.wxService.refundV3(request);
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -57,4 +57,6 @@ public class DepositController { ...@@ -57,4 +57,6 @@ public class DepositController {
WxPayUnifiedOrderV3Result.JsapiResult result = wxService.createOrderV3(TradeTypeEnum.JSAPI, request); WxPayUnifiedOrderV3Result.JsapiResult result = wxService.createOrderV3(TradeTypeEnum.JSAPI, request);
return result; return result;
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!