first commit
This commit is contained in:
77
comm/Party/src/project/data/loadcache/PartyLoadCacheService.java
Executable file
77
comm/Party/src/project/data/loadcache/PartyLoadCacheService.java
Executable file
@@ -0,0 +1,77 @@
|
||||
package project.data.loadcache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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.party.PartyRedisKeys;
|
||||
import project.party.model.Party;
|
||||
import project.party.model.UserRecom;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class PartyLoadCacheService extends HibernateDaoSupport {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(PartyLoadCacheService.class);
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public void loadcache() {
|
||||
loadParty();
|
||||
loadUserRecom();
|
||||
logger.info("完成Party数据加载redis");
|
||||
}
|
||||
|
||||
private void loadParty() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM Party ");
|
||||
List<Party> list =(List<Party>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, Party> cache = new ConcurrentHashMap<String, Party>();
|
||||
Map<String, Date> onlineCache = new ConcurrentHashMap<String, Date>();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Party party = list.get(i);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + party.getId().toString(), party);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + party.getUsername(), party);
|
||||
|
||||
cache.put(list.get(i).getId().toString(), party);
|
||||
}
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ONLINEUSER, onlineCache);
|
||||
}
|
||||
|
||||
private void loadUserRecom() {
|
||||
StringBuffer queryString = new StringBuffer(" FROM UserRecom ");
|
||||
List<UserRecom> list = (List<UserRecom>) this.getHibernateTemplate().find(queryString.toString());
|
||||
Map<String, List<UserRecom>> map = new ConcurrentHashMap<String, List<UserRecom>>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_PARTYID + list.get(i).getPartyId(), list.get(i));
|
||||
List<UserRecom> recos = map.get(list.get(i).getReco_id().toString());
|
||||
if (recos == null) {
|
||||
recos = new ArrayList<UserRecom>();
|
||||
}
|
||||
recos.add(list.get(i));
|
||||
|
||||
map.put(list.get(i).getReco_id().toString(), recos);
|
||||
}
|
||||
|
||||
Map<String, Object> params = new ConcurrentHashMap<String, Object>();
|
||||
Iterator<Entry<String, List<UserRecom>>> it = map.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, List<UserRecom>> entry = it.next();
|
||||
params.put(PartyRedisKeys.USER_RECOM_RECO_ID + entry.getKey(), entry.getValue());
|
||||
}
|
||||
redisHandler.setBatchSync(params);
|
||||
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
}
|
||||
195
comm/Party/src/project/party/NormalReg.java
Executable file
195
comm/Party/src/project/party/NormalReg.java
Executable file
@@ -0,0 +1,195 @@
|
||||
package project.party;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 注册普通用户VO类,无推荐关系,双轨图,序列关系
|
||||
*/
|
||||
public class NormalReg implements Serializable {
|
||||
|
||||
/**
|
||||
* Member Description
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 3619328158518055604L;
|
||||
|
||||
protected Serializable partyId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 权限角色
|
||||
*/
|
||||
protected String rolename;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
protected String username;
|
||||
|
||||
/**
|
||||
* 电话号码
|
||||
*/
|
||||
protected String phone;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
protected String email;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
protected String password;
|
||||
|
||||
/**
|
||||
* 安全码,资金密码,username+safeword MD5编码
|
||||
*/
|
||||
private String safeword;
|
||||
/**
|
||||
* 用户code
|
||||
*/
|
||||
private String usercode;
|
||||
|
||||
/**
|
||||
* 是否锁定,如果锁定可以登录、查看,但不能操作业务有关。
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
/**
|
||||
* 登录权限
|
||||
*/
|
||||
private boolean login_authority = true;
|
||||
|
||||
/**
|
||||
* 提现权限
|
||||
*/
|
||||
private boolean withdraw_authority = true;
|
||||
|
||||
/**
|
||||
* 充值权限
|
||||
*/
|
||||
private boolean recharge_authority = true;
|
||||
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String identifying_code;
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRolename() {
|
||||
return rolename;
|
||||
}
|
||||
|
||||
public void setRolename(String rolename) {
|
||||
this.rolename = rolename;
|
||||
}
|
||||
|
||||
public String getSafeword() {
|
||||
return safeword;
|
||||
}
|
||||
|
||||
public void setSafeword(String safeword) {
|
||||
this.safeword = safeword;
|
||||
}
|
||||
|
||||
public String getUsercode() {
|
||||
return usercode;
|
||||
}
|
||||
|
||||
public void setUsercode(String usercode) {
|
||||
this.usercode = usercode;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public boolean getLogin_authority() {
|
||||
return login_authority;
|
||||
}
|
||||
|
||||
public void setLogin_authority(boolean login_authority) {
|
||||
this.login_authority = login_authority;
|
||||
}
|
||||
|
||||
public boolean getWithdraw_authority() {
|
||||
return withdraw_authority;
|
||||
}
|
||||
|
||||
public void setWithdraw_authority(boolean withdraw_authority) {
|
||||
this.withdraw_authority = withdraw_authority;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getRecharge_authority() {
|
||||
return recharge_authority;
|
||||
}
|
||||
|
||||
public void setRecharge_authority(boolean recharge_authority) {
|
||||
this.recharge_authority = recharge_authority;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getIdentifying_code() {
|
||||
return identifying_code;
|
||||
}
|
||||
|
||||
public void setIdentifying_code(String identifying_code) {
|
||||
this.identifying_code = identifying_code;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
34
comm/Party/src/project/party/PartyRedisKeys.java
Executable file
34
comm/Party/src/project/party/PartyRedisKeys.java
Executable file
@@ -0,0 +1,34 @@
|
||||
package project.party;
|
||||
|
||||
public class PartyRedisKeys {
|
||||
/**
|
||||
* partyId
|
||||
*/
|
||||
public final static String PARTY_ID = "PARTY_ID_";
|
||||
/**
|
||||
* partyId
|
||||
*/
|
||||
public final static String PARTY_USERNAME = "PARTY_USERNAME_";
|
||||
/**
|
||||
* 在线用户
|
||||
*/
|
||||
public final static String PARTY_ONLINEUSER = "PARTY_ONLINEUSER_";
|
||||
public final static String PARTY_ONLINEUSER_PARTYID = "PARTY_ONLINEUSER_PARTYID_";
|
||||
/**
|
||||
* 推荐人
|
||||
*/
|
||||
public final static String USER_RECOM_PARTYID = "USER_RECOM_PARTYID_";
|
||||
public final static String USER_RECOM_RECO_ID = "USER_RECOM_RECO_ID_";
|
||||
|
||||
/**
|
||||
* 当前商铺被拉黑的标识
|
||||
*/
|
||||
public final static String PARTY_ID_SELLER_BLACK = "PARTY_ID_SELLER_BLACK";
|
||||
|
||||
|
||||
/**
|
||||
* 用户免登录token
|
||||
*/
|
||||
public final static String LOGIN_PARTY_ID_TOKEN = "LOGIN_PARTY_ID_TOKEN";
|
||||
|
||||
}
|
||||
208
comm/Party/src/project/party/PartyService.java
Executable file
208
comm/Party/src/project/party/PartyService.java
Executable file
@@ -0,0 +1,208 @@
|
||||
package project.party;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import project.mall.orders.model.MallAddress;
|
||||
import project.party.model.Party;
|
||||
|
||||
/**
|
||||
* Party CRUD
|
||||
*/
|
||||
public interface PartyService {
|
||||
|
||||
Party getById(String id);
|
||||
|
||||
/**
|
||||
* 获取用户等级 1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证; 4/用户高级认证;
|
||||
*/
|
||||
public int getUserLevelByAuth(Party party);
|
||||
|
||||
/**
|
||||
* @param partyId
|
||||
* @param localcache 是否读本地缓存
|
||||
* @return
|
||||
*/
|
||||
public Party cachePartyBy(Serializable partyId, boolean localcache);
|
||||
|
||||
/**
|
||||
* 根据电话号码查询用户uuid
|
||||
*
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
String selectUuidByPhone(String phone);
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* @param localcache 是否读本地缓存
|
||||
* @return
|
||||
*/
|
||||
public Party cachePartyByUsername(String username, boolean localcache);
|
||||
|
||||
public Party save(Party entity);
|
||||
|
||||
public void update(Party entity);
|
||||
|
||||
/**
|
||||
* 根据用户名
|
||||
*/
|
||||
public Party findPartyByUsername(String username);
|
||||
|
||||
/**
|
||||
* 获取PAT_PARTY 根据已验证的电话号码
|
||||
*/
|
||||
public Party findPartyByVerifiedPhone(String phone);
|
||||
|
||||
/**
|
||||
* 获取PAT_PARTY 根据已验证的邮箱
|
||||
*/
|
||||
public Party findPartyByVerifiedEmail(String email);
|
||||
|
||||
public Party getPartyByEmail(String email);
|
||||
|
||||
/**
|
||||
* 根据用户名
|
||||
*/
|
||||
public Party findPartyByUsercode(String usercode);
|
||||
|
||||
public List<Party> getAll();
|
||||
|
||||
public void updateSafeword(Party party, String safeword);
|
||||
|
||||
/**
|
||||
* 验证资金密码
|
||||
*
|
||||
* @param safeword
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public boolean checkSafeword(String safeword, String partyId);
|
||||
|
||||
/**
|
||||
* 修改redis中 用户提现资金密码错误次数
|
||||
*
|
||||
* @param partyId partyId
|
||||
* @param bool 密码是否正确
|
||||
*/
|
||||
void updateWithdrawDepositPasswordFailedNumber(String partyId, Boolean bool);
|
||||
|
||||
/**
|
||||
* 获取用户是否满足提现错误次数状态
|
||||
*
|
||||
* @param partyId partyId
|
||||
* @return 是否超过3次
|
||||
*/
|
||||
Boolean getWithdrawDepositPasswordFailedNumberStatus(String partyId);
|
||||
|
||||
void updateCache(Party party);
|
||||
|
||||
/**
|
||||
* 根据partyId获取用户默认发货地址
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
List<MallAddress> findUserAddressByPartyId(String id);
|
||||
|
||||
List<Party> getPartyBatch(List<String> idList);
|
||||
|
||||
/**
|
||||
* 根据时间统计登录人数,緩存
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCacheCountLoginByDay(String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计登录人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCountLoginByDay(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 根据时间统计注册人数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCountRegisterByDay(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 根据时间统计注册人数,緩存
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCacheCountRegisterByDay(String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* @return 统计总人数
|
||||
*/
|
||||
Integer getCountAllUser();
|
||||
|
||||
/**
|
||||
* @return 统计总人数,缓存
|
||||
*/
|
||||
Integer getCacheCountAllUser();
|
||||
|
||||
|
||||
/**
|
||||
* @return 统计总店铺数,缓存
|
||||
*/
|
||||
Integer getCacheCountAllSeller();
|
||||
|
||||
/**
|
||||
* @return 统计总店铺数
|
||||
*/
|
||||
Integer getCountAllSeller();
|
||||
|
||||
/**
|
||||
* 根据时间统计新增店铺
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总店铺数
|
||||
*/
|
||||
Integer getCacheCountRegisterSellerByDay(String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新增店铺
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计总店铺数
|
||||
*/
|
||||
Integer getCountRegisterSellerByDay(String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新增订单数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计订单数
|
||||
*/
|
||||
Integer getCountOrderByDay(String startTime, String endTime);
|
||||
|
||||
|
||||
/**
|
||||
* 根据时间统计新增订单数
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return 统计订单数
|
||||
*/
|
||||
Integer getCacheCountOrderByDay(String startTime, String endTime);
|
||||
|
||||
void updateUserRemark(String sellerId, String remarks);
|
||||
}
|
||||
35
comm/Party/src/project/party/SunLineReg.java
Executable file
35
comm/Party/src/project/party/SunLineReg.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package project.party;
|
||||
|
||||
/**
|
||||
* 太阳线注册VO
|
||||
*/
|
||||
public class SunLineReg extends NormalReg {
|
||||
|
||||
private static final long serialVersionUID = 1188648056284724586L;
|
||||
|
||||
/**
|
||||
* 推荐人usercode
|
||||
*/
|
||||
private String reco_usercode;
|
||||
|
||||
/**
|
||||
* 0=普通会员1=商户
|
||||
*/
|
||||
private int roleType;
|
||||
|
||||
public String getReco_usercode() {
|
||||
return reco_usercode;
|
||||
}
|
||||
|
||||
public void setReco_usercode(String reco_usercode) {
|
||||
this.reco_usercode = reco_usercode;
|
||||
}
|
||||
|
||||
public int getRoleType() {
|
||||
return roleType;
|
||||
}
|
||||
|
||||
public void setRoleType(int roleType) {
|
||||
this.roleType = roleType;
|
||||
}
|
||||
}
|
||||
15
comm/Party/src/project/party/UserMetricsService.java
Executable file
15
comm/Party/src/project/party/UserMetricsService.java
Executable file
@@ -0,0 +1,15 @@
|
||||
package project.party;
|
||||
|
||||
import project.mall.utils.MallPageInfo;
|
||||
import project.party.model.UserMetrics;
|
||||
|
||||
|
||||
public interface UserMetricsService {
|
||||
|
||||
UserMetrics save(UserMetrics entity);
|
||||
|
||||
UserMetrics getByPartyId(String partyId);
|
||||
|
||||
void update(UserMetrics entity);
|
||||
|
||||
}
|
||||
561
comm/Party/src/project/party/internal/PartyServiceImpl.java
Executable file
561
comm/Party/src/project/party/internal/PartyServiceImpl.java
Executable file
@@ -0,0 +1,561 @@
|
||||
package project.party.internal;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import kernel.cache.RedisLocalCache;
|
||||
import kernel.constants.LocalCacheBucketKey;
|
||||
import kernel.util.StringUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.security.providers.encoding.PasswordEncoder;
|
||||
import project.RedisKeys;
|
||||
import project.mall.MallRedisKeys;
|
||||
import project.mall.orders.model.MallAddress;
|
||||
import project.party.PartyRedisKeys;
|
||||
import project.party.PartyService;
|
||||
import project.party.model.Party;
|
||||
import project.redis.RedisHandler;
|
||||
import security.SaltSigureUtils;
|
||||
import security.SecUser;
|
||||
import security.internal.SecUserService;
|
||||
import util.cache.CacheOperation;
|
||||
import util.concurrent.gofun.core.FunParams;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PartyServiceImpl extends HibernateDaoSupport implements PartyService {
|
||||
/**
|
||||
* partyid Party
|
||||
*/
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
private RedisHandler redisHandler;
|
||||
private RedisLocalCache redisLocalCache;
|
||||
|
||||
private SecUserService secUserService;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* 获取用户等级 1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证; 4/用户高级认证;
|
||||
*/
|
||||
public int getUserLevelByAuth(Party party) {
|
||||
SecUser secUser = this.secUserService.findUserByPartyId(party.getId().toString());
|
||||
int userLevel = 1;
|
||||
if (party.getEmail_authority() || party.getPhone_authority() || secUser.isGoogle_auth_bind()) {
|
||||
if (party.getKyc_authority()) {
|
||||
if (party.isKyc_highlevel_authority()) {
|
||||
userLevel = 4;
|
||||
} else {
|
||||
userLevel = 3;
|
||||
}
|
||||
} else {
|
||||
userLevel = 2;
|
||||
}
|
||||
} else {
|
||||
userLevel = 1;
|
||||
}
|
||||
return userLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据电话号码查询用户
|
||||
*
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public String selectUuidByPhone(String phone) {
|
||||
String sql = "SELECT * FROM PAT_PARTY WHERE PHONE = '" + phone + "'";
|
||||
return this.jdbcTemplate.queryForObject(sql, String.class);
|
||||
}
|
||||
|
||||
public Party cachePartyBy(Serializable partyId, boolean localcache) {
|
||||
if (Objects.isNull(partyId)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Party party = (Party) redisHandler.get(PartyRedisKeys.PARTY_ID + partyId);
|
||||
if (party == null) {
|
||||
party = this.getById(partyId.toString());
|
||||
if (party != null) {
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + party.getId(), party);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + party.getUsername(), party);
|
||||
}
|
||||
}
|
||||
|
||||
return party;
|
||||
}
|
||||
|
||||
public Party cachePartyByUsername(String username, boolean localcache) {
|
||||
Party party = null;
|
||||
if (localcache) {
|
||||
/**
|
||||
* 非必须,可读缓存
|
||||
*/
|
||||
party = (Party) redisLocalCache.get(PartyRedisKeys.PARTY_USERNAME + username);
|
||||
} else {
|
||||
/**
|
||||
* 读数据库
|
||||
*/
|
||||
party = (Party) redisHandler.get(PartyRedisKeys.PARTY_USERNAME + username);
|
||||
}
|
||||
if (party == null) {
|
||||
party = findPartyByUsername(username);
|
||||
if (party != null) {
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + party.getId(), party);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + party.getUsername(), party);
|
||||
}
|
||||
}
|
||||
|
||||
return party;
|
||||
}
|
||||
|
||||
public Party save(Party entity) {
|
||||
entity.setCreateTime(new Date());
|
||||
this.getHibernateTemplate().save(entity);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + entity.getId(), entity);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + entity.getUsername(), entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void update(Party entity) {
|
||||
this.getHibernateTemplate().merge(entity);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + entity.getId(), entity);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + entity.getUsername(), entity);
|
||||
}
|
||||
|
||||
public Party findPartyByUsername(String username) {
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE username = ?0", username);
|
||||
if (list.size() > 0) {
|
||||
return (Party) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Party getById(String id) {
|
||||
if (StrUtil.isBlank(id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.getHibernateTemplate().get(Party.class, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PAT_PARTY 根据已验证的电话号码
|
||||
*/
|
||||
@Override
|
||||
public Party findPartyByVerifiedPhone(String phone) {
|
||||
// List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE phone = ?0 AND phone_authority = 'Y' ", phone);
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE phone = ?0", phone);
|
||||
if (list.size() > 0) {
|
||||
return (Party) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PAT_PARTY 根据已验证的邮箱
|
||||
*/
|
||||
@Override
|
||||
public Party findPartyByVerifiedEmail(String email) {
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE email = ?0 AND email_authority = 'Y' ", email);
|
||||
if (list.size() > 0) {
|
||||
return (Party) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Party getPartyByEmail(String email) {
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE email = ?0 ", email);
|
||||
if (list.size() > 0) {
|
||||
return (Party) list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Party> getAll() {
|
||||
return (List<Party>) this.getHibernateTemplate().find(" FROM Party ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Party findPartyByUsercode(String usercode) {
|
||||
// List<Party> list = (List<Party>) this.getHibernateTemplate().find(" FROM Party WHERE usercode = ?0");
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().find("FROM Party WHERE usercode = ?0", new Object[]{usercode});
|
||||
|
||||
if (list.size() > 0) {
|
||||
return (Party) list.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateSafeword(Party party, String safeword) {
|
||||
String safeword_md5 = passwordEncoder.encodePassword(safeword, SaltSigureUtils.saltfigure);
|
||||
party.setSafeword(safeword_md5);
|
||||
this.update(party);
|
||||
|
||||
//资金密码更新 重置校验密码次数
|
||||
String lockPassworkErrorKey = MallRedisKeys.MALL_PASSWORD_ERROR_LOCK + party.getId();
|
||||
redisHandler.remove(lockPassworkErrorKey);
|
||||
}
|
||||
|
||||
public boolean checkSafeword(String safeword, String partyId) {
|
||||
if (StringUtils.isEmpty(safeword))
|
||||
return Boolean.FALSE;
|
||||
Party party = this.cachePartyBy(partyId, false);
|
||||
if (party == null) {
|
||||
logger.error(MessageFormat.format("party is null,id:{0}", partyId));
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if (StringUtils.isEmpty(party.getSafeword()))
|
||||
return Boolean.FALSE;
|
||||
String md5 = passwordEncoder.encodePassword(safeword, SaltSigureUtils.saltfigure);
|
||||
return md5.equals(party.getSafeword());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWithdrawDepositPasswordFailedNumber(String partyId, Boolean bool) {
|
||||
// 密码正确 删除 redis key
|
||||
// 密码错误 先去 redis 获取
|
||||
// 如果存在key 原来的failed number + 1 并修改过期时间三分钟
|
||||
// 如果不存在则设置一个新的key failed number = 1 设置过期时间三分钟
|
||||
String key = RedisKeys.WITHDRAW_DEPOSIT_PASSWORD_FAILD_NUMBER + partyId;
|
||||
if (bool) {
|
||||
redisHandler.remove(key);
|
||||
} else {
|
||||
int failedNumber;
|
||||
int expirationTime = 3 * 60;
|
||||
String value = redisHandler.getString(key);
|
||||
if (value == null) {
|
||||
failedNumber = 1;
|
||||
redisHandler.setSyncStringEx(key, String.valueOf(failedNumber), expirationTime);
|
||||
} else {
|
||||
failedNumber = Integer.parseInt(value) + 1;
|
||||
redisHandler.setSyncStringEx(key, String.valueOf(failedNumber), expirationTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getWithdrawDepositPasswordFailedNumberStatus(String partyId) {
|
||||
// 获取redis key 若不存在 返回true
|
||||
//若存在 判断是否大于3 大于等于 false 小于 true
|
||||
String key = RedisKeys.WITHDRAW_DEPOSIT_PASSWORD_FAILD_NUMBER + partyId;
|
||||
String value = redisHandler.getString(key);
|
||||
boolean status;
|
||||
if (value == null) {
|
||||
status = true;
|
||||
} else {
|
||||
status = Integer.parseInt(value) < 3;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCache(Party party) {
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_ID + party.getId(), party);
|
||||
redisHandler.setSync(PartyRedisKeys.PARTY_USERNAME + party.getUsername(), party);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MallAddress> findUserAddressByPartyId(String id) {
|
||||
Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(MallAddress.class);
|
||||
criteria.add(Restrictions.eq("partyId", id));
|
||||
criteria.add(Restrictions.eq("status", 1));
|
||||
if (CollectionUtils.isNotEmpty(criteria.list())) {
|
||||
return criteria.list();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Party> getPartyBatch(List<String> idList) {
|
||||
DetachedCriteria criteria = DetachedCriteria.forClass(Party.class);
|
||||
criteria.add(Restrictions.in("id", idList));
|
||||
List<Party> list = (List<Party>) this.getHibernateTemplate().findByCriteria(criteria);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountLoginByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountLoginByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountLoginByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public Integer getCountLoginByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from PAT_PARTY where ROLENAME <> 'GUEST' ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND LAST_LOGIN_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND LAST_LOGIN_TIME < ? ");
|
||||
}
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountRegisterByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from PAT_PARTY where ROLENAME <> 'GUEST' ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME < ? ");
|
||||
}
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountRegisterByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountRegisterByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountRegisterByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountAllUser() {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from PAT_PARTY where ROLENAME <> 'GUEST' ");
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountAllUser() {
|
||||
|
||||
String funKey = LocalCacheBucketKey.CountAllUser;
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountAllUser();
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountAllSeller() {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from T_MALL_SELLER t1 LEFT JOIN PAT_PARTY t2 on t1.UUID = t2.UUID ");
|
||||
countSql.append("LEFT JOIN T_KYC t3 ON t1.UUID = t3.PARTY_ID ");
|
||||
countSql.append("WHERE t3.`STATUS` = 2 and t2.ROLENAME <> 'GUEST' ");
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), Integer.class);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountAllSeller() {
|
||||
|
||||
String funKey = LocalCacheBucketKey.CountAllSeller;
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountAllSeller();
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountRegisterSellerByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from T_MALL_SELLER t1 LEFT JOIN PAT_PARTY t2 on t1.UUID = t2.UUID ");
|
||||
countSql.append("LEFT JOIN T_KYC t3 ON t1.UUID = t3.PARTY_ID ");
|
||||
countSql.append("WHERE t3.`STATUS` = 2 and t2.ROLENAME <> 'GUEST' ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND t1.CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND t1.CREATE_TIME < ? ");
|
||||
}
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountRegisterSellerByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountRegisterSellerByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountRegisterSellerByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountOrderByDay(String startTime, String endTime) {
|
||||
|
||||
StringBuilder countSql = new StringBuilder();
|
||||
|
||||
countSql.append("select count(1) from T_MALL_ORDERS_PRIZE where 1= 1 and RETURN_STATUS = 0 and FLAG in(0,1) ");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(startTime)) {
|
||||
params.add(startTime);
|
||||
countSql.append("AND CREATE_TIME >= ? ");
|
||||
}
|
||||
|
||||
if (kernel.util.StringUtils.isNotEmpty(endTime)) {
|
||||
params.add(endTime);
|
||||
countSql.append("AND CREATE_TIME < ? ");
|
||||
}
|
||||
|
||||
Integer result = jdbcTemplate.queryForObject(countSql.toString(), params.toArray(), Integer.class);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCacheCountOrderByDay(String startTime, String endTime) {
|
||||
|
||||
String funKey = this.getKey(startTime, endTime, LocalCacheBucketKey.CountOrderByDay);
|
||||
|
||||
FunParams funParams = FunParams.newParam()
|
||||
.set("partyService", this);
|
||||
|
||||
// 基于一个缓存上次执行结果的组件进行数据统计方法的调用,如果上次缓存结果满足条件,则优先使用缓存结果,否则,触发真实的统计执行
|
||||
// 执行结果缓存 1 个小时
|
||||
Integer result = CacheOperation.execute(funKey, true, 600L * 1000L, funParams, (params) -> {
|
||||
PartyService partyService = params.get("partyService").getAs(PartyService.class);
|
||||
Integer getResult = partyService.getCountOrderByDay(startTime, endTime);
|
||||
return getResult;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserRemark(String partyId, String remarks) {
|
||||
Party party = this.getById(partyId);
|
||||
party.setRemarks(remarks);
|
||||
this.update(party);
|
||||
}
|
||||
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setRedisLocalCache(RedisLocalCache redisLocalCache) {
|
||||
this.redisLocalCache = redisLocalCache;
|
||||
}
|
||||
|
||||
public void setSecUserService(SecUserService secUserService) {
|
||||
this.secUserService = secUserService;
|
||||
}
|
||||
|
||||
public JdbcTemplate getJdbcTemplate() {
|
||||
return jdbcTemplate;
|
||||
}
|
||||
|
||||
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
private String getKey(String fromTime, String toTime, String key) {
|
||||
String from = fromTime.replace("-", "")
|
||||
.replace(":", "")
|
||||
.replace("000000", "")
|
||||
.replace(" ", "");
|
||||
|
||||
String to = toTime.replace("-", "")
|
||||
.replace(":", "")
|
||||
.replace("000000", "")
|
||||
.replace(" ", "");
|
||||
|
||||
String funKey = key + ":" + from + "-" + to;
|
||||
|
||||
return funKey;
|
||||
}
|
||||
}
|
||||
81
comm/Party/src/project/party/internal/UserMetricsServiceImpl.java
Executable file
81
comm/Party/src/project/party/internal/UserMetricsServiceImpl.java
Executable file
@@ -0,0 +1,81 @@
|
||||
package project.party.internal;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.DetachedCriteria;
|
||||
import org.hibernate.criterion.Projections;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import project.party.UserMetricsService;
|
||||
import project.mall.seller.model.FocusSeller;
|
||||
import project.mall.utils.MallPageInfo;
|
||||
import project.mall.utils.MallPageInfoUtil;
|
||||
import project.party.model.UserMetrics;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class UserMetricsServiceImpl extends HibernateDaoSupport implements UserMetricsService {
|
||||
|
||||
/**
|
||||
* 注意:需要防止并发冲突问题,最好调用方校验下设置的指标值是否一致.
|
||||
* 最恰当的使用方式是通过本方法尝试初始化创建一条 UserMetrics,然后再使用本方法的返回值设置具体业务的指标数据执行更新。
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public UserMetrics save(UserMetrics entity) {
|
||||
if (entity == null || StrUtil.isBlank(entity.getPartyId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
if (entity.getCreateTime() == null) {
|
||||
entity.setCreateTime(now);
|
||||
}
|
||||
if (entity.getUpdateTime() == null) {
|
||||
entity.setUpdateTime(now);
|
||||
}
|
||||
|
||||
try {
|
||||
getHibernateTemplate().save(entity);
|
||||
// getHibernateTemplate().flush();
|
||||
return entity;
|
||||
} catch (Exception e) {
|
||||
// getHibernateTemplate().clear();
|
||||
UserMetrics exist = getByPartyId(entity.getPartyId());
|
||||
if (exist != null) {
|
||||
return exist;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMetrics getByPartyId(String partyId) {
|
||||
DetachedCriteria query = DetachedCriteria.forClass(UserMetrics.class);
|
||||
query.add(Restrictions.eq("partyId", partyId));
|
||||
query.add(Restrictions.eq("status", 1));
|
||||
|
||||
List<UserMetrics> list = (List<UserMetrics>) this.getHibernateTemplate().findByCriteria(query);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UserMetrics entity) {
|
||||
if (entity == null || entity.getId() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
entity.setUpdateTime(new Date());
|
||||
getHibernateTemplate().update(entity);
|
||||
}
|
||||
|
||||
}
|
||||
137
comm/Party/src/project/party/model/Party.hbm.xml
Executable file
137
comm/Party/src/project/party/model/Party.hbm.xml
Executable file
@@ -0,0 +1,137 @@
|
||||
<?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.party.model.Party" table="PAT_PARTY">
|
||||
<id name="id" type="java.lang.String">
|
||||
<column name="UUID" />
|
||||
<generator class="uuid.hex" />
|
||||
</id>
|
||||
<property name="rolename" type="java.lang.String">
|
||||
<column name="ROLENAME" />
|
||||
</property>
|
||||
<property name="username" type="java.lang.String">
|
||||
<column name="USERNAME" />
|
||||
</property>
|
||||
<property name="usercode" type="java.lang.String">
|
||||
<column name="USERCODE" />
|
||||
</property>
|
||||
<property name="avatar" type="java.lang.String">
|
||||
<column name="AVATAR" />
|
||||
</property>
|
||||
<property name="safeword" type="java.lang.String">
|
||||
<column name="SAFEWORD" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="last_loginTime" type="timestamp">
|
||||
<column name="LAST_LOGIN_TIME" />
|
||||
</property>
|
||||
<property name="firstRechargeTime" type="timestamp">
|
||||
<column name="FIRST_RECHARGE_TIME" />
|
||||
</property>
|
||||
<property name="firstWithdrawTime" type="timestamp">
|
||||
<column name="FIRST_WITHDRAW_TIME" />
|
||||
</property>
|
||||
<property generated="never" name="enabled" type="yes_no">
|
||||
<column name="ENABLED" />
|
||||
</property>
|
||||
<property generated="never" name="withdraw_authority"
|
||||
type="yes_no">
|
||||
<column name="WITHDRAWAUTHORITY" />
|
||||
</property>
|
||||
<property generated="never" name="login_authority"
|
||||
type="yes_no">
|
||||
<column name="LOGINAUTHORITY" />
|
||||
</property>
|
||||
|
||||
<property generated="never" name="recharge_authority"
|
||||
type="yes_no">
|
||||
<column name="RECHARGE_AUTHORITY" />
|
||||
</property>
|
||||
<property name="email" type="java.lang.String">
|
||||
<column name="EMAIL" />
|
||||
</property>
|
||||
<property generated="never" name="email_authority" type="yes_no">
|
||||
<column name="EMAIL_AUTHORITY" />
|
||||
</property>
|
||||
<property name="phone" type="java.lang.String">
|
||||
<column name="PHONE" />
|
||||
</property>
|
||||
<property generated="never" name="phone_authority" type="yes_no">
|
||||
<column name="PHONE_AUTHORITY" />
|
||||
</property>
|
||||
<property generated="never" name="active"
|
||||
type="yes_no">
|
||||
<column name="ACTIVE" />
|
||||
</property>
|
||||
<property generated="never" name="kyc_authority"
|
||||
type="yes_no">
|
||||
<column name="KYC_AUTHORITY" />
|
||||
</property>
|
||||
<property generated="never" name="kyc_highlevel_authority"
|
||||
type="yes_no">
|
||||
<column name="KYC_HIGHLEVEL_AUTHORITY" />
|
||||
</property>
|
||||
<property generated="never" name="gift_user"
|
||||
type="yes_no">
|
||||
<column name="GIFT_USER" />
|
||||
</property>
|
||||
<property generated="never" name="gift_money_flag"
|
||||
type="yes_no">
|
||||
<column name="GIFT_MONEY_FLAG" />
|
||||
</property>
|
||||
<property name="remarks" type="java.lang.String">
|
||||
<column name="REMARKS" />
|
||||
</property>
|
||||
<property name="name" type="java.lang.String">
|
||||
<column name="NAME" />
|
||||
</property>
|
||||
|
||||
<property name="withdraw_limit_amount" type="double">
|
||||
<column name="WITHDRAW_LIMIT_AMOUNT" />
|
||||
</property>
|
||||
<property name="login_ip" type="java.lang.String">
|
||||
<column name="LOGIN_IP" />
|
||||
</property>
|
||||
|
||||
<property name="withdraw_limit_now_amount" type="double">
|
||||
<column name="WITHDRAW_LIMIT_NOW_AMOUNT" />
|
||||
</property>
|
||||
|
||||
<property name="user_level" type="java.lang.Integer">
|
||||
<column name="USER_LEVEL" />
|
||||
</property>
|
||||
|
||||
<property generated="never" name="register_usercode"
|
||||
type="yes_no">
|
||||
<column name="REGSITER_USERCODE" />
|
||||
</property>
|
||||
|
||||
<property name="vip_level" type="java.lang.Integer">
|
||||
<column name="VIP_LEVEL" />
|
||||
</property>
|
||||
|
||||
<property name="roleType" type="java.lang.Integer">
|
||||
<column name="ROLE_TYPE" />
|
||||
</property>
|
||||
|
||||
<property generated="never" name="autoComment" type="yes_no">
|
||||
<column name="AUTO_COMMENT" />
|
||||
</property>
|
||||
|
||||
<property name="withdrawAddress" type="java.lang.String">
|
||||
<column name="WITHDRAW_ADDRESS" />
|
||||
</property>
|
||||
<property name="withdrawCoinType" type="java.lang.String">
|
||||
<column name="WITHDRAW_COIN_TYPE" />
|
||||
</property>
|
||||
<property name="withdrawChainName" type="java.lang.String">
|
||||
<column name="WITHDRAW_CHAIN_NAME" />
|
||||
</property>
|
||||
<property name="chatAudit" type="java.lang.Integer">
|
||||
<column name="CHAT_AUDIT" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
477
comm/Party/src/project/party/model/Party.java
Executable file
477
comm/Party/src/project/party/model/Party.java
Executable file
@@ -0,0 +1,477 @@
|
||||
package project.party.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class Party extends EntityObject {
|
||||
private static final long serialVersionUID = -66585270719884278L;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private String rolename;
|
||||
|
||||
/**
|
||||
* 用户code-UID
|
||||
*/
|
||||
private String usercode;
|
||||
|
||||
/**
|
||||
* 用户名-用户WSID
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 安全码,资金密码,盐值+safeword MD5编码
|
||||
*/
|
||||
private String safeword;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private Date last_loginTime;
|
||||
|
||||
/**
|
||||
* 首充时间
|
||||
*/
|
||||
private Date firstRechargeTime;
|
||||
|
||||
/**
|
||||
* 首提时间
|
||||
*/
|
||||
private Date firstWithdrawTime;
|
||||
|
||||
/**
|
||||
* 是否锁定,如果锁定可以登录、查看,但不能操作业务有关。
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* 登录权限
|
||||
*/
|
||||
private boolean login_authority = true;
|
||||
|
||||
/**
|
||||
* 充值权限
|
||||
*/
|
||||
private boolean recharge_authority = true;
|
||||
|
||||
/**
|
||||
* 提现权限
|
||||
*/
|
||||
private boolean withdraw_authority = true;
|
||||
|
||||
private boolean kyc_authority = false;
|
||||
|
||||
/**
|
||||
* 高级认证
|
||||
*/
|
||||
private boolean kyc_highlevel_authority = false;
|
||||
|
||||
/**
|
||||
* 邮件群UID
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 是否邮箱已认证
|
||||
*/
|
||||
private boolean email_authority = false;
|
||||
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 是否手机已认证
|
||||
*/
|
||||
private boolean phone_authority = false;
|
||||
|
||||
/**
|
||||
* 是否活跃 7天无流水,则认为不是活跃用户呢
|
||||
*/
|
||||
private boolean active = true;
|
||||
|
||||
/**
|
||||
* 是否在线
|
||||
*/
|
||||
private boolean online = false;
|
||||
|
||||
/**
|
||||
* 注备
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 名称-昵称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 当日提现限制金额
|
||||
*/
|
||||
private double withdraw_limit_amount;
|
||||
|
||||
/**
|
||||
* 当前可用提现流水 WITHDRAW_LIMIT_NOW_AMOUNT
|
||||
*/
|
||||
private double withdraw_limit_now_amount;
|
||||
|
||||
/**
|
||||
* 登陆Ip
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String login_ip;
|
||||
|
||||
/**
|
||||
* 是否为赠送用户(达到限制金额)
|
||||
*/
|
||||
private boolean gift_user;
|
||||
|
||||
/**
|
||||
* 是否获得过赠送金额
|
||||
*/
|
||||
private boolean gift_money_flag;
|
||||
|
||||
/**
|
||||
* 会员等级 默认
|
||||
*/
|
||||
private int user_level;
|
||||
|
||||
/**
|
||||
* 在推荐码邀请权限开启后,是否拥有的邀请注册权限
|
||||
*/
|
||||
private boolean register_usercode;
|
||||
|
||||
/**
|
||||
* VIP等级
|
||||
*/
|
||||
private int vip_level;
|
||||
|
||||
/**
|
||||
* 0=普通会员1=商户
|
||||
*/
|
||||
private int roleType;
|
||||
|
||||
/**
|
||||
* 虚拟用户自动评价
|
||||
*/
|
||||
private boolean autoComment;
|
||||
|
||||
/**
|
||||
* 提现地址
|
||||
*/
|
||||
private String withdrawAddress;
|
||||
|
||||
private String withdrawCoinType;
|
||||
|
||||
private String withdrawChainName;
|
||||
|
||||
/**
|
||||
* 用户聊天拉黑状态,-1拉黑,0未审核,1已加白
|
||||
*/
|
||||
private int chatAudit;
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getSafeword() {
|
||||
return this.safeword;
|
||||
}
|
||||
|
||||
public void setSafeword(String safeword) {
|
||||
this.safeword = safeword;
|
||||
}
|
||||
|
||||
public Date getLast_loginTime() {
|
||||
return last_loginTime;
|
||||
}
|
||||
|
||||
public void setLast_loginTime(Date last_loginTime) {
|
||||
this.last_loginTime = last_loginTime;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getRolename() {
|
||||
return rolename;
|
||||
}
|
||||
|
||||
public void setRolename(String rolename) {
|
||||
this.rolename = rolename;
|
||||
}
|
||||
|
||||
public boolean getLogin_authority() {
|
||||
return login_authority;
|
||||
}
|
||||
|
||||
public void setLogin_authority(boolean login_authority) {
|
||||
this.login_authority = login_authority;
|
||||
}
|
||||
|
||||
public boolean getWithdraw_authority() {
|
||||
return withdraw_authority;
|
||||
}
|
||||
|
||||
public void setWithdraw_authority(boolean withdraw_authority) {
|
||||
this.withdraw_authority = withdraw_authority;
|
||||
}
|
||||
|
||||
public String getUsercode() {
|
||||
return usercode;
|
||||
}
|
||||
|
||||
public void setUsercode(String usercode) {
|
||||
this.usercode = usercode;
|
||||
}
|
||||
|
||||
public boolean isRecharge_authority() {
|
||||
return recharge_authority;
|
||||
}
|
||||
|
||||
public void setRecharge_authority(boolean recharge_authority) {
|
||||
this.recharge_authority = recharge_authority;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public boolean getEmail_authority() {
|
||||
return this.email_authority;
|
||||
}
|
||||
|
||||
public void setEmail_authority(boolean email_authority) {
|
||||
this.email_authority = email_authority;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public void setRemarks(String remarks) {
|
||||
this.remarks = remarks;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
return online;
|
||||
}
|
||||
|
||||
public void setOnline(boolean online) {
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public boolean getPhone_authority() {
|
||||
return this.phone_authority;
|
||||
}
|
||||
|
||||
public void setPhone_authority(boolean phone_authority) {
|
||||
this.phone_authority = phone_authority;
|
||||
}
|
||||
|
||||
public boolean getKyc_authority() {
|
||||
return kyc_authority;
|
||||
}
|
||||
|
||||
public void setKyc_authority(boolean kyc_authority) {
|
||||
this.kyc_authority = kyc_authority;
|
||||
}
|
||||
|
||||
public boolean isKyc_highlevel_authority() {
|
||||
return kyc_highlevel_authority;
|
||||
}
|
||||
|
||||
public void setKyc_highlevel_authority(boolean kyc_highlevel_authority) {
|
||||
this.kyc_highlevel_authority = kyc_highlevel_authority;
|
||||
}
|
||||
|
||||
public double getWithdraw_limit_amount() {
|
||||
return withdraw_limit_amount;
|
||||
}
|
||||
|
||||
public void setWithdraw_limit_amount(double withdraw_limit_amount) {
|
||||
this.withdraw_limit_amount = withdraw_limit_amount;
|
||||
}
|
||||
|
||||
public String getLogin_ip() {
|
||||
return login_ip;
|
||||
}
|
||||
|
||||
public void setLogin_ip(String login_ip) {
|
||||
this.login_ip = login_ip;
|
||||
}
|
||||
|
||||
public double getWithdraw_limit_now_amount() {
|
||||
return withdraw_limit_now_amount;
|
||||
}
|
||||
|
||||
public void setWithdraw_limit_now_amount(double withdraw_limit_now_amount) {
|
||||
this.withdraw_limit_now_amount = withdraw_limit_now_amount;
|
||||
}
|
||||
|
||||
public boolean getGift_user() {
|
||||
return gift_user;
|
||||
}
|
||||
|
||||
public void setGift_user(boolean gift_user) {
|
||||
this.gift_user = gift_user;
|
||||
}
|
||||
|
||||
public boolean getGift_money_flag() {
|
||||
return gift_money_flag;
|
||||
}
|
||||
|
||||
public void setGift_money_flag(boolean gift_money_flag) {
|
||||
this.gift_money_flag = gift_money_flag;
|
||||
}
|
||||
|
||||
public int getUser_level() {
|
||||
return user_level;
|
||||
}
|
||||
|
||||
public void setUser_level(int user_level) {
|
||||
this.user_level = user_level;
|
||||
}
|
||||
|
||||
public boolean getRegister_usercode() {
|
||||
return register_usercode;
|
||||
}
|
||||
|
||||
public void setRegister_usercode(boolean register_usercode) {
|
||||
this.register_usercode = register_usercode;
|
||||
}
|
||||
|
||||
public int getVip_level() {
|
||||
return vip_level;
|
||||
}
|
||||
|
||||
public void setVip_level(int vip_level) {
|
||||
this.vip_level = vip_level;
|
||||
}
|
||||
|
||||
public int getRoleType() {
|
||||
return roleType;
|
||||
}
|
||||
|
||||
public void setRoleType(int roleType) {
|
||||
this.roleType = roleType;
|
||||
}
|
||||
|
||||
public boolean isAutoComment() {
|
||||
return autoComment;
|
||||
}
|
||||
|
||||
public void setAutoComment(boolean autoComment) {
|
||||
this.autoComment = autoComment;
|
||||
}
|
||||
|
||||
public String getWithdrawAddress() {
|
||||
return withdrawAddress;
|
||||
}
|
||||
|
||||
public void setWithdrawAddress(String withdrawAddress) {
|
||||
this.withdrawAddress = withdrawAddress;
|
||||
}
|
||||
|
||||
public String getWithdrawCoinType() {
|
||||
return withdrawCoinType;
|
||||
}
|
||||
|
||||
public void setWithdrawCoinType(String withdrawCoinType) {
|
||||
this.withdrawCoinType = withdrawCoinType;
|
||||
}
|
||||
|
||||
public String getWithdrawChainName() {
|
||||
return withdrawChainName;
|
||||
}
|
||||
|
||||
public void setWithdrawChainName(String withdrawChainName) {
|
||||
this.withdrawChainName = withdrawChainName;
|
||||
}
|
||||
|
||||
public Date getFirstRechargeTime() {
|
||||
return firstRechargeTime;
|
||||
}
|
||||
|
||||
public void setFirstRechargeTime(Date firstRechargeTime) {
|
||||
this.firstRechargeTime = firstRechargeTime;
|
||||
}
|
||||
|
||||
public Date getFirstWithdrawTime() {
|
||||
return firstWithdrawTime;
|
||||
}
|
||||
|
||||
public void setFirstWithdrawTime(Date firstWithdrawTime) {
|
||||
this.firstWithdrawTime = firstWithdrawTime;
|
||||
}
|
||||
|
||||
public int getChatAudit() {
|
||||
return chatAudit;
|
||||
}
|
||||
|
||||
public void setChatAudit(int chatAudit) {
|
||||
this.chatAudit = chatAudit;
|
||||
}
|
||||
}
|
||||
38
comm/Party/src/project/party/model/UserMetrics.hbm.xml
Executable file
38
comm/Party/src/project/party/model/UserMetrics.hbm.xml
Executable file
@@ -0,0 +1,38 @@
|
||||
<?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.party.model.UserMetrics" table="T_MALL_USER_METRICS">
|
||||
<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="moneyRechargeAcc" type="java.lang.Double">
|
||||
<column name="MONEY_RECHARGE_ACC" />
|
||||
</property>
|
||||
<property name="storeMoneyRechargeAcc" type="java.lang.Double">
|
||||
<column name="STORE_MONEY_RECHARGE_ACC" />
|
||||
</property>
|
||||
<property name="moneyWithdrawAcc" type="java.lang.Double">
|
||||
<column name="MONEY_WITHDRAW_ACC" />
|
||||
</property>
|
||||
<property name="accountBalance" type="java.lang.Double">
|
||||
<column name="ACCOUNT_BALANCE" />
|
||||
</property>
|
||||
<property name="totleIncome" type="java.lang.Double">
|
||||
<column name="TOTLE_INCOME" />
|
||||
</property>
|
||||
<property name="status" type="java.lang.Integer">
|
||||
<column name="STATUS" />
|
||||
</property>
|
||||
<property name="createTime" type="timestamp">
|
||||
<column name="CREATE_TIME" />
|
||||
</property>
|
||||
<property name="updateTime" type="timestamp">
|
||||
<column name="UPDATE_TIME" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
40
comm/Party/src/project/party/model/UserMetrics.java
Executable file
40
comm/Party/src/project/party/model/UserMetrics.java
Executable file
@@ -0,0 +1,40 @@
|
||||
package project.party.model;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class UserMetrics extends EntityObject {
|
||||
private static final long serialVersionUID = -6010777602205862201L;
|
||||
|
||||
// @ApiModelProperty(value = "用户ID")
|
||||
private String partyId;
|
||||
|
||||
// @ApiModelProperty(value = "累计有效充值金额")
|
||||
private Double moneyRechargeAcc =0d;
|
||||
|
||||
// @ApiModelProperty(value = "店铺升级级累计有效充值金额")
|
||||
private Double storeMoneyRechargeAcc = 0d;
|
||||
|
||||
// 暂未启用该指标
|
||||
// @ApiModelProperty(value = "累计有效提现金额")
|
||||
private Double moneyWithdrawAcc;
|
||||
|
||||
// 暂未启用该指标
|
||||
// @ApiModelProperty(value = "账户余额")
|
||||
private Double accountBalance;
|
||||
|
||||
// 暂未启用该指标
|
||||
// @ApiModelProperty(value = "累计收入金额")
|
||||
private Double totleIncome;
|
||||
|
||||
|
||||
// @ApiModelProperty(value = "0-禁用 1-启用")
|
||||
private Integer status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
}
|
||||
17
comm/Party/src/project/party/model/UserRecom.hbm.xml
Executable file
17
comm/Party/src/project/party/model/UserRecom.hbm.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?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.party.model.UserRecom" table="PAT_USER_RECOM">
|
||||
<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="reco_id" type="java.lang.String">
|
||||
<column name="RECO_ID" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
30
comm/Party/src/project/party/model/UserRecom.java
Executable file
30
comm/Party/src/project/party/model/UserRecom.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package project.party.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kernel.bo.EntityObject;
|
||||
|
||||
public class UserRecom extends EntityObject {
|
||||
private static final long serialVersionUID = 4306215956505507789L;
|
||||
private Serializable partyId;
|
||||
/**
|
||||
* 推荐人
|
||||
*/
|
||||
private Serializable reco_id;
|
||||
|
||||
public Serializable getPartyId() {
|
||||
return this.partyId;
|
||||
}
|
||||
|
||||
public void setPartyId(Serializable partyId) {
|
||||
this.partyId = partyId;
|
||||
}
|
||||
|
||||
public Serializable getReco_id() {
|
||||
return this.reco_id;
|
||||
}
|
||||
|
||||
public void setReco_id(Serializable reco_id) {
|
||||
this.reco_id = reco_id;
|
||||
}
|
||||
}
|
||||
76
comm/Party/src/project/party/recom/UserRecomService.java
Executable file
76
comm/Party/src/project/party/recom/UserRecomService.java
Executable file
@@ -0,0 +1,76 @@
|
||||
package project.party.recom;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import project.party.model.Party;
|
||||
import project.party.model.UserRecom;
|
||||
|
||||
/**
|
||||
* 推荐人
|
||||
*
|
||||
*/
|
||||
public interface UserRecomService {
|
||||
public void save(UserRecom paramUserRecom);
|
||||
|
||||
public void update(Serializable partyId, Serializable reco_id);
|
||||
|
||||
public UserRecom findByPartyId(Serializable partyId);
|
||||
|
||||
/**
|
||||
* 查找所有线下用户
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public List<String> findChildren(Serializable partyId);
|
||||
|
||||
|
||||
/**
|
||||
* 查找所有直属线下用户
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public List<String> findDirectlyChildrens(Serializable partyId);
|
||||
|
||||
/**
|
||||
* 查找直推
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public List<UserRecom> findRecoms(Serializable partyId);
|
||||
|
||||
/**
|
||||
* 查找直推 partyId
|
||||
*
|
||||
*/
|
||||
public List<String> findRecomsToPartyId(Serializable partyId);
|
||||
|
||||
public List<UserRecom> getParents(Serializable paramSerializable);
|
||||
|
||||
/**
|
||||
* 查询所有上级
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public List<String> getParentsToPartyId(Serializable partyId);
|
||||
|
||||
/**
|
||||
* 获取所属代理
|
||||
* @param paramSerializable
|
||||
* @return
|
||||
*/
|
||||
Party getAgentParty(Serializable paramSerializable);
|
||||
|
||||
|
||||
/**
|
||||
* 直接返回字符串id,例如 "'1','2','3'"
|
||||
*
|
||||
* @param loginPartyId
|
||||
* @return
|
||||
*/
|
||||
public String findChildrensIds(String loginPartyId);
|
||||
|
||||
}
|
||||
261
comm/Party/src/project/party/recom/internal/UserRecomServiceImpl.java
Executable file
261
comm/Party/src/project/party/recom/internal/UserRecomServiceImpl.java
Executable file
@@ -0,0 +1,261 @@
|
||||
package project.party.recom.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
|
||||
import kernel.exception.BusinessException;
|
||||
import kernel.util.StringUtils;
|
||||
import project.Constants;
|
||||
import project.invest.vip.VipService;
|
||||
import project.party.PartyRedisKeys;
|
||||
import project.party.model.Party;
|
||||
import project.party.model.UserRecom;
|
||||
import project.party.recom.UserRecomService;
|
||||
import project.redis.RedisHandler;
|
||||
|
||||
public class UserRecomServiceImpl extends HibernateDaoSupport implements UserRecomService {
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
private VipService vipService;
|
||||
|
||||
public void save(UserRecom entity) {
|
||||
getHibernateTemplate().save(entity);
|
||||
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_PARTYID + entity.getPartyId().toString(), entity);
|
||||
List recos = (List) redisHandler.get(PartyRedisKeys.USER_RECOM_RECO_ID + entity.getReco_id().toString());
|
||||
if (recos == null) {
|
||||
recos = new ArrayList();
|
||||
}
|
||||
recos.add(entity);
|
||||
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_RECO_ID + entity.getReco_id().toString(), recos);
|
||||
vipService.updatePartyVip(entity.getReco_id().toString());
|
||||
}
|
||||
|
||||
public void update(Serializable partyId, Serializable reco_id) {
|
||||
boolean find = checkBranch(partyId, reco_id);
|
||||
if (find) {
|
||||
throw new BusinessException("直线关系,不能修改推荐");
|
||||
}
|
||||
|
||||
UserRecom entity = findByPartyId(partyId);
|
||||
if (entity == null) {
|
||||
entity = new UserRecom();
|
||||
entity.setPartyId(partyId);
|
||||
}
|
||||
Serializable reco_id_old = entity.getReco_id();
|
||||
entity.setReco_id(reco_id);
|
||||
getHibernateTemplate().merge(entity);
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_PARTYID + entity.getPartyId().toString(), entity);
|
||||
vipService.updatePartyVip(entity.getReco_id().toString());
|
||||
if (reco_id_old != null) {
|
||||
List<UserRecom> recos_old = (List) redisHandler
|
||||
.get(PartyRedisKeys.USER_RECOM_RECO_ID + reco_id_old.toString());
|
||||
if (recos_old == null) {
|
||||
recos_old = new ArrayList();
|
||||
}
|
||||
List recos_old_reset = new ArrayList();
|
||||
for (UserRecom userRecom : recos_old) {
|
||||
if (!partyId.toString().equals(userRecom.getPartyId().toString())) {
|
||||
recos_old_reset.add(userRecom);
|
||||
}
|
||||
}
|
||||
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_RECO_ID + reco_id_old.toString(), recos_old_reset);
|
||||
vipService.updatePartyVip(reco_id_old.toString());
|
||||
}
|
||||
|
||||
List recos = (List) redisHandler.get(PartyRedisKeys.USER_RECOM_RECO_ID + reco_id.toString());
|
||||
if (recos == null) {
|
||||
recos = new ArrayList();
|
||||
}
|
||||
recos.add(entity);
|
||||
redisHandler.setSync(PartyRedisKeys.USER_RECOM_RECO_ID + reco_id.toString(), recos);
|
||||
}
|
||||
|
||||
public UserRecom findByPartyId(Serializable partyId) {
|
||||
if (partyId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (UserRecom) redisHandler.get(PartyRedisKeys.USER_RECOM_PARTYID + partyId);
|
||||
}
|
||||
|
||||
public List<UserRecom> getParents(Serializable partyId) {
|
||||
List list = new LinkedList();
|
||||
if (partyId == null) {
|
||||
return list;
|
||||
}
|
||||
list = findParents(partyId, list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public Party getAgentParty(Serializable partyId) {
|
||||
Party agentParty = new Party();
|
||||
List list = new LinkedList();
|
||||
if (partyId == null) {
|
||||
return agentParty;
|
||||
}
|
||||
List<UserRecom> userRecoms = findParents(partyId, list);
|
||||
if (CollectionUtils.isNotEmpty(userRecoms)){
|
||||
for (UserRecom userRecom : userRecoms) {
|
||||
Party party = (Party) redisHandler.get(PartyRedisKeys.PARTY_ID + userRecom.getReco_id());
|
||||
if (null != party && party.getRolename().equals(Constants.SECURITY_ROLE_AGENT)){
|
||||
agentParty = party;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return agentParty;
|
||||
}
|
||||
|
||||
private List<UserRecom> findParents(Serializable partyId, List<UserRecom> list) {
|
||||
UserRecom userRecom = findByPartyId(partyId);
|
||||
if (userRecom != null) {
|
||||
list.add(userRecom);
|
||||
findParents(userRecom.getReco_id(), list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<UserRecom> findRecoms(Serializable partyId) {
|
||||
List list = (List) redisHandler.get(PartyRedisKeys.USER_RECOM_RECO_ID + partyId.toString());
|
||||
if (list == null) {
|
||||
list = new ArrayList();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getParentsToPartyId(Serializable partyId) {
|
||||
List<UserRecom> parents = new ArrayList();
|
||||
List<String> result = new ArrayList<>();
|
||||
parents = findParents(partyId, parents);
|
||||
for (int i = 0; i < parents.size(); i++) {
|
||||
result.add(parents.get(i).getReco_id().toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> findRecomsToPartyId(Serializable partyId) {
|
||||
List recom_list = findRecoms(partyId);
|
||||
List list = new ArrayList();
|
||||
for (int i = 0; i < recom_list.size(); i++) {
|
||||
list.add(((UserRecom) recom_list.get(i)).getPartyId().toString());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public boolean checkBranch(Serializable partyId1, Serializable partyId2) {
|
||||
boolean find = false;
|
||||
|
||||
List recom_list1 = getParents(partyId1);
|
||||
for (int i = 0; i < recom_list1.size(); i++) {
|
||||
if (partyId2.toString().equals(((UserRecom) recom_list1.get(i)).getReco_id().toString())) {
|
||||
find = true;
|
||||
return find;
|
||||
}
|
||||
}
|
||||
|
||||
List recom_list2 = getParents(partyId2);
|
||||
for (int i = 0; i < recom_list2.size(); i++) {
|
||||
if (partyId1.toString().equals(((UserRecom) recom_list2.get(i)).getReco_id().toString())) {
|
||||
find = true;
|
||||
return find;
|
||||
}
|
||||
}
|
||||
|
||||
return find;
|
||||
}
|
||||
|
||||
public boolean checkParents(Serializable partyId1, Serializable partyId2) {
|
||||
boolean find = false;
|
||||
if (partyId1.toString().equals(partyId2.toString())) {
|
||||
find = true;
|
||||
return find;
|
||||
}
|
||||
|
||||
List recom_list2 = getParents(partyId2);
|
||||
for (int i = 0; i < recom_list2.size(); i++) {
|
||||
if (partyId1.toString().equals(((UserRecom) recom_list2.get(i)).getReco_id().toString())) {
|
||||
find = true;
|
||||
return find;
|
||||
}
|
||||
}
|
||||
return find;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找所有下级用户
|
||||
*
|
||||
* @param partyId
|
||||
* @return
|
||||
*/
|
||||
public List<String> findChildren(Serializable partyId) {
|
||||
List list = new ArrayList();
|
||||
list = findChildren(partyId, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> findChildren(Serializable partyId, List<String> list) {
|
||||
List recom_list = findRecoms(partyId);
|
||||
for (int i = 0; i < recom_list.size(); i++) {
|
||||
list.add(((UserRecom) recom_list.get(i)).getPartyId().toString());
|
||||
findChildren(((UserRecom) recom_list.get(i)).getPartyId().toString(), list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> findDirectlyChildrens(Serializable partyId) {
|
||||
List list = new ArrayList();
|
||||
list = findDirectlyChildrens(partyId, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private List<String> findDirectlyChildrens(Serializable partyId, List<String> list) {
|
||||
List recom_list = findRecoms(partyId);
|
||||
for (int i = 0; i < recom_list.size(); i++) {
|
||||
list.add(((UserRecom) recom_list.get(i)).getPartyId().toString());
|
||||
// 查直接下属,不要级联
|
||||
// findChildren(((UserRecom) recom_list.get(i)).getPartyId().toString(), list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String findChildrensIds(String loginPartyId) {
|
||||
String childrensId = "";
|
||||
if (!StringUtils.isNullOrEmpty(loginPartyId)) {
|
||||
List<String> children = this.findChildren(loginPartyId);
|
||||
if (children.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<String> ids = new LinkedList<String>();
|
||||
for (String p : children) {
|
||||
ids.add("'" + p + "'");
|
||||
}
|
||||
childrensId = String.join(",", ids);
|
||||
}
|
||||
return childrensId;
|
||||
}
|
||||
|
||||
public void setRedisHandler(RedisHandler redisHandler) {
|
||||
this.redisHandler = redisHandler;
|
||||
}
|
||||
|
||||
public void setVipService(VipService vipService) {
|
||||
this.vipService = vipService;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user