无关风月
6 天以前 4e124926ee6ee682084466067ae37550fca475fa
cloud-server-other/src/main/java/com/dsh/other/util/PayMoneyUtil.java
@@ -5,15 +5,9 @@
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.*;
import com.alipay.api.domain.*;
import com.alipay.api.msg.AlipayMsgClient;
import com.alipay.api.msg.MsgHandler;
import com.alipay.api.request.*;
import com.alipay.api.response.*;
import com.dsh.other.util.wx.PartnerAppPrepay;
import com.dsh.other.util.wx.WXPayUtility;
import com.dsh.other.util.wx.WeChatV3SignUtil;
import com.dsh.other.util.wx.WxV3PayConfig;
import lombok.Synchronized;
import com.dsh.other.util.wx.*;
import org.apache.commons.collections.map.HashedMap;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.dom4j.Document;
@@ -23,9 +17,7 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
@@ -575,6 +567,39 @@
        System.err.println(map3);
        return ResultUtil.success(map3);
    }
    public ResultUtil weixinRefundV3(String subMchid,String outRefundNo, String transactionId, String totalFee, String notifyUrl) throws Exception {
        BigDecimal bigDecimal = new BigDecimal(totalFee);
        int i = bigDecimal.multiply(new BigDecimal("100")).intValue();
        // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340
        Create client = new Create(
                "1681873607",                    // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
                "55714944F7A7E52526F708280B176DCC838F371A",         // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
                "/usr/playpai/server/wxV3/1681873607_20250424_cert/apiclient_key.pem",    // 商户API证书私钥文件路径,本地文件路径
                "PUB_KEY_ID_0116818736072025042400351694002605",      // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
                "/usr/playpai/server/wxV3/pub_key.pem"        // 微信支付公钥文件路径,本地文件路径
        );
        Create.CreateRequest request = new Create.CreateRequest();
        request.subMchid = subMchid;
        request.transactionId = transactionId;
        request.outRefundNo = outRefundNo;
        request.reason = "退款";
        request.notifyUrl = callbackPath+notifyUrl;
        request.amount = new Create.AmountReq();
        request.amount.refund = (long) i;
        request.amount.total = (long) i;
        request.amount.currency = "CNY";
        try {
            Create.Refund response = client.run(request);
            // TODO: 请求成功,继续业务逻辑
            System.out.println(response);
        } catch (WXPayUtility.ApiException e) {
            // TODO: 请求失败,根据状态码执行不同的逻辑
            e.printStackTrace();
        }
        return ResultUtil.success();
    }
    /**
     * 发起分账