liujie
2025-12-29 7e2eb8af7459da7a03a23606651dfbfb5a5f2cee
ruoyi-system/src/main/java/com/ruoyi/system/wxPay/utils/WxV3Pay.java
@@ -138,6 +138,36 @@
            throw new RuntimeException("获取支付数据错误!");
        }
    }
    public Map<String, Object> jsApiInsurance(String tradeNo, Long amount, String openid, String description,String attach) {
        JsapiPrepay client = new JsapiPrepay(
                this.config.getMchId(),                    // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756
                this.config.getV3().getMchSerialNo(),         // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053
                this.config.getV3().getPrivateKeyPath(),     // 商户API证书私钥文件路径,本地文件路径
                this.config.getV3().getPublicKeyId(),      // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816
                this.config.getV3().getPublicKeyPath()           // 微信支付公钥文件路径,本地文件路径
        );
        JsapiPrepay.DirectAPIv3JsapiPrepayRequest request = new JsapiPrepay.DirectAPIv3JsapiPrepayRequest();
        request.appid = this.config.getAppId();
        request.mchid = this.config.getMchId();
        request.description = description;
        request.outTradeNo = tradeNo;
//        request.timeExpire = "2018-06-08T10:34:56+08:00";
        request.attach = attach;
        request.notifyUrl = this.config.getV3().getInsuranceNotifyPayUrl();
        request.goodsTag = "WXG";
        request.supportFapiao = false;
        request.amount = new JsapiPrepay.CommonAmountInfo();
        request.amount.total = amount;
        request.amount.currency = "CNY";
        request.payer = new JsapiPrepay.JsapiReqPayerInfo();
        request.payer.openid = openid;
        try {
            JsapiPrepay.DirectAPIv3JsapiPrepayResponse response = client.run(request);
            return wxTuneUp(this.privateKeySigner, this.config.getAppId(), response.prepayId);
        } catch (WXPayUtility.ApiException e) {
            throw new RuntimeException("获取支付数据错误!");
        }
    }
//    /**
//     * jsApi下单
//     *