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
6c6c6e52
Commit
6c6c6e52
authored
Jul 22, 2019
by
guanchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加脚本处理 合伙人 和 代理商 关系变更
用户的 代理商上级改为从自己开始找
parent
29a7d37e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
20 deletions
+86
-20
UserController.java
...va/com/lanren/huhu/partner/controller/UserController.java
+11
-2
PartnerAccountMapper.java
...ava/com/lanren/huhu/partner/dao/PartnerAccountMapper.java
+3
-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
-3
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
+11
-0
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 @
6c6c6e52
...
@@ -44,12 +44,21 @@ public class UserController {
...
@@ -44,12 +44,21 @@ public class UserController {
@RequestMapping
(
value
=
"/relation/change"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/relation/change"
,
method
=
RequestMethod
.
POST
)
public
Result
<
String
>
changeRelation
(
@RequestBody
@Valid
User
user
,
@RequestHeader
HttpHeaders
headers
)
{
public
Result
<
String
>
changeRelation
(
@RequestBody
@Valid
User
user
,
@RequestHeader
HttpHeaders
headers
)
{
if
(
logger
.
isInfoEnabled
())
{
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
());
logger
.
info
(
"============>"
+
Thread
.
currentThread
().
getName
());
Result
<
String
>
result
=
new
Result
<
String
>();
Result
<
String
>
result
=
new
Result
<
String
>();
result
.
setData
(
"异步,正在执行刷新......"
);
result
.
setData
(
"异步,正在执行刷新......"
);
return
result
;
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 @
6c6c6e52
...
@@ -37,4 +37,6 @@ public interface PartnerAccountMapper extends BaseMapper<PartnerAccount> {
...
@@ -37,4 +37,6 @@ public interface PartnerAccountMapper extends BaseMapper<PartnerAccount> {
"JOIN partner_account b on a.user_id=b.user_id "
+
"JOIN partner_account b on a.user_id=b.user_id "
+
"WHERE a.invite_user_id=#{userId}"
)
"WHERE a.invite_user_id=#{userId}"
)
List
<
PartnerAccount
>
getChildListByUserId
(
Integer
userId
);
List
<
PartnerAccount
>
getChildListByUserId
(
Integer
userId
);
int
updatePartnerRelation
(
String
from
,
String
to
);
}
}
\ No newline at end of file
src/main/java/com/lanren/huhu/partner/dao/UserAgentMapper.java
View file @
6c6c6e52
...
@@ -24,24 +24,19 @@ public interface UserAgentMapper extends BaseMapper<UserAgent> {
...
@@ -24,24 +24,19 @@ public interface UserAgentMapper extends BaseMapper<UserAgent> {
* @param agentId
* @param agentId
* @return
* @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"
)
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getParentAgent"
)
UserAgent
getParentAgent
(
@Param
(
"agentId"
)
Integer
agentId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
UserAgent
getParentAgent
(
@Param
(
"agentId"
)
Integer
agentId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
/**
/**
* 按uid查找下级 UserAgent
* 按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"
)
@SelectProvider
(
type
=
UserAgentSqlProvider
.
class
,
method
=
"getChildListByUserId"
)
List
<
UserAgent
>
getChildListByUserId
(
@Param
(
"userId"
)
Integer
userId
,
@Param
(
"parentColumnName"
)
String
parentColumnName
);
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 @
6c6c6e52
...
@@ -48,10 +48,10 @@ public class UserManager {
...
@@ -48,10 +48,10 @@ public class UserManager {
* @param userId
* @param userId
*/
*/
@Async
@Async
public
Result
<
String
>
chan
geRelation
(
Integer
userId
)
{
public
Result
<
String
>
pur
geRelation
(
Integer
userId
)
{
Result
<
String
>
result
=
new
Result
<
String
>();
Result
<
String
>
result
=
new
Result
<
String
>();
try
{
try
{
logger
.
info
(
"start
chan
geRelation for userId: {} ..."
,
userId
);
logger
.
info
(
"start
pur
geRelation 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
);
...
@@ -78,7 +78,7 @@ public class UserManager {
...
@@ -78,7 +78,7 @@ public class UserManager {
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
chan
geRelation for userId: {}"
,
userId
);
logger
.
info
(
"done
pur
geRelation for userId: {}"
,
userId
);
result
.
setData
(
"用户刷新成功"
);
result
.
setData
(
"用户刷新成功"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
...
@@ -263,4 +263,40 @@ public class UserManager {
...
@@ -263,4 +263,40 @@ 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
);
}
Result
<
String
>
result
=
new
Result
<
String
>();
result
.
setCode
(
500
);
return
result
;
}
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/service/UserService.java
View file @
6c6c6e52
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
);
}
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
);
}
\ No newline at end of file
\ No newline at end of file
...
...
src/main/java/com/lanren/huhu/partner/service/impl/UserServiceImpl.java
View file @
6c6c6e52
This diff is collapsed.
Click to expand it.
src/main/resources/mapper/PartnerAccountMapper.xml
View file @
6c6c6e52
...
@@ -498,4 +498,14 @@
...
@@ -498,4 +498,14 @@
</if>
</if>
</trim>
</trim>
</insert>
</insert>
<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>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mapper/UserAgentMapper.xml
View file @
6c6c6e52
...
@@ -588,4 +588,14 @@
...
@@ -588,4 +588,14 @@
</if>
</if>
</trim>
</trim>
</insert>
</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>
</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