加入erp

This commit is contained in:
Leo
2025-04-10 19:29:47 +08:00
parent f8e189c5f4
commit ec5a50ca35
36 changed files with 1103 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
//package cn.van.business.erp.request;
//
///**
// * @author Leo
// * @version 1.0
// * @create 2025/4/10 15:20
// * @descriptionERP账户枚举类
// */
//public enum ERPAccount {
// // 胡歌
// ACCOUNT_HUGE("1016208368633221", "waLiRMgFcixLbcLjUSSwo370Hp1nBcBu"),
// // 刘强东
// ACCOUNT_LQD("anotherApiKey", "anotherApiSecret");
//
// private final String apiKey;
// private final String apiKeySecret;
//
// ERPAccount(String apiKey, String apiKeySecret) {
// this.apiKey = apiKey;
// this.apiKeySecret = apiKeySecret;
// }
//
// public String getApiKey() {
// return apiKey;
// }
//
// public String getApiKeySecret() {
// return apiKeySecret;
// }
//}
//

View File

@@ -0,0 +1,20 @@
//package cn.van.business.erp.request;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//public class ProductQueryRequest extends ERPRequestBase {
// public ProductQueryRequest(String url, ERPAccount erpAccount, ApifoxModel requestBody) {
// super(url, erpAccount, requestBody);
// }
//
// @Override
// public String getRequestBodyAsString() {
// try {
// ObjectMapper objectMapper = new ObjectMapper();
// return objectMapper.writeValueAsString(requestBody);
// } catch (JsonProcessingException e) {
// throw new RuntimeException("Failed to convert request body to JSON", e);
// }
// }
//}

View File

@@ -0,0 +1,49 @@
//package cn.van.business.erp.request;
//
//import com.fasterxml.jackson.core.JsonProcessingException;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import java.nio.charset.StandardCharsets;
//import java.security.MessageDigest;
//import java.security.NoSuchAlgorithmException;
//
//public abstract class ERPRequestBase {
// protected final String url;
// protected final ERPAccount erpAccount;
// protected final Object requestBody;
//
// public ERPRequestBase(String url, ERPAccount erpAccount, Object requestBody) {
// this.url = url;
// this.erpAccount = erpAccount;
// this.requestBody = requestBody;
// }
//
// public String getUrl() {
// return url;
// }
//
// public ERPAccount getErpAccount() {
// return erpAccount;
// }
//
// public abstract String getRequestBodyAsString();
//
// protected String genMd5(String str) {
// StringBuilder result = new StringBuilder();
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
// for (byte b : digest) {
// result.append(String.format("%02x", b & 0xff));
// }
// } catch (NoSuchAlgorithmException e) {
// throw new RuntimeException(e);
// }
// return result.toString();
// }
//
// protected String genSign(long timestamp, String jsonStr) {
// String data = erpAccount.getApiKey() + "," + genMd5(jsonStr) + "," + timestamp + "," + erpAccount.getApiKeySecret();
// return genMd5(data);
// }
//}

View File

@@ -0,0 +1,111 @@
//package cn.van.business.erp.request;
//
///**
// * @author Leo
// * @version 1.0
// * @create 2025/4/9 21:30
// * @description
// */
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.OutputStream;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.nio.charset.StandardCharsets;
//import java.security.MessageDigest;
//import java.security.NoSuchAlgorithmException;
//
//public class HttpTest {
// private static long apiKey = 203413189371893L; // 开放平台提供的应用KEY
// private static String apiKeySecret = "o9wl81dncmvby3ijpq7eur456zhgtaxs"; // 开放平台提供的应用密钥
// private static String domain = "https://open.goofish.pro"; // 域名
//
// public static void main(String[] args) {
// // 获取当前时间戳
// long timestamp = System.currentTimeMillis() / 1000L;
//
// // 请求体JSON字符串
// String productId = "220656347074629";
// String jsonBody = "{\"product_id\":" + productId + "}";
//
// // 生成签名
// String sign = genSign(timestamp, jsonBody);
//
// // 拼接请求地址
// String apiUrl = domain + "/api/open/product/detail?appid=" + apiKey + "&timestamp=" + timestamp + "&sign="
// + sign;
//
// try {
// // 创建URL对象
// URL url = new URL(apiUrl);
//
// // 打开连接
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//
// // 设置请求方法为POST
// connection.setRequestMethod("POST");
//
// // 设置请求头部
// connection.setRequestProperty("Content-Type", "application/json");
// connection.setRequestProperty("Accept", "application/json");
//
// // 启用输出流
// connection.setDoOutput(true);
//
// // 获取输出流并写入请求体
// OutputStream outputStream = connection.getOutputStream();
// outputStream.write(jsonBody.getBytes(StandardCharsets.UTF_8));
// outputStream.close();
//
// // 获取响应状态码
// int responseCode = connection.getResponseCode();
// System.out.println("API Response Code: " + responseCode);
//
// // 读取响应内容
// BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
// String line;
// StringBuilder response = new StringBuilder();
// while ((line = bufferedReader.readLine()) != null) {
// response.append(line);
// }
// bufferedReader.close();
//
// // 关闭连接
// connection.disconnect();
//
// System.out.println("API Response: " + response.toString());
//
// } catch (IOException e) {
// // 在此处处理异常
// e.printStackTrace();
// }
// }
//
// // md5加密
// private static String genMd5(String str) {
// StringBuilder result = new StringBuilder();
// try {
// MessageDigest md = MessageDigest.getInstance("MD5");
// byte[] digest = md.digest(str.getBytes(StandardCharsets.UTF_8));
// for (byte b : digest) {
// result.append(String.format("%02x", b & 0xff));
// }
// } catch (NoSuchAlgorithmException e) {
// throw new RuntimeException(e);
// }
// return result.toString();
// }
//
// // 生成签名
// private static String genSign(long timestamp, String jsonStr) {
// // 拼接字符串
// String data = apiKey + "," + genMd5(jsonStr) + "," + timestamp + "," + apiKeySecret;
//
// // 商务对接模式 拼接字符串
// // String data = apiKey + "," + genMd5(jsonStr) + "," + timestamp + "," + seller_id + "," + apiKeySecret;
//
// // 生成签名
// return genMd5(data);
// }
//}