Skip to content

Commit 7cb2632

Browse files
committed
补充 example 信息
1 parent 1998d89 commit 7cb2632

5 files changed

Lines changed: 699 additions & 80 deletions

File tree

example/src/main/java/com/pingxx/example/BatchTransferExample.java

Lines changed: 166 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,23 @@ public static void runDemos(String appId) {
5656
* @return
5757
*/
5858
public BatchTransfer create() {
59+
String channel = "alipay";
60+
5961
BatchTransfer obj = null;
60-
String orderNo = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + Main.randomString(7);
62+
String batchNo = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + Main.randomString(7);
6163
Map<String, Object> params = new HashMap<String, Object>();
6264
params.put("app", appId);
63-
params.put("channel", "alipay"); // 目前支持 alipay、 unionpay
64-
params.put("batch_no", orderNo); // 企业转账使用的商户内部订单号。
65-
params.put("amount", 2000); // 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100,企业付款最小发送金额为 1 元)
66-
params.put("type", "b2c"); // 付款类型,当前仅支持 b2c 企业付款
65+
params.put("channel", channel); // 目前支持 alipay、 unionpay、wx_pub、allinpay、jdpay
66+
params.put("batch_no", batchNo); // 企业转账使用的商户内部订单号。
67+
params.put("amount", 5000); // 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100,企业付款最小发送金额为 1 元)
68+
params.put("type", "b2c"); // 付款类型,wx_pub 仅支持 b2c,alipay、 unionpay、allinpay、jdpay 支持 b2b
6769
params.put("currency", "cny");
6870
params.put("description", "your description");
6971
List<Map<String, Object>> recipients = new ArrayList<Map<String, Object>>();
7072

71-
Map<String, Object> recipient = new HashMap<String, Object>();
72-
recipient.put("account", "user001@gmail.com");
73-
recipient.put("amount", 2000);
74-
recipient.put("name", "NAME");
75-
recipients.add(recipient);
73+
recipients.add(channelRecipient(channel));
74+
// recipients.add(channelRecipient(channel));
75+
// recipients.add(channelRecipient(channel));
7676

7777
params.put("recipients", recipients);
7878

@@ -120,7 +120,6 @@ public void retrieve(String id) {
120120
} catch (RateLimitException e) {
121121
e.printStackTrace();
122122
}
123-
124123
}
125124

126125
/**
@@ -129,11 +128,12 @@ public void retrieve(String id) {
129128
* 查询批量转账记录列表,默认一次查询 10 条,用户可以使用 per_page 自定义查询数目,但是最多不超过 20 条。
130129
*/
131130
public void list() {
132-
Map<String, Object> parm = new HashMap<String, Object>();
133-
parm.put("per_page", 3);
131+
Map<String, Object> param = new HashMap<String, Object>();
132+
param.put("per_page", 3);
133+
param.put("app", appId);
134134

135135
try {
136-
BatchTransferCollection objs = BatchTransfer.list(parm);
136+
BatchTransferCollection objs = BatchTransfer.list(param);
137137
System.out.println(objs);
138138
} catch (AuthenticationException e) {
139139
e.printStackTrace();
@@ -149,4 +149,156 @@ public void list() {
149149
e.printStackTrace();
150150
}
151151
}
152+
153+
private Map<String, Object> channelRecipient(String channel) {
154+
Map<String, Object> recipient = new HashMap<String, Object>();
155+
156+
switch (channel) {
157+
case "alipay":
158+
recipient = alipayRecipient();
159+
break;
160+
case "wx_pub":
161+
recipient = wxPubRecipient();
162+
break;
163+
case "unionpay":
164+
recipient = unionpayRecipient();
165+
break;
166+
case "allinpay":
167+
recipient = allinpayRecipient();
168+
break;
169+
case "jdpay":
170+
recipient = jdpayRecipient();
171+
break;
172+
}
173+
174+
return recipient;
175+
}
176+
177+
private Map<String, Object> alipayRecipient() {
178+
Map<String, Object> extra = new HashMap<>();
179+
180+
// 必须,金额,单位为分。
181+
extra.put("amount", 5000);
182+
183+
// 必须,接收者支付宝账号。
184+
extra.put("account", "alipayaccount@gmail.com");
185+
186+
// 必须,收款人姓名,1~50位。
187+
extra.put("name", "张三");
188+
189+
// 可选,收款方账户类型。可取值:1、 ALIPAY_USERID :支付宝账号对应的支付宝唯一用户号。以2088开头的16位纯数字组成。 2、 ALIPAY_LOGONID (默认值):支付宝登录号,支持邮箱和手机号格式。
190+
// extra.put("account_type", "ALIPAY_LOGONID");
191+
192+
// 可选,批量企业付款描述,最多 200 字节。
193+
// extra.put("description", "描述");
194+
195+
// 可选,订单号,1 ~ 64 位不能重复的数字字母组合。
196+
// extra.put("order_no", "1234567890123456");
197+
198+
return extra;
199+
}
200+
201+
private Map<String, Object> wxPubRecipient() {
202+
Map<String, Object> extra = new HashMap<>();
203+
// 必须,金额,单位为分。
204+
extra.put("amount", 5000);
205+
206+
// 必须,接收者 id,为用户在 wx_pub 下的 open_id。
207+
extra.put("open_id", "o7xEMsySBFG3MVHI-9VsAJX-j50W");
208+
209+
// 可选,收款人姓名。当该参数为空,则不校验收款人姓名。
210+
// extra.put("name", "张三");
211+
212+
// 可选,是否强制校验收款人姓名。仅当 user_name 参数不为空时该参数生效。
213+
// extra.put("force_check", true);
214+
215+
// 可选,批量企业付款描述,最多 99 个英文和数字的组合或最多 33 个中文字符,不可以包含特殊字符。不填默认使用外层参数中的 description。
216+
// extra.put("description", "描述");
217+
218+
// 可选,订单号,1 ~ 32 位不能重复的数字字母组合。
219+
// extra.put("order_no", "1234567890123456");
220+
221+
return extra;
222+
}
223+
224+
private Map<String, Object> unionpayRecipient() {
225+
Map<String, Object> extra = new HashMap<>();
226+
// 必须,金额,单位为分。
227+
extra.put("amount", 5000);
228+
229+
// 必须,1~32位,收款人银行卡号或者存折号。
230+
extra.put("account", "6228480402564890011");
231+
232+
// 必须,1~100位,收款人姓名。
233+
extra.put("name", "张三");
234+
235+
/**
236+
* open_bank_code 和 open_bank 两个参数必传一个,建议使用 open_bank_code ,若都传参则优先使用 open_bank_code 读取规则;prov 和 city 均为可选参数,如果不传参,则使用默认值 "上海" 给渠道接口。
237+
*/
238+
// 条件可选,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。
239+
extra.put("open_bank_code", "0103");
240+
241+
// 条件可选,1~50位,开户银行,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。
242+
extra.put("open_bank", "农业银行");
243+
244+
// 可选,订单号,1 ~ 16 位数字。
245+
// extra.put("order_no", "1234567890123456");
246+
247+
// 可选,批量企业付款描述,最多 200 字节。
248+
// extra.put("description", "描述");
249+
250+
return extra;
251+
}
252+
253+
private Map<String, Object> allinpayRecipient() {
254+
Map<String, Object> extra = new HashMap<>();
255+
// 必须,金额,单位为分。
256+
extra.put("amount", 5000);
257+
258+
// 必须,接收者银行卡账号。
259+
extra.put("account", "6228480402564890011");
260+
261+
// 必须,收款人姓名。
262+
extra.put("name", "张三");
263+
264+
// 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。
265+
extra.put("open_bank_code", "0103");
266+
267+
// 可选,5位,业务代码,根据通联业务人员提供,不填使用通联提供默认值09900。
268+
// extra.put("business_code", "09900");
269+
270+
// 可选,1位,银行卡号类型,0:银行卡、1:存折,不填默认使用银行卡。
271+
// extra.put("card_type", 0);
272+
273+
// 可选,批量付款描述,最多 30 个 Unicode 字符。
274+
// extra.put("description", "描述");
275+
276+
// 可选,订单号, 20 ~ 40 位不能重复的数字字母组合(必须以通联的商户号开头,建议组合格式:通联商户号 + 时间戳 + 固定位数顺序流水号,不包含+号),这里不传的话程序会调用商户的通联商户号加上随机数自动生成 order_no。
277+
// extra.put("order_no", "331301234554321098765432112");
278+
279+
return extra;
280+
}
281+
282+
private Map<String, Object> jdpayRecipient() {
283+
Map<String, Object> extra = new HashMap<>();
284+
// 必须,金额,单位为分。
285+
extra.put("amount", 5000);
286+
287+
// 必须,1~32位,收款人银行卡号或者存折号。
288+
extra.put("account", "6228480402564890011");
289+
290+
// 必须,1~100位,收款人姓名。
291+
extra.put("name", "张三");
292+
293+
// 必须,4位,开户银行编号,详情请参考 企业付款(银行卡)银行编号说明:https://www.pingxx.com/api#%E9%93%B6%E8%A1%8C%E7%BC%96%E5%8F%B7%E8%AF%B4%E6%98%8E。
294+
extra.put("open_bank_code", "0103");
295+
296+
// 可选,批量付款描述,最多 100 个 Unicode 字符。
297+
// extra.put("description", "描述");
298+
299+
// 可选,订单号,jdpay 限长 1~64 位不能重复的数字字母组合。
300+
// extra.put("order_no", "1234567890123456");
301+
302+
return extra;
303+
}
152304
}

0 commit comments

Comments
 (0)