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
f8893b57
Commit
f8893b57
authored
Jul 22, 2019
by
guanchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加处理 合伙人 和 代理商 关系变更
用户的 代理商上级改为从自己开始找
parent
0086b85a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
99 additions
and
22 deletions
+99
-22
UserController.java
...va/com/lanren/huhu/partner/controller/UserController.java
+11
-2
PartnerAccountMapper.java
...ava/com/lanren/huhu/partner/dao/PartnerAccountMapper.java
+5
-0
UserAgentMapper.java
...ain/java/com/lanren/huhu/partner/dao/UserAgentMapper.java
+9
-13
UserManager.java
...ain/java/com/lanren/huhu/partner/manager/UserManager.java
+39
-4
PartnerSettleTask.java
...a/com/lanren/huhu/partner/schedule/PartnerSettleTask.java
+4
-0
UserService.java
...ain/java/com/lanren/huhu/partner/service/UserService.java
+2
-2
UserServiceImpl.java
...com/lanren/huhu/partner/service/impl/UserServiceImpl.java
+0
-0
PartnerAccountMapper.xml
src/main/resources/mapper/PartnerAccountMapper.xml
+17
-0
PartnerRewardMapper.xml
src/main/resources/mapper/PartnerRewardMapper.xml
+1
-1
UserAgentMapper.xml
src/main/resources/mapper/UserAgentMapper.xml
+11
-0
No files found.
src/main/java/com/lanren/huhu/partner/controller/UserController.java
View file @
f8893b57
...
...
@@ -44,12 +44,21 @@ public class UserController {
@RequestMapping
(
value
=
"/relation/change"
,
method
=
RequestMethod
.
POST
)
public
Result
<
String
>
changeRelation
(
@RequestBody
@Valid
User
user
,
@RequestHeader
HttpHeaders
headers
)
{
if
(
logger
.
isInfoEnabled
())
{
logger
.
info
(
"
chan
geRelation userId:{},header:{},time:{}"
,
user
.
getUserId
(),
headers
.
keySet
().
toArray
(),
LocalDateTime
.
now
());
logger
.
info
(
"
pur
geRelation userId:{},header:{},time:{}"
,
user
.
getUserId
(),
headers
.
keySet
().
toArray
(),
LocalDateTime
.
now
());
}
userManager
.
chan
geRelation
(
user
.
getUserId
());
userManager
.
pur
geRelation
(
user
.
getUserId
());
logger
.
info
(
"============>"
+
Thread
.
currentThread
().
getName
());
Result
<
String
>
result
=
new
Result
<
String
>();
result
.
setData
(
"异步,正在执行刷新......"
);
return
result
;
}
@RequestMapping
(
value
=
"/update/relation/{from}/{to}/{type}"
,
method
=
RequestMethod
.
GET
)
public
Result
<
String
>
updateRelation
(
@PathVariable
(
"from"
)
String
from
,
@PathVariable
(
"to"
)
String
to
,
@PathVariable
(
"type"
)
int
type
)
{
userManager
.
updateRelation
(
from
,
to
,
type
);
logger
.
info
(
"============>"
+
Thread
.
currentThread
().
getName
());
Result
<
String
>
result
=
new
Result
<
String
>();
result
.
setData
(
"异步,正在执行更新新......"
);
return
result
;
}
}
src/main/java/com/lanren/huhu/partner/dao/PartnerAccountMapper.java
View file @
f8893b57
...
...
@@ -39,4 +39,8 @@ public interface PartnerAccountMapper extends BaseMapper<PartnerAccount> {
List
<
PartnerAccount
>
getChildListByUserId
(
Integer
userId
);
PartnerAccount
selectOneForUpdate
(
Integer
userId
);
int
updatePartnerRelation
(
String
from
,
String
to
);
PartnerAccount
getPartnerAccountByPhone
(
String
phone
);
}
\ No newline at end of file
src/main/java/com/lanren/huhu/partner/dao/UserAgentMapper.java
View file @
f8893b57
...
...
@@ -24,24 +24,19 @@ public interface UserAgentMapper extends BaseMapper<UserAgent> {
* @param agentId
* @return
*/
// @Select("SELECT b.* " +
// "FROM user_agent a " +
// "JOIN user_agent b on a.#{parentColumnName}=b.agent_id " +
// "WHERE a.agent_id=#{agentId} and b.agent_level<=4")
// UserAgent getParentAgent(Integer agentId, String parentColumnName);
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getParentAgent"
)
UserAgent
getParentAgent
(
@Param
(
"agentId"
)
Integer
agentId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
/**
* 按uid查找下级 UserAgent
*/
// @Select("SELECT b.* " +
// "FROM user_agent a " +
// "JOIN user_agent b on a.#{parentColumnName}=b.agent_id " +
// "WHERE b.user_id=#{userId}")
// List<UserAgent> getChildListByUserId(Integer userId, String parentColumnName);
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getChildListByUserId"
)
List
<
UserAgent
>
getChildListByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
/**
* 将手机号为from的代理商的 平推 上级改为手机号为to的代理商
*/
int
updatePingtuiRelation
(
String
from
,
String
to
);
/**
* 将手机号为from的代理商的 层级 上级改为手机号为to的代理商
*/
int
updateCengjiRelation
(
String
from
,
String
to
);
}
\ No newline at end of file
src/main/java/com/lanren/huhu/partner/manager/UserManager.java
View file @
f8893b57
...
...
@@ -48,10 +48,10 @@ public class UserManager {
* @param userId
*/
@Async
public
Result
<
String
>
chan
geRelation
(
Integer
userId
)
{
public
Result
<
String
>
pur
geRelation
(
Integer
userId
)
{
Result
<
String
>
result
=
new
Result
<
String
>();
try
{
logger
.
info
(
"start
chan
geRelation for userId: {} ..."
,
userId
);
logger
.
info
(
"start
pur
geRelation for userId: {} ..."
,
userId
);
PartnerAccount
partnerAccount
=
userService
.
getPartnerAccountByUserId
(
userId
);
if
(
partnerAccount
==
null
)
{
result
.
setCode
(
413
);
...
...
@@ -78,7 +78,7 @@ public class UserManager {
recursiveSet
(
agentRoot
,
PARENT_COLUMN_NAME_CENGJI
);
recursiveSet
(
agentRoot
,
PARENT_COLUMN_NAME_PINGTUI
);
}
logger
.
info
(
"done
chan
geRelation for userId: {}"
,
userId
);
logger
.
info
(
"done
pur
geRelation for userId: {}"
,
userId
);
result
.
setData
(
"用户刷新成功"
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
...
...
@@ -189,10 +189,10 @@ public class UserManager {
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
if
(
logger
.
isDebugEnabled
())
{
logger
.
info
(
"do recursiveSet for userId: {}"
,
tree
.
getUserId
());
}
/**
* 先找到直接下级
*/
}
setChildList
(
tree
,
parentColumnName
);
ArrayList
<
AgentTree
>
children
=
tree
.
getChildList
();
/**
...
...
@@ -263,4 +263,39 @@ public class UserManager {
}
}
}
/**
* 变更 代理商 或 用户的 上级
* 变更类型: 1改层级关系 2改推荐关系 3改层级和推荐关系 4改C端邀请关系 5全部都改
*/
@Async
public
Result
<
String
>
updateRelation
(
String
from
,
String
to
,
int
type
)
{
if
(
type
==
1
||
type
==
3
||
type
==
5
)
{
int
cnt
=
updateCengjiRelation
(
from
,
to
);
logger
.
info
(
"更新代理商层级关系, 将{}的上级改为{},更新{}行数据"
,
from
,
to
,
cnt
);
}
if
(
type
==
2
||
type
==
3
||
type
==
5
)
{
int
cnt
=
updatePingtuiRelation
(
from
,
to
);
logger
.
info
(
"更新代理商推荐关系, 将{}的上级改为{},更新{}行数据"
,
from
,
to
,
cnt
);
}
if
(
type
==
4
||
type
==
5
)
{
int
cnt
=
updatePartnerRelation
(
from
,
to
);
logger
.
info
(
"更新合伙人推荐关系, 将{}的上级改为{},更新{}行数据"
,
from
,
to
,
cnt
);
}
PartnerAccount
partnerAccount
=
userService
.
getPartnerAccountByPhone
(
from
);
return
purgeRelation
(
partnerAccount
.
getUserId
());
}
private
int
updatePartnerRelation
(
String
from
,
String
to
)
{
return
userService
.
updatePartnerRelation
(
from
,
to
);
}
private
int
updatePingtuiRelation
(
String
from
,
String
to
)
{
return
userService
.
updatePingtuiRelation
(
from
,
to
);
}
private
int
updateCengjiRelation
(
String
from
,
String
to
)
{
return
userService
.
updateCengjiRelation
(
from
,
to
);
}
}
src/main/java/com/lanren/huhu/partner/schedule/PartnerSettleTask.java
View file @
f8893b57
...
...
@@ -177,7 +177,11 @@ public class PartnerSettleTask {
partnerIncomeSummary
.
setYeartime
(
yeartime
);
partnerIncomeSummary
.
setMonthtime
(
monthtime
);
partnerIncomeSummary
.
setIncome
(
ZERO
);
partnerIncomeSummary
.
setState
(
15
);
partnerIncomeSummaryService
.
save
(
partnerIncomeSummary
);
}
else
{
partnerIncomeSummary
.
setState
(
15
);
partnerIncomeSummaryService
.
updateById
(
partnerIncomeSummary
);
}
}
...
...
src/main/java/com/lanren/huhu/partner/service/UserService.java
View file @
f8893b57
package
com
.
lanren
.
huhu
.
partner
.
service
;
import
com.lanren.huhu.partner.domain.PartnerAccount
;
import
com.lanren.huhu.partner.domain.UserAgent
;
import
com.lanren.huhu.partner.model.ParentAgent
;
import
com.lanren.huhu.partner.model.User
;
import
java.util.List
;
/** * @author houseme * @date 2019-06-28 18:35 * @Project partner * @Package com.lanren.huhu.partner.service * @File: UserService */
public
interface
UserService
{
/** * @description: 根据用户id, 查找一个用户的全部合伙人上级 和 代理商上级(此处为层级关系 非平推关系) * 缓存用户邀请关系和代理商关系数据 * 缓存不能带有构造方法的Bean 所以只能返回User的Bean * 包装Result在Cacheable注解的方法之外进行操作 * 注意 !!!!!!!! 这个方法是按输入用户的邀请关系链上查找 第一个有agent_level<=4的代理商身份的邀请人, 然后再走他的代理关系 * 注意 !!!!!!!! 如果需要获取一个代理商的上级代理 需要从UserAgentService里的方法获取 * @param userId * @return User * @throws * @author chen * @date 2019-06-26 20:01 */
User
getRelationByUserId
(
Integer
userId
);
List
<
ParentAgent
>
getAgentListByUserId
(
Integer
userId
,
String
parentColumnName
);
/** * 清理用户缓存 */
boolean
deleteRalationByUserId
(
Integer
userId
);
/*** * PartnerAccount * * 根据用户id查询账户信息 * @param userId * @return PartnerAccount */
PartnerAccount
getPartnerAccountByUserId
(
Integer
userId
);
/** * @description: 根据用户id查询全部直属下级合伙人 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */
List
<
PartnerAccount
>
getPartnerAccountChildListByUserId
(
Integer
userId
);
/*** * UserAgent * 根据用户id查询账户信息 * @param userId * @return */
UserAgent
getUserAgentByUserId
(
Integer
userId
);
/** * @description: 根据用户id查询全部直属下级代理商 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */
List
<
UserAgent
>
getUserAgentChildListByUserId
(
Integer
userId
,
String
parentColumnName
);
}
\ No newline at end of file
package
com
.
lanren
.
huhu
.
partner
.
service
;
import
com.lanren.huhu.partner.domain.PartnerAccount
;
import
com.lanren.huhu.partner.domain.UserAgent
;
import
com.lanren.huhu.partner.model.ParentAgent
;
import
com.lanren.huhu.partner.model.User
;
import
java.util.List
;
/** * @author houseme * @date 2019-06-28 18:35 * @Project partner * @Package com.lanren.huhu.partner.service * @File: UserService */
public
interface
UserService
{
/** * @description: 根据用户id, 查找一个用户的全部合伙人上级 和 代理商上级(此处为层级关系 非平推关系) * 缓存用户邀请关系和代理商关系数据 * 缓存不能带有构造方法的Bean 所以只能返回User的Bean * 包装Result在Cacheable注解的方法之外进行操作 * 注意 !!!!!!!! 这个方法是按输入用户的邀请关系链上查找 第一个有agent_level<=4的代理商身份的邀请人, 然后再走他的代理关系 * 注意 !!!!!!!! 如果需要获取一个代理商的上级代理 需要从UserAgentService里的方法获取 * @param userId * @return User * @throws * @author chen * @date 2019-06-26 20:01 */
User
getRelationByUserId
(
Integer
userId
);
List
<
ParentAgent
>
getAgentListByUserId
(
Integer
userId
,
String
parentColumnName
);
/** * 清理用户缓存 */
boolean
deleteRalationByUserId
(
Integer
userId
);
/*** * PartnerAccount * * 根据用户id查询账户信息 * @param userId * @return PartnerAccount */
PartnerAccount
getPartnerAccountByUserId
(
Integer
userId
);
/** * @description: 根据用户id查询全部直属下级合伙人 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */
List
<
PartnerAccount
>
getPartnerAccountChildListByUserId
(
Integer
userId
);
/*** * UserAgent * 根据用户id查询账户信息 * @param userId * @return */
UserAgent
getUserAgentByUserId
(
Integer
userId
);
/** * @description: 根据用户id查询全部直属下级代理商 * @param userId * @return List<PartnerAccount> * @author chen * @date 2019-06-28 11:49 */
List
<
UserAgent
>
getUserAgentChildListByUserId
(
Integer
userId
,
String
parentColumnName
);
int
updatePartnerRelation
(
String
from
,
String
to
);
int
updatePingtuiRelation
(
String
from
,
String
to
);
int
updateCengjiRelation
(
String
from
,
String
to
);
PartnerAccount
getPartnerAccountByPhone
(
String
phone
);
}
\ No newline at end of file
...
...
src/main/java/com/lanren/huhu/partner/service/impl/UserServiceImpl.java
View file @
f8893b57
This diff is collapsed.
Click to expand it.
src/main/resources/mapper/PartnerAccountMapper.xml
View file @
f8893b57
...
...
@@ -501,4 +501,20 @@
<select
id=
"selectOneForUpdate"
resultMap=
"BaseResultMap"
>
SELECT * FROM partner_account WHERE user_id = #{userId} FOR UPDATE;
</select>
<update
id=
"updatePartnerRelation"
>
UPDATE partner_invite_relation a
JOIN user_info b ON a.user_id=b.user_id
SET a.invite_user_id = (
SELECT a.user_id
FROM partner_account a JOIN user_info b ON a.user_id=b.user_id
WHERE b.user_phone='#{to}'
)
WHERE b.user_phone='#{from}'
</update>
<select
id=
"getPartnerAccountByPhone"
resultMap=
"BaseResultMap"
>
SELECT a.*
FROM partner_account a
JOIN user_info b on a.user_id=b.user_id
WHERE b.user_phone=#{phone}
</select>
</mapper>
\ No newline at end of file
src/main/resources/mapper/PartnerRewardMapper.xml
View file @
f8893b57
...
...
@@ -688,7 +688,7 @@
</select>
<update
id=
"updateRewardStatusByUidAndTs"
>
UPDATE partner_reward
SET reward_status=120
SET reward_status=120
,settle_state=case when settle_state>0 then 300 else settle_state end
WHERE recharge_time
BETWEEN FROM_UNIXTIME(#{beginTs}) AND FROM_UNIXTIME(#{endTs})
AND user_id = #{userId}
...
...
src/main/resources/mapper/UserAgentMapper.xml
View file @
f8893b57
...
...
@@ -588,4 +588,14 @@
</if>
</trim>
</insert>
<update
id=
"updatePingtuiRelation"
>
UPDATE user_agent
SET presenter_id=(SELECT agent_id FROM user_agent WHERE agent_phone=#{to})
WHERE agent_phone=#{from}
</update>
<update
id=
"updateCengjiRelation"
>
UPDATE user_agent
SET parent_agent_id=(SELECT agent_id FROM user_agent WHERE agent_phone=#{to})
WHERE agent_phone=#{from}
</update>
</mapper>
\ 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