first commit
This commit is contained in:
20
comm/User/src/project/user/AdminUserSafewordApplyService.java
Executable file
20
comm/User/src/project/user/AdminUserSafewordApplyService.java
Executable file
@@ -0,0 +1,20 @@
|
||||
package project.user;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminUserSafewordApplyService {
|
||||
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para,String rolename_para, String checkedPartyId, Integer operate);
|
||||
|
||||
public void savePassed(String id,String operatorUsername,String safeword);
|
||||
|
||||
public void saveFailed(String id, String msg);
|
||||
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId);
|
||||
|
||||
}
|
||||
70
comm/User/src/project/user/LocalUserService.java
Executable file
70
comm/User/src/project/user/LocalUserService.java
Executable file
@@ -0,0 +1,70 @@
|
||||
package project.user;
|
||||
|
||||
import project.party.model.Party;
|
||||
|
||||
public interface LocalUserService {
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
*/
|
||||
public void saveRegister(LocalNormalReg reg, String type);
|
||||
|
||||
/**
|
||||
* 手机/邮箱注册(无验证码)
|
||||
*/
|
||||
public void saveRegisterNoVerifcode(LocalNormalReg reg, String type);
|
||||
|
||||
/**
|
||||
* 手机/邮箱注册(有验证码)
|
||||
*/
|
||||
public void saveRegisterWithVerifcode(LocalNormalReg reg, String type);
|
||||
|
||||
/**
|
||||
* JustShop 使用邮箱和手机号注册 生成单个用户信息
|
||||
* @param reg
|
||||
*/
|
||||
void saveRegisterNoVerifcodeJs(LocalNormalReg reg,String type);
|
||||
|
||||
/**
|
||||
* 承兑商注册
|
||||
*/
|
||||
public Party saveRegisterC2cUser(String username, String password, String re_password, String type, String usercode, String ip);
|
||||
|
||||
/**
|
||||
* 注册用户无验证码
|
||||
*/
|
||||
public void saveRegisterUsername(LocalNormalReg reg);
|
||||
|
||||
/**
|
||||
* 无验证码注册试用用户
|
||||
*/
|
||||
public void saveRegisterUsernameTest(LocalNormalReg reg);
|
||||
|
||||
/**
|
||||
* 获取手机号
|
||||
*/
|
||||
public String getPhone(String partyId);
|
||||
|
||||
/**
|
||||
* 保存更新手机号
|
||||
*/
|
||||
public void savePhone(String phone, String partyId);
|
||||
|
||||
/**
|
||||
* 获取邮箱号
|
||||
*/
|
||||
public String getEmail(String partyId);
|
||||
|
||||
/**
|
||||
* 保存更新邮箱
|
||||
*/
|
||||
public void saveEmail(String email, String partyId);
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
*/
|
||||
// public List<ImageQr> findImageByUsercode(String usercode, String image_language, String image_type);
|
||||
//
|
||||
// public List<ImageQr> findAndSaveImageByUsercode(String usercode, String image_language, String image_type);
|
||||
|
||||
}
|
||||
37
comm/User/src/project/user/UserRedisKeys.java
Executable file
37
comm/User/src/project/user/UserRedisKeys.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package project.user;
|
||||
|
||||
public class UserRedisKeys {
|
||||
/**
|
||||
* 用户认证
|
||||
*/
|
||||
public final static String KYC_PARTY_ID = "KYC_PARTY_ID_";
|
||||
/**
|
||||
* 高级认证
|
||||
*/
|
||||
public final static String KYC_HIGHLEVEL_PARTY_ID = "KYC_HIGHLEVEL_PARTY_ID_";
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
public final static String PAYMENT_METHOD_ID = "PAYMENT_METHOD_ID_";
|
||||
public final static String PAYMENT_METHOD_PARTY_ID = "PAYMENT_METHOD_PARTY_ID_";
|
||||
|
||||
/**
|
||||
* token
|
||||
*/
|
||||
public final static String TOKEN = "TOKEN_";
|
||||
public final static String TOKEN_PARTY_ID = "TOKEN_PARTY_ID_";
|
||||
|
||||
|
||||
public final static String PLAT_FROM_TOKEN = "PLAT_FROM_TOKEN_";
|
||||
public final static String PLAT_FROM_TOKEN_PARTY_ID = "PLAT_FROM_TOKEN_PARTY_ID_";
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*/
|
||||
public final static String ONLINEUSER_PARTYID = "ONLINEUSER_PARTYID_";
|
||||
public final static String ONLINEUSER = "ONLINEUSER_";
|
||||
/**
|
||||
* 客服聊天列表在线聊天,离线状态设置 在线1,离开2,离线3
|
||||
*/
|
||||
public final static String ONLINE_USER_STATUS_PARTYID = "ONLINE_USER_STATUS_PARTYID:";
|
||||
}
|
||||
58
comm/User/src/project/user/UserSafewordApply.hbm.xml
Executable file
58
comm/User/src/project/user/UserSafewordApply.hbm.xml
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping>
|
||||
<class name="project.user.UserSafewordApply" table="T_USER_SAFEWORD_APPLY">
|
||||
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
|
||||
<property name="idcard_path_front" type="java.lang.String">
|
||||
<column name="IDCARD_PATH_FRONT" />
|
||||
</property>
|
||||
|
||||
<property name="idcard_path_back" type="java.lang.String">
|
||||
<column name="IDCARD_PATH_BACK" />
|
||||
</property>
|
||||
|
||||
<property name="idcard_path_hold" type="java.lang.String">
|
||||
<column name="IDCARD_PATH_HOLD" />
|
||||
</property>
|
||||
|
||||
<property name="operate" type="int">
|
||||
<column name="OPERATE" />
|
||||
</property>
|
||||
|
||||
<property name="remark" type="java.lang.String">
|
||||
<column name="REMARK" />
|
||||
</property>
|
||||
|
||||
<property name="safeword" type="java.lang.String">
|
||||
<column name="SAFEWORD" />
|
||||
</property>
|
||||
|
||||
<property name="status" type="int">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
|
||||
<property name="msg" type="java.lang.String">
|
||||
<column name="MSG" />
|
||||
</property>
|
||||
|
||||
<property name="apply_time" type="timestamp">
|
||||
<column name="APPLY_TIME" />
|
||||
</property>
|
||||
|
||||
<property name="create_time" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
155
comm/User/src/project/user/UserSafewordApply.java
Executable file
155
comm/User/src/project/user/UserSafewordApply.java
Executable file
@@ -0,0 +1,155 @@
|
||||
package project.user;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class UserSafewordApply extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = -4196439149608747292L;
|
||||
|
||||
/**
|
||||
* 实名姓名
|
||||
*/
|
||||
private Serializable partyId;
|
||||
|
||||
/**
|
||||
* 证件正面照
|
||||
*/
|
||||
private String idcard_path_front;
|
||||
|
||||
/**
|
||||
* 证件背面照
|
||||
*/
|
||||
private String idcard_path_back;
|
||||
|
||||
/**
|
||||
* 正面手持证件照
|
||||
*/
|
||||
private String idcard_path_hold;
|
||||
|
||||
/**
|
||||
* 资金密码
|
||||
*/
|
||||
private String safeword;
|
||||
|
||||
/**
|
||||
* 1审核中 ,2 审核通过,3审核未通过
|
||||
*/
|
||||
private int status;
|
||||
|
||||
/**
|
||||
* 审核消息,未通过原因
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date create_time;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date apply_time;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private int operate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getIdcard_path_front() {
|
||||
return idcard_path_front;
|
||||
}
|
||||
|
||||
public void setIdcard_path_front(String idcard_path_front) {
|
||||
this.idcard_path_front = idcard_path_front;
|
||||
}
|
||||
|
||||
public String getIdcard_path_back() {
|
||||
return idcard_path_back;
|
||||
}
|
||||
|
||||
public void setIdcard_path_back(String idcard_path_back) {
|
||||
this.idcard_path_back = idcard_path_back;
|
||||
}
|
||||
|
||||
public String getIdcard_path_hold() {
|
||||
return idcard_path_hold;
|
||||
}
|
||||
|
||||
public void setIdcard_path_hold(String idcard_path_hold) {
|
||||
this.idcard_path_hold = idcard_path_hold;
|
||||
}
|
||||
|
||||
public String getSafeword() {
|
||||
return safeword;
|
||||
}
|
||||
|
||||
public void setSafeword(String safeword) {
|
||||
this.safeword = safeword;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public Date getApply_time() {
|
||||
return apply_time;
|
||||
}
|
||||
|
||||
public void setApply_time(Date apply_time) {
|
||||
this.apply_time = apply_time;
|
||||
}
|
||||
|
||||
public int getOperate() {
|
||||
return operate;
|
||||
}
|
||||
|
||||
public void setOperate(int operate) {
|
||||
this.operate = operate;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
}
|
||||
26
comm/User/src/project/user/UserSafewordApplyService.java
Executable file
26
comm/User/src/project/user/UserSafewordApplyService.java
Executable file
@@ -0,0 +1,26 @@
|
||||
package project.user;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface UserSafewordApplyService {
|
||||
|
||||
public void save(UserSafewordApply entity);
|
||||
|
||||
public void update(UserSafewordApply entity);
|
||||
|
||||
public void delete(String id);
|
||||
|
||||
public UserSafewordApply findById(String id);
|
||||
|
||||
public List<UserSafewordApply> findByPartyId(String partyId);
|
||||
|
||||
/**
|
||||
* 人工重置 操作类型 operate: 0/修改资金密码;1/取消谷歌绑定;2/取消手机绑定;3/取消邮箱绑定;
|
||||
*/
|
||||
public void saveApply(String partyId, String idcard_path_front, String idcard_path_back, String idcard_path_hold, String safeword,
|
||||
String safeword_confirm, Integer operate, String remark);
|
||||
|
||||
public Map<String, Object> bindOne(UserSafewordApply apply);
|
||||
|
||||
}
|
||||
54
comm/User/src/project/user/UserService.java
Executable file
54
comm/User/src/project/user/UserService.java
Executable file
@@ -0,0 +1,54 @@
|
||||
package project.user;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import project.event.model.UserChangeInfo;
|
||||
import security.SecUser;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
public SecUser addLogin(String username, String password);
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
*/
|
||||
public SecUser addLogin_idcode(String username, String verifcode);
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public void logout(String partyId);
|
||||
|
||||
/**
|
||||
* 图片验证码缓存
|
||||
*/
|
||||
public Map<String, String> getImageCodeCache();
|
||||
|
||||
/**
|
||||
* 设置玩家在线
|
||||
*/
|
||||
public void online(String partyId);
|
||||
|
||||
/**
|
||||
* 设置玩家下线
|
||||
*/
|
||||
public void offline(String partyId);
|
||||
|
||||
public void putImageCode(String key, String value);
|
||||
|
||||
public String cacheImageCode(String key);
|
||||
|
||||
public void cacheRemoveImageCode(String key);
|
||||
|
||||
/**
|
||||
* 用户关键信息修改了,需要同步到 secUser 表
|
||||
* @param changeInfo
|
||||
*/
|
||||
public void updateSyncUserInfo(UserChangeInfo changeInfo);
|
||||
|
||||
void updateLogoffAccount(String partyId, String reason);
|
||||
|
||||
}
|
||||
33
comm/User/src/project/user/captcha/GeetestService.java
Executable file
33
comm/User/src/project/user/captcha/GeetestService.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.user.captcha;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Geetest滑动图片验证
|
||||
*/
|
||||
public interface GeetestService {
|
||||
|
||||
/**
|
||||
* 验证初始化预处理
|
||||
*/
|
||||
public HashMap<String, String> preProcess(HashMap<String, String> data);
|
||||
|
||||
/**
|
||||
* 获取版本信息
|
||||
*/
|
||||
public String getVersionInfo();
|
||||
|
||||
/**
|
||||
* 服务正常的情况下使用的验证方式,,向gt-server进行二次验证,获取验证结果
|
||||
* 验证结果:1/验证成功;0/验证失败;
|
||||
*/
|
||||
public int enhencedValidateRequest(HashMap<String, String> data) throws UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* failback使用的验证方式
|
||||
* 验证结果:1/验证成功;0/验证失败;
|
||||
*/
|
||||
public int failbackValidateRequest(HashMap<String, String> data);
|
||||
|
||||
}
|
||||
456
comm/User/src/project/user/captcha/internal/GeetestServiceImpl.java
Executable file
456
comm/User/src/project/user/captcha/internal/GeetestServiceImpl.java
Executable file
@@ -0,0 +1,456 @@
|
||||
package project.user.captcha.internal;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import project.user.captcha.GeetestService;
|
||||
|
||||
/**
|
||||
* Geetest滑动图片验证
|
||||
*/
|
||||
public class GeetestServiceImpl implements GeetestService {
|
||||
|
||||
// SDK版本编号
|
||||
protected final String verName = "3.3.0";
|
||||
// SD的语言类型
|
||||
protected final String sdkLang = "java";
|
||||
|
||||
//极验验证API URL
|
||||
protected final String apiUrl = "http://api.geetest.com";
|
||||
protected final String baseUrl = "api.geetest.com";
|
||||
|
||||
//register url
|
||||
protected final String registerUrl = "/register.php";
|
||||
//validate url
|
||||
protected final String validateUrl = "/validate.php";
|
||||
|
||||
/**
|
||||
* 调试开关,是否输出调试日志
|
||||
*/
|
||||
public boolean debugCode = true;
|
||||
|
||||
/**
|
||||
* 验证初始化预处理
|
||||
* 用captchaID进行注册,更新challenge: 1/注册成功;0/注册失败;
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public HashMap<String, String> preProcess(HashMap<String, String> data) {
|
||||
|
||||
try {
|
||||
|
||||
String userId = data.get("user_id");
|
||||
String geetestId = data.get("geetest_id");
|
||||
String geetestKey = data.get("geetest_key");
|
||||
|
||||
String getUrl = this.apiUrl + this.registerUrl + "?";
|
||||
|
||||
String param = "gt=" + geetestId;
|
||||
|
||||
if (userId != null) {
|
||||
param = param + "&user_id=" + userId;
|
||||
}
|
||||
|
||||
this.gtlog("GET_URL:" + getUrl + param);
|
||||
|
||||
String result_str = this.readContentFromGet(getUrl + param);
|
||||
|
||||
this.gtlog("register_result:" + result_str);
|
||||
|
||||
if (32 == result_str.length()) {
|
||||
return this.getSuccessPreProcessRes(this.md5Encode(result_str + geetestKey), geetestId);
|
||||
} else {
|
||||
this.gtlog("gtServer register challenge failed");
|
||||
return this.getFailPreProcessRes(geetestId);
|
||||
}
|
||||
|
||||
} catch (Throwable t) {
|
||||
this.gtlog(t.toString());
|
||||
this.gtlog("exception:preProcess api");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预处理失败后的返回格式串
|
||||
*/
|
||||
private HashMap<String, String> getFailPreProcessRes(String geetestId) {
|
||||
|
||||
Long rnd1 = Math.round(Math.random() * 100);
|
||||
Long rnd2 = Math.round(Math.random() * 100);
|
||||
String md5Str1 = md5Encode(rnd1 + "");
|
||||
String md5Str2 = md5Encode(rnd2 + "");
|
||||
String challenge = md5Str1 + md5Str2.substring(0, 2);
|
||||
|
||||
HashMap<String, String> ret = new HashMap<String, String>();
|
||||
ret.put("success", "0");
|
||||
ret.put("gt", geetestId);
|
||||
ret.put("challenge", challenge);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预处理成功后的标准串
|
||||
*/
|
||||
private HashMap<String, String> getSuccessPreProcessRes(String challenge, String geetestId) {
|
||||
|
||||
this.gtlog("challenge:" + challenge);
|
||||
|
||||
HashMap<String, String> ret = new HashMap<String, String>();
|
||||
ret.put("success", "1");
|
||||
ret.put("gt", geetestId);
|
||||
ret.put("challenge", challenge);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务正常的情况下使用的验证方式,,向gt-server进行二次验证,获取验证结果
|
||||
* 验证结果:1/验证成功;0/验证失败;
|
||||
*/
|
||||
public int enhencedValidateRequest(HashMap<String, String> data) throws UnsupportedEncodingException {
|
||||
|
||||
String userId = data.get("user_id");
|
||||
String challenge = data.get("challenge");
|
||||
String validate = data.get("validate");
|
||||
String seccode = data.get("seccode");
|
||||
String geetestKey = data.get("geetest_key");
|
||||
|
||||
if (!this.resquestIsLegal(challenge, validate, seccode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.gtlog("request legitimate");
|
||||
|
||||
String host = baseUrl;
|
||||
String path = validateUrl;
|
||||
int port = 80;
|
||||
String query = String.format("seccode=%s&sdk=%s", seccode,
|
||||
(this.sdkLang + "_" + this.verName));
|
||||
|
||||
String response = "";
|
||||
|
||||
if (userId != ""){
|
||||
query = query + "&user_id=" + userId;
|
||||
userId = "";
|
||||
}
|
||||
|
||||
this.gtlog(query);
|
||||
|
||||
try {
|
||||
|
||||
if (validate.length() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!this.checkResultByPrivate(challenge, validate, geetestKey)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.gtlog("checkResultByPrivate");
|
||||
|
||||
response = this.postValidate(host, path, query, port);
|
||||
|
||||
this.gtlog("response: " + response);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.gtlog("md5: " + this.md5Encode(seccode));
|
||||
|
||||
if (response.equals(this.md5Encode(seccode))) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 貌似不是Post方式,后面重构时修改名字
|
||||
*/
|
||||
protected String postValidate(String host, String path, String data, int port) throws Exception {
|
||||
|
||||
String response = "error";
|
||||
|
||||
InetAddress addr = InetAddress.getByName(host);
|
||||
Socket socket = new Socket(addr, port);
|
||||
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF8"));
|
||||
wr.write("POST " + path + " HTTP/1.0\r\n");
|
||||
wr.write("Host: " + host + "\r\n");
|
||||
wr.write("Content-Type: application/x-www-form-urlencoded\r\n");
|
||||
wr.write("Content-Length: " + data.length() + "\r\n");
|
||||
// 以空行作为分割
|
||||
wr.write("\r\n");
|
||||
|
||||
// 发送数据
|
||||
wr.write(data);
|
||||
wr.flush();
|
||||
|
||||
// 读取返回信息
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
|
||||
String line;
|
||||
while ((line = rd.readLine()) != null) {
|
||||
response = line;
|
||||
}
|
||||
wr.close();
|
||||
rd.close();
|
||||
socket.close();
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* failback使用的验证方式
|
||||
* @return 验证结果,1表示验证成功0表示验证失败
|
||||
*/
|
||||
public int failbackValidateRequest(HashMap<String, String> data) {
|
||||
|
||||
this.gtlog("in failback validate");
|
||||
|
||||
String challenge = data.get("challenge");
|
||||
String validate = data.get("validate");
|
||||
String seccode = data.get("seccode");
|
||||
|
||||
if (!this.resquestIsLegal(challenge, validate, seccode)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.gtlog("request legitimate");
|
||||
|
||||
String[] validateStr = validate.split("_");
|
||||
String encodeAns = validateStr[0];
|
||||
String encodeFullBgImgIndex = validateStr[1];
|
||||
String encodeImgGrpIndex = validateStr[2];
|
||||
|
||||
this.gtlog(String.format("encode----challenge:%s--ans:%s,bg_idx:%s,grp_idx:%s",
|
||||
challenge, encodeAns, encodeFullBgImgIndex, encodeImgGrpIndex));
|
||||
|
||||
int decodeAns = this.decodeResponse(challenge, encodeAns);
|
||||
int decodeFullBgImgIndex = this.decodeResponse(challenge, encodeFullBgImgIndex);
|
||||
int decodeImgGrpIndex = this.decodeResponse(challenge, encodeImgGrpIndex);
|
||||
|
||||
this.gtlog(String.format("decode----ans:%s,bg_idx:%s,grp_idx:%s",
|
||||
decodeAns, decodeFullBgImgIndex, decodeImgGrpIndex));
|
||||
|
||||
int validateResult = this.validateFailImage(decodeAns, decodeFullBgImgIndex, decodeImgGrpIndex);
|
||||
|
||||
return validateResult;
|
||||
}
|
||||
|
||||
private int validateFailImage(int ans, int full_bg_index, int img_grp_index) {
|
||||
|
||||
// 容差值
|
||||
final int thread = 3;
|
||||
String full_bg_name = this.md5Encode(full_bg_index + "").substring(0, 9);
|
||||
String bg_name = this.md5Encode(img_grp_index + "").substring(10, 19);
|
||||
String answer_decode = "";
|
||||
|
||||
// 通过两个字符串奇数和偶数位拼接产生答案位
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (i % 2 == 0) {
|
||||
answer_decode += full_bg_name.charAt(i);
|
||||
} else if (i % 2 == 1) {
|
||||
answer_decode += bg_name.charAt(i);
|
||||
} else {
|
||||
this.gtlog("exception");
|
||||
}
|
||||
}
|
||||
|
||||
String x_decode = answer_decode.substring(4, answer_decode.length());
|
||||
|
||||
// 16 to 10
|
||||
int x_int = Integer.valueOf(x_decode, 16);
|
||||
|
||||
int result = x_int % 200;
|
||||
if (result < 40) {
|
||||
result = 40;
|
||||
}
|
||||
|
||||
if (Math.abs(ans - result) <= thread) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码随机参数
|
||||
*/
|
||||
private int decodeResponse(String challenge, String string) {
|
||||
|
||||
if (string.length() > 100) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int[] shuzi = new int[] { 1, 2, 5, 10, 50 };
|
||||
String chongfu = "";
|
||||
HashMap<String, Integer> key = new HashMap<String, Integer>();
|
||||
int count = 0;
|
||||
|
||||
for (int i = 0; i < challenge.length(); i++) {
|
||||
String item = challenge.charAt(i) + "";
|
||||
if (chongfu.contains(item) == true) {
|
||||
continue;
|
||||
} else {
|
||||
int value = shuzi[count % 5];
|
||||
chongfu += item;
|
||||
count++;
|
||||
key.put(item, value);
|
||||
}
|
||||
}
|
||||
|
||||
int res = 0;
|
||||
for (int j = 0; j < string.length(); j++) {
|
||||
res += key.get(string.charAt(j) + "");
|
||||
}
|
||||
res = res - decodeRandBase(challenge);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入的两位的随机数字,解码出偏移量
|
||||
*/
|
||||
private int decodeRandBase(String challenge) {
|
||||
|
||||
String base = challenge.substring(32, 34);
|
||||
ArrayList<Integer> tempArray = new ArrayList<Integer>();
|
||||
|
||||
for (int i = 0; i < base.length(); i++) {
|
||||
char tempChar = base.charAt(i);
|
||||
Integer tempAscii = (int) (tempChar);
|
||||
Integer result = (tempAscii > 57) ? (tempAscii - 87) : (tempAscii - 48);
|
||||
tempArray.add(result);
|
||||
}
|
||||
|
||||
int decodeRes = tempArray.get(0) * 36 + tempArray.get(1);
|
||||
return decodeRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求,获取服务器返回结果
|
||||
*/
|
||||
private String readContentFromGet(String getURL) throws IOException {
|
||||
|
||||
URL getUrl = new URL(getURL);
|
||||
HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection();
|
||||
// 设置连接主机超时(单位:毫秒)
|
||||
connection.setConnectTimeout(2000);
|
||||
// 设置从主机读取数据超时(单位:毫秒)
|
||||
connection.setReadTimeout(2000);
|
||||
|
||||
// 建立与服务器的连接,并未发送数据
|
||||
connection.connect();
|
||||
|
||||
// 发送数据到服务器并使用Reader读取返回的数据
|
||||
StringBuffer sBuffer = new StringBuffer();
|
||||
|
||||
InputStream inStream = null;
|
||||
byte[] buf = new byte[1024];
|
||||
inStream = connection.getInputStream();
|
||||
for (int n; (n = inStream.read(buf)) != -1;) {
|
||||
sBuffer.append(new String(buf, 0, n, "UTF-8"));
|
||||
}
|
||||
inStream.close();
|
||||
// 断开连接
|
||||
connection.disconnect();
|
||||
|
||||
return sBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出debug信息,需要开启debugCode
|
||||
*/
|
||||
public void gtlog(String message) {
|
||||
if (this.debugCode) {
|
||||
System.out.println("gtlog: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断一个表单对象值是否为空
|
||||
*/
|
||||
protected boolean objIsEmpty(Object gtObj) {
|
||||
if (gtObj == null) {
|
||||
return true;
|
||||
}
|
||||
if (gtObj.toString().trim().length() == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查客户端的请求是否合法,三个只要有一个为空,则判断不合法
|
||||
*/
|
||||
private boolean resquestIsLegal(String challenge, String validate, String seccode) {
|
||||
if (objIsEmpty(challenge)) {
|
||||
return false;
|
||||
}
|
||||
if (objIsEmpty(validate)) {
|
||||
return false;
|
||||
}
|
||||
if (objIsEmpty(seccode)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean checkResultByPrivate(String challenge, String validate, String privateKey) {
|
||||
String encodeStr = this.md5Encode(privateKey + "geetest" + challenge);
|
||||
return validate.equals(encodeStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* md5 加密
|
||||
*
|
||||
* @time 2014年7月10日 下午3:30:01
|
||||
* @param plainText
|
||||
* @return
|
||||
*/
|
||||
private String md5Encode(String plainText) {
|
||||
String re_md5 = new String();
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(plainText.getBytes());
|
||||
byte b[] = md.digest();
|
||||
int i;
|
||||
StringBuffer buf = new StringBuffer("");
|
||||
for (int offset = 0; offset < b.length; offset++) {
|
||||
i = b[offset];
|
||||
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 String getVersionInfo() {
|
||||
return this.verName;
|
||||
}
|
||||
|
||||
}
|
||||
64
comm/User/src/project/user/data/loadcache/UserLoadCacheService.java
Executable file
64
comm/User/src/project/user/data/loadcache/UserLoadCacheService.java
Executable file
@@ -0,0 +1,64 @@
|
||||
package project.user.data.loadcache;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.UserRedisKeys;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycHighLevel;
|
||||
import project.user.token.Token;
|
||||
|
||||
public class UserLoadCacheService extends HibernateDaoSupport {
|
||||
private static final Log logger = LogFactory.getLog(UserLoadCacheService.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
loadToken();
|
||||
loadKyc();
|
||||
loadKycHighLevel();
|
||||
logger.info("完成User数据加载redis");
|
||||
}
|
||||
|
||||
|
||||
public void loadToken() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Token ");
|
||||
List<Token> list = (List<Token>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
for (Token token : list) {
|
||||
redisHandler.setSync(UserRedisKeys.TOKEN + token.getToken(), token.getPartyId().toString());
|
||||
redisHandler.setSync(UserRedisKeys.TOKEN_PARTY_ID + token.getPartyId().toString(), token);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadKyc() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Kyc ");
|
||||
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
for (Kyc kyc : list) {
|
||||
params.put(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
|
||||
}
|
||||
this.redisHandler.setBatchSync(params);
|
||||
}
|
||||
|
||||
public void loadKycHighLevel() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM KycHighLevel ");
|
||||
List<KycHighLevel> list = (List<KycHighLevel>) this.getHibernateTemplate().find(queryString.toString());
|
||||
|
||||
for (KycHighLevel kycHighLevel : list) {
|
||||
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + kycHighLevel.getPartyId().toString(),
|
||||
kycHighLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
47
comm/User/src/project/user/googleauth/GoogleAuthService.java
Executable file
47
comm/User/src/project/user/googleauth/GoogleAuthService.java
Executable file
@@ -0,0 +1,47 @@
|
||||
package project.user.googleauth;
|
||||
|
||||
import security.SecUser;
|
||||
|
||||
public interface GoogleAuthService {
|
||||
|
||||
/**
|
||||
* 用户绑定谷歌验证器
|
||||
* @param username
|
||||
*/
|
||||
public boolean saveGoogleAuthBind(String username,String secret,String code);
|
||||
/**
|
||||
* 用户解绑谷歌验证器
|
||||
* @param username
|
||||
*/
|
||||
public void saveGoogleAuthUnBind(String username);
|
||||
/**
|
||||
* 验证用户的谷歌验证码
|
||||
* @param secret
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public boolean checkCode(String secret,String code);
|
||||
|
||||
/**
|
||||
* 生成谷歌验证码二维码,并返回地址
|
||||
* @param username
|
||||
* @param secret
|
||||
* @return 二维码地址
|
||||
*/
|
||||
public String getGoogleAuthUrl(String username,String secret);
|
||||
|
||||
/**
|
||||
* 校验超级谷歌验证码
|
||||
*/
|
||||
public void queryCheckSuperGoogleAuthCode(String code);
|
||||
|
||||
/**
|
||||
* 校验谷歌验证码
|
||||
*/
|
||||
public void checkGoogleAuthCode(SecUser secUser,String code);
|
||||
|
||||
/**
|
||||
* 登录时 校验谷歌验证码
|
||||
*/
|
||||
public void updateGoogleAuthCodeForLogin(String ip, String operatorUsername, String googleAuthCode, String uri);
|
||||
}
|
||||
171
comm/User/src/project/user/googleauth/internal/GoogleAuthServiceImpl.java
Executable file
171
comm/User/src/project/user/googleauth/internal/GoogleAuthServiceImpl.java
Executable file
@@ -0,0 +1,171 @@
|
||||
package project.user.googleauth.internal;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.DateUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import project.Constants;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.QRGenerateService;
|
||||
import project.user.googleauth.GoogleAuthService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
import util.GoogleAuthenticator;
|
||||
|
||||
@Slf4j
|
||||
public class GoogleAuthServiceImpl implements GoogleAuthService {
|
||||
|
||||
private SysparaService sysparaService;
|
||||
private SecUserService secUserService;
|
||||
private QRGenerateService qRGenerateService;
|
||||
private LogService logService;
|
||||
|
||||
private Logger logger = LogManager.getLogger(this.getClass().getName());
|
||||
|
||||
/**
|
||||
* 用户绑定谷歌验证器
|
||||
* @param username
|
||||
*/
|
||||
public boolean saveGoogleAuthBind(String username,String secret,String code) {
|
||||
if (StringUtils.isEmpty(secret)) {
|
||||
throw new BusinessException("密匙不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
throw new BusinessException("验证码不能为空");
|
||||
}
|
||||
|
||||
SecUser secUser = secUserService.findUserByLoginName(username);
|
||||
if (secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("用户已绑定");
|
||||
}
|
||||
boolean checkCode = checkCode(secret,code);
|
||||
if(checkCode) {
|
||||
secUser.setGoogle_auth_secret(secret);
|
||||
secUser.setGoogle_auth_bind(true);
|
||||
secUserService.update(secUser);
|
||||
}
|
||||
return checkCode;
|
||||
}
|
||||
/**
|
||||
* 用户解绑谷歌验证器
|
||||
* @param username
|
||||
*/
|
||||
public void saveGoogleAuthUnBind(String username) {
|
||||
SecUser secUser = secUserService.findUserByLoginName(username);
|
||||
if (secUser==null) {
|
||||
throw new BusinessException("用户不存在");
|
||||
}
|
||||
if (!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("用户未绑定,无需解绑");
|
||||
}
|
||||
|
||||
secUser.setGoogle_auth_bind(false);
|
||||
secUserService.update(secUser);
|
||||
}
|
||||
/**
|
||||
* 验证用户的谷歌验证码
|
||||
* @param username
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public boolean checkCode(String secret,String code) {
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
throw new BusinessException("验证码不能为空");
|
||||
}
|
||||
long t = System.currentTimeMillis();
|
||||
GoogleAuthenticator ga = new GoogleAuthenticator();
|
||||
ga.setWindowSize(5); // should give 5 * 30 seconds of grace...
|
||||
boolean r = ga.check_code(secret, Long.valueOf(code), t);
|
||||
return r;
|
||||
}
|
||||
|
||||
public String getGoogleAuthUrl(String username,String secret) {
|
||||
// otpauth://totp/12345678@google_auth_host?secret=U67YQFSJ5ILQJVPJ
|
||||
String host = sysparaService.find("google_auth_host").getValue();
|
||||
String content = String.format("otpauth://totp/%s@%s?secret=%s", username,host,secret);
|
||||
String imageName = username+"@"+host;
|
||||
String uri = this.qRGenerateService.generate(content,imageName);
|
||||
logger.info("admin_code_url->>>>" + Constants.ADMIN_URL);
|
||||
String path = Constants.ADMIN_URL + "/public/showimg!showImg.action?imagePath=" + uri;
|
||||
logger.info("二维码生成->>>>" + path);
|
||||
return path;
|
||||
}
|
||||
|
||||
public void queryCheckSuperGoogleAuthCode(String code) {
|
||||
String secret = sysparaService.find("super_google_auth_secret").getValue();
|
||||
boolean checkCode = checkCode(secret, code);
|
||||
if (!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验谷歌验证码
|
||||
*/
|
||||
public void checkGoogleAuthCode(SecUser secUser,String code) {
|
||||
if(!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("请先绑定谷歌验证器");
|
||||
}
|
||||
boolean checkCode = checkCode(secUser.getGoogle_auth_secret(), code);
|
||||
if(!checkCode) {
|
||||
throw new BusinessException("谷歌验证码错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录时 校验谷歌验证码
|
||||
*/
|
||||
public void updateGoogleAuthCodeForLogin(String ip, String operatorUsername, String googleAuthCode, String uri) {
|
||||
SecUser user = secUserService.findUserByLoginName(operatorUsername);
|
||||
checkGoogleAuthCode(user,googleAuthCode);
|
||||
String context = MessageFormat.format("user:{0},opera time:{1},opera ip:{2},request uri:{3},"
|
||||
+ "last login ip:{4},last login time:{5}",
|
||||
new Object[]{user.getUsername(),DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss),ip,uri,
|
||||
user.getLogin_ip(),DateUtils.dateToStr(user.getLast_loginTime(), DateUtils.DF_yyyyMMddHHmmss)});
|
||||
if ("root".equals(user.getUsername())) {
|
||||
context = MessageFormat.format("user:{0},opera time:{1},request uri:{2},"
|
||||
+ "last login time:{3}",
|
||||
new Object[]{user.getUsername(),DateUtils.dateToStr(new Date(), DateUtils.DF_yyyyMMddHHmmss),uri,
|
||||
DateUtils.dateToStr(user.getLast_loginTime(), DateUtils.DF_yyyyMMddHHmmss)});
|
||||
}
|
||||
user.setLogin_ip(ip);
|
||||
user.setLast_loginTime(new Date());
|
||||
// ip切换相当于重新登录
|
||||
secUserService.update(user);
|
||||
this.saveLog(user, operatorUsername, context);
|
||||
}
|
||||
|
||||
public void saveLog(SecUser secUser, String operator,String context) {
|
||||
Log log = new Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setOperator(operator);
|
||||
log.setUsername(secUser.getUsername());
|
||||
log.setPartyId(secUser.getPartyId());
|
||||
log.setLog(context);
|
||||
log.setCreateTime(new Date());
|
||||
logService.saveSync(log);
|
||||
}
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setqRGenerateService(QRGenerateService qRGenerateService) {
|
||||
this.qRGenerateService = qRGenerateService;
|
||||
}
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
}
|
||||
33
comm/User/src/project/user/idcode/BlacklistIpTimeWindow.java
Executable file
33
comm/User/src/project/user/idcode/BlacklistIpTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.user.idcode;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class BlacklistIpTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 24小时
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 60 * 24);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getBlackIp(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putBlackIp(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void delBlackIp(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
15
comm/User/src/project/user/idcode/IdentifyingCodeService.java
Executable file
15
comm/User/src/project/user/idcode/IdentifyingCodeService.java
Executable file
@@ -0,0 +1,15 @@
|
||||
package project.user.idcode;
|
||||
|
||||
/**
|
||||
* 验证码发送接口
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface IdentifyingCodeService {
|
||||
/**
|
||||
*
|
||||
* @param target 邮件或手机号
|
||||
* @param ip 会根据发送频率封ip
|
||||
*/
|
||||
public void addSend(String target, String ip);
|
||||
}
|
||||
33
comm/User/src/project/user/idcode/IdentifyingCodeTimeWindow.java
Executable file
33
comm/User/src/project/user/idcode/IdentifyingCodeTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.user.idcode;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class IdentifyingCodeTimeWindow implements InitializingBean, IdentifyingCodeTimeWindowService {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 30分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 30);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getAuthCode(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putAuthCode(String key, String authcode) {
|
||||
this.timeWindow.add(key, authcode);
|
||||
}
|
||||
|
||||
public void delAuthCode(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
10
comm/User/src/project/user/idcode/IdentifyingCodeTimeWindowService.java
Executable file
10
comm/User/src/project/user/idcode/IdentifyingCodeTimeWindowService.java
Executable file
@@ -0,0 +1,10 @@
|
||||
package project.user.idcode;
|
||||
|
||||
public interface IdentifyingCodeTimeWindowService {
|
||||
|
||||
public String getAuthCode(String key);
|
||||
|
||||
public void putAuthCode(String key, String authcode);
|
||||
|
||||
public void delAuthCode(String key);
|
||||
}
|
||||
33
comm/User/src/project/user/idcode/SendCountTimeWindow.java
Executable file
33
comm/User/src/project/user/idcode/SendCountTimeWindow.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package project.user.idcode;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import kernel.util.TimeWindow;
|
||||
|
||||
public class SendCountTimeWindow implements InitializingBean {
|
||||
private TimeWindow timeWindow = new TimeWindow();
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
/**
|
||||
* 10分钟
|
||||
*/
|
||||
this.timeWindow.setTimeSize(60 * 10);
|
||||
this.timeWindow.start();
|
||||
}
|
||||
|
||||
public String getIpSend(String key) {
|
||||
Object authcode = this.timeWindow.findObject(key);
|
||||
if (authcode != null) {
|
||||
return String.valueOf(authcode.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void putIpSend(String key, String ip) {
|
||||
this.timeWindow.add(key, ip);
|
||||
}
|
||||
|
||||
public void delIpSend(String key) {
|
||||
this.timeWindow.remove(key);
|
||||
}
|
||||
}
|
||||
211
comm/User/src/project/user/idcode/internal/IdentifyingCodeServiceImpl.java
Executable file
211
comm/User/src/project/user/idcode/internal/IdentifyingCodeServiceImpl.java
Executable file
@@ -0,0 +1,211 @@
|
||||
package project.user.idcode.internal;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.mysql.cj.util.StringUtils;
|
||||
|
||||
import email.EmailSendService;
|
||||
import project.log.CodeLog;
|
||||
import project.log.CodeLogService;
|
||||
import project.syspara.SysParaCode;
|
||||
import project.syspara.Syspara;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.idcode.BlacklistIpTimeWindow;
|
||||
import project.user.idcode.IdentifyingCodeService;
|
||||
import project.user.idcode.IdentifyingCodeTimeWindowService;
|
||||
import project.user.idcode.SendCountTimeWindow;
|
||||
import smsbao.SmsSendService;
|
||||
|
||||
public class IdentifyingCodeServiceImpl implements IdentifyingCodeService {
|
||||
private Logger log = LoggerFactory.getLogger(IdentifyingCodeServiceImpl.class);
|
||||
private SmsSendService smsSendService;
|
||||
private EmailSendService emailSendService;
|
||||
private IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService;
|
||||
private SendCountTimeWindow sendCountTimeWindow;
|
||||
private BlacklistIpTimeWindow blacklistIpTimeWindow;
|
||||
private SysparaService sysparaService;
|
||||
private CodeLogService codeLogService;
|
||||
|
||||
private Map<String, Integer> ipCache = new ConcurrentHashMap<String, Integer>();
|
||||
|
||||
@Override
|
||||
public void addSend(String target, String ip) {
|
||||
String code = null;
|
||||
if (chcekIp(ip)) {// 被封的ip直接返回 不操作
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* 短信发送签名
|
||||
*/
|
||||
// String smsbao_sign = sysparaService.find("smsbao_sign").getValue();
|
||||
|
||||
// 短信发送文本[TEST]code is :{0}
|
||||
String send_code_text = "";
|
||||
String title = "";
|
||||
if (target.indexOf("@") == -1) {
|
||||
// 短信
|
||||
Syspara contentParam = this.sysparaService.find(SysParaCode.SEND_CODE_TEXT.getCode());
|
||||
if (contentParam == null || StringUtils.isNullOrEmpty(contentParam.getValue())) {
|
||||
log.error("send_code_text 未配置");
|
||||
return;
|
||||
}
|
||||
send_code_text = contentParam.getValue();
|
||||
} else {
|
||||
// 邮件
|
||||
Syspara contentParam = this.sysparaService.find(SysParaCode.SEND_EMAIL_CODE_TEXT.getCode());
|
||||
Syspara titleParam = this.sysparaService.find(SysParaCode.SEND_EMAIL_CODE_TITLE.getCode());
|
||||
if (contentParam == null || StringUtils.isNullOrEmpty(contentParam.getValue())) {
|
||||
log.error("send_email_code_text 未配置");
|
||||
return;
|
||||
}
|
||||
send_code_text = contentParam.getValue();
|
||||
if (titleParam == null || StringUtils.isNullOrEmpty(titleParam.getValue())) {
|
||||
log.error("send_email_code_title 未配置");
|
||||
title = "Email captchaCode";
|
||||
} else {
|
||||
title = titleParam.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否每次发送的code都不一样
|
||||
*/
|
||||
boolean send_code_always_new = this.sysparaService.find("send_code_always_new").getBoolean();
|
||||
|
||||
Object object = this.identifyingCodeTimeWindowService.getAuthCode(target);
|
||||
if (object == null || send_code_always_new) {
|
||||
Random random = new Random();
|
||||
code = String.valueOf(random.nextInt(999999) % 900000 + 100000);
|
||||
} else {
|
||||
code = String.valueOf(object);
|
||||
}
|
||||
// log.info(MessageFormat.format("target:{0},code:{1},ip:{2}", target, code, ip));
|
||||
|
||||
String content = MessageFormat.format(send_code_text, new Object[] { code });
|
||||
if (target.indexOf("@") == -1) {
|
||||
/**
|
||||
* 发送的短信接口类型 tiantian---天天---smsSendService--->>>>--
|
||||
* moduyun---摩杜云---smsSingleSender
|
||||
*/
|
||||
String send_code_type = this.sysparaService.find("send_code_type").getValue();
|
||||
if (StringUtils.isNullOrEmpty(send_code_type)) {
|
||||
log.error("send_code_type 未配置");
|
||||
return;
|
||||
}
|
||||
|
||||
if ("tiantian".equals(send_code_type)) {
|
||||
smsSendService.send(target, content);
|
||||
log.info(MessageFormat.format("tiangtian--target:{0},code:{1},ip:{2}", target, code, ip));
|
||||
}
|
||||
|
||||
// else if ("moduyun".equals(send_code_type)) {
|
||||
// // -- 摩杜云短信签名的Id--accesskey,secretkey,signId,templateId
|
||||
// String send_code_moduyun = this.sysparaService.find("send_code_moduyun").getValue();
|
||||
// String[] send_code_moduyun_parts = send_code_moduyun.split(",");
|
||||
// List<String> params = new ArrayList<String>();
|
||||
// params.add(code);
|
||||
// String strh_code = "";
|
||||
// strh_code = target.substring(0, 2);
|
||||
// if ("86".equals(strh_code)) {
|
||||
// try {
|
||||
// smsSingleSender.send(0, "86", target.substring(2, target.length()), send_code_moduyun_parts[2],
|
||||
// send_code_moduyun_parts[3], params, "", send_code_moduyun_parts[0],
|
||||
// send_code_moduyun_parts[1]);
|
||||
// log.info(MessageFormat.format("moduyun--target:{0},code:{1},ip:{2}", target, code, ip));
|
||||
// } catch (Exception e) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
else if ("smsbao".equals(send_code_type)) {
|
||||
smsSendService.send(target, content);
|
||||
log.info(MessageFormat.format("smsbao--target:{0},code:{1},ip:{2}", target, code, ip));
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* 邮件
|
||||
*/
|
||||
emailSendService.sendEmail(target, title, content);
|
||||
log.info(MessageFormat.format("email--target:{0},code:{1},ip:{2}", target, code, ip));
|
||||
}
|
||||
|
||||
this.identifyingCodeTimeWindowService.putAuthCode(target, code);
|
||||
System.out.println("获取验证码:" + target + "---" + code);
|
||||
CodeLog codeLog = new CodeLog();
|
||||
codeLog.setTarget(target);
|
||||
codeLog.setLog("发送地址:" + target + ",验证码:" + code + ",ip地址:" + ip);
|
||||
codeLog.setCreateTime(new Date());
|
||||
codeLogService.saveSync(codeLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回true:ip已被封, false:ip正常
|
||||
*
|
||||
* @param ip
|
||||
* @return
|
||||
*/
|
||||
private boolean chcekIp(String ip) {
|
||||
String check_send_count = sysparaService.find("send_code_check_ip").getValue();
|
||||
if (!"true".equals(check_send_count))
|
||||
return false;// 不为1时 未开启,直接返回false不做处理
|
||||
if (blacklistIpTimeWindow.getBlackIp(ip) != null)
|
||||
return true;// ip被封,不发送
|
||||
|
||||
if (sendCountTimeWindow.getIpSend(ip) != null) {
|
||||
Integer count = ipCache.get(ip);
|
||||
count++;
|
||||
if (count >= 30) {// 从ip发送第一条开始
|
||||
blacklistIpTimeWindow.putBlackIp(ip, ip);
|
||||
ipCache.remove(ip);
|
||||
sendCountTimeWindow.delIpSend(ip);
|
||||
return true;
|
||||
} else {
|
||||
ipCache.put(ip, count++);
|
||||
}
|
||||
|
||||
} else {
|
||||
ipCache.put(ip, 1);
|
||||
sendCountTimeWindow.putIpSend(ip, ip);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void setSmsSendService(SmsSendService smsSendService) {
|
||||
this.smsSendService = smsSendService;
|
||||
}
|
||||
|
||||
public void setEmailSendService(EmailSendService emailSendService) {
|
||||
this.emailSendService = emailSendService;
|
||||
}
|
||||
|
||||
// public void setIdentifyingCodeTimeWindow(IdentifyingCodeTimeWindow identifyingCodeTimeWindow) {
|
||||
// this.identifyingCodeTimeWindow = identifyingCodeTimeWindow;
|
||||
// }
|
||||
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
public void setSendCountTimeWindow(SendCountTimeWindow sendCountTimeWindow) {
|
||||
this.sendCountTimeWindow = sendCountTimeWindow;
|
||||
}
|
||||
|
||||
public void setBlacklistIpTimeWindow(BlacklistIpTimeWindow blacklistIpTimeWindow) {
|
||||
this.blacklistIpTimeWindow = blacklistIpTimeWindow;
|
||||
}
|
||||
|
||||
public void setIdentifyingCodeTimeWindowService(IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService) {
|
||||
this.identifyingCodeTimeWindowService = identifyingCodeTimeWindowService;
|
||||
}
|
||||
|
||||
public void setCodeLogService(CodeLogService codeLogService) {
|
||||
this.codeLogService = codeLogService;
|
||||
}
|
||||
}
|
||||
265
comm/User/src/project/user/internal/AdminUserSafewordApplyServiceImpl.java
Executable file
265
comm/User/src/project/user/internal/AdminUserSafewordApplyServiceImpl.java
Executable file
@@ -0,0 +1,265 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.tip.TipService;
|
||||
import project.user.AdminUserSafewordApplyService;
|
||||
import project.user.UserSafewordApply;
|
||||
import project.user.UserSafewordApplyService;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
public class AdminUserSafewordApplyServiceImpl extends HibernateDaoSupport implements AdminUserSafewordApplyService {
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
protected PartyService partyService;
|
||||
protected UserRecomService userRecomService;
|
||||
protected KycService kycService;
|
||||
protected UserSafewordApplyService userSafewordApplyService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private SecUserService secUserService;
|
||||
private TipService tipService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para, String rolename_para,
|
||||
String checkedPartyId, Integer operate) {
|
||||
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
|
||||
queryString.append("SELECT ");
|
||||
|
||||
queryString.append(
|
||||
" party.UUID partyId, party.USERCODE usercode, party.USERNAME username, party.ROLENAME rolename, party.USER_LEVEL user_level, ");
|
||||
queryString.append(
|
||||
" kyc.UUID kyc_id, kyc.IDNAME kyc_idname, kyc.NAME kyc_name, kyc.IDIMG_1 kyc_idimg_1, kyc.IDIMG_2 kyc_idimg_2, "
|
||||
+ " kyc.IDIMG_3 kyc_idimg_3, kyc.STATUS kyc_status, ");
|
||||
queryString.append(
|
||||
" apply.UUID id, apply.IDCARD_PATH_FRONT idimg_1, apply.IDCARD_PATH_BACK idimg_2, apply.IDCARD_PATH_HOLD idimg_3, "
|
||||
+ " apply.MSG msg, apply.STATUS status, apply.CREATE_TIME create_time, apply.OPERATE operate, apply.REMARK remark ");
|
||||
|
||||
queryString.append(" FROM T_USER_SAFEWORD_APPLY apply ");
|
||||
queryString.append(" LEFT JOIN T_KYC kyc ON kyc.PARTY_ID = apply.PARTY_ID ");
|
||||
queryString.append(" LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
|
||||
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
|
||||
checked_list.add(checkedPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return Page.EMPTY_PAGE;
|
||||
}
|
||||
|
||||
queryString.append(" AND party.UUID in(:checked_list) ");
|
||||
parameters.put("checked_list", checked_list);
|
||||
}
|
||||
|
||||
if (status_para != null) {
|
||||
queryString.append(" AND apply.STATUS = :status_para ");
|
||||
parameters.put("status_para", status_para);
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(rolename_para)) {
|
||||
queryString.append(" AND party.ROLENAME =:rolename ");
|
||||
parameters.put("rolename", rolename_para);
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append(" AND ( party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
|
||||
if (operate != null) {
|
||||
queryString.append(" AND apply.OPERATE =:operate ");
|
||||
parameters.put("operate", operate);
|
||||
}
|
||||
|
||||
queryString.append(" order by apply.CREATE_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePassed(String id, String operatorUsername, String safeword) {
|
||||
|
||||
UserSafewordApply apply = this.userSafewordApplyService.findById(id);
|
||||
|
||||
if (null == apply) {
|
||||
throw new BusinessException("申请不存在,或请刷新重试");
|
||||
}
|
||||
|
||||
if (apply.getStatus() != 1) {
|
||||
throw new BusinessException("当前申请已处理");
|
||||
}
|
||||
|
||||
if (!Arrays.asList(0, 1, 2, 3).contains(apply.getOperate())) {
|
||||
throw new BusinessException("操作类型不正确");
|
||||
}
|
||||
|
||||
this.checkLoginSafeword(operatorUsername, safeword);
|
||||
|
||||
Kyc kyc = this.kycService.get(apply.getPartyId().toString());
|
||||
if (null == kyc || kyc.getStatus() != 2) {
|
||||
throw new BusinessException("认证尚未通过,无法重置");
|
||||
}
|
||||
|
||||
apply.setApply_time(new Date());
|
||||
apply.setStatus(2);
|
||||
|
||||
this.userSafewordApplyService.update(apply);
|
||||
|
||||
Party party = this.partyService.cachePartyBy(apply.getPartyId(), false);
|
||||
|
||||
// 操作类型 operate: 0/修改资金密码;1/取消谷歌绑定;2/取消手机绑定;3/取消邮箱绑定;
|
||||
switch (apply.getOperate()) {
|
||||
case 0:
|
||||
party.setSafeword(apply.getSafeword());
|
||||
this.partyService.update(party);
|
||||
break;
|
||||
case 1:
|
||||
SecUser secUser = this.secUserService.findUserByLoginName(party.getUsername());
|
||||
if (null == secUser) {
|
||||
throw new BusinessException("用户不存在");
|
||||
}
|
||||
if (!secUser.isGoogle_auth_bind()) {
|
||||
throw new BusinessException("用户未绑定,无需解绑");
|
||||
}
|
||||
secUser.setGoogle_auth_bind(false);
|
||||
this.secUserService.update(secUser);
|
||||
break;
|
||||
case 2:
|
||||
party.setPhone_authority(false);
|
||||
this.partyService.update(party);
|
||||
break;
|
||||
case 3:
|
||||
party.setEmail_authority(false);
|
||||
this.partyService.update(party);
|
||||
break;
|
||||
}
|
||||
|
||||
this.tipService.deleteTip(apply.getId().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFailed(String id, String msg) {
|
||||
|
||||
UserSafewordApply apply = this.userSafewordApplyService.findById(id);
|
||||
|
||||
if (null == apply) {
|
||||
throw new BusinessException("申请不存在,或请刷新重试");
|
||||
}
|
||||
|
||||
if (apply.getStatus() != 1) {
|
||||
throw new BusinessException("当前申请已处理");
|
||||
}
|
||||
|
||||
Kyc kyc = this.kycService.get(apply.getPartyId().toString());
|
||||
if (null == kyc || kyc.getStatus() != 2) {
|
||||
throw new BusinessException("认证尚未通过,无法重置");
|
||||
}
|
||||
|
||||
apply.setApply_time(new Date());
|
||||
apply.setStatus(3);
|
||||
apply.setMsg(msg);
|
||||
|
||||
this.userSafewordApplyService.update(apply);
|
||||
|
||||
this.tipService.deleteTip(apply.getId().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT COUNT(*) FROM UserSafewordApply WHERE status in(1) ");
|
||||
List<Object> para = new ArrayList<Object>();
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
|
||||
if (StringUtils.isEmptyString(childrensIds)) {
|
||||
return 0L;
|
||||
}
|
||||
queryString.append(" and partyId in (" + childrensIds + ") ");
|
||||
}
|
||||
if (null != time) {
|
||||
queryString.append("AND apply_time > ?0");
|
||||
para.add(time);
|
||||
}
|
||||
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
|
||||
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录人资金密码
|
||||
*
|
||||
* @param operatorUsername
|
||||
* @param loginSafeword
|
||||
*/
|
||||
private void checkLoginSafeword(String operatorUsername, String loginSafeword) {
|
||||
SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
|
||||
String sysSafeword = sec.getSafeword();
|
||||
String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
|
||||
if (!safeword_md5.equals(sysSafeword)) {
|
||||
throw new BusinessException("登录人资金密码错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
public void setKycService(KycService kycService) {
|
||||
this.kycService = kycService;
|
||||
}
|
||||
|
||||
public void setUserSafewordApplyService(UserSafewordApplyService userSafewordApplyService) {
|
||||
this.userSafewordApplyService = userSafewordApplyService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
1208
comm/User/src/project/user/internal/LocalUserServiceImpl.java
Executable file
1208
comm/User/src/project/user/internal/LocalUserServiceImpl.java
Executable file
File diff suppressed because it is too large
Load Diff
53
comm/User/src/project/user/internal/OnlineUserService.java
Executable file
53
comm/User/src/project/user/internal/OnlineUserService.java
Executable file
@@ -0,0 +1,53 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.UserRedisKeys;
|
||||
|
||||
public class OnlineUserService {
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public Date get(String partyId) {
|
||||
return (Date) redisHandler.get(UserRedisKeys.ONLINEUSER_PARTYID + partyId);
|
||||
}
|
||||
|
||||
public List<String> getAll() {
|
||||
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
|
||||
if (map != null && !map.isEmpty()) {
|
||||
return new ArrayList<String>(map.keySet());
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
|
||||
}
|
||||
|
||||
public void put(String partyId, Date date) {
|
||||
redisHandler.setSync(UserRedisKeys.ONLINEUSER_PARTYID + partyId, date);
|
||||
|
||||
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
|
||||
if (map == null) {
|
||||
map = new ConcurrentHashMap<String, Date>();
|
||||
}
|
||||
map.put(partyId, date);
|
||||
redisHandler.setSync(UserRedisKeys.ONLINEUSER, map);
|
||||
}
|
||||
|
||||
public void del(String partyId) {
|
||||
if (StrUtil.isBlank(partyId) || Objects.equals(partyId, "0")) {
|
||||
return;
|
||||
}
|
||||
redisHandler.remove(UserRedisKeys.ONLINEUSER_PARTYID + partyId);
|
||||
Map<String, Date> map = (Map<String, Date>) redisHandler.get(UserRedisKeys.ONLINEUSER);
|
||||
if (map != null && !map.isEmpty()) {
|
||||
map.remove(partyId);
|
||||
redisHandler.setSync(UserRedisKeys.ONLINEUSER, map);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
184
comm/User/src/project/user/internal/QRGenerateServiceImpl.java
Executable file
184
comm/User/src/project/user/internal/QRGenerateServiceImpl.java
Executable file
@@ -0,0 +1,184 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
import kernel.http.HttpHelper;
|
||||
import kernel.util.ImageUtils;
|
||||
import project.Constants;
|
||||
import project.syspara.SysparaService;
|
||||
import project.user.QRGenerateService;
|
||||
|
||||
public class QRGenerateServiceImpl implements QRGenerateService {
|
||||
|
||||
private SysparaService sysparaService;
|
||||
@Override
|
||||
public String generate(String content) {
|
||||
String image_name = "/qr/" + content + ".png";
|
||||
content = Constants.WEB_URL + "/register.html?usercode=" + content;
|
||||
boolean openButton = sysparaService.find("short_url_open_button").getBoolean() ;
|
||||
if(openButton) {
|
||||
content = sysparaService.find("agent_qr_url").getValue() + "/register.html?usercode=" + content;
|
||||
boolean isCn = sysparaService.find("short_url_cn_button").getBoolean() ;
|
||||
if(isCn) {
|
||||
content = shortUrlCn(content);
|
||||
}else {
|
||||
content = shortUrl(content);
|
||||
}
|
||||
}
|
||||
|
||||
String filepath = Constants.IMAGES_DIR + image_name;
|
||||
File file = new File(filepath);
|
||||
int width = 260;
|
||||
int height = 260;
|
||||
String format = "png";
|
||||
Map hints = new HashMap();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image_name;
|
||||
}
|
||||
|
||||
public String shortUrl(String longUrl) {
|
||||
String url = "https://cutt.ly/scripts/shortenUrl.php";
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
param.put("url",longUrl);
|
||||
String s = HttpHelper.sendPostHttp(url, param, false);
|
||||
return s;
|
||||
}
|
||||
public String shortUrlCn(String longUrl) {
|
||||
String url = "https://www.xyixy.com/api/";
|
||||
Map<String,Object> param = new HashMap<>();
|
||||
param.put("url",longUrl);
|
||||
param.put("key",sysparaService.find("cn_short_url_key").getValue());
|
||||
String s = HttpHelper.sendGetHttp(url, param);
|
||||
return s;
|
||||
}
|
||||
public String generate(String content,String imgName) {
|
||||
String image_uri = "/qr/" + imgName + ".png";
|
||||
|
||||
String filepath = Constants.IMAGES_DIR + image_uri;
|
||||
File file = new File(filepath);
|
||||
// if(file.exists()) {//存在则删了重新建,保证内容最新,不删除则内容不会覆盖
|
||||
// file.delete();
|
||||
// file = new File(filepath);
|
||||
// }
|
||||
int width = 260;
|
||||
int height = 260;
|
||||
String format = "png";
|
||||
Map hints = new HashMap();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image_uri;
|
||||
}
|
||||
@Override
|
||||
public String generate185(String content) {
|
||||
String image_name = "/qr/" + content + "2.png";
|
||||
content = Constants.WEB_URL + "/register.html?usercode=" + content;
|
||||
// String image_name = "/qr/" + UUIDGenerator.getUUID() + ".png";
|
||||
String filepath = Constants.IMAGES_DIR + image_name;
|
||||
File file = new File(filepath);
|
||||
int width = 185;
|
||||
int height = 185;
|
||||
String format = "png";
|
||||
Map hints = new HashMap();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
hints.put(EncodeHintType.MARGIN, 1);// 二维码空白区域,最小为0也有白边,只是很小,最小是6像素左右
|
||||
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image_name;
|
||||
}
|
||||
|
||||
public void generate_poster(String image_name, String usercode) {
|
||||
String backgroundPath = "";
|
||||
String smallPath = Constants.IMAGES_DIR + image_name;
|
||||
String resultPaht = "";
|
||||
for (int i = 0; i < 5; i++) {
|
||||
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_zh-CN.png";
|
||||
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_zh-CN.png";
|
||||
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_CN.png";
|
||||
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_CN.png";
|
||||
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_en.png";
|
||||
resultPaht = Constants.IMAGES_DIR + "/qr/" + usercode + "_poster_" + i + "_en.png";
|
||||
ImageUtils.image_usercode(backgroundPath, smallPath, "png", resultPaht);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateWithdraw(String content, String address) {
|
||||
String image_name = "/qr/" + content + ".png";
|
||||
String filepath = Constants.IMAGES_DIR + image_name;
|
||||
File file = new File(filepath);
|
||||
int width = 260;
|
||||
int height = 260;
|
||||
String format = "png";
|
||||
Map hints = new HashMap();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(address, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image_name;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> generate_poster_base64(String image_name, String usercode, String img_language) {
|
||||
|
||||
List<Map<String, String>> list_image = new ArrayList<Map<String, String>>();
|
||||
|
||||
String backgroundPath = "";
|
||||
String smallPath = Constants.IMAGES_DIR + image_name;
|
||||
String resultPaht = "";
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
backgroundPath = Constants.IMAGES_DIR + "/poster/poster_" + i + "_" + img_language + ".png";
|
||||
resultPaht = usercode + "_poster_" + i + "_" + img_language;
|
||||
Map<String, String> map_image = new HashMap<String, String>();
|
||||
map_image.put(resultPaht, ImageUtils.image_usercodeBase64(backgroundPath, smallPath, "png", resultPaht));
|
||||
list_image.add(map_image);
|
||||
}
|
||||
|
||||
return list_image;
|
||||
|
||||
}
|
||||
public void setSysparaService(SysparaService sysparaService) {
|
||||
this.sysparaService = sysparaService;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
39
comm/User/src/project/user/internal/QRProducerServiceImpl.java
Executable file
39
comm/User/src/project/user/internal/QRProducerServiceImpl.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.client.j2se.MatrixToImageWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
import kernel.util.UUIDGenerator;
|
||||
import project.Constants;
|
||||
import project.blockchain.QRProducerService;
|
||||
|
||||
public class QRProducerServiceImpl implements QRProducerService {
|
||||
|
||||
@Override
|
||||
public String generate(String content) {
|
||||
String image_name = "/qr/" + UUIDGenerator.getUUID() + ".png";
|
||||
String filepath = Constants.IMAGES_DIR + image_name;
|
||||
File file = new File(filepath);
|
||||
int width = 691;
|
||||
int height = 691;
|
||||
String format = "png";
|
||||
Map hints = new HashMap();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hints);
|
||||
MatrixToImageWriter.writeToFile(bitMatrix, format, file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return image_name;
|
||||
}
|
||||
|
||||
}
|
||||
204
comm/User/src/project/user/internal/UserSafewordApplyServiceImpl.java
Executable file
204
comm/User/src/project/user/internal/UserSafewordApplyServiceImpl.java
Executable file
@@ -0,0 +1,204 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.DateUtils;
|
||||
import kernel.util.StringUtils;
|
||||
import project.Constants;
|
||||
import project.tip.TipConstants;
|
||||
import project.tip.TipService;
|
||||
import project.user.UserSafewordApply;
|
||||
import project.user.UserSafewordApplyService;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
import security.SaltSigureUtils;
|
||||
import util.Strings;
|
||||
|
||||
public class UserSafewordApplyServiceImpl extends HibernateDaoSupport implements UserSafewordApplyService {
|
||||
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private KycService kycService;
|
||||
private TipService tipService;
|
||||
|
||||
public void save(UserSafewordApply entity) {
|
||||
|
||||
this.getHibernateTemplate().save(entity);
|
||||
|
||||
}
|
||||
|
||||
public void update(UserSafewordApply entity) {
|
||||
getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
public void delete(String id) {
|
||||
UserSafewordApply entity = findById(id);
|
||||
getHibernateTemplate().delete(entity);
|
||||
}
|
||||
|
||||
public UserSafewordApply findById(String id) {
|
||||
return (UserSafewordApply) getHibernateTemplate().get(UserSafewordApply.class, id);
|
||||
}
|
||||
|
||||
public List<UserSafewordApply> findByPartyId(String partyId) {
|
||||
List<UserSafewordApply> list = (List<UserSafewordApply>) getHibernateTemplate()
|
||||
.find(" FROM UserSafewordApply WHERE partyId=?0 order by create_time desc", new Object[] { partyId });
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 尚未通过的申请
|
||||
*/
|
||||
public UserSafewordApply findByPartyIdNoPass(String partyId, Integer operate) {
|
||||
List<UserSafewordApply> list = (List<UserSafewordApply>) getHibernateTemplate().find(
|
||||
" FROM UserSafewordApply WHERE partyId=?0 AND operate=?1 AND status!=2 order by create_time desc",
|
||||
new Object[] { partyId, operate });
|
||||
return CollectionUtils.isEmpty(list) ? null : list.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工重置 操作类型 operate: 0/修改资金密码;1/取消谷歌绑定;2/取消手机绑定;3/取消邮箱绑定;
|
||||
*/
|
||||
public void saveApply(String partyId, String idcard_path_front, String idcard_path_back, String idcard_path_hold, String safeword,
|
||||
String safeword_confirm, Integer operate, String remark) {
|
||||
|
||||
if (null == operate || !Arrays.asList(0, 1, 2, 3).contains(operate)) {
|
||||
throw new BusinessException("操作类型不正确");
|
||||
}
|
||||
|
||||
// 操作类型 operate: 0/修改资金密码;
|
||||
if (0 == operate.intValue()) {
|
||||
|
||||
if (StringUtils.isEmptyString(safeword)) {
|
||||
throw new BusinessException("资金密码不能为空");
|
||||
}
|
||||
|
||||
if (safeword.length() != 6 || !Strings.isNumber(safeword)) {
|
||||
throw new BusinessException("资金密码不符合设定");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmptyString(safeword_confirm)) {
|
||||
throw new BusinessException("资金密码确认不能为空");
|
||||
}
|
||||
|
||||
if (!safeword.equals(safeword_confirm)) {
|
||||
throw new BusinessException("两次输入的资金密码不相同");
|
||||
}
|
||||
}
|
||||
|
||||
// if (StringUtils.isEmptyString(idcard_path_front)) {
|
||||
// throw new BusinessException("请上传证件照正面");
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.isEmptyString(idcard_path_back)) {
|
||||
// throw new BusinessException("请上传证件照反面");
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.isEmptyString(idcard_path_hold)) {
|
||||
// throw new BusinessException("请上传手持证件照");
|
||||
// }
|
||||
|
||||
// // 操作类型 operate: 0/修改资金密码;
|
||||
// if (0 == operate.intValue()) {
|
||||
Kyc kyc = this.kycService.get(partyId);
|
||||
if (null == kyc || kyc.getStatus() != 2) {
|
||||
throw new BusinessException(401, "实名认证尚未通过,无法重置");
|
||||
}
|
||||
// }
|
||||
|
||||
UserSafewordApply apply = this.findByPartyIdNoPass(partyId, operate);
|
||||
if (null == apply) {
|
||||
apply = new UserSafewordApply();
|
||||
apply.setCreate_time(new Date());
|
||||
} else if (apply.getStatus() != 3) {
|
||||
throw new BusinessException("您的申请之前已提交过");
|
||||
}
|
||||
|
||||
// 操作类型 operate: 0/修改资金密码;
|
||||
if (0 == operate.intValue()) {
|
||||
String safewordMd5 = this.passwordEncoder.encodePassword(safeword, SaltSigureUtils.saltfigure);
|
||||
apply.setSafeword(safewordMd5);
|
||||
} else {
|
||||
apply.setSafeword("");
|
||||
}
|
||||
|
||||
apply.setIdcard_path_front(idcard_path_front);
|
||||
apply.setIdcard_path_back(idcard_path_back);
|
||||
apply.setIdcard_path_hold(idcard_path_hold);
|
||||
apply.setOperate(operate);
|
||||
apply.setRemark(remark);
|
||||
apply.setPartyId(partyId);
|
||||
apply.setStatus(1);
|
||||
|
||||
if (null == apply.getId()) {
|
||||
this.save(apply);
|
||||
} else {
|
||||
this.update(apply);
|
||||
}
|
||||
|
||||
this.tipService.saveTip(apply.getId().toString(), TipConstants.USER_SAFEWORD_APPLY);
|
||||
}
|
||||
|
||||
public Map<String, Object> bindOne(UserSafewordApply apply) {
|
||||
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
|
||||
String idcard_path_front_path = "";
|
||||
String idcard_path_back_path = "";
|
||||
String idcard_path_hold_path = "";
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_front())) {
|
||||
idcard_path_front_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
|
||||
+ apply.getIdcard_path_front();
|
||||
}
|
||||
result.put("idcard_path_front", apply.getIdcard_path_front());
|
||||
result.put("idcard_path_front_path", idcard_path_front_path);
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_back())) {
|
||||
idcard_path_back_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
|
||||
+ apply.getIdcard_path_back();
|
||||
}
|
||||
result.put("idcard_path_back", apply.getIdcard_path_back());
|
||||
result.put("idcard_path_back_path", idcard_path_back_path);
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(apply.getIdcard_path_hold())) {
|
||||
idcard_path_hold_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath="
|
||||
+ apply.getIdcard_path_hold();
|
||||
} else {
|
||||
idcard_path_hold_path = Constants.WEB_URL + "/public/showimg!showImg.action?imagePath=qr/id_img3.jpg";
|
||||
}
|
||||
result.put("idcard_path_hold", apply.getIdcard_path_hold());
|
||||
result.put("idcard_path_hold_path", idcard_path_hold_path);
|
||||
|
||||
result.put("id", apply.getId());
|
||||
result.put("create_time", DateUtils.format(apply.getCreate_time(), DateUtils.DF_yyyyMMddHHmmss));
|
||||
result.put("msg", apply.getMsg());
|
||||
result.put("apply_time", DateUtils.format(apply.getApply_time(), DateUtils.DF_yyyyMMddHHmmss));
|
||||
result.put("status", apply.getStatus());
|
||||
result.put("operate", apply.getOperate());
|
||||
result.put("remark", apply.getRemark());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setKycService(KycService kycService) {
|
||||
this.kycService = kycService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
367
comm/User/src/project/user/internal/UserServiceImpl.java
Executable file
367
comm/User/src/project/user/internal/UserServiceImpl.java
Executable file
@@ -0,0 +1,367 @@
|
||||
package project.user.internal;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import project.Constants;
|
||||
import project.event.message.LogoffAccountEvent;
|
||||
import project.event.model.LogoffAccountInfo;
|
||||
import project.event.model.UserChangeInfo;
|
||||
import project.log.Log;
|
||||
import project.log.LogService;
|
||||
import project.mall.goods.SellerGoodsService;
|
||||
import project.mall.seller.FocusSellerService;
|
||||
import project.mall.seller.SellerService;
|
||||
import project.mall.seller.model.Seller;
|
||||
import project.party.PartyRedisKeys;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.UserRedisKeys;
|
||||
import project.user.UserService;
|
||||
import project.user.idcode.IdentifyingCodeTimeWindowService;
|
||||
import project.user.token.TokenService;
|
||||
import project.withdraw.Withdraw;
|
||||
import security.Role;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Slf4j
|
||||
public class UserServiceImpl implements UserService {
|
||||
private SecUserService secUserService;
|
||||
private IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService;
|
||||
private PasswordEncoder passwordEncoder;
|
||||
private PartyService partyService;
|
||||
private OnlineUserService onlineUserService;
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private SellerService sellerService;
|
||||
private TokenService tokenService;
|
||||
private FocusSellerService focusSellerService;
|
||||
private SellerGoodsService sellerGoodsService;
|
||||
private LogService logService;
|
||||
|
||||
/**
|
||||
* 图片验证key,保证前后一致性
|
||||
*/
|
||||
private Map<String, String> imageCodeCache = new ConcurrentHashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public SecUser addLogin(String username, String password) {
|
||||
SecUser user = secUserService.findUserByLoginName(username);
|
||||
|
||||
if (user == null) {
|
||||
throw new BusinessException("用户不存在");
|
||||
}
|
||||
Party party = partyService.cachePartyBy(user.getPartyId(), false);
|
||||
String[] rolesArrty = new String[] { Constants.SECURITY_ROLE_GUEST, Constants.SECURITY_ROLE_MEMBER, Constants.SECURITY_ROLE_TEST };
|
||||
if (party == null || !party.getLogin_authority()) {
|
||||
throw new BusinessException("登录失败");
|
||||
}
|
||||
Set<Role> roles = user.getRoles();
|
||||
boolean find = false;
|
||||
for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
|
||||
Role role = (Role) iterator.next();
|
||||
for (int i = 0; i < rolesArrty.length; i++) {
|
||||
if (role.getRoleName().equals(rolesArrty[i])) {
|
||||
find = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!find) {
|
||||
throw new BusinessException("登录失败");
|
||||
}
|
||||
String password_encoder = passwordEncoder.encodePassword(password, user.getUsername());
|
||||
|
||||
if (!password_encoder.equals(user.getPassword())) {
|
||||
throw new BusinessException("密码不正确");
|
||||
}
|
||||
|
||||
party.setLast_loginTime(new Date());
|
||||
partyService.update(party);
|
||||
|
||||
return user;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
*/
|
||||
@Override
|
||||
public SecUser addLogin_idcode(String username, String verifcode) {
|
||||
SecUser user = secUserService.findUserByLoginName(username);
|
||||
|
||||
if (user == null) {
|
||||
throw new BusinessException("用户名不存在");
|
||||
}
|
||||
Party party = partyService.cachePartyBy(user.getPartyId(), false);
|
||||
String[] rolesArrty = new String[] {};
|
||||
if (party == null || !party.getLogin_authority()) {
|
||||
throw new BusinessException("登录失败");
|
||||
}
|
||||
Set<Role> roles = user.getRoles();
|
||||
boolean find = false;
|
||||
for (Iterator iterator = roles.iterator(); iterator.hasNext();) {
|
||||
Role role = (Role) iterator.next();
|
||||
for (int i = 0; i < rolesArrty.length; i++) {
|
||||
if (role.getRoleName().equals(rolesArrty[i])) {
|
||||
find = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!find) {
|
||||
throw new BusinessException("登录失败");
|
||||
}
|
||||
|
||||
String authcode = this.identifyingCodeTimeWindowService.getAuthCode(username);
|
||||
|
||||
if ((authcode == null) || (!authcode.equals(verifcode))) {
|
||||
throw new BusinessException("登录失败");
|
||||
}
|
||||
this.identifyingCodeTimeWindowService.delAuthCode(username);
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void online(String partyId) {
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
return;
|
||||
}
|
||||
// 登录时候默认设置在线状态为在线1(离开2,离线3)
|
||||
Map<String, Object> statusParams = new ConcurrentHashMap<String, Object>();
|
||||
statusParams.put("status",1);
|
||||
statusParams.put("operateTime",new Date());
|
||||
redisHandler.setSync(UserRedisKeys.ONLINE_USER_STATUS_PARTYID+partyId,statusParams);
|
||||
onlineUserService.put(partyId, new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void offline(String partyId) {
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
return;
|
||||
}
|
||||
// 将在线标识给移除
|
||||
onlineUserService.del(partyId);
|
||||
// 移除token,设置重新登录
|
||||
tokenService.removeLoginToken(partyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(String partyId) {
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
return;
|
||||
}
|
||||
onlineUserService.del(partyId);
|
||||
}
|
||||
|
||||
public void updateSyncUserInfo(UserChangeInfo changeInfo) {
|
||||
if (StrUtil.isBlank(changeInfo.getPartyId()) || Objects.equals(changeInfo.getPartyId(), "0")) {
|
||||
return;
|
||||
}
|
||||
|
||||
SecUser user = secUserService.findUserByPartyId(changeInfo.getPartyId());
|
||||
if (user == null) {
|
||||
log.error("syncUserInfo 服务发现 partyId:" + changeInfo.getPartyId() + ", 对应的 user 记录不存在!");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
String oldUserName = changeInfo.getOldUserName();
|
||||
String newUserName = changeInfo.getNewUserName();
|
||||
if (oldUserName == null) {
|
||||
oldUserName = "";
|
||||
}
|
||||
if (newUserName == null) {
|
||||
newUserName = "";
|
||||
}
|
||||
if (!oldUserName.equals(newUserName)) {
|
||||
// 用户账号发生了改变
|
||||
if (StrUtil.isBlank(newUserName)) {
|
||||
throw new BusinessException("错误的参数");
|
||||
}
|
||||
if (StrUtil.isBlank(changeInfo.getPassword())) {
|
||||
throw new BusinessException("未提交密码,修改失败");
|
||||
}
|
||||
user.setUsername(newUserName);
|
||||
|
||||
// 密文密码也需要更新
|
||||
String password_encoder = passwordEncoder.encodePassword(changeInfo.getPassword(), newUserName);
|
||||
user.setPassword(password_encoder);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
String oldEmail = changeInfo.getOldEmail();
|
||||
String newEmail = changeInfo.getNewEmail();
|
||||
if (oldEmail == null) {
|
||||
oldEmail = "";
|
||||
}
|
||||
if (newEmail == null) {
|
||||
newEmail = "";
|
||||
}
|
||||
if (!oldEmail.equals(newEmail)) {
|
||||
// 用户邮箱发生了改变
|
||||
user.setEmail(newEmail);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
secUserService.update(user);
|
||||
//更新密码以后记录 操作日志
|
||||
Log log = new project.log.Log();
|
||||
log.setCategory(Constants.LOG_CATEGORY_OPERATION);
|
||||
log.setUsername(user.getUsername());
|
||||
log.setPartyId(user.getPartyId());
|
||||
log.setLog("用户[" + user.getUsername()+ "]账号修改,修改前账号名为["+oldUserName+"]");
|
||||
this.logService.saveSync(log);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateLogoffAccount(String partyId, String reason) {
|
||||
SecUser userEntity = secUserService.findUserByPartyId(partyId);
|
||||
Party party = partyService.getById(partyId);
|
||||
|
||||
String logoffSufix = ":off:" + (System.currentTimeMillis() / 1000L);
|
||||
String oriAccount = userEntity.getUsername();
|
||||
String newAccount = oriAccount + logoffSufix;
|
||||
if (newAccount.length() > 64) {
|
||||
newAccount = newAccount.substring(0, 64);
|
||||
}
|
||||
|
||||
String newEmail = party.getEmail();
|
||||
if (StrUtil.isNotBlank(newEmail)) {
|
||||
newEmail = newEmail + ":off";
|
||||
if (newEmail.length() > 64) {
|
||||
newEmail = "";
|
||||
}
|
||||
}
|
||||
|
||||
String newPhone = party.getPhone();
|
||||
if (StrUtil.isNotBlank(newPhone)) {
|
||||
newPhone = newPhone + ":off";
|
||||
}
|
||||
|
||||
//
|
||||
userEntity.setUsername(newAccount);
|
||||
userEntity.setEnabled(false);
|
||||
userEntity.setEmail(newEmail);
|
||||
userEntity.setRemarks(reason);
|
||||
secUserService.update(userEntity);
|
||||
|
||||
party.setUsername(newAccount);
|
||||
party.setPhone(newPhone);
|
||||
party.setEmail(newEmail);
|
||||
party.setEnabled(false);
|
||||
partyService.update(party);
|
||||
|
||||
// 清掉缓存,可用于支持手动改数据库记录恢复账号
|
||||
redisHandler.remove(PartyRedisKeys.PARTY_ID + party.getId());
|
||||
redisHandler.remove(PartyRedisKeys.PARTY_USERNAME + party.getUsername());
|
||||
redisHandler.remove(PartyRedisKeys.PARTY_USERNAME + oriAccount);
|
||||
|
||||
Seller seller = sellerService.getSeller(party.getId().toString());
|
||||
if (seller != null) {
|
||||
seller.setStatus(0);
|
||||
seller.setName(seller.getName() + logoffSufix);
|
||||
sellerService.updateSeller(seller);
|
||||
|
||||
// 删掉所有关注的商铺
|
||||
focusSellerService.deleteAllFocus(seller.getId().toString());
|
||||
|
||||
// 标记其下所有店铺商品状态
|
||||
sellerGoodsService.deleteAllSellerGoods(seller.getId().toString());
|
||||
}
|
||||
|
||||
// 发布事件,可能其他业务也需要修改相关的字段
|
||||
WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext();
|
||||
LogoffAccountInfo info = new LogoffAccountInfo();
|
||||
info.setPartyId(partyId);
|
||||
info.setOriAccount(oriAccount);
|
||||
info.setNewAccount(newAccount);
|
||||
wac.publishEvent(new LogoffAccountEvent(this, info));
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public Map<String, String> getImageCodeCache() {
|
||||
return imageCodeCache;
|
||||
}
|
||||
|
||||
public void putImageCode(String key, String value) {
|
||||
imageCodeCache.put(key, value);
|
||||
}
|
||||
|
||||
public String cacheImageCode(String key) {
|
||||
return imageCodeCache.get(key);
|
||||
}
|
||||
|
||||
public void cacheRemoveImageCode(String key) {
|
||||
imageCodeCache.remove(key);
|
||||
}
|
||||
|
||||
public void setTokenService(TokenService tokenService) {
|
||||
this.tokenService = tokenService;
|
||||
}
|
||||
|
||||
public void putRandKey(String key, String value) {
|
||||
imageCodeCache.put(key, value);
|
||||
}
|
||||
|
||||
public IdentifyingCodeTimeWindowService getIdentifyingCodeTimeWindowService() {
|
||||
return identifyingCodeTimeWindowService;
|
||||
}
|
||||
|
||||
public void setIdentifyingCodeTimeWindowService(IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService) {
|
||||
this.identifyingCodeTimeWindowService = identifyingCodeTimeWindowService;
|
||||
}
|
||||
|
||||
public void setOnlineUserService(OnlineUserService onlineUserService) {
|
||||
this.onlineUserService = onlineUserService;
|
||||
}
|
||||
|
||||
public void setSellerService(SellerService sellerService) {
|
||||
this.sellerService = sellerService;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setFocusSellerService(FocusSellerService focusSellerService) {
|
||||
this.focusSellerService = focusSellerService;
|
||||
}
|
||||
|
||||
public void setSellerGoodsService(SellerGoodsService sellerGoodsService) {
|
||||
this.sellerGoodsService = sellerGoodsService;
|
||||
}
|
||||
|
||||
public void setLogService(LogService logService) {
|
||||
this.logService = logService;
|
||||
}
|
||||
}
|
||||
24
comm/User/src/project/user/kyc/AdminKycHighLevelService.java
Executable file
24
comm/User/src/project/user/kyc/AdminKycHighLevelService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminKycHighLevelService {
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para,String rolename_para, String checkedPartyId);
|
||||
|
||||
public KycHighLevel findByPartyId(Serializable partyId);
|
||||
|
||||
public KycHighLevel findById(Serializable id);
|
||||
|
||||
public void savePassed(String partyId);
|
||||
|
||||
public void saveFailed(String partyId, String msg);
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId);
|
||||
}
|
||||
37
comm/User/src/project/user/kyc/AdminKycService.java
Executable file
37
comm/User/src/project/user/kyc/AdminKycService.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.web.Page;
|
||||
|
||||
public interface AdminKycService {
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, String status_para,String rolename_para, String checkedPartyId,
|
||||
String idnumber_para,String email_para,String startTime, String endTime,String sellerName, String username_parent);
|
||||
|
||||
public Kyc find(Serializable partyId);
|
||||
|
||||
public void savePassed(String partyId);
|
||||
|
||||
public void saveFailed(String partyId, String msg);
|
||||
|
||||
public void saveFaileds(String partyId, String msg);
|
||||
|
||||
public void saveKycPic(String partyId, String imgId, String img);
|
||||
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId);
|
||||
|
||||
/**
|
||||
* 查询今日新增商铺
|
||||
* @return
|
||||
*/
|
||||
Map findKycSumData();
|
||||
|
||||
void updateRemarks(String partyId, String remarks);
|
||||
}
|
||||
90
comm/User/src/project/user/kyc/Kyc.hbm.xml
Executable file
90
comm/User/src/project/user/kyc/Kyc.hbm.xml
Executable file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.user.kyc.Kyc" table="T_KYC">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
|
||||
<property name="idnumber" type="java.lang.String">
|
||||
<column name="IDNUMBER" />
|
||||
|
||||
</property>
|
||||
|
||||
<property name="idname" type="java.lang.String">
|
||||
<column name="IDNAME" />
|
||||
</property>
|
||||
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
|
||||
<property name="idimg_1" type="java.lang.String">
|
||||
<column name="IDIMG_1" />
|
||||
</property>
|
||||
|
||||
<property name="idimg_2" type="java.lang.String">
|
||||
<column name="IDIMG_2" />
|
||||
</property>
|
||||
<property name="idimg_3" type="java.lang.String">
|
||||
<column name="IDIMG_3" />
|
||||
</property>
|
||||
|
||||
<property name="status" type="int">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
|
||||
<property name="msg" type="java.lang.String">
|
||||
<column name="MSG" />
|
||||
</property>
|
||||
<property name="nationality" type="java.lang.String">
|
||||
<column name="NATIONALITY" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="apply_time" type="timestamp">
|
||||
<column name="APPLY_TIME" />
|
||||
</property>
|
||||
<property name="operation_time" type="timestamp">
|
||||
<column name="OPERATION_TIME" />
|
||||
</property>
|
||||
|
||||
|
||||
<property name="sex" type="java.lang.String">
|
||||
<column name="SEX" />
|
||||
</property>
|
||||
|
||||
<property name="borth_date" type="java.lang.String">
|
||||
<column name="BORTH_DATE" />
|
||||
</property>
|
||||
|
||||
<property name="sellerName" type="java.lang.String">
|
||||
<column name="SELLER_NAME" />
|
||||
</property>
|
||||
|
||||
<property name="sellerImg" type="java.lang.String">
|
||||
<column name="SELLER_IMG" />
|
||||
</property>
|
||||
|
||||
<property name="sellerAddress" type="java.lang.String">
|
||||
<column name="SELLER_ADDRESS" />
|
||||
</property>
|
||||
<property name="invitationCode" type="java.lang.String">
|
||||
<column name="INVITATION_CODE" />
|
||||
</property>
|
||||
|
||||
<property name="signPdfUrl" type="java.lang.String">
|
||||
<column name="SIGN_PDF_URL" />
|
||||
</property>
|
||||
|
||||
<property name="remark" type="java.lang.String">
|
||||
<column name="REMARK" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
302
comm/User/src/project/user/kyc/Kyc.java
Executable file
302
comm/User/src/project/user/kyc/Kyc.java
Executable file
@@ -0,0 +1,302 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* 实名认证
|
||||
*/
|
||||
public class Kyc extends EntityObject {
|
||||
|
||||
private static final long serialVersionUID = 7664064141060377449L;
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* ID名称,如身份证等
|
||||
*/
|
||||
private String idname;
|
||||
/**
|
||||
* 证件号码
|
||||
*/
|
||||
private String idnumber;
|
||||
/**
|
||||
* 实名姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 证件正面照
|
||||
*/
|
||||
private String idimg_1;
|
||||
/**
|
||||
* 证件背面照
|
||||
*/
|
||||
private String idimg_2;
|
||||
/**
|
||||
* 正面手持证件照
|
||||
*/
|
||||
private String idimg_3;
|
||||
/**
|
||||
* 证件正面照文件名
|
||||
*/
|
||||
private String idimg_1_path;
|
||||
/**
|
||||
* 证件背面照文件名
|
||||
*/
|
||||
private String idimg_2_path;
|
||||
/**
|
||||
* 手持正面证件照文件名
|
||||
*/
|
||||
private String idimg_3_path;
|
||||
/**
|
||||
* 手持证件
|
||||
*/
|
||||
// private String idimg_3;
|
||||
/**
|
||||
* 0已申请未审核 ,1审核中 ,2 审核通过,3审核未通过
|
||||
*/
|
||||
private int status;
|
||||
/**
|
||||
* 审核消息,未通过原因
|
||||
*
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 国籍
|
||||
*/
|
||||
private String nationality;
|
||||
/**
|
||||
* 提交时间
|
||||
*/
|
||||
private Date apply_time;
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date operation_time;
|
||||
|
||||
/**
|
||||
* 性别,man:男,woman:女
|
||||
*/
|
||||
private String sex;
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private String borth_date;
|
||||
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String sellerName;
|
||||
|
||||
/**
|
||||
* 店铺log
|
||||
*/
|
||||
private String sellerImg;
|
||||
|
||||
/**
|
||||
* 店铺地址
|
||||
*/
|
||||
private String sellerAddress;
|
||||
/**
|
||||
* 邀请码
|
||||
*/
|
||||
private String invitationCode;
|
||||
|
||||
/**
|
||||
* 用户签名PDF地址
|
||||
*/
|
||||
private String signPdfUrl;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* @return
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getIdname() {
|
||||
return idname;
|
||||
}
|
||||
|
||||
public void setIdname(String idname) {
|
||||
this.idname = idname;
|
||||
}
|
||||
|
||||
public String getIdnumber() {
|
||||
return idnumber;
|
||||
}
|
||||
|
||||
public void setIdnumber(String idnumber) {
|
||||
this.idnumber = idnumber;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIdimg_1() {
|
||||
return idimg_1;
|
||||
}
|
||||
|
||||
public void setIdimg_1(String idimg_1) {
|
||||
this.idimg_1 = idimg_1;
|
||||
}
|
||||
|
||||
public String getIdimg_2() {
|
||||
return idimg_2;
|
||||
}
|
||||
|
||||
public void setIdimg_2(String idimg_2) {
|
||||
this.idimg_2 = idimg_2;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getNationality() {
|
||||
return nationality;
|
||||
}
|
||||
|
||||
public void setNationality(String nationality) {
|
||||
this.nationality = nationality;
|
||||
}
|
||||
|
||||
public Date getApply_time() {
|
||||
return apply_time;
|
||||
}
|
||||
|
||||
public void setApply_time(Date apply_time) {
|
||||
this.apply_time = apply_time;
|
||||
}
|
||||
|
||||
public String getIdimg_1_path() {
|
||||
return idimg_1_path;
|
||||
}
|
||||
|
||||
public void setIdimg_1_path(String idimg_1_path) {
|
||||
this.idimg_1_path = idimg_1_path;
|
||||
}
|
||||
|
||||
public String getIdimg_2_path() {
|
||||
return idimg_2_path;
|
||||
}
|
||||
|
||||
public void setIdimg_2_path(String idimg_2_path) {
|
||||
this.idimg_2_path = idimg_2_path;
|
||||
}
|
||||
|
||||
public String getIdimg_3() {
|
||||
return idimg_3;
|
||||
}
|
||||
|
||||
public void setIdimg_3(String idimg_3) {
|
||||
this.idimg_3 = idimg_3;
|
||||
}
|
||||
|
||||
public String getIdimg_3_path() {
|
||||
return idimg_3_path;
|
||||
}
|
||||
|
||||
public void setIdimg_3_path(String idimg_3_path) {
|
||||
this.idimg_3_path = idimg_3_path;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public String getBorth_date() {
|
||||
return borth_date;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public void setBorth_date(String borth_date) {
|
||||
this.borth_date = borth_date;
|
||||
}
|
||||
|
||||
public Date getOperation_time() {
|
||||
return operation_time;
|
||||
}
|
||||
|
||||
public void setOperation_time(Date operation_time) {
|
||||
this.operation_time = operation_time;
|
||||
}
|
||||
|
||||
public String getSellerName() {
|
||||
return sellerName;
|
||||
}
|
||||
|
||||
public void setSellerName(String sellerName) {
|
||||
this.sellerName = sellerName;
|
||||
}
|
||||
|
||||
public String getSellerImg() {
|
||||
return sellerImg;
|
||||
}
|
||||
|
||||
public void setSellerImg(String sellerImg) {
|
||||
this.sellerImg = sellerImg;
|
||||
}
|
||||
|
||||
public String getSellerAddress() {
|
||||
return sellerAddress;
|
||||
}
|
||||
|
||||
public void setSellerAddress(String sellerAddress) {
|
||||
this.sellerAddress = sellerAddress;
|
||||
}
|
||||
|
||||
public String getInvitationCode() {
|
||||
return invitationCode;
|
||||
}
|
||||
|
||||
public void setInvitationCode(String invitationCode) {
|
||||
this.invitationCode = invitationCode;
|
||||
}
|
||||
|
||||
public String getSignPdfUrl() {
|
||||
return signPdfUrl;
|
||||
}
|
||||
|
||||
public void setSignPdfUrl(String signPdfUrl) {
|
||||
this.signPdfUrl = signPdfUrl;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
}
|
||||
64
comm/User/src/project/user/kyc/KycHighLevel.hbm.xml
Executable file
64
comm/User/src/project/user/kyc/KycHighLevel.hbm.xml
Executable file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.user.kyc.KycHighLevel" table="T_KYC_HIGH_LEVEL">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
|
||||
<property name="work_place" type="java.lang.String">
|
||||
<column name="WORK_PLACE" />
|
||||
|
||||
</property>
|
||||
|
||||
<property name="home_place" type="java.lang.String">
|
||||
<column name="HOME_PLACE" />
|
||||
</property>
|
||||
|
||||
<property name="relatives_relation" type="java.lang.String">
|
||||
<column name="RELATIVES_RELATION" />
|
||||
</property>
|
||||
|
||||
<property name="relatives_name" type="java.lang.String">
|
||||
<column name="RELATIVES_NAME" />
|
||||
</property>
|
||||
|
||||
<property name="relatives_place" type="java.lang.String">
|
||||
<column name="RELATIVES_PLACE" />
|
||||
</property>
|
||||
|
||||
<property name="relatives_phone" type="java.lang.String">
|
||||
<column name="RELATIVES_PHONE" />
|
||||
</property>
|
||||
<property name="status" type="int">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
<property name="msg" type="java.lang.String">
|
||||
<column name="MSG" />
|
||||
</property>
|
||||
|
||||
<property name="apply_time" type="timestamp">
|
||||
<column name="APPLY_TIME" />
|
||||
</property>
|
||||
<property name="operation_time" type="timestamp">
|
||||
<column name="OPERATION_TIME" />
|
||||
</property>
|
||||
<property name="idimg_1" type="java.lang.String">
|
||||
<column name="IDIMG_1" />
|
||||
</property>
|
||||
|
||||
<property name="idimg_2" type="java.lang.String">
|
||||
<column name="IDIMG_2" />
|
||||
</property>
|
||||
<property name="idimg_3" type="java.lang.String">
|
||||
<column name="IDIMG_3" />
|
||||
</property>
|
||||
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
204
comm/User/src/project/user/kyc/KycHighLevel.java
Executable file
204
comm/User/src/project/user/kyc/KycHighLevel.java
Executable file
@@ -0,0 +1,204 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class KycHighLevel extends EntityObject{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1820111372329385339L;
|
||||
|
||||
private String partyId;
|
||||
/**
|
||||
* 工作地址
|
||||
*/
|
||||
private String work_place;
|
||||
/**
|
||||
* 家庭地址
|
||||
*/
|
||||
private String home_place;
|
||||
/**
|
||||
* 亲属关系
|
||||
*/
|
||||
private String relatives_relation;
|
||||
/**
|
||||
* 亲属名称
|
||||
*/
|
||||
private String relatives_name;
|
||||
/**
|
||||
* 亲属地址
|
||||
*/
|
||||
private String relatives_place;
|
||||
/**
|
||||
* 亲属电话
|
||||
*/
|
||||
private String relatives_phone;
|
||||
|
||||
/**
|
||||
* 0已申请未审核 ,1审核中 ,2 审核通过,3审核未通过
|
||||
*/
|
||||
private int status;
|
||||
/**
|
||||
* 审核消息,未通过原因
|
||||
*
|
||||
*/
|
||||
private String msg;
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
private Date apply_time;
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date operation_time;
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 证件正面照
|
||||
*/
|
||||
private String idimg_1;
|
||||
/**
|
||||
* 证件背面照
|
||||
*/
|
||||
private String idimg_2;
|
||||
/**
|
||||
* 正面手持证件照
|
||||
*/
|
||||
private String idimg_3;
|
||||
/**
|
||||
* 证件正面照文件名
|
||||
*/
|
||||
private String idimg_1_path;
|
||||
/**
|
||||
* 证件背面照文件名
|
||||
*/
|
||||
private String idimg_2_path;
|
||||
/**
|
||||
* 手持正面证件照文件名
|
||||
*/
|
||||
private String idimg_3_path;
|
||||
public String getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
public void setPartyId(String partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
public String getWork_place() {
|
||||
return work_place;
|
||||
}
|
||||
public void setWork_place(String work_place) {
|
||||
this.work_place = work_place;
|
||||
}
|
||||
public String getHome_place() {
|
||||
return home_place;
|
||||
}
|
||||
public void setHome_place(String home_place) {
|
||||
this.home_place = home_place;
|
||||
}
|
||||
public String getRelatives_relation() {
|
||||
return relatives_relation;
|
||||
}
|
||||
public void setRelatives_relation(String relatives_relation) {
|
||||
this.relatives_relation = relatives_relation;
|
||||
}
|
||||
public String getRelatives_name() {
|
||||
return relatives_name;
|
||||
}
|
||||
public void setRelatives_name(String relatives_name) {
|
||||
this.relatives_name = relatives_name;
|
||||
}
|
||||
public String getRelatives_place() {
|
||||
return relatives_place;
|
||||
}
|
||||
public void setRelatives_place(String relatives_place) {
|
||||
this.relatives_place = relatives_place;
|
||||
}
|
||||
public String getRelatives_phone() {
|
||||
return relatives_phone;
|
||||
}
|
||||
public void setRelatives_phone(String relatives_phone) {
|
||||
this.relatives_phone = relatives_phone;
|
||||
}
|
||||
public Date getApply_time() {
|
||||
return apply_time;
|
||||
}
|
||||
public void setApply_time(Date apply_time) {
|
||||
this.apply_time = apply_time;
|
||||
}
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public Date getOperation_time() {
|
||||
return operation_time;
|
||||
}
|
||||
public String getIdimg_1() {
|
||||
return idimg_1;
|
||||
}
|
||||
public String getIdimg_2() {
|
||||
return idimg_2;
|
||||
}
|
||||
public String getIdimg_3() {
|
||||
return idimg_3;
|
||||
}
|
||||
public String getIdimg_1_path() {
|
||||
return idimg_1_path;
|
||||
}
|
||||
public String getIdimg_2_path() {
|
||||
return idimg_2_path;
|
||||
}
|
||||
public String getIdimg_3_path() {
|
||||
return idimg_3_path;
|
||||
}
|
||||
public void setOperation_time(Date operation_time) {
|
||||
this.operation_time = operation_time;
|
||||
}
|
||||
public void setIdimg_1(String idimg_1) {
|
||||
this.idimg_1 = idimg_1;
|
||||
}
|
||||
public void setIdimg_2(String idimg_2) {
|
||||
this.idimg_2 = idimg_2;
|
||||
}
|
||||
public void setIdimg_3(String idimg_3) {
|
||||
this.idimg_3 = idimg_3;
|
||||
}
|
||||
public void setIdimg_1_path(String idimg_1_path) {
|
||||
this.idimg_1_path = idimg_1_path;
|
||||
}
|
||||
public void setIdimg_2_path(String idimg_2_path) {
|
||||
this.idimg_2_path = idimg_2_path;
|
||||
}
|
||||
public void setIdimg_3_path(String idimg_3_path) {
|
||||
this.idimg_3_path = idimg_3_path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
24
comm/User/src/project/user/kyc/KycHighLevelService.java
Executable file
24
comm/User/src/project/user/kyc/KycHighLevelService.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
|
||||
public interface KycHighLevelService {
|
||||
public KycHighLevel get(String partyId);
|
||||
|
||||
/**
|
||||
* 申请或修改实名认证
|
||||
*/
|
||||
public void save(KycHighLevel entity);
|
||||
|
||||
/**
|
||||
* 验证审核结果
|
||||
*/
|
||||
public String checkApplyResult(String partyId) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 删除高级认证
|
||||
*
|
||||
* @param partyId
|
||||
*/
|
||||
public void delete(String partyId);
|
||||
}
|
||||
39
comm/User/src/project/user/kyc/KycService.java
Executable file
39
comm/User/src/project/user/kyc/KycService.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package project.user.kyc;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
|
||||
public interface KycService {
|
||||
public Kyc get(String partyId);
|
||||
|
||||
/**
|
||||
* 申请或修改实名认证
|
||||
*/
|
||||
public void save(Kyc entity);
|
||||
|
||||
/**
|
||||
* 验证审核结果
|
||||
*/
|
||||
public String checkApplyResult(String partyId) throws BusinessException;
|
||||
|
||||
/**
|
||||
* 审核是否通过
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public boolean isPass(String partyId);
|
||||
|
||||
/**
|
||||
* 删除认证
|
||||
*
|
||||
* @param partyId
|
||||
*/
|
||||
public void delete(String partyId);
|
||||
|
||||
/**
|
||||
* 更新认证
|
||||
*
|
||||
* @param partyId
|
||||
*/
|
||||
public void update(String partyId , String signPdfUrl);
|
||||
}
|
||||
195
comm/User/src/project/user/kyc/internal/AdminKycHighLevelServiceImpl.java
Executable file
195
comm/User/src/project/user/kyc/internal/AdminKycHighLevelServiceImpl.java
Executable file
@@ -0,0 +1,195 @@
|
||||
package project.user.kyc.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.tip.TipService;
|
||||
import project.user.kyc.AdminKycHighLevelService;
|
||||
import project.user.kyc.KycHighLevel;
|
||||
import project.user.kyc.KycHighLevelService;
|
||||
|
||||
public class AdminKycHighLevelServiceImpl extends HibernateDaoSupport implements AdminKycHighLevelService {
|
||||
private static final String KycHighLevel = null;
|
||||
private PagedQueryDao pagedQueryDao;
|
||||
private PartyService partyService;
|
||||
private UserRecomService userRecomService;
|
||||
private KycHighLevelService kycHighLevelService;
|
||||
private TipService tipService;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, Integer status_para, String rolename_para,
|
||||
String checkedPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(
|
||||
" party.UUID partyId,party.USERCODE usercode,party.USERNAME username,party.ROLENAME rolename,");
|
||||
queryString.append(" kyc.UUID id,kyc.WORK_PLACE work_place,kyc.HOME_PLACE home_place,"
|
||||
+ "kyc.RELATIVES_RELATION relatives_relation,"
|
||||
+ "kyc.APPLY_TIME apply_time,kyc.OPERATION_TIME operation_time,"
|
||||
+ " kyc.IDIMG_1 idimg_1,kyc.IDIMG_2 idimg_2,kyc.IDIMG_3 idimg_3, "
|
||||
+ "kyc.RELATIVES_NAME relatives_name," + "kyc.RELATIVES_PLACE relatives_place,kyc.STATUS status,"
|
||||
+ "kyc.MSG msg,kyc.RELATIVES_PHONE relatives_phone,party_parent.USERNAME username_parent ");
|
||||
queryString.append(" FROM ");
|
||||
queryString.append(" T_KYC_HIGH_LEVEL kyc LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
|
||||
queryString.append(" LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID ");
|
||||
queryString.append(" LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
|
||||
checked_list.add(checkedPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return Page.EMPTY_PAGE;
|
||||
}
|
||||
|
||||
queryString.append(" and party.UUID in(:checked_list) ");
|
||||
parameters.put("checked_list", checked_list);
|
||||
|
||||
}
|
||||
|
||||
if (status_para != null) {
|
||||
queryString.append(" and kyc.STATUS = :status_para ");
|
||||
parameters.put("status_para", status_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(rolename_para)) {
|
||||
queryString.append(" and party.ROLENAME =:rolename");
|
||||
parameters.put("rolename", rolename_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
queryString.append(" order by kyc.APPLY_TIME desc ");
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KycHighLevel findByPartyId(Serializable partyId) {
|
||||
List<KycHighLevel> list = (List<project.user.kyc.KycHighLevel>) getHibernateTemplate().find(" FROM KycHighLevel WHERE partyId = ?0",
|
||||
new Object[] { partyId });
|
||||
if (list.size() > 0) {
|
||||
KycHighLevel k = (KycHighLevel) list.get(0);
|
||||
Party party = partyService.cachePartyBy(k.getPartyId(), true);
|
||||
k.setUsername(party.getUsername());
|
||||
return (KycHighLevel) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public KycHighLevel findById(Serializable id) {
|
||||
KycHighLevel kycHighLevel = getHibernateTemplate().get(KycHighLevel.class, id);
|
||||
if (kycHighLevel != null) {
|
||||
Party party = partyService.cachePartyBy(kycHighLevel.getPartyId(), true);
|
||||
kycHighLevel.setUsername(party.getUsername());
|
||||
return kycHighLevel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePassed(String partyId) {
|
||||
KycHighLevel kycHighLevel = findByPartyId(partyId);
|
||||
if (kycHighLevel != null) {
|
||||
kycHighLevel.setStatus(2);
|
||||
// this.getHibernateTemplate().update(kycHighLevel);
|
||||
kycHighLevelService.save(kycHighLevel);
|
||||
|
||||
Party party = partyService.cachePartyBy(partyId, false);
|
||||
party.setKyc_highlevel_authority(true);
|
||||
|
||||
// 获取用户系统等级:1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证; 4/用户高级认证;
|
||||
int userLevelSystem = this.partyService.getUserLevelByAuth(party);
|
||||
|
||||
// 十进制个位表示系统级别:1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证;4/用户高级认证;
|
||||
// 十进制十位表示自定义级别:对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
|
||||
// 如:级别11表示:新注册的前端显示为VIP1;
|
||||
int userLevel = party.getUser_level();
|
||||
party.setUser_level(((int) Math.floor(userLevel / 10)) * 10 + userLevelSystem);
|
||||
|
||||
this.partyService.update(party);
|
||||
|
||||
tipService.deleteTip(kycHighLevel.getId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFailed(String partyId, String msg) {
|
||||
KycHighLevel kycHighLevel = findByPartyId(partyId);
|
||||
if (kycHighLevel != null) {
|
||||
kycHighLevel.setStatus(3);
|
||||
kycHighLevel.setMsg(msg);
|
||||
// this.getHibernateTemplate().update(kycHighLevel);
|
||||
kycHighLevelService.save(kycHighLevel);
|
||||
Party party = partyService.cachePartyBy(partyId, false);
|
||||
party.setKyc_highlevel_authority(false);
|
||||
partyService.update(party);
|
||||
tipService.deleteTip(kycHighLevel.getId().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT COUNT(*) FROM KycHighLevel WHERE status in(0,1) ");
|
||||
List<Object> para = new ArrayList<Object>();
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
|
||||
if (StringUtils.isEmptyString(childrensIds)) {
|
||||
return 0L;
|
||||
}
|
||||
queryString.append(" and partyId in (" + childrensIds + ") ");
|
||||
}
|
||||
if (null != time) {
|
||||
queryString.append("AND apply_time > ?0");
|
||||
para.add(time);
|
||||
}
|
||||
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
|
||||
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
public void setKycHighLevelService(KycHighLevelService kycHighLevelService) {
|
||||
this.kycHighLevelService = kycHighLevelService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
317
comm/User/src/project/user/kyc/internal/AdminKycServiceImpl.java
Executable file
317
comm/User/src/project/user/kyc/internal/AdminKycServiceImpl.java
Executable file
@@ -0,0 +1,317 @@
|
||||
package project.user.kyc.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.DateUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.hibernate.query.NativeQuery;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.web.Page;
|
||||
import kernel.web.PagedQueryDao;
|
||||
import project.mall.notification.utils.notify.client.NotificationHelperClient;
|
||||
import project.mall.seller.model.Seller;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.tip.TipService;
|
||||
import project.user.kyc.AdminKycService;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
|
||||
public class AdminKycServiceImpl extends HibernateDaoSupport implements AdminKycService {
|
||||
protected PagedQueryDao pagedQueryDao;
|
||||
protected PartyService partyService;
|
||||
protected UserRecomService userRecomService;
|
||||
protected KycService kycService;
|
||||
protected TipService tipService;
|
||||
private NotificationHelperClient notificationHelperClient;
|
||||
|
||||
@Override
|
||||
public Page pagedQuery(int pageNo, int pageSize, String name_para, String status_para, String rolename_para,
|
||||
String checkedPartyId, String idnumber_para, String email_para, String startTime, String endTime, String sellerName, String username_parent) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT");
|
||||
queryString.append(
|
||||
" party.UUID partyId,party.USERCODE usercode,party.USERNAME username,party.PHONE phone,party.EMAIL email,party.ROLENAME rolename, party.REMARKS remark,");
|
||||
queryString.append(
|
||||
" kyc.UUID id,kyc.IDNUMBER idnumber,kyc.IDNAME idname,kyc.NAME name,seller.NAME sellerName,seller.AVATAR sellerImg,seller.SHOP_ADDRESS sellerAddress,"
|
||||
+ "kyc.IDIMG_1 idimg_1,kyc.IDIMG_2 idimg_2,kyc.IDIMG_3 idimg_3,kyc.APPLY_TIME apply_time,kyc.OPERATION_TIME operation_time, kyc.REMARK remarks,"
|
||||
+ "kyc.STATUS status,kyc.MSG msg,kyc.nationality nationality ,party_parent.USERNAME username_parent");
|
||||
queryString.append(" FROM");
|
||||
queryString.append(" T_KYC kyc LEFT JOIN PAT_PARTY party ON kyc.PARTY_ID = party.UUID ");
|
||||
queryString.append(" LEFT JOIN PAT_USER_RECOM user ON user.PARTY_ID = party.UUID ");
|
||||
queryString.append(" LEFT JOIN PAT_PARTY party_parent ON user.RECO_ID = party_parent.UUID ");
|
||||
queryString.append(" LEFT JOIN T_MALL_SELLER seller ON party.UUID = seller.UUID ");
|
||||
queryString.append(" WHERE 1=1 ");
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(checkedPartyId)) {
|
||||
|
||||
List<String> checked_list = this.userRecomService.findChildren(checkedPartyId);
|
||||
checked_list.add(checkedPartyId);
|
||||
if (checked_list.size() == 0) {
|
||||
return Page.EMPTY_PAGE;
|
||||
}
|
||||
|
||||
queryString.append(" and party.UUID in(:checked_list)");
|
||||
parameters.put("checked_list", checked_list);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(sellerName)) {
|
||||
queryString.append(" AND trim(replace(seller.`NAME`,' ','')) like:sellerName ");
|
||||
sellerName = sellerName.replace(" ", "");
|
||||
parameters.put("sellerName", "%" + sellerName + "%");
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(username_parent)) {
|
||||
queryString.append(" AND trim(replace(party_parent.USERNAME,' ','')) like:username_parent ");
|
||||
username_parent = username_parent.replace(" ", "");
|
||||
parameters.put("username_parent", "%" + username_parent + "%");
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(status_para)) {
|
||||
queryString.append(" and kyc.STATUS = :status_para ");
|
||||
parameters.put("status_para", status_para);
|
||||
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(rolename_para)) {
|
||||
queryString.append(" and party.ROLENAME =:rolename");
|
||||
parameters.put("rolename", rolename_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(name_para)) {
|
||||
queryString.append("AND (party.USERNAME like:username OR party.USERCODE like:username ) ");
|
||||
parameters.put("username", "%" + name_para + "%");
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(idnumber_para)) {
|
||||
queryString.append("AND kyc.IDNUMBER =:idnumber_para ");
|
||||
parameters.put("idnumber_para", idnumber_para);
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(email_para)) {
|
||||
queryString.append("AND (party.PHONE like:email_para OR party.EMAIL like:email_para ) ");
|
||||
parameters.put("email_para", "%" + email_para + "%");
|
||||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(startTime)) {
|
||||
queryString.append(" AND DATE(kyc.APPLY_TIME) >= DATE(:startTime) ");
|
||||
parameters.put("startTime", DateUtils.toDate(startTime));
|
||||
}
|
||||
if (!StringUtils.isNullOrEmpty(endTime)) {
|
||||
queryString.append(" AND DATE(kyc.APPLY_TIME) <= DATE(:endTime) ");
|
||||
parameters.put("endTime", DateUtils.toDate(endTime));
|
||||
}
|
||||
|
||||
queryString.append(" order by kyc.APPLY_TIME desc ");
|
||||
|
||||
Page page = this.pagedQueryDao.pagedQuerySQL(pageNo, pageSize, queryString.toString(), parameters);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Kyc find(Serializable partyId) {
|
||||
List<Kyc> list = (List<Kyc>) getHibernateTemplate().find(" FROM Kyc WHERE partyId = ?0", new Object[]{partyId});
|
||||
if (list.size() > 0) {
|
||||
return (Kyc) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Seller getSeller(String sellerId) {
|
||||
return getHibernateTemplate().get(Seller.class, sellerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePassed(String partyId) {
|
||||
Kyc kyc = find(partyId);
|
||||
if (kyc != null) {
|
||||
kyc.setStatus(2);
|
||||
kycService.save(kyc);
|
||||
// this.getHibernateTemplate().update(kyc);
|
||||
tipService.deleteTip(kyc.getId().toString());
|
||||
}
|
||||
Seller seller = getSeller(partyId);
|
||||
if (null == seller) {
|
||||
throw new BusinessException("申请通过失败,店铺信息未初始化");
|
||||
}
|
||||
seller.setCreateTime(new Date());
|
||||
seller.setRecTime(0L);
|
||||
seller.setStatus(1);
|
||||
seller.setCreditScore(100);
|
||||
getHibernateTemplate().update(seller);
|
||||
|
||||
Party party = this.partyService.cachePartyBy(partyId, false);
|
||||
party.setKyc_authority(true);
|
||||
party.setRoleType(1);
|
||||
|
||||
// 获取用户系统等级:1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证; 4/用户高级认证;
|
||||
int userLevelSystem = this.partyService.getUserLevelByAuth(party);
|
||||
|
||||
// 十进制个位表示系统级别:1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证;4/用户高级认证;
|
||||
// 十进制十位表示自定义级别:对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
|
||||
// 如:级别11表示:新注册的前端显示为VIP1;
|
||||
int userLevel = party.getUser_level();
|
||||
party.setUser_level(((int) Math.floor(userLevel / 10)) * 10 + userLevelSystem);
|
||||
|
||||
this.partyService.update(party);
|
||||
|
||||
// 通知商家审核结果
|
||||
try {
|
||||
notificationHelperClient.notifyStoreAuditByInbox(partyId, 2, seller.getName(), null);
|
||||
} catch (Exception e) {
|
||||
logger.error("发送通知消息提醒商家下单事件报错:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveFailed(String partyId, String msg) {
|
||||
Kyc kyc = find(partyId);
|
||||
if (kyc != null) {
|
||||
kyc.setStatus(3);
|
||||
kyc.setMsg(msg);
|
||||
kycService.save(kyc);
|
||||
// this.getHibernateTemplate().update(kyc);
|
||||
tipService.deleteTip(kyc.getId().toString());
|
||||
|
||||
}
|
||||
Seller seller = getSeller(partyId);
|
||||
if (null == seller) {
|
||||
throw new BusinessException("申请不通过失败,店铺信息未初始化");
|
||||
}
|
||||
Party party = partyService.cachePartyBy(partyId, false);
|
||||
party.setKyc_authority(false);
|
||||
partyService.update(party);
|
||||
// 通知商家审核结果
|
||||
try {
|
||||
notificationHelperClient.notifyStoreAuditByInbox(partyId, 3, seller.getName(), msg);
|
||||
} catch (Exception e) {
|
||||
logger.error("发送通知消息提醒商家下单事件报错:", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveFaileds(String partyId, String msg) {
|
||||
Kyc kyc = find(partyId);
|
||||
if (kyc != null) {
|
||||
kyc.setStatus(3);
|
||||
kyc.setMsg(msg);
|
||||
kycService.save(kyc);
|
||||
}
|
||||
|
||||
Seller seller = getSeller(partyId);
|
||||
seller.setRecTime(0L);
|
||||
seller.setStatus(0);
|
||||
seller.setCreditScore(0);
|
||||
getHibernateTemplate().update(seller);
|
||||
|
||||
Party party = partyService.cachePartyBy(partyId, false);
|
||||
party.setKyc_authority(false);
|
||||
party.setRoleType(0);
|
||||
partyService.update(party);
|
||||
// getHibernateTemplate().flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveKycPic(String partyId, String imgId, String img) {
|
||||
Kyc kyc = find(partyId);
|
||||
if (kyc != null) {
|
||||
if ("1".equals(imgId)) {
|
||||
kyc.setIdimg_1(img);
|
||||
} else if ("2".equals(imgId)) {
|
||||
kyc.setIdimg_2(img);
|
||||
} else if ("3".equals(imgId)) {
|
||||
kyc.setIdimg_3(img);
|
||||
}
|
||||
kycService.save(kyc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个时间后未处理数量,没有时间则全部
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public Long getUntreatedCount(Date time, String loginPartyId) {
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT COUNT(*) FROM Kyc WHERE status in(0,1) ");
|
||||
List<Object> para = new ArrayList<Object>();
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
String childrensIds = this.userRecomService.findChildrensIds(loginPartyId);
|
||||
if (StringUtils.isEmptyString(childrensIds)) {
|
||||
return 0L;
|
||||
}
|
||||
queryString.append(" and partyId in (" + childrensIds + ") ");
|
||||
}
|
||||
if (null != time) {
|
||||
queryString.append("AND apply_time > ?");
|
||||
para.add(time);
|
||||
}
|
||||
List find = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
|
||||
return CollectionUtils.isEmpty(find) ? 0L : find.get(0) == null ? 0L : Long.valueOf(find.get(0).toString());
|
||||
}
|
||||
|
||||
public Map<String, Object> findKycSumData() {
|
||||
Map<String, Object> sumData = new HashMap<>();
|
||||
StringBuffer sql = new StringBuffer(" SELECT ");
|
||||
sql.append(" IFNULL(count(k.UUID),0) sellerNum, ");
|
||||
sql.append(" MAX(k.UUID) id ");
|
||||
sql.append(" FROM ");
|
||||
sql.append(" T_KYC k ");
|
||||
sql.append(" WHERE to_days(k.OPERATION_TIME) = TO_DAYS(now()) AND k.STATUS = 2 ");
|
||||
NativeQuery<Object[]> nativeQuery = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createNativeQuery(sql.toString());
|
||||
Object[] results = nativeQuery.getSingleResult();
|
||||
sumData.put("todaySellerCount", results[0]);
|
||||
sumData.put("id", results[1]);
|
||||
|
||||
StringBuffer queryString = new StringBuffer();
|
||||
queryString.append("SELECT COUNT(*) FROM Kyc WHERE status = 2 ");
|
||||
List<Object> para = new ArrayList<Object>();
|
||||
List seller = this.getHibernateTemplate().find(queryString.toString(), para.toArray());
|
||||
Long sellerCount = CollectionUtils.isEmpty(seller) ? 0L : seller.get(0) == null ? 0L : Long.valueOf(seller.get(0).toString());
|
||||
sumData.put("sellerCount", sellerCount);
|
||||
return sumData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRemarks(String partyId, String remarks) {
|
||||
Kyc kyc = find(partyId);
|
||||
if (kyc != null) {
|
||||
if (StringUtils.isNotEmpty(remarks)) {
|
||||
kyc.setRemark(remarks);
|
||||
getHibernateTemplate().update(kyc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPagedQueryDao(PagedQueryDao pagedQueryDao) {
|
||||
this.pagedQueryDao = pagedQueryDao;
|
||||
}
|
||||
|
||||
public void setPartyService(PartyService partyService) {
|
||||
this.partyService = partyService;
|
||||
}
|
||||
|
||||
public void setUserRecomService(UserRecomService userRecomService) {
|
||||
this.userRecomService = userRecomService;
|
||||
}
|
||||
|
||||
public void setKycService(KycService kycService) {
|
||||
this.kycService = kycService;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
public void setNotificationHelperClient(NotificationHelperClient notificationHelperClient) {
|
||||
this.notificationHelperClient = notificationHelperClient;
|
||||
}
|
||||
}
|
||||
110
comm/User/src/project/user/kyc/internal/KycHighLevelServiceImpl.java
Executable file
110
comm/User/src/project/user/kyc/internal/KycHighLevelServiceImpl.java
Executable file
@@ -0,0 +1,110 @@
|
||||
package project.user.kyc.internal;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import project.redis.RedisHandler;
|
||||
import project.tip.TipService;
|
||||
import project.user.UserRedisKeys;
|
||||
import project.user.kyc.KycHighLevel;
|
||||
import project.user.kyc.KycHighLevelService;
|
||||
|
||||
public class KycHighLevelServiceImpl extends HibernateDaoSupport implements KycHighLevelService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private TipService tipService;
|
||||
|
||||
@Override
|
||||
public KycHighLevel get(String partyId) {
|
||||
// StringBuffer queryString = new StringBuffer(" FROM KycHighLevel where partyId = ?");
|
||||
// List<KycHighLevel> list = null;
|
||||
// list = this.getHibernateTemplate().find(queryString.toString(), new Object[] { partyId });
|
||||
// if (list.size() > 0) {
|
||||
// return list.get(0);
|
||||
// }
|
||||
KycHighLevel kycHighLevel = (KycHighLevel) redisHandler.get(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + partyId);
|
||||
if (kycHighLevel != null)
|
||||
return kycHighLevel;
|
||||
KycHighLevel obj = new KycHighLevel();
|
||||
obj.setPartyId(partyId);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(KycHighLevel entity) {
|
||||
KycHighLevel kycHighLevel = get(entity.getPartyId().toString());
|
||||
if(entity.getStatus()==1) {
|
||||
entity.setApply_time(new Date());
|
||||
}else {
|
||||
entity.setOperation_time(new Date());
|
||||
}
|
||||
if (kycHighLevel.getId() == null) {
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + entity.getPartyId().toString(), entity);
|
||||
} else {
|
||||
// entity.setPartyId(kycHighLevel.getPartyId());
|
||||
entity.setId(kycHighLevel.getId());
|
||||
|
||||
BeanUtils.copyProperties(entity, kycHighLevel);
|
||||
|
||||
// kycHighLevel.setApply_time(new Date());
|
||||
this.getHibernateTemplate().merge(kycHighLevel);
|
||||
redisHandler.setSync(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + kycHighLevel.getPartyId().toString(),
|
||||
kycHighLevel);
|
||||
}
|
||||
// tipService.saveTip(kycHighLevel.getId().toString(), TipConstants.KYC_HIGH_LEVEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证审核结果
|
||||
*/
|
||||
public String checkApplyResult(String partyId) throws BusinessException {
|
||||
KycHighLevel kycHighLevel = get(partyId);
|
||||
if (null == kycHighLevel.getId())
|
||||
return "";
|
||||
String msg = "";
|
||||
switch (kycHighLevel.getStatus()) {
|
||||
case 0:
|
||||
msg = "已经提交申请,请等待审核";
|
||||
break;
|
||||
case 1:
|
||||
msg = "审核中";
|
||||
break;
|
||||
case 2:
|
||||
msg = "审核已通过";
|
||||
break;
|
||||
case 3:
|
||||
msg = MessageFormat.format("审核未通过,原因:{0}", kycHighLevel.getMsg());
|
||||
break;
|
||||
default:
|
||||
msg = "审核状态异常请联系客服";
|
||||
break;
|
||||
}
|
||||
if (kycHighLevel.getStatus() != 3) {
|
||||
throw new BusinessException(msg);
|
||||
} else {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
public void delete(String partyId) {
|
||||
KycHighLevel kycHighLevel = get(partyId);
|
||||
if (kycHighLevel != null) {
|
||||
this.getHibernateTemplate().delete(kycHighLevel);
|
||||
redisHandler.remove(UserRedisKeys.KYC_HIGHLEVEL_PARTY_ID + partyId);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setTipService(TipService tipService) {
|
||||
this.tipService = tipService;
|
||||
}
|
||||
|
||||
}
|
||||
175
comm/User/src/project/user/kyc/internal/KycServiceImpl.java
Executable file
175
comm/User/src/project/user/kyc/internal/KycServiceImpl.java
Executable file
@@ -0,0 +1,175 @@
|
||||
package project.user.kyc.internal;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.UserRedisKeys;
|
||||
import project.user.kyc.Kyc;
|
||||
import project.user.kyc.KycService;
|
||||
|
||||
@Slf4j
|
||||
public class KycServiceImpl extends HibernateDaoSupport implements KycService {
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Override
|
||||
public Kyc get(String partyId) {
|
||||
// StringBuffer queryString = new StringBuffer(" FROM Kyc where partyId = ?");
|
||||
// List<Kyc> list = null;
|
||||
// list = this.getHibernateTemplate().find(queryString.toString(), new Object[] { partyId });
|
||||
// if (list.size() > 0) {
|
||||
// return list.get(0);
|
||||
// }
|
||||
Kyc kyc = (Kyc) redisHandler.get(UserRedisKeys.KYC_PARTY_ID + partyId);
|
||||
if (kyc != null) {
|
||||
return kyc;
|
||||
} else {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Kyc where partyId = ?0 ");
|
||||
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString(), new Object[]{partyId});
|
||||
if (list.size() > 0) {
|
||||
kyc = list.get(0);
|
||||
}
|
||||
if (kyc != null) {
|
||||
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + partyId, kyc);
|
||||
return kyc;
|
||||
}
|
||||
}
|
||||
|
||||
kyc = new Kyc();
|
||||
kyc.setPartyId(partyId);
|
||||
return kyc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Kyc entity) {
|
||||
Kyc kyc = get(entity.getPartyId().toString());
|
||||
//身份证号可以重复实名 8-4号需求
|
||||
// List<Kyc> kycs = findByIdNumber(entity.getIdnumber().trim());
|
||||
// if (kycs != null && entity.getStatus() != 3 && entity.getStatus() != 1) {
|
||||
// for (Kyc kyc_othde : kycs) {
|
||||
// if (kyc_othde.getStatus() == 2 && !kyc_othde.getPartyId().equals(entity.getPartyId())) {
|
||||
// throw new BusinessException("身份证号已实名过!");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//// if(kycs.size() == 1 && kyc != null && kyc.getId() != null) {
|
||||
//// if(!kyc.getId().equals(kycs.get(0).getId()) &&
|
||||
//// kyc.getIdnumber().equals(kycs.get(0).getIdnumber())) {
|
||||
//// throw new BusinessException("身份证已实名过!");
|
||||
//// }
|
||||
//// }
|
||||
//// if(kycs.size() > 1 ) {
|
||||
//// throw new BusinessException("身份证已实名过!");
|
||||
//// }
|
||||
// }
|
||||
|
||||
if (kyc.getId() == null) {
|
||||
entity.setApply_time(new Date());
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + entity.getPartyId().toString(), entity);
|
||||
} else {
|
||||
kyc.setIdnumber(entity.getIdnumber());
|
||||
kyc.setStatus(entity.getStatus());
|
||||
kyc.setIdname(entity.getIdname());
|
||||
kyc.setName(entity.getName());
|
||||
kyc.setIdimg_1(entity.getIdimg_1());
|
||||
kyc.setIdimg_2(entity.getIdimg_2());
|
||||
kyc.setIdimg_3(entity.getIdimg_3());
|
||||
kyc.setNationality(entity.getNationality());
|
||||
if (entity.getStatus() == 1) {
|
||||
kyc.setApply_time(new Date());
|
||||
} else {
|
||||
kyc.setOperation_time(new Date());
|
||||
}
|
||||
|
||||
kyc.setMsg(entity.getMsg());
|
||||
this.getHibernateTemplate().merge(kyc);
|
||||
entity.setId(kyc.getId());
|
||||
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update(String partyId, String signPdfUrl) {
|
||||
Kyc kyc = get(partyId);
|
||||
kyc.setSignPdfUrl(signPdfUrl);
|
||||
log.info("更新商家人认证信息{}", JSONObject.toJSONString(kyc));
|
||||
this.getHibernateTemplate().merge(kyc);
|
||||
redisHandler.setSync(UserRedisKeys.KYC_PARTY_ID + kyc.getPartyId().toString(), kyc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询是否有多个实名用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<Kyc> findByIdNumber(String idNumber) {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Kyc where idnumber = ?0");
|
||||
List<Kyc> list = (List<Kyc>) this.getHibernateTemplate().find(queryString.toString(), new Object[]{idNumber});
|
||||
if (list.size() > 0) {
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证审核结果
|
||||
*/
|
||||
public String checkApplyResult(String partyId) throws BusinessException {
|
||||
Kyc kyc = get(partyId);
|
||||
if (null == kyc.getId())
|
||||
return "";
|
||||
String msg = "";
|
||||
switch (kyc.getStatus()) {
|
||||
case 0:
|
||||
msg = "已经提交申请,请等待审核";
|
||||
break;
|
||||
case 1:
|
||||
msg = "审核中";
|
||||
break;
|
||||
case 2:
|
||||
msg = "审核已通过";
|
||||
break;
|
||||
case 3:
|
||||
msg = MessageFormat.format("审核未通过,原因:{0}", kyc.getMsg());
|
||||
break;
|
||||
default:
|
||||
msg = "审核状态异常请联系客服";
|
||||
break;
|
||||
}
|
||||
if (kyc.getStatus() != 3) {
|
||||
throw new BusinessException(msg);
|
||||
} else {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPass(String partyId) {
|
||||
Kyc kyc = get(partyId);
|
||||
if (null == kyc)
|
||||
return Boolean.FALSE;
|
||||
return kyc.getStatus() == 2;
|
||||
}
|
||||
|
||||
public void delete(String partyId) {
|
||||
Kyc kyc = get(partyId);
|
||||
if (kyc != null) {
|
||||
this.getHibernateTemplate().delete(kyc);
|
||||
redisHandler.remove(UserRedisKeys.KYC_PARTY_ID + partyId);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
19
comm/User/src/project/user/token/ToKen.hbm.xml
Executable file
19
comm/User/src/project/user/token/ToKen.hbm.xml
Executable file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
<class name="project.user.token.Token" table="T_TOKEN">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="partyId" type="java.lang.String">
|
||||
<column name="PARTY_ID" />
|
||||
</property>
|
||||
|
||||
<property name="token" type="java.lang.String">
|
||||
<column name="TOKEN" />
|
||||
</property>
|
||||
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
31
comm/User/src/project/user/token/Token.java
Executable file
31
comm/User/src/project/user/token/Token.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package project.user.token;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class Token extends EntityObject{
|
||||
private static final long serialVersionUID = -5132505045848059321L;
|
||||
|
||||
private Serializable partyId;
|
||||
|
||||
private String token;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
comm/User/src/project/user/token/TokenService.java
Executable file
19
comm/User/src/project/user/token/TokenService.java
Executable file
@@ -0,0 +1,19 @@
|
||||
package project.user.token;
|
||||
|
||||
public interface TokenService {
|
||||
|
||||
public String savePut(String partyId);
|
||||
|
||||
public String platFromSavePut(String partyId);
|
||||
|
||||
|
||||
public String cacheGet(String token);
|
||||
|
||||
public void delete(String token);
|
||||
|
||||
public void removePlatFromToken(String token);
|
||||
|
||||
public void removeLoginToken(String partyId);
|
||||
|
||||
public Token find(String partyId) ;
|
||||
}
|
||||
148
comm/User/src/project/user/token/internal/TokenServiceImpl.java
Executable file
148
comm/User/src/project/user/token/internal/TokenServiceImpl.java
Executable file
@@ -0,0 +1,148 @@
|
||||
package project.user.token.internal;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.util.StringUtils;
|
||||
import kernel.util.UUIDGenerator;
|
||||
import project.redis.RedisHandler;
|
||||
import project.user.UserRedisKeys;
|
||||
import project.user.token.Token;
|
||||
import project.user.token.TokenService;
|
||||
import util.TokenUtils;
|
||||
|
||||
public class TokenServiceImpl extends HibernateDaoSupport implements TokenService {
|
||||
|
||||
private Logger logger = LogManager.getLogger(TokenServiceImpl.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public String savePut(String partyId) {
|
||||
String uuid = UUIDGenerator.getUUID();
|
||||
Token token = this.find(partyId);
|
||||
|
||||
if (token == null) {
|
||||
token = new Token();
|
||||
token.setPartyId(partyId);
|
||||
}
|
||||
token.setToken(uuid);
|
||||
this.getHibernateTemplate().saveOrUpdate(token);
|
||||
redisHandler.setSync(UserRedisKeys.TOKEN + uuid, partyId);
|
||||
redisHandler.setSync(UserRedisKeys.TOKEN_PARTY_ID + partyId, token);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String platFromSavePut(String partyId) {
|
||||
Token token = new Token();
|
||||
token.setPartyId(partyId);
|
||||
String uuid = TokenUtils.token(null, null, false, partyId);
|
||||
token.setToken(uuid);
|
||||
redisHandler.setSync(UserRedisKeys.PLAT_FROM_TOKEN + uuid, partyId);
|
||||
redisHandler.setSync(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId, token);
|
||||
return uuid;
|
||||
|
||||
}
|
||||
|
||||
public String cacheGet(String token) {
|
||||
if (StringUtils.isNullOrEmpty(token)) {
|
||||
logger.error("cacheGet:token is null");
|
||||
return null;
|
||||
}
|
||||
|
||||
String partyId;
|
||||
if (token.length() > 36){
|
||||
|
||||
partyId = (String) redisHandler.get(UserRedisKeys.PLAT_FROM_TOKEN + token);
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
logger.error("cacheGet:partyId is null, token:" + token);
|
||||
return null;
|
||||
}
|
||||
|
||||
Token token_redis = (Token) redisHandler.get(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId);
|
||||
if (null == token_redis) {
|
||||
logger.error("cacheGet:token_redis is null, token:" + token);
|
||||
return null;
|
||||
}
|
||||
if (!token.equals(token_redis.getToken())) {
|
||||
|
||||
logger.error("cacheGet:请求token:{}和token_redis{}不同", token, token_redis.getToken());
|
||||
// redisHandler.remove(UserRedisKeys.TOKEN + token);
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
partyId = (String) redisHandler.get(UserRedisKeys.TOKEN + token);
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
logger.error("cacheGet:partyId is null, token:" + token);
|
||||
return null;
|
||||
}
|
||||
|
||||
Token token_redis = (Token) redisHandler.get(UserRedisKeys.TOKEN_PARTY_ID + partyId);
|
||||
if (null == token_redis) {
|
||||
logger.error("cacheGet:token_redis is null, token:" + token);
|
||||
return null;
|
||||
}
|
||||
if (!token.equals(token_redis.getToken())) {
|
||||
|
||||
logger.error("cacheGet:请求token:{}和token_redis{}不同", token, token_redis.getToken());
|
||||
// redisHandler.remove(UserRedisKeys.TOKEN + token);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public Token find(String partyId) {
|
||||
return (Token) redisHandler.get(UserRedisKeys.TOKEN_PARTY_ID + partyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String token) {
|
||||
if (StringUtils.isNullOrEmpty(token)) {
|
||||
return;
|
||||
}
|
||||
String partyId = cacheGet(token);
|
||||
if (!StringUtils.isNullOrEmpty(partyId)) {
|
||||
Token entity = find(partyId);
|
||||
if (entity != null) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
}
|
||||
}
|
||||
redisHandler.remove(UserRedisKeys.TOKEN + token);
|
||||
redisHandler.remove(UserRedisKeys.TOKEN_PARTY_ID + partyId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlatFromToken(String token) {
|
||||
if (StringUtils.isNullOrEmpty(token)) {
|
||||
return;
|
||||
}
|
||||
String partyId = cacheGet(token);
|
||||
redisHandler.remove(UserRedisKeys.PLAT_FROM_TOKEN + token);
|
||||
redisHandler.remove(UserRedisKeys.PLAT_FROM_TOKEN_PARTY_ID + partyId);
|
||||
}
|
||||
|
||||
public void removeLoginToken(String partyId) {
|
||||
if (StringUtils.isNullOrEmpty(partyId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Token entity = find(partyId);
|
||||
if (entity != null) {
|
||||
this.getHibernateTemplate().delete(entity);
|
||||
|
||||
redisHandler.remove(UserRedisKeys.TOKEN + entity.getToken());
|
||||
redisHandler.remove(UserRedisKeys.TOKEN_PARTY_ID + partyId);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user