Pre Merge pull request !420 from dianwp/dev
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
## 平台的简介
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
|
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
|
||||||
</p>
|
</p>
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package com.ruoyi;
|
package com.ruoyi;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
@ -12,10 +19,12 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
|||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
|
//private static final Log logger = LogFactory.getLog(MethodHandles.lookup().lookupClass());
|
||||||
|
private static final Logger syslog = LoggerFactory.getLogger(RuoYiApplication.class);
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
SpringApplication.run(RuoYiApplication.class, args);
|
ApplicationContext appc = SpringApplication.run(RuoYiApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
" .-------. ____ __ \n" +
|
" .-------. ____ __ \n" +
|
||||||
" | _ _ \\ \\ \\ / / \n" +
|
" | _ _ \\ \\ \\ / / \n" +
|
||||||
@ -26,5 +35,21 @@ public class RuoYiApplication
|
|||||||
" | | \\ `' /| `-' / \n" +
|
" | | \\ `' /| `-' / \n" +
|
||||||
" | | \\ / \\ / \n" +
|
" | | \\ / \\ / \n" +
|
||||||
" ''-' `'-' `-..-' ");
|
" ''-' `'-' `-..-' ");
|
||||||
|
|
||||||
|
// 打印应用启动环境信息
|
||||||
|
Environment env = appc.getEnvironment();
|
||||||
|
String ip = "localhost";
|
||||||
|
try {
|
||||||
|
ip = InetAddress.getLocalHost().getHostAddress();
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
syslog.info("\n----------------------------------------------------------\n\t" +
|
||||||
|
"Application '{}' is running! Access URLs:\n\t" +
|
||||||
|
"Local: \t\thttp://{}:{}\n\t" +
|
||||||
|
"----------------------------------------------------------",
|
||||||
|
env.getProperty("spring.profiles.active"),ip,
|
||||||
|
env.getProperty("server.port"));
|
||||||
|
syslog.info("程序启动完成!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
133
ruoyi-admin/src/main/java/com/ruoyi/common/utils/ShopAuth.java
Normal file
133
ruoyi-admin/src/main/java/com/ruoyi/common/utils/ShopAuth.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ruoyi.common.core.text.CharsetKit;
|
||||||
|
|
||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author libiao
|
||||||
|
* @version 1.0
|
||||||
|
* @Description: 虾皮2.0授权工具类
|
||||||
|
* @date 2021/10/24 21:12
|
||||||
|
**/
|
||||||
|
public class ShopAuth {
|
||||||
|
public static final String AUTH_SIGN_METHOD = "HmacSHA256";
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 虾皮测试环境
|
||||||
|
String host = "https://partner.test-stable.shopeemobile.com";
|
||||||
|
String path = "/api/v2/shop/auth_partner";
|
||||||
|
//TODO 回跳到花生壳内网地址(转发到8080端口),需要补充URI
|
||||||
|
String redirect_url = "http://4v4c570155.zicp.vip:47393/swagger-ui/index.html";
|
||||||
|
// edterp 的 测试 Partner
|
||||||
|
long partner_id = 1002192L;
|
||||||
|
String partner_key = "8e8618dbb99923b4b298517d263b0b45df02a2ef8341d512539bdbacc76b0bb1";
|
||||||
|
String authUrl = calculateShopAuthUrl(host, path, redirect_url, partner_id, partner_key);
|
||||||
|
System.out.println(authUrl);
|
||||||
|
|
||||||
|
getTokenShopLevel("code123",partner_id,partner_key,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 虾皮店铺授权链接生成
|
||||||
|
* 1.拼接基础字符串,api path + partner_id + api path + timestamp
|
||||||
|
* 2.基于基础字符串计算签名
|
||||||
|
* @Author: libiao
|
||||||
|
* @Date: 2021/10/24 21:56
|
||||||
|
* @param host: 虾皮地址
|
||||||
|
* @param path: 虾皮授权接口路径(授权:"/api/v2/shop/auth_partner",取消授权:"/api/v2/shop/cancel_auth_partner")
|
||||||
|
* @param redirect_url: 授权成功后跳转地址,ERP的地址
|
||||||
|
* @param partner_id: 开发者账号id
|
||||||
|
* @param partner_key: 开发者账号key
|
||||||
|
* @return: java.lang.String 授权链接
|
||||||
|
**/
|
||||||
|
public static String calculateShopAuthUrl(String host, String path, String redirect_url, long partner_id, String partner_key) {
|
||||||
|
long timestamp = System.currentTimeMillis() / 1000L;
|
||||||
|
String tmp_base_string = String.format("%s%s%s", partner_id, path, timestamp);
|
||||||
|
byte[] partner_key_bytes;
|
||||||
|
byte[] base_string_bytes;
|
||||||
|
// 计算加密签名
|
||||||
|
BigInteger sign = null;
|
||||||
|
String sign_str = "";
|
||||||
|
try {
|
||||||
|
partner_key_bytes = partner_key.getBytes(CharsetKit.CHARSET_UTF_8);
|
||||||
|
base_string_bytes = tmp_base_string.getBytes(CharsetKit.CHARSET_UTF_8);
|
||||||
|
Mac mac = Mac.getInstance("HmacSHA256"); //"HmacSHA256"
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(partner_key_bytes, "HmacSHA256");
|
||||||
|
mac.init(secretKeySpec);
|
||||||
|
//sign = new BigInteger(mac.doFinal(base_string_bytes));
|
||||||
|
byte[] sign_bytes = mac.doFinal(base_string_bytes);
|
||||||
|
sign_str = byteArrayToHexString(sign_bytes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 拼接授权url
|
||||||
|
//String url = host + path + String.format("?partner_id=%s×tamp=%s&sign=%032x&redirect=%s", partner_id, timestamp, sign, redirect_url);
|
||||||
|
String url = host + path + String.format("?partner_id=%s×tamp=%s&sign=%s&redirect=%s", partner_id, timestamp, sign_str, redirect_url);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 获取店铺级别接口鉴权access_token refresh_token
|
||||||
|
* @Author: libiao
|
||||||
|
* @Date: 2021/11/3 21:16
|
||||||
|
* @param code: 店铺授权成功后返回的
|
||||||
|
* @param partner_id: 开发者账号id
|
||||||
|
* @param partner_key: 开发者账号key
|
||||||
|
* @param shop_id: 店铺id(店铺授权成功后也会返回)
|
||||||
|
* @return: void
|
||||||
|
**/
|
||||||
|
public static void getTokenShopLevel(String code, long partner_id, String partner_key, String shop_id){
|
||||||
|
long timestamp = System.currentTimeMillis()/1000L;
|
||||||
|
JSONObject body = new JSONObject();
|
||||||
|
body.put("code",code);
|
||||||
|
body.put("shop_id",shop_id);
|
||||||
|
body.put("partner_id", partner_id);
|
||||||
|
|
||||||
|
//String host = "https://partner.shopeemobile.com/api/v2/auth/token/get";
|
||||||
|
String host = "https://partner.test-stable.shopeemobile.com";
|
||||||
|
String path = "/api/v2/auth/token/get";
|
||||||
|
String tmp_base_string = String.format("%s%s%s",partner_id,path,timestamp);
|
||||||
|
|
||||||
|
byte[] partner_key_bytes;
|
||||||
|
byte[] base_string_bytes;
|
||||||
|
|
||||||
|
String sign = null;
|
||||||
|
try {
|
||||||
|
partner_key_bytes = partner_key.getBytes("UTF-8");
|
||||||
|
base_string_bytes = tmp_base_string.getBytes("UTF-8");
|
||||||
|
Mac mac = Mac.getInstance(AUTH_SIGN_METHOD); //"HmacSHA256"
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(partner_key_bytes,AUTH_SIGN_METHOD);
|
||||||
|
mac.init(secretKeySpec);
|
||||||
|
byte[] sign_bytes = mac.doFinal(base_string_bytes);
|
||||||
|
sign = byteArrayToHexString(sign_bytes);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 拼接授权url
|
||||||
|
String url = host + path + String.format("?partner_id=%s×tamp=%s&sign=%s",partner_id,timestamp,sign);
|
||||||
|
// TODO http请求获取access_token和refresh_token
|
||||||
|
System.out.println(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将加密后的字节数组转换成字符串
|
||||||
|
*
|
||||||
|
* @param b 字节数组
|
||||||
|
* @return 字符串
|
||||||
|
*/
|
||||||
|
public static String byteArrayToHexString(byte[] b) {
|
||||||
|
StringBuilder hs = new StringBuilder();
|
||||||
|
String stmp;
|
||||||
|
for (int n = 0; b!=null && n < b.length; n++) {
|
||||||
|
stmp = Integer.toHexString(b[n] & 0XFF);
|
||||||
|
if (stmp.length() == 1)
|
||||||
|
hs.append('0');
|
||||||
|
hs.append(stmp);
|
||||||
|
}
|
||||||
|
return hs.toString().toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
85
ruoyi-admin/src/main/java/com/ruoyi/common/utils/Test.java
Normal file
85
ruoyi-admin/src/main/java/com/ruoyi/common/utils/Test.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.text.CharsetKit;
|
||||||
|
|
||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author libiao
|
||||||
|
* @version 1.0
|
||||||
|
* @Description: TODO
|
||||||
|
* @date 2021/11/3 21:48
|
||||||
|
**/
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 虾皮测试环境
|
||||||
|
String host = "https://partner.test-stable.shopeemobile.com";
|
||||||
|
String path = "/api/v2/shop/auth_partner";
|
||||||
|
//TODO 回跳到花生壳内网地址(转发到8080端口),需要补充URI
|
||||||
|
String redirect_url = "http://4v4c570155.zicp.vip:47393";
|
||||||
|
// edterp 的 测试 Partner
|
||||||
|
long partner_id = 1002192;
|
||||||
|
String partner_key = "8e8618dbb99923b4b298517d263b0b45df02a2ef8341d512539bdbacc76b0bb1";
|
||||||
|
String authUrl = calculateShopAuthUrl(host, path, redirect_url, partner_id, partner_key);
|
||||||
|
System.out.println(authUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 虾皮店铺授权链接生成
|
||||||
|
* 1.拼接基础字符串,api path + partner_id + api path + timestamp
|
||||||
|
* 2.基于基础字符串计算签名
|
||||||
|
* @Author: libiao
|
||||||
|
* @Date: 2021/10/24 21:56
|
||||||
|
* @param host: 虾皮地址
|
||||||
|
* @param path: 虾皮授权接口路径(授权:"/api/v2/shop/auth_partner",取消授权:"/api/v2/shop/cancel_auth_partner")
|
||||||
|
* @param redirect_url: 授权成功后跳转地址
|
||||||
|
* @param partner_id: 开发者账号id
|
||||||
|
* @param partner_key: 开发者账号key
|
||||||
|
* @return: java.lang.String 授权链接
|
||||||
|
**/
|
||||||
|
public static String calculateShopAuthUrl(String host, String path, String redirect_url, long partner_id, String partner_key) {
|
||||||
|
long timestamp = System.currentTimeMillis() / 1000L;
|
||||||
|
String tmp_base_string = String.format("%s%s%s", partner_id, path, timestamp);
|
||||||
|
byte[] partner_key_bytes;
|
||||||
|
byte[] base_string_bytes;
|
||||||
|
// 计算加密签名
|
||||||
|
BigInteger sign = null;
|
||||||
|
String sign_str = "";
|
||||||
|
try {
|
||||||
|
partner_key_bytes = partner_key.getBytes(CharsetKit.CHARSET_UTF_8);
|
||||||
|
base_string_bytes = tmp_base_string.getBytes(CharsetKit.CHARSET_UTF_8);
|
||||||
|
Mac mac = Mac.getInstance("HmacSHA256"); //"HmacSHA256"
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(partner_key_bytes, "HmacSHA256");
|
||||||
|
mac.init(secretKeySpec);
|
||||||
|
//sign = new BigInteger(mac.doFinal(base_string_bytes));
|
||||||
|
byte[] sign_bytes = mac.doFinal(base_string_bytes);
|
||||||
|
sign_str = byteArrayToHexString(sign_bytes);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 拼接授权url
|
||||||
|
//String url = host + path + String.format("?partner_id=%s×tamp=%s&sign=%032x&redirect=%s", partner_id, timestamp, sign, redirect_url);
|
||||||
|
String url = host + path + String.format("?partner_id=%s×tamp=%s&sign=%s&redirect=%s", partner_id, timestamp, sign_str, redirect_url);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将加密后的字节数组转换成字符串
|
||||||
|
*
|
||||||
|
* @param b 字节数组
|
||||||
|
* @return 字符串
|
||||||
|
*/
|
||||||
|
public static String byteArrayToHexString(byte[] b) {
|
||||||
|
StringBuilder hs = new StringBuilder();
|
||||||
|
String stmp;
|
||||||
|
for (int n = 0; b!=null && n < b.length; n++) {
|
||||||
|
stmp = Integer.toHexString(b[n] & 0XFF);
|
||||||
|
if (stmp.length() == 1)
|
||||||
|
hs.append('0');
|
||||||
|
hs.append(stmp);
|
||||||
|
}
|
||||||
|
return hs.toString().toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
@ -6,9 +6,9 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
# 主库数据源
|
# 主库数据源
|
||||||
master:
|
master:
|
||||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
url: jdbc:mysql://localhost:3306/shopee_erp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||||
username: root
|
username: shopee_erp
|
||||||
password: password
|
password: shopee_erp123
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
slave:
|
slave:
|
||||||
# 从数据源开关/默认关闭
|
# 从数据源开关/默认关闭
|
||||||
|
20
ruoyi-admin/src/main/resources/application-shopee.yml
Normal file
20
ruoyi-admin/src/main/resources/application-shopee.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
shopee:
|
||||||
|
partnerID: 845774
|
||||||
|
secrret: ea6e399abcBb69eacbeBfe38bc89a9ef35Za8Ze48a92535211c2Ъ92e18Ba52d
|
||||||
|
#回跳到系统
|
||||||
|
redirectURL: http://www.edterp.com/shop/shop
|
||||||
|
#shopee 认证
|
||||||
|
authpartner_url: https://partner.shopeemobile.com/api/v1/shop/auth partner
|
||||||
|
#
|
||||||
|
cancel_auth_partner_url: https://partner.shopeemobile.com/api/v1/shop/cancel_auth_partner
|
||||||
|
#shopee 消息推送到系统
|
||||||
|
msgPushUrl: http://www.edterp.com/dev-dpi/orders/shop/verfiyPushMsg
|
||||||
|
#shopee
|
||||||
|
shopInfoApiUrl: https://partner.shopeemobile.com/api/v1/shop/get
|
||||||
|
ordersApiUrl: https://partner.shopeemobile.com/api/v1/orders/basics
|
||||||
|
#
|
||||||
|
orderDetailApiUrl:https://partner.shopeemobile.com/api/v1/orders/detail
|
||||||
|
#
|
||||||
|
orderDetailUariationspiUrl1: https://partner.shopeemobile.com/api/v1/item/tier_var/get
|
||||||
|
socketHost: 172.19.92.42
|
||||||
|
socketPort: 10000
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- 日志存放路径 -->
|
<!-- 日志存放路径 -->
|
||||||
<property name="log.path" value="/home/ruoyi/logs" />
|
<property name="log.path" value="./logs" />
|
||||||
<!-- 日志输出格式 -->
|
<!-- 日志输出格式 -->
|
||||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user