From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/util/charge/FuLuChargeApiUtil.java | 224 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 112 insertions(+), 112 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/charge/FuLuChargeApiUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/charge/FuLuChargeApiUtil.java index d768cd2..9c8fe28 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/charge/FuLuChargeApiUtil.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/charge/FuLuChargeApiUtil.java @@ -1,112 +1,112 @@ -package com.yeshi.fanli.util.charge; - -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.methods.PostMethod; - -import com.yeshi.fanli.exception.shop.FuLuChargeException; -import com.yeshi.fanli.util.StringUtil; -import org.yeshi.utils.TimeUtil; - -import net.sf.json.JSONObject; - -/** - * 绂忓綍寮�鏀惧钩鍙癆PI鍏ュ彛锛坥pen.fulu.com锛� - * - * @author Administrator - * - */ -public class FuLuChargeApiUtil { - // 娌欑 - // private final static String APP_KEY = - // "i4esv1l+76l/7NQCL3QudG90Fq+YgVfFGJAWgT+7qO1Bm9o/adG/1iwO2qXsAXNB"; - // private final static String APP_SECRET = - // "0a091b3aa4324435aab703142518a8f7"; - // 姝e紡 - private final static String APP_KEY = "CrtDnTh1E5eYY5D42T8uArVrl4GWq9AWR9ZrNC2qvXYIBMwOTuiJQy7YYaJSYlb6"; - private final static String APP_SECRET = "a5f6c827903e4b1eac6eb2ba2cf715be"; - - @SuppressWarnings("deprecation") - private static String post(String url, String body) { - HttpClient client = new HttpClient(); - PostMethod method = new PostMethod(url); - method.addRequestHeader("Content-Type", "application/json;charset=UTF-8"); - method.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); - method.setRequestBody(body); - try { - client.executeMethod(method); - return method.getResponseBodyAsString(); - } catch (HttpException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - private static void baseRequest(String method, JSONObject bizContent) throws FuLuChargeException { - // String url = "http://pre.openapi.fulu.com/api/getway"; - String url = "http://openapi.fulu.com/api/getway"; - Map<String, String> params = new HashMap<>(); - params.put("app_key", APP_KEY); - params.put("method", method); - params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); - params.put("version", "2.0"); - params.put("format", "json"); - params.put("charset", "utf-8"); - params.put("sign_type", "md5"); - params.put("app_auth_token", ""); - params.put("biz_content", bizContent.toString()); - JSONObject resultJson = JSONObject.fromObject(params); - char[] s = resultJson.toString().toCharArray(); - Arrays.sort(s); - String outputSignOriginalStr = new String(s) + APP_SECRET; - String sign = StringUtil.Md5(outputSignOriginalStr); - params.put("sign", sign); - String result = post(url, JSONObject.fromObject(params).toString()); - System.out.println(result); - JSONObject json = JSONObject.fromObject(result); - { - if (json.optInt("code") != 0) {// 鎴愬姛 - throw new FuLuChargeException(json.optInt("code"), json.optString("message")); - } else { - } - } - - } - - /** - * 鍏呭�� - * - * @param goodsNo-鍟嗗搧缂栧彿 - * @param orderId-鍟嗘埛璁㈠崟鍙� - * @param account-鏁伴噺 - */ - public static void charge(String goodsNo, String orderId, String account) throws FuLuChargeException { - JSONObject json = new JSONObject(); - json.put("customer_order_no", orderId); - json.put("product_id", goodsNo); - json.put("charge_account", account); - json.put("buy_num", "1"); - baseRequest("fulu.order.direct.add", json); - } - - /** - * 娌欑鍏呭�� - */ - public static void shaXiangCharge(String goodsNo, String orderId, String account) throws FuLuChargeException { - JSONObject json = new JSONObject(); - json.put("charge_type", "鐖卞鑹轰細鍛�"); - json.put("customer_order_no", orderId); - json.put("product_id", "10000586"); - json.put("charge_account", account); - json.put("buy_num", "1"); - baseRequest("fulu.order.direct.add", json); - } - -} +package com.yeshi.fanli.util.charge; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.methods.PostMethod; + +import com.yeshi.fanli.exception.shop.FuLuChargeException; +import com.yeshi.fanli.util.StringUtil; +import org.yeshi.utils.TimeUtil; + +import net.sf.json.JSONObject; + +/** + * 绂忓綍寮�鏀惧钩鍙癆PI鍏ュ彛锛坥pen.fulu.com锛� + * + * @author Administrator + * + */ +public class FuLuChargeApiUtil { + // 娌欑 + // private final static String APP_KEY = + // "i4esv1l+76l/7NQCL3QudG90Fq+YgVfFGJAWgT+7qO1Bm9o/adG/1iwO2qXsAXNB"; + // private final static String APP_SECRET = + // "0a091b3aa4324435aab703142518a8f7"; + // 姝e紡 + private final static String APP_KEY = "CrtDnTh1E5eYY5D42T8uArVrl4GWq9AWR9ZrNC2qvXYIBMwOTuiJQy7YYaJSYlb6"; + private final static String APP_SECRET = "a5f6c827903e4b1eac6eb2ba2cf715be"; + + @SuppressWarnings("deprecation") + private static String post(String url, String body) { + HttpClient client = new HttpClient(); + PostMethod method = new PostMethod(url); + method.addRequestHeader("Content-Type", "application/json;charset=UTF-8"); + method.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + method.setRequestBody(body); + try { + client.executeMethod(method); + return method.getResponseBodyAsString(); + } catch (HttpException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + private static void baseRequest(String method, JSONObject bizContent) throws FuLuChargeException { + // String url = "http://pre.openapi.fulu.com/api/getway"; + String url = "http://openapi.fulu.com/api/getway"; + Map<String, String> params = new HashMap<>(); + params.put("app_key", APP_KEY); + params.put("method", method); + params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); + params.put("version", "2.0"); + params.put("format", "json"); + params.put("charset", "utf-8"); + params.put("sign_type", "md5"); + params.put("app_auth_token", ""); + params.put("biz_content", bizContent.toString()); + JSONObject resultJson = JSONObject.fromObject(params); + char[] s = resultJson.toString().toCharArray(); + Arrays.sort(s); + String outputSignOriginalStr = new String(s) + APP_SECRET; + String sign = StringUtil.Md5(outputSignOriginalStr); + params.put("sign", sign); + String result = post(url, JSONObject.fromObject(params).toString()); + System.out.println(result); + JSONObject json = JSONObject.fromObject(result); + { + if (json.optInt("code") != 0) {// 鎴愬姛 + throw new FuLuChargeException(json.optInt("code"), json.optString("message")); + } else { + } + } + + } + + /** + * 鍏呭�� + * + * @param goodsNo-鍟嗗搧缂栧彿 + * @param orderId-鍟嗘埛璁㈠崟鍙� + * @param account-鏁伴噺 + */ + public static void charge(String goodsNo, String orderId, String account) throws FuLuChargeException { + JSONObject json = new JSONObject(); + json.put("customer_order_no", orderId); + json.put("product_id", goodsNo); + json.put("charge_account", account); + json.put("buy_num", "1"); + baseRequest("fulu.order.direct.add", json); + } + + /** + * 娌欑鍏呭�� + */ + public static void shaXiangCharge(String goodsNo, String orderId, String account) throws FuLuChargeException { + JSONObject json = new JSONObject(); + json.put("charge_type", "鐖卞鑹轰細鍛�"); + json.put("customer_order_no", orderId); + json.put("product_id", "10000586"); + json.put("charge_account", account); + json.put("buy_num", "1"); + baseRequest("fulu.order.direct.add", json); + } + +} -- Gitblit v1.8.0