|
|
@ -1,6 +1,8 @@ |
|
|
|
package org.jeecg.modules.transferTest; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.google.gson.annotations.SerializedName; |
|
|
|
import io.swagger.util.Json; |
|
|
|
import okhttp3.*; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
@ -17,64 +19,64 @@ public class TransferToUser { |
|
|
|
private static String HOST = "https://api.mch.weixin.qq.com"; |
|
|
|
private static String METHOD = "POST"; |
|
|
|
private static String PATH = "/v3/fund-app/mch-transfer/transfer-bills"; |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
// TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 |
|
|
|
// String mchid = "1712378227"; |
|
|
|
// String certiticateSerialNo ="33E9FE8076531A7C7AD401DC34E053DBD7C28E22"; |
|
|
|
// String privateKeyFilePath = "jeecg-boot-module-system/src/main/resources/apiclient_key.pem"; |
|
|
|
// String wechatPayPublicKeyId = "PUB_KEY_ID_0117123782272025033100396400002931"; |
|
|
|
// String wechatPayPublicKeyFilePaht = "jeecg-boot-module-system/src/main/resources/pub_key.pem"; |
|
|
|
String mchid = "1673516176"; |
|
|
|
String certiticateSerialNo ="525CDBD76E640EFB008288572C97D2715F3F18B2"; |
|
|
|
String privateKeyFilePath = "jeecg-boot-module-system/src/main/resources/apiclient_key_yaodu.pem"; |
|
|
|
String wechatPayPublicKeyId = "PUB_KEY_ID_0116735161762025040100448900000949"; |
|
|
|
String wechatPayPublicKeyFilePaht = "jeecg-boot-module-system/src/main/resources/pub_key_yaodu.pem"; |
|
|
|
TransferToUser client = new TransferToUser( |
|
|
|
mchid, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 |
|
|
|
certiticateSerialNo, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 |
|
|
|
privateKeyFilePath, // 商户API证书私钥文件路径,本地文件路径 |
|
|
|
wechatPayPublicKeyId, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 |
|
|
|
wechatPayPublicKeyFilePaht // 微信支付公钥文件路径,本地文件路径 |
|
|
|
); |
|
|
|
|
|
|
|
String appid = "wxa4d29e67e8a58d38"; |
|
|
|
String openid = "oFzrW4migndUepy7zYgYO2YoZ5to"; |
|
|
|
String notifyUrl = "https://admin.hhlm1688.com/api/hello/"; |
|
|
|
TransferToUserRequest request = new TransferToUserRequest(); |
|
|
|
request.appid = appid; |
|
|
|
request.outBillNo = "plfk2020042013"; |
|
|
|
request.transferSceneId = "1000"; |
|
|
|
request.openid = openid; |
|
|
|
request.userName = client.encrypt("唐斌"); |
|
|
|
request.transferAmount = 400L; |
|
|
|
request.transferRemark = "新会员开通有礼"; |
|
|
|
request.notifyUrl = notifyUrl; |
|
|
|
request.userRecvPerception = "现金奖励"; |
|
|
|
request.transferSceneReportInfos = new ArrayList<>(); |
|
|
|
{ |
|
|
|
TransferSceneReportInfo item0 = new TransferSceneReportInfo(); |
|
|
|
item0.infoType = "活动名称"; |
|
|
|
item0.infoContent = "新会员有礼"; |
|
|
|
request.transferSceneReportInfos.add(item0); |
|
|
|
TransferSceneReportInfo item1 = new TransferSceneReportInfo(); |
|
|
|
item1.infoType = "奖励说明"; |
|
|
|
item1.infoContent = "注册会员抽奖一等奖"; |
|
|
|
request.transferSceneReportInfos.add(item1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
try { |
|
|
|
TransferToUserResponse response = client.run(request); |
|
|
|
|
|
|
|
// TODO: 请求成功,继续业务逻辑 |
|
|
|
System.out.println(response); |
|
|
|
} catch (WXPayUtility.ApiException e) { |
|
|
|
// TODO: 请求失败,根据状态码执行不同的逻辑 |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
// |
|
|
|
// public static void main(String[] args) { |
|
|
|
// // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 |
|
|
|
//// String mchid = "1712378227"; |
|
|
|
//// String certiticateSerialNo ="33E9FE8076531A7C7AD401DC34E053DBD7C28E22"; |
|
|
|
//// String privateKeyFilePath = "jeecg-boot-module-system/src/main/resources/apiclient_key.pem"; |
|
|
|
//// String wechatPayPublicKeyId = "PUB_KEY_ID_0117123782272025033100396400002931"; |
|
|
|
//// String wechatPayPublicKeyFilePaht = "jeecg-boot-module-system/src/main/resources/pub_key.pem"; |
|
|
|
// String mchid = "1673516176"; |
|
|
|
// String certiticateSerialNo ="525CDBD76E640EFB008288572C97D2715F3F18B2"; |
|
|
|
// String privateKeyFilePath = "jeecg-boot-module-system/src/main/resources/apiclient_key_yaodu.pem"; |
|
|
|
// String wechatPayPublicKeyId = "PUB_KEY_ID_0116735161762025040100448900000949"; |
|
|
|
// String wechatPayPublicKeyFilePaht = "jeecg-boot-module-system/src/main/resources/pub_key_yaodu.pem"; |
|
|
|
// TransferToUser client = new TransferToUser( |
|
|
|
// mchid, // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 |
|
|
|
// certiticateSerialNo, // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 |
|
|
|
// privateKeyFilePath, // 商户API证书私钥文件路径,本地文件路径 |
|
|
|
// wechatPayPublicKeyId, // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 |
|
|
|
// wechatPayPublicKeyFilePaht // 微信支付公钥文件路径,本地文件路径 |
|
|
|
// ); |
|
|
|
// |
|
|
|
// String appid = "wxa4d29e67e8a58d38"; |
|
|
|
// String openid = "oFzrW4migndUepy7zYgYO2YoZ5to"; |
|
|
|
// String notifyUrl = "https://admin.hhlm1688.com/api/hello/"; |
|
|
|
// TransferToUserRequest request = new TransferToUserRequest(); |
|
|
|
// request.appid = appid; |
|
|
|
// request.out_bill_no = "plfk2020042013"; |
|
|
|
// request.transfer_scene_id = "1000"; |
|
|
|
// request.openid = openid; |
|
|
|
// request.user_name = client.encrypt("唐斌"); |
|
|
|
// request.transfer_amount = 400L; |
|
|
|
// request.transfer_remark = "新会员开通有礼"; |
|
|
|
// request.notify_url = notifyUrl; |
|
|
|
// request.user_recv_perception = "现金奖励"; |
|
|
|
// request.transferSceneReportInfos = new ArrayList<>(); |
|
|
|
// { |
|
|
|
// TransferSceneReportInfo item0 = new TransferSceneReportInfo(); |
|
|
|
// item0.info_type = "活动名称"; |
|
|
|
// item0.info_content = "新会员有礼"; |
|
|
|
// request.transferSceneReportInfos.add(item0); |
|
|
|
// TransferSceneReportInfo item1 = new TransferSceneReportInfo(); |
|
|
|
// item1.info_type = "奖励说明"; |
|
|
|
// item1.info_content = "注册会员抽奖一等奖"; |
|
|
|
// request.transferSceneReportInfos.add(item1); |
|
|
|
// |
|
|
|
// |
|
|
|
// |
|
|
|
// }; |
|
|
|
// try { |
|
|
|
// TransferToUserResponse response = client.run(request); |
|
|
|
// |
|
|
|
// // TODO: 请求成功,继续业务逻辑 |
|
|
|
// System.out.println(response); |
|
|
|
// } catch (WXPayUtility.ApiException e) { |
|
|
|
// // TODO: 请求失败,根据状态码执行不同的逻辑 |
|
|
|
// e.printStackTrace(); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
public void run(){ |
|
|
|
String mchid = "1673516176"; |
|
|
@ -91,27 +93,28 @@ public class TransferToUser { |
|
|
|
); |
|
|
|
|
|
|
|
String appid = "wxa4d29e67e8a58d38"; |
|
|
|
String openid = "oFzrW4migndUepy7zYgYO2YoZ5to"; |
|
|
|
String openid = "oFzrW4tqZUvN9T0RQzWPdCT1St68"; |
|
|
|
String notifyUrl = "https://admin.hhlm1688.com/api/cashout/cashout/"; |
|
|
|
TransferToUserRequest request = new TransferToUserRequest(); |
|
|
|
request.appid = appid; |
|
|
|
request.outBillNo = "plfk2020042013"; |
|
|
|
request.transferSceneId = "1000"; |
|
|
|
String idStr = "H" + IdWorker.getIdStr(); |
|
|
|
request.out_bill_no = idStr; |
|
|
|
request.transfer_scene_id = "1005";//只开通了佣金报酬 |
|
|
|
request.openid = openid; |
|
|
|
request.userName = client.encrypt("唐斌"); |
|
|
|
request.transferAmount = 400L; |
|
|
|
request.transferRemark = "新会员开通有礼"; |
|
|
|
request.notifyUrl = notifyUrl; |
|
|
|
request.userRecvPerception = "现金奖励"; |
|
|
|
request.user_name = client.encrypt("廖志翔"); |
|
|
|
request.transfer_amount = 100L; |
|
|
|
request.transfer_remark = "佣金报酬"; |
|
|
|
request.notify_url = notifyUrl; |
|
|
|
request.userRecvPerception = "劳务报酬"; // 修改用户收款感知描述 |
|
|
|
request.transferSceneReportInfos = new ArrayList<>(); |
|
|
|
{ |
|
|
|
TransferSceneReportInfo item0 = new TransferSceneReportInfo(); |
|
|
|
item0.infoType = "活动名称"; |
|
|
|
item0.infoContent = "新会员有礼"; |
|
|
|
item0.infoType = "岗位类型";//固定 |
|
|
|
item0.infoContent = "外卖员";//只开通了佣金报酬 |
|
|
|
request.transferSceneReportInfos.add(item0); |
|
|
|
TransferSceneReportInfo item1 = new TransferSceneReportInfo(); |
|
|
|
item1.infoType = "奖励说明"; |
|
|
|
item1.infoContent = "注册会员抽奖一等奖"; |
|
|
|
item1.infoType = "报酬说明";//固定 |
|
|
|
item1.infoContent = "高温补贴";//只开通了佣金报酬 |
|
|
|
request.transferSceneReportInfos.add(item1); |
|
|
|
|
|
|
|
|
|
|
@ -128,9 +131,13 @@ public class TransferToUser { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public TransferToUserResponse run(TransferToUserRequest request) { |
|
|
|
String uri = PATH; |
|
|
|
String reqBody = WXPayUtility.toJson(request); |
|
|
|
// String reqBody = Json.pretty(request); |
|
|
|
System.out.println("reqBody========================="); |
|
|
|
System.out.println(reqBody); |
|
|
|
|
|
|
|
Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); |
|
|
|
reqBuilder.addHeader("Accept", "application/json"); |
|
|
@ -151,7 +158,10 @@ public class TransferToUser { |
|
|
|
httpResponse.headers(), respBody); |
|
|
|
|
|
|
|
// 从HTTP应答报文构建返回数据 |
|
|
|
return WXPayUtility.fromJson(respBody, TransferToUserResponse.class); |
|
|
|
TransferToUserResponse transferToUserResponse = WXPayUtility.fromJson(respBody, TransferToUserResponse.class); |
|
|
|
System.out.println("transferToUserResponse========================="); |
|
|
|
System.out.println(Json.pretty(transferToUserResponse)); |
|
|
|
return transferToUserResponse; |
|
|
|
} else { |
|
|
|
throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); |
|
|
|
} |
|
|
@ -227,31 +237,41 @@ public class TransferToUser { |
|
|
|
public String appid; |
|
|
|
|
|
|
|
@SerializedName("out_bill_no") |
|
|
|
public String outBillNo; |
|
|
|
// public String outBillNo; |
|
|
|
public String out_bill_no; |
|
|
|
|
|
|
|
@SerializedName("transfer_scene_id") |
|
|
|
public String transferSceneId; |
|
|
|
// public String transferSceneId; |
|
|
|
public String transfer_scene_id; |
|
|
|
|
|
|
|
@SerializedName("openid") |
|
|
|
public String openid; |
|
|
|
|
|
|
|
@SerializedName("user_name") |
|
|
|
public String userName; |
|
|
|
// public String userName; |
|
|
|
public String user_name; |
|
|
|
|
|
|
|
@SerializedName("transfer_amount") |
|
|
|
public Long transferAmount; |
|
|
|
// public Long transferAmount; |
|
|
|
public Long transfer_amount; |
|
|
|
|
|
|
|
@SerializedName("transfer_remark") |
|
|
|
public String transferRemark; |
|
|
|
// public String transferRemark; |
|
|
|
public String transfer_remark; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SerializedName("notify_url") |
|
|
|
public String notifyUrl; |
|
|
|
// public String notifyUrl; |
|
|
|
public String notify_url; |
|
|
|
|
|
|
|
@SerializedName("user_recv_perception") |
|
|
|
public String userRecvPerception; |
|
|
|
|
|
|
|
@SerializedName("transfer_scene_report_infos") |
|
|
|
public List<TransferSceneReportInfo> transferSceneReportInfos; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |