Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张云鹏
/
uc-engine
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
9ce6111e
...
9ce6111ef1bcb63da62d05c3e99b2855c515c496
authored
2022-05-19 15:03:41 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.优化
1 parent
bee83e21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
121 additions
and
34 deletions
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
9ce6111
...
...
@@ -170,61 +170,138 @@ public class UserOperationServiceImpl implements UserOperationService {
String
headimgurl
=
resources
.
getHeadimgurl
();
Integer
sex
=
resources
.
getSex
();
//
检查小屏账户是否
存在
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstBy
UnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
()))
{
//
账户和会员都
存在
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstBy
AppIdAndOpenId
(
appId
,
openId
);
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
())
&&
Objects
.
nonNull
(
userWeixinDTO
.
getMemberId
())
)
{
log
.
error
(
"createWeixinUserAndMember ==>> result ==>> [{}]"
,
userWeixinDTO
);
throw
new
BadRequestException
(
GlobeExceptionMsg
.
OPERATION_FORBID
+
"==>> "
+
GlobeExceptionMsg
.
ENTITY_ALREADY_EXISTS
);
}
// 当前用户的任意微信app,因为同一unionId的会员是唯一的
UserWeixinDTO
_userWeixinDTO
=
this
.
findFirstByUnionId
(
unionId
);
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
// 账号存在但无会员
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
())
&&
Objects
.
isNull
(
userWeixinDTO
.
getMemberId
()))
{
Assert
.
notNull
(
_userWeixinDTO
.
getMemberId
(),
GlobeExceptionMsg
.
MEMBER_ID_IS_NULL
);
// 当前用户的任意微信app,因为同一unionId的会员是唯一的
UserWeixinDTO
_userWeixinDTO
=
this
.
findFirstByUnionId
(
unionId
);
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
// 小屏会员
MemberDTO
memberDTO
=
this
.
findMemberById
(
_userWeixinDTO
.
getMemberId
());
if
(
Objects
.
nonNull
(
memberDTO
))
{
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getMemberId
()))
{
resources
.
setMemberId
(
_userWeixinDTO
.
getMemberId
());
UserWeixin
userWeixin
=
UserWeixinBuilder
.
build
(
resources
);
UserWeixinDTO
weixinDTO
=
this
.
createWeixinUser
(
userWeixin
,
memberDTO
.
getId
(),
memberDTO
.
getCode
());
weixinDTO
.
setMemberCode
(
memberDTO
.
getCode
());
// 有其他账号的话,将此账号与对应的会员进行绑定
MemberDTO
memberDTO
=
this
.
findMemberById
(
_userWeixinDTO
.
getMemberId
());
userWeixinDTO
.
setMemberId
(
memberDTO
.
getId
());
userWeixinDTO
.
setMemberCode
(
memberDTO
.
getCode
());
if
(
StringUtils
.
isBlank
(
userWeixinDTO
.
getUnionid
()))
{
userWeixinDTO
.
setUnionid
(
unionId
);
}
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
userWeixinDTO
,
userWeixin
);
UserWeixinDTO
_userWeixinDTO1
=
this
.
updateWeixin
(
userWeixin
);
return
_userWeixinDTO1
;
// 同步至iptv
((
UserOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncWeixin
(
weixinDTO
);
}
else
{
return
weixinDTO
;
// 有其他账号但都无会员,新建会员并将此账号绑定新建的这个会员
Member
_member
=
MemberBuilder
.
build
(
LocalConstants
.
MEMBER_PLATFORM_TYPE_WEIXIN
,
headimgurl
,
nickname
,
0
,
sex
);
}
MemberDTO
memberDTO
=
this
.
createMember
(
_member
);
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"code"
,
GlobeExceptionMsg
.
MEMBER_CODE_IS_NULL
);
if
(
Objects
.
nonNull
(
memberDTO
))
{
userWeixinDTO
.
setMemberId
(
memberDTO
.
getId
());
userWeixinDTO
.
setMemberCode
(
memberDTO
.
getCode
());
if
(
StringUtils
.
isBlank
(
userWeixinDTO
.
getUnionid
()))
{
userWeixinDTO
.
setUnionid
(
unionId
);
}
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
userWeixinDTO
,
userWeixin
);
UserWeixinDTO
_userWeixinDTO1
=
this
.
updateWeixin
(
userWeixin
);
return
_userWeixinDTO1
;
}
else
{
}
// 新建会员
Member
_member
=
MemberBuilder
.
build
(
LocalConstants
.
MEMBER_PLATFORM_TYPE_WEIXIN
,
headimgurl
,
nickname
,
0
,
sex
);
}
MemberDTO
memberDTO
=
this
.
createMember
(
_member
);
}
else
{
if
(
Objects
.
nonNull
(
memberDTO
))
{
UserWeixin
userWeixin
=
UserWeixinBuilder
.
build
(
memberDTO
.
getId
(),
resources
);
UserWeixinDTO
_userWeixinDTO1
=
this
.
createWeixinUser
(
userWeixin
,
memberDTO
.
getId
(),
memberDTO
.
getCode
());
// 该账号存在但无其他账号,新建会员
Member
_member
=
MemberBuilder
.
build
(
LocalConstants
.
MEMBER_PLATFORM_TYPE_WEIXIN
,
headimgurl
,
nickname
,
0
,
sex
);
// 同步至iptv
((
UserOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncMemberAndUserWeixin4Iptv
(
new
MemberAndWeixinUserDTO
(
memberDTO
,
_userWeixinDTO1
));
MemberDTO
memberDTO
=
this
.
createMember
(
_member
);
if
(
Objects
.
nonNull
(
memberDTO
))
{
userWeixinDTO
.
setMemberId
(
memberDTO
.
getId
());
userWeixinDTO
.
setMemberCode
(
memberDTO
.
getCode
());
if
(
StringUtils
.
isBlank
(
userWeixinDTO
.
getUnionid
()))
{
userWeixinDTO
.
setUnionid
(
unionId
);
}
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
userWeixinDTO
,
userWeixin
);
UserWeixinDTO
_userWeixinDTO1
=
this
.
updateWeixin
(
userWeixin
);
return
_userWeixinDTO1
;
}
return
_userWeixinDTO1
;
}
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"code"
,
GlobeExceptionMsg
.
MEMBER_CODE_IS_NULL
);
}
// 无账号
if
(
Objects
.
isNull
(
userWeixinDTO
.
getId
()))
{
// 当前用户的任意微信app,因为同一unionId的会员是唯一的
UserWeixinDTO
_userWeixinDTO
=
this
.
findFirstByUnionId
(
unionId
);
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
Assert
.
notNull
(
_userWeixinDTO
.
getMemberId
(),
GlobeExceptionMsg
.
MEMBER_ID_IS_NULL
);
// 小屏会员
MemberDTO
memberDTO
=
this
.
findMemberById
(
_userWeixinDTO
.
getMemberId
());
if
(
Objects
.
nonNull
(
memberDTO
))
{
resources
.
setMemberId
(
_userWeixinDTO
.
getMemberId
());
UserWeixin
userWeixin
=
UserWeixinBuilder
.
build
(
resources
);
UserWeixinDTO
weixinDTO
=
this
.
createWeixinUser
(
userWeixin
,
memberDTO
.
getId
(),
memberDTO
.
getCode
());
weixinDTO
.
setMemberCode
(
memberDTO
.
getCode
());
// 同步至iptv
((
UserOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncWeixin
(
weixinDTO
);
return
weixinDTO
;
}
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"code"
,
GlobeExceptionMsg
.
MEMBER_CODE_IS_NULL
);
}
else
{
// 新建会员
Member
_member
=
MemberBuilder
.
build
(
LocalConstants
.
MEMBER_PLATFORM_TYPE_WEIXIN
,
headimgurl
,
nickname
,
0
,
sex
);
MemberDTO
memberDTO
=
this
.
createMember
(
_member
);
if
(
Objects
.
nonNull
(
memberDTO
))
{
UserWeixin
userWeixin
=
UserWeixinBuilder
.
build
(
memberDTO
.
getId
(),
resources
);
UserWeixinDTO
_userWeixinDTO1
=
this
.
createWeixinUser
(
userWeixin
,
memberDTO
.
getId
(),
memberDTO
.
getCode
());
// 同步至iptv
((
UserOperationServiceImpl
)
AopContext
.
currentProxy
()).
asyncMemberAndUserWeixin4Iptv
(
new
MemberAndWeixinUserDTO
(
memberDTO
,
_userWeixinDTO1
));
return
_userWeixinDTO1
;
}
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"code"
,
GlobeExceptionMsg
.
MEMBER_CODE_IS_NULL
);
}
}
return
userWeixinDTO
;
}
...
...
@@ -1114,11 +1191,21 @@ public class UserOperationServiceImpl implements UserOperationService {
* @param openId
* @return
*/
private
UserWeixinDTO
findFirstByUnionIdAndAppIdAndOpenId
(
String
unionId
,
String
appId
,
String
openId
)
{
private
UserWeixinDTO
findFirstByUnionIdAndAppIdAndOpenId
(
String
unionId
,
String
appId
,
String
openId
)
{
return
this
.
userWeixinService
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
}
/**
* 获取小屏账户
* @param appId
* @param openId
* @return
*/
private
UserWeixinDTO
findFirstByAppIdAndOpenId
(
String
appId
,
String
openId
)
{
return
this
.
userWeixinService
.
findFirstByAppIdAndOpenId
(
appId
,
openId
);
}
/**
*
* @param member
* @return
...
...
Please
register
or
sign in
to post a comment