From 1e12b2abcaa1bdbdb57d3694446337126168bef1 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期五, 28 三月 2025 19:15:08 +0800 Subject: [PATCH] bug修改 --- xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/utils/JuHeFuUtil.java | 179 +++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 147 insertions(+), 32 deletions(-) diff --git a/xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/utils/JuHeFuUtil.java b/xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/utils/JuHeFuUtil.java index e872aee..cbde3c3 100644 --- a/xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/utils/JuHeFuUtil.java +++ b/xinquan-common/xinquan-common-core/src/main/java/com/xinquan/common/core/utils/JuHeFuUtil.java @@ -1,10 +1,13 @@ package com.xinquan.common.core.utils; +import cn.hutool.core.util.RandomUtil; import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.obs.services.IFSClient; import com.xinquan.common.core.domain.R; import com.xinquan.common.core.exception.ServiceException; @@ -12,10 +15,8 @@ import java.security.PrivateKey; import java.security.Signature; import java.security.spec.PKCS8EncodedKeySpec; -import java.util.Base64; -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; +import java.text.SimpleDateFormat; +import java.util.*; import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID; import org.slf4j.Logger; @@ -65,6 +66,7 @@ private static final String BALANCE_QUERY_INTERFACE = "/api/member/balance_query_a"; private static final String BALANCE_WITHDRAW_INTERFACE = "/api/member/balance_withdraw_a"; private static final String BALANCE_PAY = "/api/account/balance_pay"; + private static final String WITHDRAW_LIST = "/api/query/query_user_withdraw_list"; // 创建支付订单 private static final String CREATE_PAYMENT_INTERFACE = "/api/payment/create_payment"; private static final String CREATE_PAYMENT_INTERFACE_CODE = "/api/payment/create_payment_qrcode"; @@ -73,6 +75,8 @@ private static final String PAYMENT_REFUND_INTERFACE = "/api/payment/payment_refund"; private static final String QUERY_PAYMENT_INTERFACE = "/api/query/query_payment"; private static final String MERCHANT_PAY_INTERFACE = "/api/account/merchant_pay"; + // 查询用户列表 + private static final String QUERY_USER_LIST = "/api/query/query_user_list"; // 接口地址 TODO private static final String BASE_URL = "https://payapi.juhefu.com/"; // 支付宝支付渠道 @@ -82,7 +86,93 @@ private static final String PAY_CHANNEL_WECHAT_THiRD = "wx"; // 微信小程序id TODO private static final String WX_APP_ID = ""; + public static void main(String[] args) throws Exception { +// createPayment1("CZ192818331231230901", 1, "0.01", +// "充值", "充值", +// "127.0.0.1", "o4Q_v6QMqkcO7kIOOxp-x1-UpOww", +// "https://xq.xqzhihui.com/api/order/client/order/order/base/callback") +//// "https://xq.xqzhihui.com/api/order/client/order/order/base/callback") +// ; +// String orderNo = OrderUtil.getOrderNoForPrefix("User"); +// long time = new Date().getTime(); +// String s = RandomUtil.randomNumbers(4); +// String s1 = "FZ" + time + s; +// System.err.println(s1); + createUser("1","董国庆","00" + ,"511602199910018718" + ,"18224358736" + ,"6230520460328218072"); +// updateAccount("FZ17403857003793677","邱仕珍","13682696011" +// ,"4367427200563236884"); +// updateAccount("FZ17430446395934603","刘晓梅","18186305036" +// ,"6215591804000544393"); +// balancePay("CZ09809217341", "FZ17343419268427877","0.01", ""); +// queryBalance("FZ17343419268427877"); +// String decrypt = decrypt("z8Che/JwxrGj/oTOuAvU8HFN6vXL/OqeioV41ZuPV/xVQPt9vCHHc1R5LgAO51Hq5ilD9wqsminRvSiJj6Fs/Bfk8espZSOO2g1OE7FZyqcLB1w01MSWyxfQT8nc2GH/EfOKXCuaKBCeyW24OvW3ng=="); +// System.err.println(decrypt); +// balanceWithdraw("TX1000928371648172","0.01","FZ17343419268427877","https://xq.xqzhihui.com/api/user/client/app-user-withdraw/base/callbackA"); + queryUserList("420881198207202109"); +// queryBalanceList("FZ17430701653874185"); +// queryPayment("002212025032410341110750073154527547392"); + } + public static String queryUserList(String identifier) + throws Exception { + JSONObject data = new JSONObject(); +// data.put("app_id", APP_ID); + data.put("app_id", "app_e7301b75-19f1-40e5-96ac-0fee847d4da0"); + data.put("member_type", "01"); + data.put("identifier", identifier); + data.put("page_index", "1"); + data.put("page_size", "10"); + JSONObject body = new JSONObject(); + body.put("merId", "1120241105365033"); + body.put("sign", sign(JSONObject.toJSONString(data))); +// body.put("reqCipher", +// EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); + body.put("reqCipher", + EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), "6d548eb01bad44bbbb4a23743e733103")); + body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); + System.err.println(body); +// String result = sendPost(BASE_URL + CREATE_USER_INTERFACE, body); + String result = sendPost("https://payapi.juhefu.com/" + QUERY_USER_LIST, body); + JSONObject resJsonObject = JSONObject.parseObject(result); + System.err.println(resJsonObject); + if (resJsonObject.get("error_msg")!=null){ + return resJsonObject.getString("error_msg"); + } + String string = resJsonObject.getString("resCipher"); + String decrypt = decrypt(string); + System.err.println(decrypt); + JSONObject jsonObject = JSONObject.parseObject(decrypt); + System.err.println(jsonObject); + if (jsonObject!=null){ + JSONArray data1 = jsonObject.getJSONArray("data"); + if(data1==null){ + return null; + }else{ + for (Object o : data1) { + // 将Object转化为jsonObject + JSONObject jsonObject1 = (JSONObject) o; + if(jsonObject1!=null){ + String fzId = jsonObject1.getString("member_id"); + String sfz = jsonObject1.getString("identifier"); + if (org.springframework.util.StringUtils.hasLength(fzId)&&org.springframework.util.StringUtils.hasLength(sfz)){ + if (sfz.equals(identifier)){ + return fzId; + } + }else{ + return null; + } + }else{ + return null; + } + } + return null; + } + } + return null; + } /** * 创建用户 * @@ -130,16 +220,21 @@ // String result = sendPost(BASE_URL + CREATE_USER_INTERFACE, body); String result = sendPost("https://payapi.juhefu.com/" + CREATE_USER_INTERFACE, body); JSONObject resJsonObject = JSONObject.parseObject(result); + if (org.springframework.util.StringUtils.hasLength(resJsonObject.getString("error_msg"))){ + return resJsonObject.getString("error_msg"); + } System.err.println(resJsonObject); - String string = resJsonObject.getString("reqCipher"); + String string = resJsonObject.getString("resCipher"); String decrypt = decrypt(string); System.err.println(decrypt); JSONObject jsonObject = JSONObject.parseObject(decrypt); - if (resJsonObject.get("error_msg")!=null){ + if (jsonObject.get("error_msg")!=null){ + System.err.println("添加银行卡失败没有获取到分账id"+resJsonObject.get("error_msg")); return resJsonObject.getString("error_msg"); } return "success"; } + public static String updateAccount( String memberId ,String username @@ -156,6 +251,7 @@ data.put("card_id", cardId); data.put("card_name", username); data.put("tel_no", telNo); + data.put("bank_acct_type", "2"); JSONObject body = new JSONObject(); // body.put("merId", MER_ID); body.put("merId", "1120241105365033"); @@ -171,9 +267,12 @@ JSONObject resJsonObject = JSONObject.parseObject(result); System.err.println(resJsonObject); if (resJsonObject.get("error_msg")!=null){ + if (resJsonObject.getString("error_msg").contains("无需更新")){ + return "success"; + } return resJsonObject.getString("error_msg"); } - String string = resJsonObject.getString("reqCipher"); + String string = resJsonObject.getString("resCipher"); String decrypt = decrypt(string); if (decrypt==null){ return "false"+"发生未知异常(应该是银行卡信息和持卡人信息不一致 但是第三方没有返回准确的错误信息 这里统一返回为银行卡信息或持卡人信息有误)"; @@ -193,9 +292,8 @@ JSONObject data = new JSONObject(); // data.put("app_id", APP_ID); - data.put("app_id", "app_e7301b75-19f1-40e5-96ac-0fee847d4da0"); + data.put("app_id", APP_ID); data.put("member_id", memberId); - data.put("member_type", "01"); JSONObject body = new JSONObject(); // body.put("merId", MER_ID); body.put("merId", "1120241105365033"); @@ -220,33 +318,48 @@ System.err.println(jsonObject); return "success"; } + public static String queryBalanceList(String member_id) + throws Exception { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + Date date = new Date(); + String format = simpleDateFormat.format(date); + date.setDate(date.getDate()-10); + String format1 = simpleDateFormat.format(date); - public static void main(String[] args) throws Exception { -// createPayment1("CZ192818331231230901", 1, "0.01", -// "充值", "充值", -// "127.0.0.1", "o4Q_v6QMqkcO7kIOOxp-x1-UpOww", -// "https://xq.xqzhihui.com/api/order/client/order/order/base/callback") -//// "https://xq.xqzhihui.com/api/order/client/order/order/base/callback") -// ; -// String orderNo = OrderUtil.getOrderNoForPrefix("User"); -// createUser("test945622121","周帅","00" -// ,"513902200006257079" -// ,"19983174515" -// ,"6228480469852935177"); -// updateAccount("test945622121","周帅","19983174515" -// ,"6228480469852935177"); - updateAccount("test945622121","周帅","19983174515" - ,"6228480469852935177"); -// queryBalance("test945622121"); -// balancePay("PAY100388123123", "test945622121","0.05", ""); -// String decrypt = decrypt("z8Che/JwxrGj/oTOuAvU8HFN6vXL/OqeioV41ZuPV/xVQPt9vCHHc1R5LgAO51Hq5ilD9wqsminRvSiJj6Fs/Bfk8espZSOO2g1OE7FZyqcLB1w01MSWyxfQT8nc2GH/EfOKXCuaKBCeyW24OvW3ng=="); -// System.err.println(decrypt); -// balanceWithdraw("TX98633336569","0.05","test945622121","https://xq.xqzhihui.com/api/user/client/app-user-withdraw/base/callbackA"); + JSONObject data = new JSONObject(); +// data.put("app_id", APP_ID); + data.put("start_date", format1); + data.put("end_date", format); + data.put("page_index", "01"); + data.put("page_size", "10"); + data.put("member_id", member_id); + JSONObject body = new JSONObject(); +// body.put("merId", MER_ID); + body.put("merId", "1120241105365033"); + body.put("sign", sign(JSONObject.toJSONString(data))); +// body.put("reqCipher", +// EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), AES_KEY)); + body.put("reqCipher", + EncryptUtils.aes256ECBPkcs7PaddingEncrypt(JSONObject.toJSONString(data), "6d548eb01bad44bbbb4a23743e733103")); + body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); + System.err.println(body); +// String result = sendPost(BASE_URL + CREATE_USER_INTERFACE, body); + String result = sendPost("https://payapi.juhefu.com/" + WITHDRAW_LIST, body); + JSONObject resJsonObject = JSONObject.parseObject(result); + if (resJsonObject.get("error_msg")!=null){ + return resJsonObject.getString("error_msg"); + } + String string = resJsonObject.getString("resCipher"); + String decrypt = decrypt(string); + JSONObject jsonObject = JSONObject.parseObject(decrypt); + System.err.println(jsonObject); + return "success"; } + + public static JSONObject balancePay(String orderNo, String memberId, String payAmt, String notifyUrl) throws Exception { JSONObject data = new JSONObject(); - data.put("order_no", orderNo); data.put("app_id", APP_ID); data.put("pay_amt", payAmt); @@ -267,6 +380,7 @@ String string = resJsonObject.getString("resCipher"); String decrypt = decrypt(string); JSONObject jsonObject = JSONObject.parseObject(decrypt); + System.err.println("转账到用户余额"+jsonObject); return jsonObject; } public static JSONObject balanceWithdraw(String orderNo,String payAmt, String memberId,String notifyUrl) throws Exception { @@ -284,13 +398,14 @@ body.put("reqTime", DateUtils.dateTimeNow("yyyyMMddHHmmsssss")); String result = sendPost(BASE_URL + BALANCE_WITHDRAW_INTERFACE, body); JSONObject resJsonObject = JSONObject.parseObject(result); - System.err.println(resJsonObject); + System.err.println("提现返回参数---未解签"+resJsonObject); if (resJsonObject.getString("error_msg")!=null){ return resJsonObject; } String string = resJsonObject.getString("resCipher"); String decrypt = decrypt(string); JSONObject jsonObject = JSONObject.parseObject(decrypt); + System.err.println("提现返回的响应结果"+jsonObject); return jsonObject; } -- Gitblit v1.7.1