微信零钱提现

 /**
     * 微信提现零钱
     */
    @Override
    public AjaxResult withdraw(PayVo payVo) {
        String outTradeNo = WXPayUtil.generateNonceStr();
        Map<String,String> param = new HashMap<>();
        param.put("mch_appid",appId);
        param.put("mchid",michIdPatient);
        param.put("nonce_str",outTradeNo);
        param.put("partner_trade_no",outTradeNo);
        param.put("openid",payVo.getOpenId());
        param.put("check_name","NO_CHECK");
        param.put("amount",String.valueOf(payVo.getTotalPrice() * 100));
        param.put("desc","withdraw");//提现
        param.put("spbill_create_ip",spbillCreateIp);
        try {
            //创建流水
            String xml = WXPayUtil.generateSignedXml(param, apikeyPatient);
            xml = new String(xml.getBytes("UTF-8"), "ISO8859-1");
            //2.发送请求
            CloseableHttpClient httpClient = null;
            CloseableHttpResponse httpResponse = null;
            KeyStore keyStore = getCertificate(michIdPatient);
            SSLContext sslContext = SSLContexts.custom().loadKeyMaterial(keyStore, michIdPatient.toCharArray()).build();
            SSLConnectionSocketFactory sslf = new SSLConnectionSocketFactory(sslContext);
            httpClient = HttpClients.custom().setSSLSocketFactory(sslf).build();
            HttpPost httpPost = new HttpPost(withdrawUrl);
            StringEntity reqEntity = new StringEntity(xml);
            // 设置类型
            reqEntity.setContentType("application/x-www-form-urlencoded");
            httpPost.setEntity(reqEntity);
            httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            String resultStr = EntityUtils.toString(httpEntity, "UTF-8");
            log.info("微信响应报文:" + resultStr);
            EntityUtils.consume(httpEntity);
            //提现成功
            Map<String, String> str = WXPayUtil.xmlToMap(resultStr);
            if ("SUCCESS".equals(str.get("result_code"))) {
                //修改流水状态
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值