javacodeadmin/ruoyi-system/src/main/java/com/ruoyi/system/controller/ApiWechatPayController.java

85 lines
3.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ruoyi.system.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.ControllerUtil.WechatPayV3Util;
import com.ruoyi.system.service.WechatCertificateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Map;
/**
* 微信支付API控制器无需认证
*
* @author Mr. Zhang Pan
* @version 1.0
* @date 2025-01-17
*/
@RestController
@RequestMapping("/api/wechat/pay/v3")
public class ApiWechatPayController extends BaseController {
//
// private static final Logger log = LoggerFactory.getLogger(ApiWechatPayController.class);
//
// @Autowired
// private WechatPayV3Util wechatPayV3Util;
//
// @Autowired
// private WechatCertificateService wechatCertificateService;
//
// /**
// * 快速提现(简化参数)简化参数
// */
// @PostMapping("/quick-withdraw")
// @Log(title = "微信支付V3快速提现", businessType = BusinessType.OTHER)
// public AjaxResult quickWithdraw(@RequestParam String openid,
// @RequestParam BigDecimal amount,
// @RequestParam(required = false) String desc) {
// try {
// log.info("⚡ API快速提现请求 - 用户户: {}, 金额: {}元", openid.substring(0, 6) + "****", amount);
//
// Map<String, Object> result = wechatPayV3Util.quickWithdraw(openid, amount, desc);
//
// if ((Boolean) result.get("success")) {
// return AjaxResult.success("快速提现成功", result.get("data"));
// } else {
// return AjaxResult.error(result.get("message").toString());
// }
// } catch (Exception e) {
// log.error("❌ API快速提现异常: {}", e.getMessage(), e);
// return AjaxResult.error("快速提现失败: " + e.getMessage());
// }
// }
// /**
// * 测试私钥加载
// */
// @GetMapping("/test-key")
// @Log(title = "微信支付V3测试私钥", businessType = BusinessType.OTHER)
// public AjaxResult testKey() {
// try {
// log.info("🔐 API测试私钥加载");
//
// // 通过反射调用私有方法测试私钥加载
// java.lang.reflect.Method method = WechatPayV3Util.class.getDeclaredMethod("getPrivateKey");
// method.setAccessible(true);
// Object privateKey = method.invoke(wechatPayV3Util);
//
// if (privateKey != null) {
// return AjaxResult.success("私钥加载成功", "私钥算法: " + privateKey.getClass().getSimpleName());
// } else {
// return AjaxResult.error("私钥加载失败");
// }
// } catch (Exception e) {
// log.error("❌ API测试私钥异常: {}", e.getMessage(), e);
// return AjaxResult.error("测试私钥失败: " + e.getMessage());
// }
// }
}