String mchid = WeChatConfig.WX_APP_MCH_ID;
String appId = WeChatConfig.WX_APP_ID;
String privatekeypath = WeChatConfig.WX_APICLIENT_KEY_FILE;
String path = WeChatConfig.WX_APICLIENT_CERT_FILE;
Map<String, Object> postMap = new HashMap<String, Object>();
postMap.put("appid", appId);
postMap.put("out_batch_no", outNo);
postMap.put("batch_name", "提现");
postMap.put("batch_remark", "提现");
BigDecimal b1 = new BigDecimal(txprice);
BigDecimal b2 = new BigDecimal(100);
double price = b1.multiply(b2).doubleValue();
postMap.put("total_amount", price);
postMap.put("total_num", 1);
List<Map> list = new ArrayList<>();
Map<String, Object> subMap = new HashMap<>(4);
subMap.put("out_detail_no", outNo);
subMap.put("transfer_amount", price);
subMap.put("transfer_remark", "发放奖励");
subMap.put("openid", openId);
X509Certificate x509Certificate = HttpUtil.getSaveCertificates(path);
subMap.put("user_name", RsaCryptoUtil.encryptOAEP(userName, x509Certificate));
list.add(subMap);
postMap.put("transfer_detail_list", list);
String resStr = HttpUtil.postTransBatRequest(
"https://api.mch.weixin.qq.com/v3/transfer/batches",
GSON.toJson(postMap),
wechatPayserialNo, planNum,
mchid,
privatekeypath);
return GSON.toJson(postMap) + "@@@@" + resStr;
可以直接用sdkhttps://github.com/wechatpay-apiv3/wechatpay-java/tree/main/service/src/main/java/com/wechat/pay/java/service/transferbatch
现在老报:{xml=FAIL
签名错误,请检查后再试
, return_msg=签名错误,请检查后再试, return_code=FAIL}