| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.tourguide.modules.order.service.HuifuPaymentCallbackService; |
| | | import com.tourguide.modules.order.service.HuifuRefundCallbackService; |
| | | import com.tourguide.modules.finance.service.GuideWithdrawalService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | |
| | | private final HuifuCallbackVerifier callbackVerifier; |
| | | private final HuifuPaymentCallbackService paymentCallbackService; |
| | | private final HuifuRefundCallbackService refundCallbackService; |
| | | private final GuideWithdrawalService withdrawalService; |
| | | |
| | | public DouGongNotifyController(HuifuCallbackVerifier callbackVerifier, |
| | | HuifuPaymentCallbackService paymentCallbackService, |
| | | HuifuRefundCallbackService refundCallbackService) { |
| | | HuifuRefundCallbackService refundCallbackService, |
| | | GuideWithdrawalService withdrawalService) { |
| | | this.callbackVerifier = callbackVerifier; |
| | | this.paymentCallbackService = paymentCallbackService; |
| | | this.refundCallbackService = refundCallbackService; |
| | | this.withdrawalService = withdrawalService; |
| | | } |
| | | |
| | | @PostMapping("/pay-notify") |
| | |
| | | @PostMapping("/encashment") |
| | | public String encashment(@RequestParam(value = "sign", required = false) String sign, |
| | | @RequestParam(value = "resp_data", required = false) String respData) { |
| | | return handleNotify("dougong-encashment", sign, respData); |
| | | try { |
| | | JSONObject body = callbackVerifier.verify(sign, respData); |
| | | withdrawalService.handleCallback(body); |
| | | return "200"; |
| | | } catch (Exception exception) { |
| | | log.warn("dougong-encashment callback failed: {}", exception.getMessage()); |
| | | return "FAIL"; |
| | | } |
| | | } |
| | | |
| | | private String handleNotify(String bizName, String sign, String respData) { |