| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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<Object> 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<Object> refundNotify(HttpServletRequest request) {
- return wxPayService.wxRefundNotify(request);
- }
- }
|