package com.kym.miniapp.controller; import cn.dev33.satoken.annotation.SaIgnore; import cn.dev33.satoken.stp.StpUtil; import com.kym.common.R; import com.kym.common.annotation.ApiLog; import com.kym.service.wechat.WxPayService; import jakarta.servlet.http.HttpServletRequest; import lombok.SneakyThrows; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; /** * @author skyline * @description * @date 2023-07-22 20:36 */ @Controller @RequestMapping("/payment") public class PaymentController { private final WxPayService wxPayService; public PaymentController(WxPayService wxPayService) { this.wxPayService = wxPayService; } /** * 充值 * * @param rechargeConfigId * @return */ @ApiLog("用户充值微信支付") @GetMapping("/wxPay") @ResponseBody R prepay(@RequestParam Long rechargeConfigId, @RequestParam(value = "stationId", required = false) String stationId) { return R.success(wxPayService.wxPay(rechargeConfigId, stationId)); } @ApiLog(value = "微信回调", ignoreParams = true) @SneakyThrows @SaIgnore @PostMapping("/notify") ResponseEntity notify(HttpServletRequest request) { return wxPayService.wxNotify(request); } /** * 专属优惠活动充值 */ @ApiLog("用户优惠活动充值微信支付") @GetMapping("/promotionPay") @ResponseBody R promotionPay(@RequestParam String promotionToken, @RequestParam(value = "stationId", required = false) String stationId) { return R.success(wxPayService.promotionPay(promotionToken, stationId)); } @ApiLog("用户申请退款") @PostMapping("/wxApplyRefund") @ResponseBody R wxAppRefund(@RequestParam String reason) { wxPayService.applyWxRefund(StpUtil.getLoginIdAsLong(), reason); return R.success(); } @ApiLog(value = "微信退款回调", ignoreParams = true) @SaIgnore @PostMapping("/refundNotify") ResponseEntity refundNotify(HttpServletRequest request) { return wxPayService.wxRefundNotify(request); } }