Merge remote-tracking branch 'origin/cc_partner_init' into cc_partner_init
This commit is contained in:
@@ -70,6 +70,11 @@
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun.openservices</groupId>
|
||||
<artifactId>ons-client</artifactId>
|
||||
|
||||
@@ -263,4 +263,14 @@ public class RedisConstant {
|
||||
*/
|
||||
public static final String PARTNER_APPOINTMENT_LOCK = "partner:appointment:lock:{0}";
|
||||
|
||||
/**
|
||||
* 用户意向区域key
|
||||
*/
|
||||
public static final String USER_WANT_AREA_CACHE = "user_want_area_cache_";
|
||||
|
||||
/**
|
||||
* 招商经理轮询key
|
||||
*/
|
||||
public static final String INVESTMENT_MANAGER_CACHE = "investment_manager_cache_";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* describe:职位来源枚举
|
||||
*
|
||||
* @author zhouyiping
|
||||
* @date 2020/12/30
|
||||
*/
|
||||
public enum RoleSourceEnum {
|
||||
/**
|
||||
* 职位来源
|
||||
*/
|
||||
CREATE("create", "自建"),
|
||||
EHR("ehr", "EHR"),
|
||||
SYNC("sync", "钉钉同步");
|
||||
|
||||
private static final Map<String, RoleSourceEnum> map = Arrays.stream(values()).collect(
|
||||
Collectors.toMap(RoleSourceEnum::getCode, Function.identity()));
|
||||
|
||||
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
RoleSourceEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static RoleSourceEnum getByCode(String code) {
|
||||
return map.get(code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
package com.cool.store.utils;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class EncryptUtil {
|
||||
|
||||
/** Base64 编码 */
|
||||
private static final Base64 B64 = new Base64();
|
||||
/** 安全的随机数源 */
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
/** AES加密算法 */
|
||||
private static final String AES_ALGORITHM = "AES";
|
||||
|
||||
private static final String AES = "AES/ECB/PKCS5Padding";
|
||||
|
||||
|
||||
public static String MD5(String str) {
|
||||
String re_md5 = "";
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes());
|
||||
byte b[] = md.digest();
|
||||
|
||||
int i;
|
||||
|
||||
StringBuilder buf = new StringBuilder("");
|
||||
for (byte aB : b) {
|
||||
i = aB;
|
||||
if (i < 0) {
|
||||
i += 256;
|
||||
}
|
||||
if (i < 16) {
|
||||
buf.append("0");
|
||||
}
|
||||
buf.append(Integer.toHexString(i));
|
||||
}
|
||||
re_md5 = buf.toString();
|
||||
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return re_md5;
|
||||
}
|
||||
|
||||
public static String maskMail(String mail) {
|
||||
if (Strings.isNullOrEmpty(mail)) {
|
||||
return mail;
|
||||
}
|
||||
if (!mail.contains("@")) {
|
||||
return mail;
|
||||
}
|
||||
String[] arrays = mail.split("@");
|
||||
String account = arrays[0];
|
||||
String domain = arrays[1];
|
||||
Integer len = account.length();
|
||||
if (len <= 2) return mail;
|
||||
if (len <= 4) {
|
||||
account = account.substring(0, 2) + "****";
|
||||
} else {
|
||||
String left = account.substring(0, 2);
|
||||
String right = account.substring(len - 2, len);
|
||||
account = left + "****" + right;
|
||||
}
|
||||
return account + "@" + domain;
|
||||
}
|
||||
|
||||
public static String maskMobile(String mobile) {
|
||||
if (Strings.isNullOrEmpty(mobile)) {
|
||||
return mobile;
|
||||
}
|
||||
if (mobile.length() < 11) {
|
||||
return mobile;
|
||||
}
|
||||
return mobile.substring(0, 3) + "****" + mobile.substring(7, 11);
|
||||
}
|
||||
|
||||
public static String mask(String str) {
|
||||
if (Strings.isNullOrEmpty(str)) {
|
||||
return str;
|
||||
}
|
||||
|
||||
int len = str.length();
|
||||
|
||||
if (len < 5) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return str.substring(0, 2) + "****" + str.substring(len - 2, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param str
|
||||
* 需要加密的明文
|
||||
* @param key
|
||||
* 密钥
|
||||
* @return 加密后的密文(str / key为null返回null)
|
||||
*/
|
||||
public static String aesEncryp(String str, String key) {
|
||||
return aesEncryp(str, key, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param str
|
||||
* 需要加密的明文
|
||||
* @param key
|
||||
* 密钥
|
||||
* @param urlSafety
|
||||
* 密文是否需要Url安全
|
||||
* @return 加密后的密文(str / key为null返回null)
|
||||
*/
|
||||
public static String aesEncryp(String str, String key, boolean urlSafety) {
|
||||
if (null != str && null != key) {
|
||||
try {
|
||||
Cipher c = Cipher.getInstance(AES);
|
||||
c.init(Cipher.ENCRYPT_MODE, aesKey(key), RANDOM);
|
||||
// 加密
|
||||
byte[] bytes = c.doFinal(str.getBytes("UTF-8"));
|
||||
if (urlSafety) {
|
||||
return Base64.encodeBase64URLSafeString(bytes);
|
||||
} else {
|
||||
return new String(B64.encode(bytes));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return new BaseOut(2, "AES加密失败, 密文:" + str + ", key:" + key, null).toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
*
|
||||
* @param str
|
||||
* 需要解密的密文(base64编码字符串)
|
||||
* @param key
|
||||
* 密钥
|
||||
* @return 解密后的明文
|
||||
*/
|
||||
public static BaseOut aesDecrypt(String str, String key) {
|
||||
if (null != str && null != key) {
|
||||
try {
|
||||
Cipher c = Cipher.getInstance(AES);
|
||||
c.init(Cipher.DECRYPT_MODE, aesKey(key), RANDOM);
|
||||
// 解密
|
||||
return new BaseOut(0, "解密成功", new String(c.doFinal(B64.decode(str)), "UTF-8"));
|
||||
} catch (BadPaddingException e) {
|
||||
return new BaseOut(2, "AES解密失败, 密文:" + str + ", key:" + key, null);
|
||||
} catch (Exception e) {
|
||||
return new BaseOut(2, "AES解密失败, 密文:" + str + ", key:" + key, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/** AES密钥 */
|
||||
private static SecretKeySpec aesKey(String key) {
|
||||
byte[] bs = key.getBytes();
|
||||
if (bs.length != 16) {
|
||||
bs = Arrays.copyOf(bs, 16);// 处理数组长度为16
|
||||
}
|
||||
return new SecretKeySpec(bs, AES_ALGORITHM);
|
||||
}
|
||||
|
||||
public static String oaMd5() {
|
||||
String key = "coolcollege20201211sc";
|
||||
String thirdSecret = "135990bd839c5fe0a1ca9cbee2475431";
|
||||
return MD5(key + thirdSecret);
|
||||
}
|
||||
|
||||
public static String oaB2gnMd5() {
|
||||
String key = "coolStore_buErJia_20220425";
|
||||
String thirdSecret = "d14cc076b44b435ea0ab06d0b7e04ea8";
|
||||
return MD5(key + thirdSecret);
|
||||
}
|
||||
|
||||
public static String oaMd5(String param) {
|
||||
String key = "coolstore20220329";
|
||||
String thirdSecret = "d14cc076b44b435ea0ab06d0b7e04ea8";
|
||||
return MD5(key + thirdSecret + param);
|
||||
}
|
||||
|
||||
public static String xfsgMd5(String param) {
|
||||
String key = "coolstorexfsg20240329";
|
||||
return MD5(key + param);
|
||||
}
|
||||
|
||||
public static String getData(String ticket) {
|
||||
BaseOut result = aesDecrypt(ticket, oaMd5());
|
||||
if(result == null || result.getCode() != 0){
|
||||
return null;
|
||||
}
|
||||
return result.getData().toString();
|
||||
}
|
||||
|
||||
public static String getB2gnData(String ticket) {
|
||||
BaseOut result = aesDecrypt(ticket, oaB2gnMd5());
|
||||
if(result == null || result.getCode() != 0){
|
||||
return null;
|
||||
}
|
||||
return result.getData().toString();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
//签名
|
||||
StringBuffer sb = new StringBuffer();
|
||||
//用户唯一标识id
|
||||
sb.append("userId=132537313837929006").append("&");
|
||||
//企业唯一标识enterpriseId
|
||||
sb.append("enterpriseId=45f92210375346858b6b6694967f44de").append("&");
|
||||
sb.append("bizContent={\"taskList\":[{\"taskName\":\"阿斯顿\",\"taskType\":\"QUESTION_ORDER\",\"taskDesc\":\"测试\",\"attachUrl\":\"{\\\"id\\\":149,\\\"fileName\\\":\\\"新建 DOC 文档.doc\\\",\\\"url\\\":\\\"https://oss-store.coolcollege.cn/doc/sop/45471386126883973.doc\\\",\\\"type\\\":\\\"doc\\\",\\\"category\\\":\\\"doc\\\",\\\"createUserId\\\":\\\"0327344625645542\\\",\\\"createUser\\\":\\\"不易\\\",\\\"createTime\\\":1642692983000,\\\"visibleUser\\\":\\\"\\\",\\\"visibleRole\\\":\\\"\\\",\\\"visibleUserName\\\":\\\"\\\",\\\"visibleRoleName\\\":\\\"\\\"}\",\"taskInfo\":\"{\\\"photos\\\":[\\\"https://oss-store.coolcollege.cn/eid/45f92210375346858b6b6694967f44de/2203/5fc6b6f2cd2243588272992382452bb4.jpg\\\"],\\\"videos\\\":\\\"{\\\\\\\"videoList\\\\\\\":[]}\\\",\\\"contentLearnFirst\\\":false,\\\"courseList\\\":[]}\",\"beginTime\":1648546065361,\"endTime\":1649150454152,\"beginTime\":1648546065361,\"endTime\":1649150454152,\"form\":[{\"type\":\"STANDARD_COLUMN\",\"value\":4324,\"name\":\"奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员奥尔业务员\"}],\"storeIds\":[{\"type\":\"store\",\"value\":\"c61119bf721940f098169ec4d065e79a\"}],\"process\":[{\"nodeNo\":1,\"user\":[{\"type\":\"person\",\"value\":\"132537313837929006\"}],\"approveType\":\"any\"},{\"nodeNo\":2,\"user\":[{\"type\":\"person\",\"value\":\"132537313837929006\"}],\"approveType\":\"any\"},{\"nodeNo\":3,\"user\":[{\"type\":\"person\",\"value\":\"132537313837929006\"}],\"approveType\":\"any\"},{\"nodeNo\":\"cc\",\"user\":[{\"type\":\"person\",\"value\":\"132537313837929006\"}],\"approveType\":\"any\"}]}]}");
|
||||
//sb.append("bizContent={\"pageNumber\":\"1\",\"pageSize\":\"10\",\"storeId\":\"888ab0bddac5432e9b037078366598d6\"}");
|
||||
//加密
|
||||
String sign = oaMd5(sb.toString());
|
||||
System.out.println("sign:" + sign);
|
||||
}
|
||||
}
|
||||
|
||||
class BaseOut {
|
||||
|
||||
private int code = 0;
|
||||
|
||||
private String msg;
|
||||
|
||||
private Object data;
|
||||
|
||||
public BaseOut() {
|
||||
}
|
||||
|
||||
public BaseOut(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public BaseOut(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public BaseOut(int code, String msg, Object data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,4 +98,13 @@ public class RedisConstantUtil {
|
||||
|
||||
return active + "_" + RedisConstant.PHONE_NUMBER + phoneNumber;
|
||||
}
|
||||
|
||||
public String getUserWantAreaListKey(String userId) {
|
||||
return active + "_" + RedisConstant.USER_WANT_AREA_CACHE + eid + ":" + userId;
|
||||
}
|
||||
|
||||
public String getInvestmentManagerKey(Long wantShopAreaId) {
|
||||
return active + "_" + RedisConstant.INVESTMENT_MANAGER_CACHE + eid + ":" + wantShopAreaId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user