Java springboot微信小程序提现,企业向个人付款

@Autowired
    WeixinMiniProgramPayProperties weixinPayProperties;

    @Override
    public Map enterprice2User(String logKey, String orderNumber, String openId, String fee, String body) throws Exception
    {
        //1.参数封装 ,作者qq1023732997
        Map param = new HashMap();
        param.put("mch_appid", weixinPayProperties.getAppid());// 商户账号appid
        param.put("mchid", weixinPayProperties.getMchId());// 商户
//        param.put("mch_id", weixinPayProperties.getMchId());// 商户
        param.put("nonce_str", WXPayUtil.generateNonceStr());// 随机字符串
        param.put("partner_trade_no", orderNumber);// 交易订单号
//        param.put("out_trade_no", orderNumber);// 交易订单号
        param.put("openid", openId); // 用户openid
        param.put("check_name", "NO_CHECK"); // 校验用户姓名选项
        param.put("amount", fee); // 金额
//        param.put("total_fee", fee); // 金额
        param.put("desc", body);
//        param.put("body", body); // 商品描述
        param.put("spbill_create_ip", weixinPayProperties.getSpbillCreateIp());

        logger.info(logKey + " weixinPayProperties" + weixinPayProperties);
        String sign = WXPayUtil.generateSignature(param, weixinPayProperties.getPartnerkey());
        param.put("sign", sign);
        logger.info(logKey + " weixinService#enterprice2User:" + param);

//        HttpClient httpClient = new HttpClient(weixinPayProperties.getWechatTransfersUrl());
//        httpClient.setHttps(true);
//        httpClient.setXmlParam(xml2String(param));
//        httpClient.post();
//
//        String xmlResult = httpClient.getContent();
//        Map<String, String> mapResult = WXPayUtil.xmlToMap(xmlResult);

        String xmlResult = WXHttpCertUtils.doPost(weixinPayProperties.getWechatTransfersUrl(), xml2String(param));
        Map<String, String> mapResult = WXPayUtil.xmlToMap(xmlResult);
        logger.info(logKey + " weixinService#enterprice2User.wxpay.mp.result:" + mapResult);

        Map<String, String> result = new HashMap<>();
        result.put("code", "500");
        result.put("message", "系统错误");

        // {mchid=1520737191, mch_appid=wx2f030dd8ebda3a63, err_code=NOTENOUGH, return_msg=支付失败, result_code=FAIL, err_code_des=余额不足, return_code=SUCCESS}
        // 转账成功
        if("SUCCESS".equalsIgnoreCase(mapResult.get("result_code")))
        {
            result.put("code", "200");
            result.put("message", "支付成功");
        }
        // 转帐失败
        else if ("FAIL".equalsIgnoreCase(mapResult.get("result_code")))
        {
            result.put("code", "500");
            // 系统错误需要重试[请先调用查询接口,查看此次付款结果,如结果为不明确状态(如订单号不存在),请务必使用原商户订单号进行重试。
            if ("SYSTEMERROR".equalsIgnoreCase(mapResult.get("err_code")))
            {
//                result.put("message", "支付成功");]
            }
            // 金额超限
            else if("AMOUNT_LIMIT".equalsIgnoreCase(mapResult.get("err_code")))
            {
                result.put("message", "金额超限");
            }
            // 余额不足
            else if("NOTENOUGH".equalsIgnoreCase(mapResult.get("err_code")))
            {
//                result.put("message", "支付成功");
            }
            // 超过频率限制,请稍后再试。
            else if("FREQ_LIMIT".equalsIgnoreCase(mapResult.get("err_code")))
            {
                result.put("message", "超过频率限制,请稍后再试。");
            }
            // 已经达到今日付款总额上限/已达到付款给此用户额度上限
            else if("MONEY_LIMIT".equalsIgnoreCase(mapResult.get("err_code")))
            {
                result.put("message", "已经达到今日付款总额上限");
            }
            // 无法给非实名用户付款
            else if ("V2_ACCOUNT_SIMPLE_BAN".equalsIgnoreCase(mapResult.get("err_code")))
            {
                result.put("message", "无法给非实名用户付款");
            }
            // 该用户今日付款次数超过限制,如有需要请登录微信支付商户平台更改API安全配置
            else if("SENDNUM_LIMIT".equalsIgnoreCase(mapResult.get("err_code")))
            {
                result.put("message", "今日付款次数超过限制");
            }
        }
        else
        {
            // 系统错误
            result.put("code", "500");
            result.put("message", "系统错误");
        }

        return result;
    }
  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Java SpringBoot是一种流行的后端框架,可以用来构建微信小程序的后端服务。通过Java SpringBoot,我们可以实现微信小程序的增删改查功能。 首先,我们可以利用SpringBoot提供的RESTful API来实现数据的增删改查操作。通过编写对应的Controller来处理微信小程序发送的请求,比如增加数据的请求可以由POST方法处理,删除数据的请求可以由DELETE方法处理,更新数据的请求可以由PUT方法处理,查询数据的请求可以由GET方法处理。 其次,我们需要结合微信小程序的开放能力,利用微信提供的API来实现用户登录和数据交互。通过微信小程序的API,我们可以实现用户登录获取用户的唯一标识openid,然后在后端实现对用户数据的操作。 另外,我们可以使用Spring Data JPA来简化对数据库的操作。Spring Data JPA提供了很多便利的方法来实现对数据库的增删改查操作,可以大大简化我们的代码开发。 最后,我们需要部署这个SpringBoot应用到服务器上,并且配置好数据库等相关环境。可以选择使用云服务商提供的PaaS服务,比如阿里云、腾讯云等,来快速部署我们的应用。 通过以上步骤,我们就可以实现一个使用Java SpringBoot的后端服务,用于支持微信小程序的增删改查功能。这样用户就可以通过微信小程序与我们的后端服务进行数据交互,实现各种功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云上上云

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值