|
@@ -1,18 +1,726 @@
|
|
|
package com.szwl;
|
|
|
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huifu.bspay.sdk.opps.core.utils.DateTools;
|
|
|
+import com.huifu.bspay.sdk.opps.core.utils.OkHttpClientTools;
|
|
|
+import com.huifu.bspay.sdk.opps.core.utils.SequenceTools;
|
|
|
+import com.szwl.common.HuifuBaseCommon;
|
|
|
+import com.szwl.config.OppsMerchantConfig;
|
|
|
+import com.szwl.constant.HuifuConstant;
|
|
|
+import com.szwl.utils.HuifuUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpStatus;
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
+import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.TreeMap;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@SpringBootTest
|
|
|
class ApplicationTests {
|
|
|
|
|
|
-// @Autowired
|
|
|
-// private EsTOrderAbroadService esTOrderAbroadService;
|
|
|
-//
|
|
|
-// @Test
|
|
|
-// void testInitTableFun() {
|
|
|
-// esTOrderAbroadService.initTableFun();
|
|
|
-// }
|
|
|
+ @Value("${oauth.wx.appID}")
|
|
|
+ private String appID;
|
|
|
+
|
|
|
+ @Value("${oauth.wx.appSecret}")
|
|
|
+ private String appSecret;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试聚合正扫
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void HuifuPay() throws Exception {
|
|
|
+ String url = "https://api.huifu.com/v2/trade/payment/jspay";
|
|
|
+ HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id",SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000136120737");
|
|
|
+ request.put("trade_type", "T_JSAPI");
|
|
|
+ request.put("trans_amt", "1.00");
|
|
|
+ request.put("goods_desc", "测试商品");
|
|
|
+ // 分账明细
|
|
|
+ JSONObject acctSplitBunch = new JSONObject();
|
|
|
+ JSONArray acctInfos = new JSONArray();
|
|
|
+ JSONObject acctInfo1 = new JSONObject();
|
|
|
+ acctInfo1.put("div_amt", "0.01");
|
|
|
+ acctInfo1.put("huifu_id","6666000136120737");
|
|
|
+ JSONObject acctInfo2 = new JSONObject();
|
|
|
+ acctInfo2.put("div_amt", "0.59");
|
|
|
+ acctInfo2.put("huifu_id","6666000135495540");
|
|
|
+ JSONObject acctInfo3 = new JSONObject();
|
|
|
+ acctInfo3.put("div_amt", "0.40");
|
|
|
+ acctInfo3.put("huifu_id","6666000136424957");
|
|
|
+ acctInfos.add(acctInfo1);
|
|
|
+ acctInfos.add(acctInfo2);
|
|
|
+ acctInfos.add(acctInfo3);
|
|
|
+
|
|
|
+
|
|
|
+ acctSplitBunch.put("acct_infos", acctInfos);
|
|
|
+ request.put("acct_split_bunch", acctSplitBunch.toJSONString());
|
|
|
+
|
|
|
+ // 取现信息配置
|
|
|
+ JSONObject wxData = new JSONObject();
|
|
|
+ wxData.put("sub_appid",appID);
|
|
|
+// wxData.put("open_id","ooT-O5z6HL1yhPWC1enDdy-_-cd8");
|
|
|
+ request.put("wx_data", wxData);
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试扫码交易退款
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void refund() throws Exception {
|
|
|
+ String url = "https://api.huifu.com/v2/trade/payment/scanpay/refund";
|
|
|
+ HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", "20230711100826951i2zi4k2qwdhsju");
|
|
|
+ request.put("req_date", "20230711");
|
|
|
+ request.put("huifu_id", "6666000136120737");
|
|
|
+ request.put("ord_amt", "1.00");
|
|
|
+ request.put("org_req_date", "20230711");
|
|
|
+ request.put("org_hf_seq_id","002900TOP3B230711100828P001ac139c1300000");
|
|
|
+ // 分账明细
|
|
|
+// JSONObject acctInfos = new JSONObject();
|
|
|
+// acctInfos.put("div_amt", "1.00");
|
|
|
+// acctInfos.put("huifu_id","6666000135495540");
|
|
|
+//// acctInfos.put("acct_id","6666000135495540");
|
|
|
+// request.put("acct_infos", acctInfos);
|
|
|
+
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试个人商户信息入驻
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void addPersonage() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/basicdata/indv";
|
|
|
+ HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32()); // 请求流水号
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD()); // 请求日期
|
|
|
+ request.put("upper_huifu_id", HuifuConstant.HUIFU_ID); // 上级主体ID
|
|
|
+ request.put("reg_name", "广州申泽智能科技有限公司"); // 商户名称
|
|
|
+ request.put("short_name", "申泽智能"); // 商户简称
|
|
|
+ request.put("prov_id", "440000"); // 经营省
|
|
|
+ request.put("area_id", "441900"); // 经营市
|
|
|
+ request.put("district_id", "440113"); // 经营区
|
|
|
+ request.put("detail_addr", "经营详细地址"); // 经营详细地址
|
|
|
+ request.put("contact_name", "联系人姓名"); // 联系人姓名
|
|
|
+ request.put("contact_mobile_no", "联系人手机号"); // 联系人手机号
|
|
|
+ request.put("contact_email", "联系人电子邮箱"); // 联系人电子邮箱
|
|
|
+ request.put("sms_send_flag", "M"); // 商户名
|
|
|
+ request.put("async_return_url", "异步通知地址"); // 异步通知地址:审核结果消息接收地址
|
|
|
+ request.put("settle_card_front_pic", "结算卡正面"); // 结算卡正面
|
|
|
+ request.put("settle_card_back_pic", "结算卡反面"); // 结算卡反面
|
|
|
+ // 结算卡信息配置
|
|
|
+ JSONObject cardInfo = new JSONObject();
|
|
|
+ cardInfo.put("card_name", "洪序滨"); // 卡户名
|
|
|
+ cardInfo.put("card_no", "6222032010021731588"); // 结算账号
|
|
|
+ cardInfo.put("prov_id", "440000"); // 银行所在省
|
|
|
+ cardInfo.put("area_id", "441900"); // 银行所在市
|
|
|
+ cardInfo.put("cert_type", "00"); // 持卡人证件类型
|
|
|
+ cardInfo.put("cert_no", "440510199712190811"); // 持卡人证件号码
|
|
|
+ cardInfo.put("cert_validity_type", "0"); // 持卡人证件有效期类型,1:长期有效,0:非长期有效;
|
|
|
+ cardInfo.put("cert_begin_date", "20170428"); // 持卡人证件有效期开始
|
|
|
+ cardInfo.put("cert_end_date", "20270428"); // 持卡人证件有效期截止日期
|
|
|
+ cardInfo.put("mp", "15815278034"); // 结算人手机号
|
|
|
+ request.put("card_info", cardInfo);
|
|
|
+ // 结算规则配置
|
|
|
+ JSONObject settleConfig = new JSONObject();
|
|
|
+ settleConfig.put("settle_cycle", "T1"); // 结算周期
|
|
|
+ request.put("settle_config", settleConfig);
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试企业商户信息入驻
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void addFirm() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/basicdata/ent";
|
|
|
+ HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32()); // 请求流水号
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD()); // 请求日期
|
|
|
+ request.put("upper_huifu_id", HuifuConstant.HUIFU_ID); // 上级主体ID
|
|
|
+ request.put("reg_name", "广州申泽智能科技有限公司"); // 商户名称
|
|
|
+ request.put("short_name", "申泽智能"); // 商户简称
|
|
|
+ request.put("ent_type", "3"); // 公司类型
|
|
|
+ request.put("license_code", "91440113MA59B2PW0B"); // 营业执照编号
|
|
|
+ request.put("license_validity_type", "1"); // 营业执照有效期类型,0:非长期有效 ,1:长期有效
|
|
|
+ request.put("license_begin_date", "20151208"); // 营业执照有效期开始日期
|
|
|
+// request.put("license_end_date", "20220125"); // 营业执照有效期截止日期
|
|
|
+ request.put("reg_prov_id", "440000"); // 注册省
|
|
|
+ request.put("reg_area_id", "440100"); // 注册市
|
|
|
+ request.put("reg_district_id", "440113"); // 注册区
|
|
|
+ request.put("reg_detail", "广州市番禺区桥南街蚬涌村联兴路11号501部位01"); // 注册详细地址
|
|
|
+ request.put("legal_name", "朱方频"); // 法人姓名
|
|
|
+ request.put("legal_cert_type", "00"); // 法人证件类型
|
|
|
+ request.put("legal_cert_no", "440225197912020437"); // 法人证件号码
|
|
|
+ request.put("legal_cert_validity_type", "0"); // 法人证件有效期类型,1:长期有效;0:非长期有效 ;
|
|
|
+ request.put("legal_cert_begin_date", "20110311"); // 法人证件有效期开始日期
|
|
|
+ request.put("legal_cert_end_date", "20310311"); // 法人证件有效期截止日期
|
|
|
+ request.put("prov_id", "440000"); // 经营省
|
|
|
+ request.put("area_id", "440100"); // 经营市
|
|
|
+ request.put("district_id", "440113"); // 经营区
|
|
|
+ request.put("detail_addr", "广州市番禺区桥南街蚬涌村联兴路11号501部位01"); // 经营详细地址
|
|
|
+ request.put("contact_name", "朱方频"); // 联系人姓名
|
|
|
+ request.put("contact_mobile_no", "13826453788"); // 联系人手机号
|
|
|
+ request.put("contact_email", "ben@sunzee.com"); // 联系人电子邮箱
|
|
|
+ request.put("service_phone", "02031062206"); // 客服电话
|
|
|
+// request.put("sms_send_flag", "M"); // 商户通知标识
|
|
|
+ request.put("busi_type", "1"); // 经营类型,1:实体,2:虚拟 ;
|
|
|
+ request.put("receipt_name", "广州申泽智能科技有限公司"); // 小票名称
|
|
|
+ request.put("mcc", "6071"); // 所属行业
|
|
|
+ request.put("open_licence_no", "J5810091371903"); // 基本存款账户编号或核准号
|
|
|
+ request.put("reg_acct_pic", "e2e2c13c-8111-3c17-9f9a-f2b4ae17c74a"); // 开户许可证
|
|
|
+ request.put("legal_cert_back_pic", "83a881cf-06f6-3bf4-9dc1-b1edae6d1c8b"); // 法人身份证人像面
|
|
|
+ request.put("legal_cert_front_pic", "02084b83-eb62-3e46-81e1-3c6315e71099"); // 法人身份证国徽面
|
|
|
+ request.put("license_pic", "de325cde-65e7-3bfc-b824-1ab164de742c"); // 营业执照图片
|
|
|
+ request.put("found_date", "20151208"); // 成立时间
|
|
|
+ request.put("legal_mobile_no", "13826453788"); // 法人手机号
|
|
|
+ request.put("legal_addr", "广州市番禺区南华路168号一座一梯1103房"); // 法人身份证地址
|
|
|
+ // 结算卡信息配置
|
|
|
+ JSONObject cardInfo = new JSONObject();
|
|
|
+ cardInfo.put("card_type", "0"); // 结算账户类型
|
|
|
+ cardInfo.put("card_name", "广州申泽智能科技有限公司"); // 卡户名
|
|
|
+ cardInfo.put("card_no", "3602024309200919603"); // 结算账号
|
|
|
+ cardInfo.put("prov_id", "440000"); // 银行所在省
|
|
|
+ cardInfo.put("area_id", "440100"); // 银行所在市
|
|
|
+ cardInfo.put("branch_code", "102581000281"); // 联行号
|
|
|
+ request.put("card_info", cardInfo);
|
|
|
+ // 结算规则配置
|
|
|
+ JSONObject settleConfig = new JSONObject();
|
|
|
+ settleConfig.put("settle_cycle", "T1"); // 结算周期
|
|
|
+ request.put("settle_config", settleConfig);
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试商户基本信息修改
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void modifyMerchant() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/basicdata/modify";
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("upper_huifu_id", HuifuConstant.HUIFU_ID);
|
|
|
+ request.put("huifu_id", "6666000135495540");
|
|
|
+
|
|
|
+ // 取现信息配置
|
|
|
+ JSONObject cardInfo = new JSONObject();
|
|
|
+ cardInfo.put("card_type", "1");
|
|
|
+ cardInfo.put("card_name", "洪序滨");
|
|
|
+ cardInfo.put("card_no", "6222032010021731588");
|
|
|
+ cardInfo.put("prov_id", "440000");
|
|
|
+ cardInfo.put("area_id", "441900");
|
|
|
+ cardInfo.put("cert_type", "00");
|
|
|
+ cardInfo.put("cert_no", "440510199712190811");
|
|
|
+ cardInfo.put("cert_validity_type", "0");
|
|
|
+ cardInfo.put("cert_begin_date", "20170428");
|
|
|
+ cardInfo.put("cert_end_date", "20270428");
|
|
|
+ cardInfo.put("mp", "15815278034");
|
|
|
+ cardInfo.put("settle_card_front_pic", "a2823ff4-63d6-3bf8-a678-56c41a1bad66");
|
|
|
+ cardInfo.put("settle_cert_front_pic", "5eedb03d-2d21-3e0a-b0f5-1777d6b8c416");
|
|
|
+ cardInfo.put("settle_cert_back_pic", "7c3f6ffe-4da8-3493-9b68-f693785eff23");
|
|
|
+ request.put("card_info", cardInfo);
|
|
|
+
|
|
|
+ // 结算规则配置
|
|
|
+ JSONObject settleConfig = new JSONObject();
|
|
|
+ settleConfig.put("settle_status", "1");
|
|
|
+ settleConfig.put("settle_cycle", "T1");
|
|
|
+ request.put("settle_config", settleConfig);
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试商户业务开通
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void open() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/busi/open";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000136120737");
|
|
|
+ request.put("upper_huifu_id", HuifuConstant.HUIFU_ID);
|
|
|
+ request.put("short_name", "申泽智能"); // 微信支付宝商户简称
|
|
|
+ // 支付宝配置
|
|
|
+ ArrayList<Object> aliConfList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("pay_scene","1");
|
|
|
+ jsonObject.put("fee_rate","1.00");
|
|
|
+ jsonObject.put("mcc","6071");
|
|
|
+ aliConfList.add(jsonObject);
|
|
|
+ System.out.println(aliConfList);
|
|
|
+ // 微信配置
|
|
|
+ ArrayList<Object> wxConfList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("pay_scene","1");
|
|
|
+ jsonObject1.put("fee_rate","1.00");
|
|
|
+ jsonObject1.put("mcc","6071");
|
|
|
+ jsonObject1.put("service_codes", "");
|
|
|
+ wxConfList.add(jsonObject1);
|
|
|
+
|
|
|
+ request.put("ali_conf_list",aliConfList.toString());
|
|
|
+ request.put("wx_conf_list",wxConfList.toString());
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试商户业务修改
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void modify() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/busi/modify";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000135495540");
|
|
|
+ request.put("upper_huifu_id", HuifuConstant.HUIFU_ID);
|
|
|
+ request.put("out_fee_flag", "1");
|
|
|
+ request.put("out_fee_huifuid", HuifuConstant.HUIFU_ID);
|
|
|
+ // 支付宝配置
|
|
|
+// JSONObject jsonObject = new JSONObject();
|
|
|
+// jsonObject.put("pay_scene","1");
|
|
|
+// jsonObject.put("fee_rate","1.00");
|
|
|
+// jsonObject.put("mcc","6071");
|
|
|
+// String aliConfList = JSON.toJSONString(jsonObject);
|
|
|
+// System.out.println(aliConfList);
|
|
|
+ // 微信配置
|
|
|
+ ArrayList<Object> wxConfList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("pay_scene","1");
|
|
|
+ jsonObject1.put("fee_rate","1.00");
|
|
|
+ jsonObject1.put("mcc","6071");
|
|
|
+ jsonObject1.put("service_codes", "[\"JSAPI\",\"APPLET\",\"MICROPAY\"]");
|
|
|
+ wxConfList.add(jsonObject1);
|
|
|
+ request.put("wx_conf_list",wxConfList.toString());
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试微信实名认证
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void realname() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/busi/realname";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000136120737");
|
|
|
+ request.put("owner", "Y");
|
|
|
+ request.put("identification_address", "广州市番禺区南华路168号一座一梯1103房");
|
|
|
+ ArrayList<Object> uboInfoList = new ArrayList<>();
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
+ jsonObject1.put("ubo_id_doc_type","00");
|
|
|
+ jsonObject1.put("ubo_id_doc_copy","83a881cf-06f6-3bf4-9dc1-b1edae6d1c8b");
|
|
|
+ jsonObject1.put("ubo_id_doc_copy_back","02084b83-eb62-3e46-81e1-3c6315e71099");
|
|
|
+ jsonObject1.put("ubo_id_doc_name","朱方频");
|
|
|
+ jsonObject1.put("ubo_id_doc_number","440225197912020437");
|
|
|
+ jsonObject1.put("ubo_id_doc_address","广州市番禺区南华路168号一座一梯1103房");
|
|
|
+ jsonObject1.put("ubo_period_begin","20110311");
|
|
|
+ jsonObject1.put("ubo_period_end","20310311");
|
|
|
+ uboInfoList.add(jsonObject1);
|
|
|
+ request.put("ubo_info_list",uboInfoList.toString());
|
|
|
+ request.put("name", "朱方频");
|
|
|
+ request.put("mobile", "13926468029");
|
|
|
+ request.put("id_card_number", "440225197912020437");
|
|
|
+ request.put("contact_type", "LEGAL");
|
|
|
+// request.put("micro_biz_type", "MICRO_TYPE_MOBILE");
|
|
|
+// request.put("store_header_copy", "79bf1e91-108c-3499-b3bb-621ea283be98");
|
|
|
+// request.put("store_indoor_copy", "79bf1e91-108c-3499-b3bb-621ea283be98");
|
|
|
+// request.put("store_name", "申泽棉花糖机器人");
|
|
|
+// request.put("store_address_code", "440000");
|
|
|
+// request.put("store_address", "广州市番禺区桥南街道联兴路11号华深科技园第五层");
|
|
|
+// request.put("identification_front_copy", "7c3f6ffe-4da8-3493-9b68-f693785eff23");
|
|
|
+// request.put("identification_back_copy", "5eedb03d-2d21-3e0a-b0f5-1777d6b8c416");
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试微信商户配置
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void config() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/busi/config";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000135495540");
|
|
|
+ request.put("fee_type", "02");
|
|
|
+ request.put("wx_woa_app_id", appID);
|
|
|
+ request.put("wx_woa_secret", appSecret);
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试商户分账配置
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void separateAccount() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/split/config";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000135495540");
|
|
|
+ request.put("rule_origin", "01");
|
|
|
+ request.put("div_flag", "Y");
|
|
|
+ request.put("apply_ratio", "50.00");
|
|
|
+ request.put("start_type", "0");
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 汇付测试支付宝实名认证
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void apply() throws Exception {
|
|
|
+ // 请求接口
|
|
|
+ String url = "https://api.huifu.com/v2/merchant/busi/ali/realname/apply";
|
|
|
+ // 设置商户参数(全局只需设置一次)
|
|
|
+// HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
|
|
|
+ // 请求参数:Data
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ request.put("huifu_id", "6666000135495540");
|
|
|
+ JSONObject contactPersonInfo = new JSONObject();
|
|
|
+ contactPersonInfo.put("id_card_number", "440510199712190811");
|
|
|
+ JSONObject legalPersonInfo = new JSONObject();
|
|
|
+ legalPersonInfo.put("card_front_img", "7c3f6ffe-4da8-3493-9b68-f693785eff23");
|
|
|
+ legalPersonInfo.put("card_back_img", "5eedb03d-2d21-3e0a-b0f5-1777d6b8c416");
|
|
|
+ JSONObject authIdentityInfo = new JSONObject();
|
|
|
+ authIdentityInfo.put("business_type", "0");
|
|
|
+ authIdentityInfo.put("finance_institution_flag", "N");
|
|
|
+ JSONObject supportCredentials = new JSONObject();
|
|
|
+ supportCredentials.put("micro_biz_type","MICRO_TYPE_MOBILE");
|
|
|
+ supportCredentials.put("store_name", "申泽棉花糖机器人");
|
|
|
+ supportCredentials.put("province_code", "440000");
|
|
|
+ supportCredentials.put("province", "广东省");
|
|
|
+ supportCredentials.put("city_code", "440100");
|
|
|
+ supportCredentials.put("city", "广州市");
|
|
|
+ supportCredentials.put("district_code", "440113");
|
|
|
+ supportCredentials.put("district", "番禺区");
|
|
|
+ supportCredentials.put("store_address", "广州市番禺区桥南街道联兴路11号华深科技园第五层");
|
|
|
+ authIdentityInfo.put("support_credentials", supportCredentials.toString());
|
|
|
+
|
|
|
+ request.put("legal_person_info", legalPersonInfo.toString());
|
|
|
+ request.put("auth_identity_info", authIdentityInfo.toString());
|
|
|
+ request.put("contact_person_info", contactPersonInfo.toString());
|
|
|
+
|
|
|
+
|
|
|
+ // 签名:sign
|
|
|
+ String s = JSON.toJSONString(request);
|
|
|
+ String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
|
|
|
+ String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
|
|
|
+
|
|
|
+ // 公共参数
|
|
|
+ System.out.println("请求参数:"+ request);
|
|
|
+ JSONObject requestData = new JSONObject();
|
|
|
+ requestData.put("sys_id", HuifuConstant.SYS_ID);
|
|
|
+ requestData.put("product_id", HuifuConstant.PRODUCT_ID);
|
|
|
+ requestData.put("sign", sign);
|
|
|
+ requestData.put("data", request);
|
|
|
+ System.out.println("请求体:"+ requestData);
|
|
|
+
|
|
|
+ String success = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
|
|
|
+ System.out.println("返回的数据:"+ success);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 图片上传
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ void picture() throws Exception {
|
|
|
+
|
|
|
+ String url = "https://api.huifu.com/v2/supplementary/picture";
|
|
|
+ // 请求参数
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ // 请求流水号,需保证当天商户下唯一,推荐采用日期时间+几位流水号的形式
|
|
|
+ params.put("req_seq_id", SequenceTools.getReqSeqId32());
|
|
|
+ params.put("req_date", DateTools.getCurrentDateYYYYMMDD());
|
|
|
+ params.put("file_type", HuifuConstant.fileType.F13);
|
|
|
+ params.put("picture", HuifuConstant.fileType.F13.toValue());
|
|
|
+// params.put("huifu_id", "6666000135495540");
|
|
|
+ String data = JSON.toJSONString(params);
|
|
|
+ String localFile = "D:\\Users\\Desktop\\微信图片_20230714173427.jpg";
|
|
|
+ File file = new File(localFile);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CloseableHttpClient httpclient1 = HttpClients.createDefault();
|
|
|
+ CloseableHttpResponse response = null;
|
|
|
+ String result = null;
|
|
|
+
|
|
|
+ try {
|
|
|
+ HttpPost httpPost = new HttpPost(url);
|
|
|
+ ContentType contentType = ContentType.create("text/plain", Charset.forName("UTF-8"));
|
|
|
+ MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create();
|
|
|
+ mEntityBuilder.addTextBody("sys_id", HuifuConstant.SYS_ID, contentType);
|
|
|
+ mEntityBuilder.addTextBody("product_id", HuifuConstant.PRODUCT_ID, contentType);
|
|
|
+ mEntityBuilder.addTextBody("data", data, contentType);
|
|
|
+ mEntityBuilder.addBinaryBody("file", file);
|
|
|
+
|
|
|
+ httpPost.setEntity(mEntityBuilder.build());
|
|
|
+ response = httpclient1.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == HttpStatus.SC_OK) {
|
|
|
+ HttpEntity resEntity = response.getEntity();
|
|
|
+ result = EntityUtils.toString(resEntity);
|
|
|
+ System.out.print(result);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void testNum() throws Exception {
|
|
|
+ String str = "玫瑰精灵x1,童心未泯x1,五彩缤纷x1,天雪恋舞x1,水中芙蓉x1";
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+
|
|
|
+ String[] products = str.split(",");
|
|
|
+ for (String product : products) {
|
|
|
+ String[] parts = product.split("x");
|
|
|
+ String name = parts[0].trim();
|
|
|
+ int quantity = Integer.parseInt(parts[1].trim().replaceAll("[^0-9]", ""));
|
|
|
+ map.put(name, quantity);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 输出Map的键值对
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ System.out.println(key + ": " + map.get(key));
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println(HuifuConstant.fileType.F03);
|
|
|
+ }
|
|
|
|
|
|
}
|