Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
huhu-partner
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanchen
huhu-partner
Commits
f7f3b1fe
Commit
f7f3b1fe
authored
Mar 20, 2020
by
guanchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新奖励类型790
接口返回代理商关系时 剔除失效
parent
48c284ed
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
284 additions
and
273 deletions
+284
-273
Constants.java
...ain/java/com/lanren/huhu/partner/constants/Constants.java
+23
-12
UserManager.java
...ain/java/com/lanren/huhu/partner/manager/UserManager.java
+208
-213
AgentTree.java
src/main/java/com/lanren/huhu/partner/model/AgentTree.java
+15
-16
ParentAgent.java
src/main/java/com/lanren/huhu/partner/model/ParentAgent.java
+14
-23
AgentRewardQueueTask.java
...om/lanren/huhu/partner/schedule/AgentRewardQueueTask.java
+5
-3
RevokeAgentRewardTask.java
...m/lanren/huhu/partner/schedule/RevokeAgentRewardTask.java
+3
-1
UserServiceImpl.java
...com/lanren/huhu/partner/service/impl/UserServiceImpl.java
+16
-5
No files found.
src/main/java/com/lanren/huhu/partner/constants/Constants.java
View file @
f7f3b1fe
...
@@ -19,10 +19,10 @@ public class Constants {
...
@@ -19,10 +19,10 @@ public class Constants {
*/
*/
public
static
final
int
AGENT_REWARD_TYPE_YEAR_VIP
=
710
;
public
static
final
int
AGENT_REWARD_TYPE_YEAR_VIP
=
710
;
public
static
final
String
AGENT_REWARD_TYPE_YEAR_VIP_REMARK
=
"推荐奖励-年VIP"
;
public
static
final
String
AGENT_REWARD_TYPE_YEAR_VIP_REMARK
=
"推荐奖励-年VIP"
;
//
public static final int AGENT_REWARD_TYPE_HALF_YEAR_VIP = 720;
public
static
final
int
AGENT_REWARD_TYPE_HALF_YEAR_VIP
=
720
;
//
public static final String AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK = "城市代理商所得的购买半年-VIP";
public
static
final
String
AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK
=
"城市代理商所得的购买半年-VIP"
;
//
public static final int AGENT_REWARD_TYPE_SVIP = 730;
public
static
final
int
AGENT_REWARD_TYPE_SVIP
=
730
;
//
public static final String AGENT_REWARD_TYPE_SVIP_REMARK = "城市代理商所得的购买超级VIP收益";
public
static
final
String
AGENT_REWARD_TYPE_SVIP_REMARK
=
"城市代理商所得的购买超级VIP收益"
;
public
static
final
int
AGENT_REWARD_TYPE_REDPACK
=
740
;
public
static
final
int
AGENT_REWARD_TYPE_REDPACK
=
740
;
public
static
final
String
AGENT_REWARD_TYPE_REDPACK_REMARK
=
"推荐奖励-普通用户购买红包"
;
public
static
final
String
AGENT_REWARD_TYPE_REDPACK_REMARK
=
"推荐奖励-普通用户购买红包"
;
public
static
final
int
AGENT_REWARD_TYPE_SELF_ORDER
=
750
;
public
static
final
int
AGENT_REWARD_TYPE_SELF_ORDER
=
750
;
...
@@ -31,6 +31,8 @@ public class Constants {
...
@@ -31,6 +31,8 @@ public class Constants {
public
static
final
String
AGENT_REWARD_TYPE_SHARE_ORDER_REMARK
=
"推荐奖励-分享赚"
;
public
static
final
String
AGENT_REWARD_TYPE_SHARE_ORDER_REMARK
=
"推荐奖励-分享赚"
;
public
static
final
int
AGENT_REWARD_TYPE_VIP_PACKAGE
=
780
;
public
static
final
int
AGENT_REWARD_TYPE_VIP_PACKAGE
=
780
;
public
static
final
String
AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK
=
"推荐奖励-VIP礼包"
;
public
static
final
String
AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK
=
"推荐奖励-VIP礼包"
;
public
static
final
int
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
=
790
;
public
static
final
String
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP_REMARK
=
"推荐奖励-购买礼包(送VIP会员)"
;
public
static
final
int
JD_OFFSET
=
1000
;
//用于查找京东的平推奖励比例
public
static
final
int
JD_OFFSET
=
1000
;
//用于查找京东的平推奖励比例
public
static
final
int
MT_OFFSET
=
2000
;
//用于查找美团的平推奖励比例
public
static
final
int
MT_OFFSET
=
2000
;
//用于查找美团的平推奖励比例
public
static
final
int
TN_OFFSET
=
3000
;
//用于查找途牛的平推奖励比例
public
static
final
int
TN_OFFSET
=
3000
;
//用于查找途牛的平推奖励比例
...
@@ -60,6 +62,7 @@ public class Constants {
...
@@ -60,6 +62,7 @@ public class Constants {
public
static
final
int
AGENT_REVOKE_TYPE_SHARE_ORDER
=
400
;
public
static
final
int
AGENT_REVOKE_TYPE_SHARE_ORDER
=
400
;
public
static
final
String
AGENT_REVOKE_TYPE_SHARE_ORDER_REMARK
=
"分享赚奖励扣回"
;
public
static
final
String
AGENT_REVOKE_TYPE_SHARE_ORDER_REMARK
=
"分享赚奖励扣回"
;
public
static
Map
<
Integer
,
String
>
AGENT_REVOKE_TYPE_MAP
=
new
HashMap
<
Integer
,
String
>();
public
static
Map
<
Integer
,
String
>
AGENT_REVOKE_TYPE_MAP
=
new
HashMap
<
Integer
,
String
>();
/**
/**
* 回扣状态
* 回扣状态
*/
*/
...
@@ -90,9 +93,10 @@ public class Constants {
...
@@ -90,9 +93,10 @@ public class Constants {
* 代理商平推奖励比例配置
* 代理商平推奖励比例配置
*/
*/
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_YEAR_VIP
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_YEAR_VIP
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_HALF_YEAR_VIP
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SVIP
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_VIP_PACKAGE
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_VIP_PACKAGE
,
new
HashMap
<
Integer
,
BigDecimal
>());
// AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
,
new
HashMap
<
Integer
,
BigDecimal
>());
// AGENT_RATE_MAP.put(AGENT_REWARD_TYPE_SVIP, new HashMap<Integer, BigDecimal>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_REDPACK
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_REDPACK
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SHARE_ORDER
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SHARE_ORDER
,
new
HashMap
<
Integer
,
BigDecimal
>());
...
@@ -103,10 +107,16 @@ public class Constants {
...
@@ -103,10 +107,16 @@ public class Constants {
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
+
MTJD_OFFSET
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
+
MTJD_OFFSET
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
+
ELM_OFFSET
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
+
ELM_OFFSET
,
new
HashMap
<
Integer
,
BigDecimal
>());
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_YEAR_VIP
).
put
(
0
,
new
BigDecimal
(
"0.02512563"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_YEAR_VIP
).
put
(
0
,
new
BigDecimal
(
"0.03015076"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_YEAR_VIP
).
put
(
1
,
new
BigDecimal
(
"0.01507538"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_YEAR_VIP
).
put
(
1
,
new
BigDecimal
(
"0.0201005"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_VIP_PACKAGE
).
put
(
0
,
new
BigDecimal
(
"0.02512563"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_HALF_YEAR_VIP
).
put
(
0
,
new
BigDecimal
(
"0.03015076"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_VIP_PACKAGE
).
put
(
1
,
new
BigDecimal
(
"0.01507538"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_HALF_YEAR_VIP
).
put
(
1
,
new
BigDecimal
(
"0.0201005"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_SVIP
).
put
(
0
,
new
BigDecimal
(
"0.03015076"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_SVIP
).
put
(
1
,
new
BigDecimal
(
"0.0201005"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_VIP_PACKAGE
).
put
(
0
,
new
BigDecimal
(
"0.03015076"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_VIP_PACKAGE
).
put
(
1
,
new
BigDecimal
(
"0.0201005"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
).
put
(
0
,
new
BigDecimal
(
"0.03015076"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
).
put
(
1
,
new
BigDecimal
(
"0.0201005"
));
/**
/**
* 红包
* 红包
...
@@ -137,9 +147,10 @@ public class Constants {
...
@@ -137,9 +147,10 @@ public class Constants {
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_SHARE_ORDER
+
JD_OFFSET
).
put
(
1
,
new
BigDecimal
(
"0.0087"
));
AGENT_RATE_MAP
.
get
(
AGENT_REWARD_TYPE_SHARE_ORDER
+
JD_OFFSET
).
put
(
1
,
new
BigDecimal
(
"0.0087"
));
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_YEAR_VIP
,
AGENT_REWARD_TYPE_YEAR_VIP_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_YEAR_VIP
,
AGENT_REWARD_TYPE_YEAR_VIP_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_HALF_YEAR_VIP
,
AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_SVIP
,
AGENT_REWARD_TYPE_SVIP_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_VIP_PACKAGE
,
AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_VIP_PACKAGE
,
AGENT_REWARD_TYPE_VIP_PACKAGE_REMARK
);
// AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_HALF_YEAR_VIP, AGENT_REWARD_TYPE_HALF_YEAR_VIP_REMARK);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
,
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP_REMARK
);
// AGENT_REWARD_REMARK.put(AGENT_REWARD_TYPE_SVIP, AGENT_REWARD_TYPE_SVIP_REMARK);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_REDPACK
,
AGENT_REWARD_TYPE_REDPACK_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_REDPACK
,
AGENT_REWARD_TYPE_REDPACK_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
,
AGENT_REWARD_TYPE_SELF_ORDER_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_SELF_ORDER
,
AGENT_REWARD_TYPE_SELF_ORDER_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_SHARE_ORDER
,
AGENT_REWARD_TYPE_SHARE_ORDER_REMARK
);
AGENT_REWARD_REMARK
.
put
(
AGENT_REWARD_TYPE_SHARE_ORDER
,
AGENT_REWARD_TYPE_SHARE_ORDER_REMARK
);
...
...
src/main/java/com/lanren/huhu/partner/manager/UserManager.java
View file @
f7f3b1fe
package
com
.
lanren
.
huhu
.
partner
.
manager
;
package
com
.
lanren
.
huhu
.
partner
.
manager
;
import
com.lanren.huhu.partner.domain.PartnerAccount
;
import
com.lanren.huhu.partner.domain.PartnerAccount
;
import
com.lanren.huhu.partner.domain.UserAgent
;
import
com.lanren.huhu.partner.model.User
;
import
com.lanren.huhu.partner.model.*
;
import
com.lanren.huhu.partner.result.Result
;
import
com.lanren.huhu.partner.result.Result
;
import
com.lanren.huhu.partner.service.UserService
;
import
com.lanren.huhu.partner.service.UserService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -11,11 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -11,11 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
static
com
.
lanren
.
huhu
.
partner
.
constants
.
Constants
.
PARENT_COLUMN_NAME_CENGJI
;
import
static
com
.
lanren
.
huhu
.
partner
.
constants
.
Constants
.
PARENT_COLUMN_NAME_PINGTUI
;
/**
/**
* @author houseme
* @author houseme
*/
*/
...
@@ -43,226 +37,226 @@ public class UserManager {
...
@@ -43,226 +37,226 @@ public class UserManager {
return
result
;
return
result
;
}
}
/**
//
/**
* 根据输入的userId, 完成递归查找
//
* 根据输入的userId, 完成递归查找
* @param userId
//
* @param userId
*/
//
*/
@Async
//
@Async
public
Result
<
String
>
purgeRelation
(
Integer
userId
)
{
//
public Result<String> purgeRelation(Integer userId) {
Result
<
String
>
result
=
new
Result
<
String
>();
//
Result<String> result = new Result<String>();
try
{
//
try{
logger
.
info
(
"start purgeRelation for userId: {} ..."
,
userId
);
//
logger.info("start purgeRelation for userId: {} ...", userId);
PartnerAccount
partnerAccount
=
userService
.
getPartnerAccountByUserId
(
userId
);
//
PartnerAccount partnerAccount = userService.getPartnerAccountByUserId(userId);
if
(
partnerAccount
==
null
)
{
//
if (partnerAccount == null) {
result
.
setCode
(
413
);
//
result.setCode(413);
}
//
}
int
partnerLevel
=
partnerAccount
.
getIsSuperPartner
()
==
1
?
30
:
partnerAccount
.
getPartnerLevel
();
//
int partnerLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
/**
//
/**
* 合伙人按邀请关系
//
* 合伙人按邀请关系
*/
//
*/
PartnerTree
root
=
new
PartnerTree
();
//
PartnerTree root = new PartnerTree();
root
.
setUserId
(
partnerAccount
.
getUserId
());
//
root.setUserId(partnerAccount.getUserId());
root
.
setLevel
(
partnerLevel
);
//
root.setLevel(partnerLevel);
root
.
setParentList
(
new
ArrayList
<
ParentPartner
>());
//
root.setParentList(new ArrayList<ParentPartner>());
recursiveSet
(
root
);
//
recursiveSet(root);
/**
//
/**
* 如果这个用户还是代理商身份, 也要处理他的代理商下级(层级下级 和 平推下级)
//
* 如果这个用户还是代理商身份, 也要处理他的代理商下级(层级下级 和 平推下级)
*/
//
*/
UserAgent
agent
=
userService
.
getUserAgentByUserId
(
partnerAccount
.
getUserId
());
//
UserAgent agent = userService.getUserAgentByUserId(partnerAccount.getUserId());
if
(
null
!=
agent
)
{
//
if (null != agent) {
AgentTree
agentRoot
=
new
AgentTree
();
//
AgentTree agentRoot = new AgentTree();
agentRoot
.
setUserId
(
partnerAccount
.
getUserId
());
//
agentRoot.setUserId(partnerAccount.getUserId());
agentRoot
.
setAgentId
(
agent
.
getAgentId
());
//
agentRoot.setAgentId(agent.getAgentId());
agentRoot
.
setLevel
(
partnerLevel
);
//
agentRoot.setLevel(partnerLevel);
agentRoot
.
setParentList
(
new
ArrayList
<
ParentAgent
>());
//
agentRoot.setParentList(new ArrayList<ParentAgent>());
recursiveSet
(
agentRoot
,
PARENT_COLUMN_NAME_CENGJI
);
//
recursiveSet(agentRoot, PARENT_COLUMN_NAME_CENGJI);
recursiveSet
(
agentRoot
,
PARENT_COLUMN_NAME_PINGTUI
);
//
recursiveSet(agentRoot, PARENT_COLUMN_NAME_PINGTUI);
}
//
}
logger
.
info
(
"done purgeRelation for userId: {}"
,
userId
);
//
logger.info("done purgeRelation for userId: {}", userId);
result
.
setData
(
"用户刷新成功"
);
//
result.setData("用户刷新成功");
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
logger
.
error
(
e
.
getMessage
(),
e
);
//
logger.error(e.getMessage(), e);
result
.
setCode
(
500
);
//
result.setCode(500);
}
//
}
return
result
;
//
return result;
}
//
}
/**
/**
* ****************************************分割线****合伙人***************************************************************
* ****************************************分割线****合伙人***************************************************************
*/
*/
/**
//
/**
* 递归查找, 完成输入的tree的所有下级查找
//
* 递归查找, 完成输入的tree的所有下级查找
* @param tree
//
* @param tree
*/
//
*/
private
void
recursiveSet
(
PartnerTree
tree
)
{
//
private void recursiveSet(PartnerTree tree) {
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
//
logger.info("do recursiveSet for userId: {}", tree.getUserId());
if
(
logger
.
isDebugEnabled
())
{
//
if (logger.isDebugEnabled()) {
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
//
logger.info("do recursiveSet for userId: {}", tree.getUserId());
}
//
}
/**
//
/**
* 先找到直接下级
//
* 先找到直接下级
*/
//
*/
setChildList
(
tree
);
//
setChildList(tree);
ArrayList
<
PartnerTree
>
children
=
tree
.
getChildList
();
//
ArrayList<PartnerTree> children = tree.getChildList();
/**
//
/**
* 如果没有下级了 那么直接输出结果
//
* 如果没有下级了 那么直接输出结果
*/
//
*/
if
(
children
.
size
()
==
0
)
{
//
if (children.size() == 0) {
outputTree
(
tree
);
//
outputTree(tree);
}
else
{
//
} else {
/**
//
/**
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
//
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
*/
//
*/
for
(
PartnerTree
child
:
children
)
{
//
for (PartnerTree child : children) {
recursiveSet
(
child
);
//
recursiveSet(child);
/**
//
/**
* 当完成 对每个下级再执行recursiveSet 之后
//
* 当完成 对每个下级再执行recursiveSet 之后
* 判断一下, 每个下级是否有直接下级
//
* 判断一下, 每个下级是否有直接下级
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
//
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
* 所以要在这里执行一次, 把他们自己输出
//
* 所以要在这里执行一次, 把他们自己输出
*/
//
*/
if
(
child
.
getChildList
().
size
()
>
0
)
{
//
if (child.getChildList().size() > 0) {
outputTree
(
child
);
//
outputTree(child);
}
//
}
}
//
}
/**
//
/**
* 最后输出自己
//
* 最后输出自己
*/
//
*/
outputTree
(
tree
);
//
outputTree(tree);
}
//
}
}
//
}
/**
//
/**
* 完成刷新用户缓存数据
//
* 完成刷新用户缓存数据
* @param tree
//
* @param tree
*/
//
*/
private
void
outputTree
(
PartnerTree
tree
)
{
//
private void outputTree(PartnerTree tree) {
StringBuilder
sb
=
new
StringBuilder
();
//
StringBuilder sb = new StringBuilder();
ArrayList
<
ParentPartner
>
list
=
tree
.
getParentList
();
//
ArrayList<ParentPartner> list = tree.getParentList();
for
(
ParentPartner
p
:
list
)
{
//
for (ParentPartner p : list) {
sb
.
append
(
p
.
getUserId
()).
append
(
","
);
//
sb.append(p.getUserId()).append(",");
}
//
}
if
(
logger
.
isDebugEnabled
())
{
//
if (logger.isDebugEnabled()) {
logger
.
info
(
"begin to clean cache......"
);
//
logger.info("begin to clean cache......");
logger
.
info
(
"userId: {}, parent is: {}"
,
tree
.
getUserId
(),
sb
.
toString
());
//
logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
}
//
}
deleteRalationByUserId
(
tree
.
getUserId
());
//
deleteRalationByUserId(tree.getUserId());
/**
//
/**
* 加快接口返回速度 不再为每一个叶子做刷新
//
* 加快接口返回速度 不再为每一个叶子做刷新
* 只做清楚缓存的操作
//
* 只做清楚缓存的操作
*/
//
*/
// getRelationByUserId(tree.getUserId());
//
//
getRelationByUserId(tree.getUserId());
}
//
}
/**
//
/**
* 无递归操作, 只往下查找一级
//
* 无递归操作, 只往下查找一级
* 把下级的数据, 设置到输入的tree中的childrenList
//
* 把下级的数据, 设置到输入的tree中的childrenList
* @param tree
//
* @param tree
*/
//
*/
private
void
setChildList
(
PartnerTree
tree
)
{
//
private void setChildList(PartnerTree tree) {
ArrayList
<
PartnerAccount
>
partnerAccountArrayList
=
(
ArrayList
<
PartnerAccount
>)
userService
.
getPartnerAccountChildListByUserId
(
tree
.
getUserId
());
//
ArrayList<PartnerAccount> partnerAccountArrayList = (ArrayList<PartnerAccount>) userService.getPartnerAccountChildListByUserId(tree.getUserId());
for
(
PartnerAccount
partnerAccount
:
partnerAccountArrayList
)
{
//
for (PartnerAccount partnerAccount : partnerAccountArrayList) {
Integer
childId
=
partnerAccount
.
getUserId
();
//
Integer childId = partnerAccount.getUserId();
Integer
childLevel
=
partnerAccount
.
getIsSuperPartner
()
==
1
?
30
:
partnerAccount
.
getPartnerLevel
();
//
Integer childLevel = partnerAccount.getIsSuperPartner() == 1 ? 30 : partnerAccount.getPartnerLevel();
if
(!
tree
.
getParentList
().
contains
(
childId
))
{
//
if (!tree.getParentList().contains(childId)) {
ArrayList
<
ParentPartner
>
parentList4Child
=
tree
.
cloneParent
();
//
ArrayList<ParentPartner> parentList4Child = tree.cloneParent();
parentList4Child
.
add
(
new
ParentPartner
(
tree
.
getUserId
(),
tree
.
getLevel
()));
//
parentList4Child.add(new ParentPartner(tree.getUserId(), tree.getLevel()));
PartnerTree
oneChild
=
new
PartnerTree
();
//
PartnerTree oneChild = new PartnerTree();
oneChild
.
setUserId
(
childId
);
//
oneChild.setUserId(childId);
oneChild
.
setLevel
(
childLevel
);
//
oneChild.setLevel(childLevel);
oneChild
.
setParentList
(
parentList4Child
);
//
oneChild.setParentList(parentList4Child);
tree
.
getChildList
().
add
(
oneChild
);
//
tree.getChildList().add(oneChild);
}
//
}
}
//
}
}
//
}
/**
/**
* ****************************************分割线****代理商***************************************************************
* ****************************************分割线****代理商***************************************************************
*/
*/
/**
//
/**
* 递归查找, 完成输入的tree的所有下级查找
//
* 递归查找, 完成输入的tree的所有下级查找
* @param tree
//
* @param tree
*/
//
*/
private
void
recursiveSet
(
AgentTree
tree
,
String
parentColumnName
)
{
//
private void recursiveSet(AgentTree tree, String parentColumnName) {
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
//
logger.info("do recursiveSet for userId: {}", tree.getUserId());
if
(
logger
.
isDebugEnabled
())
{
//
if (logger.isDebugEnabled()) {
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
//
logger.info("do recursiveSet for userId: {}", tree.getUserId());
}
//
}
/**
//
/**
* 先找到直接下级
//
* 先找到直接下级
*/
//
*/
setChildList
(
tree
,
parentColumnName
);
//
setChildList(tree, parentColumnName);
ArrayList
<
AgentTree
>
children
=
tree
.
getChildList
();
//
ArrayList<AgentTree> children = tree.getChildList();
/**
//
/**
* 如果没有下级了 那么直接输出结果
//
* 如果没有下级了 那么直接输出结果
*/
//
*/
if
(
children
.
size
()
==
0
)
{
//
if (children.size() == 0) {
outputTree
(
tree
);
//
outputTree(tree);
}
else
{
//
} else {
/**
//
/**
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
//
* 如果有直接下级, 遍历下级, 对每个下级再执行recursiveSet
*/
//
*/
for
(
AgentTree
child
:
children
)
{
//
for (AgentTree child : children) {
recursiveSet
(
child
,
parentColumnName
);
//
recursiveSet(child, parentColumnName);
/**
//
/**
* 当完成 对每个下级再执行recursiveSet 之后
//
* 当完成 对每个下级再执行recursiveSet 之后
* 判断一下, 每个下级是否有直接下级
//
* 判断一下, 每个下级是否有直接下级
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
//
* 如果有 那么在各自的recursiveSet中 应该没有走到 line:52 的outputTree 方法
* 所以要在这里执行一次, 把他们自己输出
//
* 所以要在这里执行一次, 把他们自己输出
*/
//
*/
if
(
child
.
getChildList
().
size
()
>
0
)
{
//
if (child.getChildList().size() > 0) {
outputTree
(
child
);
//
outputTree(child);
}
//
}
}
//
}
/**
//
/**
* 最后输出自己
//
* 最后输出自己
*/
//
*/
outputTree
(
tree
);
//
outputTree(tree);
}
//
}
}
//
}
/**
//
/**
* 完成刷新用户缓存数据
//
* 完成刷新用户缓存数据
* @param tree
//
* @param tree
*/
//
*/
private
void
outputTree
(
AgentTree
tree
)
{
//
private void outputTree(AgentTree tree) {
StringBuilder
sb
=
new
StringBuilder
();
//
StringBuilder sb = new StringBuilder();
ArrayList
<
ParentAgent
>
list
=
tree
.
getParentList
();
//
ArrayList<ParentAgent> list = tree.getParentList();
for
(
ParentAgent
p
:
list
)
{
//
for (ParentAgent p : list) {
sb
.
append
(
p
.
getUserId
()).
append
(
","
);
//
sb.append(p.getUserId()).append(",");
}
//
}
if
(
logger
.
isDebugEnabled
())
{
//
if (logger.isDebugEnabled()) {
logger
.
info
(
"begin to clean cache......"
);
//
logger.info("begin to clean cache......");
logger
.
info
(
"userId: {}, parent is: {}"
,
tree
.
getUserId
(),
sb
.
toString
());
//
logger.info("userId: {}, parent is: {}", tree.getUserId(), sb.toString());
}
//
}
deleteRalationByUserId
(
tree
.
getUserId
());
//
deleteRalationByUserId(tree.getUserId());
}
//
}
/**
/**
* 无递归操作, 只往下查找一级
//
* 无递归操作, 只往下查找一级
* 把下级的数据, 设置到输入的tree中的childrenList
//
* 把下级的数据, 设置到输入的tree中的childrenList
* @param tree
//
* @param tree
*/
//
*/
private
void
setChildList
(
AgentTree
tree
,
String
parentColumnName
)
{
//
private void setChildList(AgentTree tree, String parentColumnName) {
ArrayList
<
UserAgent
>
partnerAccountArrayList
=
(
ArrayList
<
UserAgent
>)
userService
.
getUserAgentChildListByUserId
(
tree
.
getUserId
(),
parentColumnName
);
//
ArrayList<UserAgent> partnerAccountArrayList = (ArrayList<UserAgent>) userService.getUserAgentChildListByUserId(tree.getUserId(), parentColumnName);
for
(
UserAgent
userAgent
:
partnerAccountArrayList
)
{
//
for (UserAgent userAgent : partnerAccountArrayList) {
Integer
childId
=
userAgent
.
getUserId
();
//
Integer childId = userAgent.getUserId();
Integer
agentId
=
userAgent
.
getAgentId
();
//
Integer agentId = userAgent.getAgentId();
Integer
childLevel
=
userAgent
.
getAgentLevel
();
//
Integer childLevel = userAgent.getAgentLevel();
if
(!
tree
.
getParentList
().
contains
(
childId
))
{
//
if (!tree.getParentList().contains(childId)) {
ArrayList
<
ParentAgent
>
parentList4Child
=
tree
.
cloneParent
();
//
ArrayList<ParentAgent> parentList4Child = tree.cloneParent();
parentList4Child
.
add
(
new
ParentAgent
(
tree
.
getUserId
(),
tree
.
getAgentId
(),
tree
.
getLevel
()
));
// parentList4Child.add(new ParentAgent(tree.getUserId(), tree.getAgentId(), tree.getLevel(), 0
));
AgentTree
oneChild
=
new
AgentTree
();
//
AgentTree oneChild = new AgentTree();
oneChild
.
setUserId
(
childId
);
//
oneChild.setUserId(childId);
oneChild
.
setAgentId
(
agentId
);
//
oneChild.setAgentId(agentId);
oneChild
.
setLevel
(
childLevel
);
//
oneChild.setLevel(childLevel);
oneChild
.
setParentList
(
parentList4Child
);
//
oneChild.setParentList(parentList4Child);
tree
.
getChildList
().
add
(
oneChild
);
//
tree.getChildList().add(oneChild);
}
//
}
}
//
}
}
//
}
/**
/**
* 变更 代理商 或 用户的 上级
* 变更 代理商 或 用户的 上级
...
@@ -284,7 +278,8 @@ public class UserManager {
...
@@ -284,7 +278,8 @@ public class UserManager {
logger
.
info
(
"更新合伙人推荐关系, 将{}的上级改为{},更新{}行数据"
,
from
,
to
,
cnt
);
logger
.
info
(
"更新合伙人推荐关系, 将{}的上级改为{},更新{}行数据"
,
from
,
to
,
cnt
);
}
}
PartnerAccount
partnerAccount
=
userService
.
getPartnerAccountByPhone
(
from
);
PartnerAccount
partnerAccount
=
userService
.
getPartnerAccountByPhone
(
from
);
return
purgeRelation
(
partnerAccount
.
getUserId
());
// return purgeRelation(partnerAccount.getUserId());
return
new
Result
<
String
>();
}
}
private
int
updatePartnerRelation
(
String
from
,
String
to
)
{
private
int
updatePartnerRelation
(
String
from
,
String
to
)
{
...
...
src/main/java/com/lanren/huhu/partner/model/AgentTree.java
View file @
f7f3b1fe
...
@@ -3,8 +3,6 @@ package com.lanren.huhu.partner.model;
...
@@ -3,8 +3,6 @@ package com.lanren.huhu.partner.model;
import
com.lanren.huhu.partner.model.base.BaseModel
;
import
com.lanren.huhu.partner.model.base.BaseModel
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.ArrayList
;
/**
/**
* @author chen
* @author chen
* @title: AgentTree
* @title: AgentTree
...
@@ -14,19 +12,20 @@ import java.util.ArrayList;
...
@@ -14,19 +12,20 @@ import java.util.ArrayList;
* @date 2019-07-02 20:15
* @date 2019-07-02 20:15
*/
*/
@Data
@Data
@Deprecated
public
class
AgentTree
extends
BaseModel
{
public
class
AgentTree
extends
BaseModel
{
Integer
userId
;
//
Integer userId;
Integer
agentId
;
//
Integer agentId;
Integer
level
;
//
Integer level;
ArrayList
<
ParentAgent
>
parentList
;
//
ArrayList<ParentAgent> parentList;
ArrayList
<
AgentTree
>
childList
=
new
ArrayList
<
AgentTree
>();
//
ArrayList<AgentTree> childList = new ArrayList<AgentTree>();
//
public
ArrayList
<
ParentAgent
>
cloneParent
()
{
//
public ArrayList<ParentAgent> cloneParent() {
ArrayList
<
ParentAgent
>
copyList
=
new
ArrayList
<
ParentAgent
>();
//
ArrayList<ParentAgent> copyList = new ArrayList<ParentAgent>();
for
(
ParentAgent
parentAgent
:
this
.
getParentList
())
{
//
for (ParentAgent parentAgent : this.getParentList()) {
ParentAgent
one
=
new
ParentAgent
(
parentAgent
.
getUserId
(),
parentAgent
.
getAgentId
(),
parentAgent
.
getLevel
());
//
ParentAgent one = new ParentAgent(parentAgent.getUserId(), parentAgent.getAgentId(), parentAgent.getLevel());
copyList
.
add
(
one
);
//
copyList.add(one);
}
//
}
return
copyList
;
//
return copyList;
}
//
}
}
}
src/main/java/com/lanren/huhu/partner/model/ParentAgent.java
View file @
f7f3b1fe
package
com
.
lanren
.
huhu
.
partner
.
model
;
package
com
.
lanren
.
huhu
.
partner
.
model
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.lanren.huhu.partner.model.base.BaseModel
;
import
com.lanren.huhu.partner.model.base.BaseModel
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.Objects
;
/**
/**
* @author chen
* @author chen
* @title: ParentAgent
* @title: ParentAgent
...
@@ -16,42 +19,30 @@ public class ParentAgent extends BaseModel {
...
@@ -16,42 +19,30 @@ public class ParentAgent extends BaseModel {
int
userId
;
int
userId
;
int
agentId
;
int
agentId
;
int
level
;
int
level
;
@JSONField
(
serialize
=
false
)
int
agentState
;
public
ParentAgent
(
int
userId
,
int
agentId
,
int
level
)
{
public
ParentAgent
(
int
userId
,
int
agentId
,
int
level
,
int
agentState
)
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
this
.
agentId
=
agentId
;
this
.
agentId
=
agentId
;
this
.
level
=
level
;
this
.
level
=
level
;
this
.
agentState
=
agentState
;
}
}
@Override
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
o
)
{
if
(
obj
==
null
)
{
if
(
this
==
o
)
{
return
false
;
}
if
(
this
==
obj
)
{
return
true
;
return
true
;
}
}
if
(
obj
instanceof
ParentAgent
){
if
(!(
o
instanceof
ParentAgent
))
{
ParentAgent
parentAgent
=
(
ParentAgent
)
obj
;
return
false
;
if
(
parentAgent
.
agentId
==
this
.
agentId
)
{
return
true
;
}
else
{
return
false
;
}
}
}
return
false
;
ParentAgent
that
=
(
ParentAgent
)
o
;
return
agentId
==
that
.
agentId
;
}
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
StringBuilder
sb
=
new
StringBuilder
();
return
Objects
.
hash
(
agentId
);
sb
.
append
(
agentId
);
char
[]
charArr
=
sb
.
toString
().
toCharArray
();
int
hash
=
0
;
for
(
char
c
:
charArr
)
{
hash
=
hash
*
131
+
c
;
}
return
hash
;
}
}
}
}
src/main/java/com/lanren/huhu/partner/schedule/AgentRewardQueueTask.java
View file @
f7f3b1fe
...
@@ -22,6 +22,7 @@ import org.springframework.data.redis.core.RedisTemplate;
...
@@ -22,6 +22,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.TransactionStatus
;
...
@@ -63,7 +64,7 @@ public class AgentRewardQueueTask {
...
@@ -63,7 +64,7 @@ public class AgentRewardQueueTask {
@Autowired
@Autowired
TransactionDefinition
transactionDefinition
;
TransactionDefinition
transactionDefinition
;
//
@Scheduled(fixedDelay = 5000L)
@Scheduled
(
fixedDelay
=
5000L
)
public
void
runScheduledTask
()
{
public
void
runScheduledTask
()
{
logger
.
info
(
"run AgentRewardQueueTask"
);
logger
.
info
(
"run AgentRewardQueueTask"
);
runConsume
();
runConsume
();
...
@@ -320,6 +321,7 @@ public class AgentRewardQueueTask {
...
@@ -320,6 +321,7 @@ public class AgentRewardQueueTask {
agentReward
.
setCreatedAt
(
System
.
currentTimeMillis
()
/
1000L
);
agentReward
.
setCreatedAt
(
System
.
currentTimeMillis
()
/
1000L
);
agentReward
.
setCommissionRate
(
commissionRate
);
agentReward
.
setCommissionRate
(
commissionRate
);
agentReward
.
setRewardTypeChild
(
message
.
getRewardTypeChild
()
==
null
?
""
:
message
.
getRewardTypeChild
());
agentReward
.
setRewardTypeChild
(
message
.
getRewardTypeChild
()
==
null
?
""
:
message
.
getRewardTypeChild
());
agentReward
.
setRewardStatus
(
100
);
/**
/**
* agent_reward里:
* agent_reward里:
* money 面额(message里, 需要上供的代理商自己获得的奖励)
* money 面额(message里, 需要上供的代理商自己获得的奖励)
...
@@ -329,8 +331,8 @@ public class AgentRewardQueueTask {
...
@@ -329,8 +331,8 @@ public class AgentRewardQueueTask {
* cash_code 支付金额
* cash_code 支付金额
*/
*/
BigDecimal
rewardBasement
;
BigDecimal
rewardBasement
;
// if (rewardType == AGENT_REWARD_TYPE_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_HALF_YEAR_VIP || rewardType == AGENT_REWARD_TYPE_SVIP) {
if
(
rewardType
==
AGENT_REWARD_TYPE_YEAR_VIP
||
rewardType
==
AGENT_REWARD_TYPE_HALF_YEAR_VIP
||
rewardType
==
AGENT_REWARD_TYPE_SVIP
if
(
rewardType
==
AGENT_REWARD_TYPE_YEAR_VIP
||
rewardType
==
AGENT_REWARD_TYPE_REDPACK
||
rewardType
==
AGENT_REWARD_TYPE_VIP_PACKAGE
)
{
||
rewardType
==
AGENT_REWARD_TYPE_REDPACK
||
rewardType
==
AGENT_REWARD_TYPE_VIP_PACKAGE
||
rewardType
==
AGENT_REWARD_TYPE_PACKAGE_WITH_VIP
)
{
rewardBasement
=
message
.
getSourceUserPayment
();
rewardBasement
=
message
.
getSourceUserPayment
();
}
else
{
}
else
{
/**
/**
...
...
src/main/java/com/lanren/huhu/partner/schedule/RevokeAgentRewardTask.java
View file @
f7f3b1fe
...
@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
...
@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionDefinition
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.TransactionStatus
;
...
@@ -41,7 +42,7 @@ public class RevokeAgentRewardTask {
...
@@ -41,7 +42,7 @@ public class RevokeAgentRewardTask {
@Autowired
@Autowired
TransactionDefinition
transactionDefinition
;
TransactionDefinition
transactionDefinition
;
//
@Scheduled(fixedDelay = 5000L)
@Scheduled
(
fixedDelay
=
5000L
)
public
void
runScheduledTask
()
{
public
void
runScheduledTask
()
{
logger
.
info
(
"run RevokeAgentRewardTask"
);
logger
.
info
(
"run RevokeAgentRewardTask"
);
runConsume
();
runConsume
();
...
@@ -117,6 +118,7 @@ public class RevokeAgentRewardTask {
...
@@ -117,6 +118,7 @@ public class RevokeAgentRewardTask {
agentReward
.
setAmount
(
agentReward
.
getAmount
().
negate
());
agentReward
.
setAmount
(
agentReward
.
getAmount
().
negate
());
agentReward
.
setCommission
(
agentReward
.
getAmount
().
negate
());
agentReward
.
setCommission
(
agentReward
.
getAmount
().
negate
());
agentReward
.
setSettleTime
(
new
Date
());
agentReward
.
setSettleTime
(
new
Date
());
agentReward
.
setRewardStatus
(
100
);
insertList
.
add
(
agentReward
);
insertList
.
add
(
agentReward
);
}
else
if
(
agentReward
.
getSettleState
()
==
SETTLE_STATE_ON_THE_WAY
||
agentReward
.
getSettleState
()
==
SETTLE_STATE_PRE
)
{
}
else
if
(
agentReward
.
getSettleState
()
==
SETTLE_STATE_ON_THE_WAY
||
agentReward
.
getSettleState
()
==
SETTLE_STATE_PRE
)
{
agentReward
.
setAmount
(
new
BigDecimal
(
0
));
agentReward
.
setAmount
(
new
BigDecimal
(
0
));
...
...
src/main/java/com/lanren/huhu/partner/service/impl/UserServiceImpl.java
View file @
f7f3b1fe
...
@@ -71,7 +71,7 @@ public class UserServiceImpl implements UserService {
...
@@ -71,7 +71,7 @@ public class UserServiceImpl implements UserService {
return
user
;
return
user
;
}
}
@Override
@Override
@CacheEvict
(
key
=
"#userId"
)
@CacheEvict
(
key
=
"#userId"
)
public
boolean
deleteRalationByUserId
(
Integer
userId
)
{
public
boolean
deleteRalationByUserId
(
Integer
userId
)
{
logger
.
info
(
"UserServiceImpl delete user relation cache, userId: {}"
,
userId
);
logger
.
info
(
"UserServiceImpl delete user relation cache, userId: {}"
,
userId
);
...
@@ -234,7 +234,7 @@ public class UserServiceImpl implements UserService {
...
@@ -234,7 +234,7 @@ public class UserServiceImpl implements UserService {
ParentAgent
parentAgent
=
null
;
ParentAgent
parentAgent
=
null
;
if
(
null
!=
userAgent
)
{
if
(
null
!=
userAgent
)
{
int
agentLevel
=
userAgent
.
getAgentLevel
();
int
agentLevel
=
userAgent
.
getAgentLevel
();
parentAgent
=
new
ParentAgent
(
userAgent
.
getUserId
(),
userAgent
.
getAgentId
(),
agentLevel
);
parentAgent
=
new
ParentAgent
(
userAgent
.
getUserId
(),
userAgent
.
getAgentId
(),
agentLevel
,
userAgent
.
getAgentState
()
);
}
}
return
parentAgent
;
return
parentAgent
;
}
}
...
@@ -337,7 +337,7 @@ public class UserServiceImpl implements UserService {
...
@@ -337,7 +337,7 @@ public class UserServiceImpl implements UserService {
/**
/**
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
*/
*/
agentList
.
add
(
new
ParentAgent
(
firstAgent
.
getUserId
(),
firstAgent
.
getAgentId
(),
firstAgent
.
getAgentLevel
()));
agentList
.
add
(
new
ParentAgent
(
firstAgent
.
getUserId
(),
firstAgent
.
getAgentId
(),
firstAgent
.
getAgentLevel
()
,
firstAgent
.
getAgentState
()
));
if
(
firstAgent
.
getAgentLevel
()
!=
AGENT_LEVEL_1
)
{
if
(
firstAgent
.
getAgentLevel
()
!=
AGENT_LEVEL_1
)
{
loopTimes
=
0
;
loopTimes
=
0
;
if
(
logger
.
isDebugEnabled
())
{
if
(
logger
.
isDebugEnabled
())
{
...
@@ -361,7 +361,7 @@ public class UserServiceImpl implements UserService {
...
@@ -361,7 +361,7 @@ public class UserServiceImpl implements UserService {
/**
/**
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
* 添加代理到list时 都需要加个判断 如果找到总代 就不再找了
*/
*/
agentList
.
add
(
new
ParentAgent
(
loopUserAgent
.
getUserId
(),
loopUserAgent
.
getAgentId
(),
loopUserAgent
.
getLevel
()));
agentList
.
add
(
new
ParentAgent
(
loopUserAgent
.
getUserId
(),
loopUserAgent
.
getAgentId
(),
loopUserAgent
.
getLevel
()
,
loopUserAgent
.
getAgentState
()
));
if
(
loopUserAgent
.
getLevel
()
==
AGENT_LEVEL_1
)
{
if
(
loopUserAgent
.
getLevel
()
==
AGENT_LEVEL_1
)
{
break
;
break
;
}
}
...
@@ -398,6 +398,16 @@ public class UserServiceImpl implements UserService {
...
@@ -398,6 +398,16 @@ public class UserServiceImpl implements UserService {
if
(
logger
.
isInfoEnabled
())
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
"setAgentList {} for user: {} end"
,
parentColumnName
,
userId
);
logger
.
info
(
"setAgentList {} for user: {} end"
,
parentColumnName
,
userId
);
}
}
return
agentList
;
return
filterInvalid
(
agentList
);
}
private
List
<
ParentAgent
>
filterInvalid
(
ArrayList
<
ParentAgent
>
agentList
)
{
List
<
ParentAgent
>
resultList
=
new
ArrayList
<
ParentAgent
>();
for
(
ParentAgent
parentAgent
:
agentList
)
{
if
(
parentAgent
.
getAgentState
()
==
1
)
{
resultList
.
add
(
parentAgent
);
}
}
return
resultList
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment