|
@@ -0,0 +1,54 @@
|
|
|
+package com.ywt.alipaympapi.web.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alipay.api.request.AlipayTradeFastpayRefundQueryRequest;
|
|
|
+import com.alipay.api.response.AlipayTradeFastpayRefundQueryResponse;
|
|
|
+import com.ywt.alipaympapi.core.utils.Checker;
|
|
|
+import com.ywt.alipaympapi.face.impl.AlipayService;
|
|
|
+import com.ywt.alipaympapi.models.BaseResponse2;
|
|
|
+import com.ywt.alipaympapi.models.outpatient.QueryRefundReq;
|
|
|
+import com.ywt.core.exception.AppMessageException;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author Walker
|
|
|
+ * Created on 2023/12/7
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController("/pay")
|
|
|
+@RequestMapping({"/pay"})
|
|
|
+public class PayController {
|
|
|
+ @Autowired
|
|
|
+ AlipayService alipayService;
|
|
|
+
|
|
|
+ @RequestMapping(value = {"/queryRefund"}, method = RequestMethod.POST)
|
|
|
+ public @ResponseBody BaseResponse2<String> queryRefund(@RequestBody QueryRefundReq reqData) {
|
|
|
+ BaseResponse2<String> baseResponse = new BaseResponse2<>();
|
|
|
+ try {
|
|
|
+ String outTradeNo = Checker.getStringValue(reqData.getOutTradeNo());
|
|
|
+ String tradeNo = Checker.getStringValue(reqData.getTradeNo());
|
|
|
+ String refundNo = Checker.getStringValue(reqData.getRefundNo());
|
|
|
+ String appId = Checker.getStringValue(reqData.getAppId());
|
|
|
+ AlipayTradeFastpayRefundQueryRequest request = new AlipayTradeFastpayRefundQueryRequest();
|
|
|
+ Map<String, String> bizContent = new HashMap<>();
|
|
|
+ bizContent.put("out_trade_no", outTradeNo);
|
|
|
+ bizContent.put("trade_no", tradeNo);
|
|
|
+ bizContent.put("out_request_no", refundNo);
|
|
|
+// bizContent.put("query_options", "");
|
|
|
+ request.setBizContent(JSONObject.toJSONString(bizContent));
|
|
|
+ AlipayTradeFastpayRefundQueryResponse response = alipayService.getAlipayClient(appId).execute(request);
|
|
|
+ log.info("PayController#queryRefund(reqData={} ): response={}", reqData, JSONObject.toJSONString(response));
|
|
|
+ return baseResponse.succeed("", JSONObject.toJSONString(response));
|
|
|
+ } catch (AppMessageException appMessageException) {
|
|
|
+ return baseResponse.error(appMessageException.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("PayController#queryRefund(): {}", e.getMessage(), e);
|
|
|
+ return baseResponse.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|