Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
向汉
/
uc-consumer
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
9c6f17c3
...
9c6f17c36a60aa43b55566083795a70d6ff6e097
authored
2022-03-28 16:19:39 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.优化
1 parent
64abfab0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
9 deletions
src/main/java/com/topdraw/business/module/user/weixin/service/dto/UserWeixinDTO.java
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
src/main/java/com/topdraw/exception/GlobeExceptionMsg.java
src/main/java/com/topdraw/business/module/user/weixin/service/dto/UserWeixinDTO.java
View file @
9c6f17c
...
...
@@ -13,6 +13,8 @@ import java.sql.Timestamp;
@Data
public
class
UserWeixinDTO
implements
Serializable
{
private
String
memberCode
;
/** ID */
private
Long
id
;
...
...
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
9c6f17c
...
...
@@ -13,6 +13,8 @@ import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import
com.topdraw.business.process.service.UserOperationService
;
import
com.topdraw.business.process.service.dto.MemberAndUserTvDTO
;
import
com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO
;
import
com.topdraw.exception.EntityNotFoundException
;
import
com.topdraw.exception.GlobeExceptionMsg
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -54,13 +56,24 @@ public class UserOperationServiceImpl implements UserOperationService {
}
else
{
// 会员不存在
MemberDTO
memberDTO
=
memberAndWeixinUserDTO
.
getMemberDTO
();
MemberDTO
_memberDTO
=
this
.
createMember
(
memberDTO
);
userWeixinDTO
.
setMemberId
(
_memberDTO
.
getId
());
this
.
createWeixin
(
userWeixinDTO
);
}
}
else
{
// 账号存在,修改账号和会员
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
MemberDTO
_memberDTO
=
this
.
memberService
.
findById
(
_userWeixinDTO
.
getMemberId
());
MemberDTO
memberDTO
=
memberAndWeixinUserDTO
.
getMemberDTO
();
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
}
...
...
@@ -68,15 +81,71 @@ public class UserOperationServiceImpl implements UserOperationService {
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncMemberAndUserTv4Iptv
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
UserTvDTO
userTvDTO
=
memberAndUserTvDTO
.
getUserTvDTO
();
MemberDTO
memberDTO
=
memberAndUserTvDTO
.
getMemberDTO
();
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
UserTvDTO
_userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
isNull
(
_userTvDTO
))
{
// 创建大屏会员
MemberDTO
memberDTO
=
this
.
createMember
(
memberAndUserTvDTO
.
getMemberDTO
());
userTvDTO
.
setMemberId
(
memberDTO
.
getId
());
MemberDTO
_
memberDTO
=
this
.
createMember
(
memberAndUserTvDTO
.
getMemberDTO
());
userTvDTO
.
setMemberId
(
_
memberDTO
.
getId
());
// 创建大屏账号
this
.
createUserTv
(
userTvDTO
);
}
else
{
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
String
code
=
memberDTO
.
getCode
();
MemberDTO
_memberDTO
=
this
.
memberService
.
findByCode
(
code
);
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncAppletBind
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
UserTvDTO
userTvDTO
=
memberAndUserTvDTO
.
getUserTvDTO
();
MemberDTO
memberDTO
=
memberAndUserTvDTO
.
getMemberDTO
();
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
UserTvDTO
_userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
nonNull
(
_userTvDTO
))
{
//
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
String
code
=
memberDTO
.
getCode
();
MemberDTO
_memberDTO
=
this
.
memberService
.
findByCode
(
code
);
memberDTO
.
setUserIptvId
(
_userTvDTO
.
getId
());
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
else
{
throw
new
EntityNotFoundException
(
UserTvDTO
.
class
,
"id"
,
GlobeExceptionMsg
.
IPTV_IS_NULL
);
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncUnbind
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
UserTvDTO
userTvDTO
=
memberAndUserTvDTO
.
getUserTvDTO
();
MemberDTO
memberDTO
=
memberAndUserTvDTO
.
getMemberDTO
();
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
UserTvDTO
_userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
nonNull
(
_userTvDTO
))
{
//
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
String
code
=
memberDTO
.
getCode
();
MemberDTO
_memberDTO
=
this
.
memberService
.
findByCode
(
code
);
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
...
...
@@ -85,9 +154,20 @@ public class UserOperationServiceImpl implements UserOperationService {
String
unionid
=
userWeixinDTO
.
getUnionid
();
String
appid
=
userWeixinDTO
.
getAppid
();
UserWeixinDTO
_userWeixinDTO
=
this
.
userWeixinService
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionid
,
appid
,
openid
);
if
(
Objects
.
nonNull
(
_userWeixinDTO
))
{
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
userWeixinDTO
.
setId
(
_userWeixinDTO
.
getId
());
this
.
updateWeixin
(
userWeixinDTO
);
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
}
else
{
userWeixinDTO
.
setId
(
null
);
String
memberCode
=
userWeixinDTO
.
getMemberCode
();
MemberDTO
memberDTO
=
this
.
memberService
.
findByCode
(
memberCode
);
userWeixinDTO
.
setMemberId
(
memberDTO
.
getId
());
this
.
createWeixin
(
userWeixinDTO
);
}
}
...
...
@@ -99,7 +179,7 @@ public class UserOperationServiceImpl implements UserOperationService {
if
(
Objects
.
nonNull
(
_userTvDTO
))
{
Long
id
=
_userTvDTO
.
getId
();
userTvDTO
.
setId
(
id
);
this
.
updateUserTv
(
userTvDTO
);
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
}
}
...
...
@@ -112,11 +192,44 @@ public class UserOperationServiceImpl implements UserOperationService {
if
(
Objects
.
nonNull
(
_memberDTO
))
{
Long
id
=
_memberDTO
.
getId
();
memberDTO
.
setId
(
id
);
this
.
updateMember
(
memberDTO
);
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncUnsubscribe
(
MemberAndWeixinUserDTO
memberAndWeixinUserDTO
)
{
UserWeixinDTO
userWeixinDTO
=
memberAndWeixinUserDTO
.
getUserWeixinDTO
();
String
openid
=
userWeixinDTO
.
getOpenid
();
String
unionid
=
userWeixinDTO
.
getUnionid
();
String
appid
=
userWeixinDTO
.
getAppid
();
MemberDTO
memberDTO
=
memberAndWeixinUserDTO
.
getMemberDTO
();
UserWeixinDTO
_userWeixinDTO
=
this
.
userWeixinService
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionid
,
appid
,
openid
);
if
(
Objects
.
nonNull
(
_userWeixinDTO
))
{
// 账号存在,修改账号和会员
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
MemberDTO
_memberDTO
=
this
.
memberService
.
findById
(
_userWeixinDTO
.
getMemberId
());
if
(
Objects
.
nonNull
(
_memberDTO
))
{
memberDTO
.
setUserIptvId
(
_memberDTO
.
getUserIptvId
());
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
else
{
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"id"
,
GlobeExceptionMsg
.
MEMBER_ID_IS_NULL
);
}
}
else
{
throw
new
EntityNotFoundException
(
UserWeixinDTO
.
class
,
"id"
,
GlobeExceptionMsg
.
WEIXIN_IS_NULL
);
}
}
private
MemberDTO
createMember
(
MemberDTO
memberDTO
){
Member
member
=
new
Member
();
...
...
@@ -124,7 +237,11 @@ public class UserOperationServiceImpl implements UserOperationService {
return
this
.
memberService
.
create
(
member
);
}
private
MemberDTO
updateMember
(
MemberDTO
memberDTO
){
private
MemberDTO
updateMember
(
MemberDTO
_memberDTO
,
MemberDTO
memberDTO
){
memberDTO
.
setId
(
_memberDTO
.
getId
());
memberDTO
.
setCode
(
_memberDTO
.
getCode
());
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO
,
member
);
return
this
.
memberService
.
update
(
member
);
...
...
@@ -136,7 +253,13 @@ public class UserOperationServiceImpl implements UserOperationService {
this
.
userWeixinService
.
create
(
userWeixin
);
}
private
void
updateWeixin
(
UserWeixinDTO
weixinDTO
){
private
void
updateWeixin
(
UserWeixinDTO
_userWeixinDTO
,
UserWeixinDTO
weixinDTO
){
weixinDTO
.
setId
(
_userWeixinDTO
.
getId
());
weixinDTO
.
setMemberId
(
_userWeixinDTO
.
getMemberId
());
weixinDTO
.
setUnionid
(
_userWeixinDTO
.
getUnionid
());
weixinDTO
.
setAppid
(
_userWeixinDTO
.
getAppid
());
weixinDTO
.
setOpenid
(
_userWeixinDTO
.
getOpenid
());
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
weixinDTO
,
userWeixin
);
this
.
userWeixinService
.
update
(
userWeixin
);
...
...
@@ -148,7 +271,13 @@ public class UserOperationServiceImpl implements UserOperationService {
this
.
userTvService
.
create
(
userTv
);
}
private
void
updateUserTv
(
UserTvDTO
userTvDTO
){
private
void
updateUserTv
(
UserTvDTO
_userTvDTO
,
UserTvDTO
userTvDTO
){
userTvDTO
.
setId
(
_userTvDTO
.
getId
());
userTvDTO
.
setVisUserId
(
_userTvDTO
.
getVisUserId
());
userTvDTO
.
setMemberId
(
_userTvDTO
.
getMemberId
());
userTvDTO
.
setPlatformAccount
(
_userTvDTO
.
getPlatformAccount
());
userTvDTO
.
setCreateTime
(
_userTvDTO
.
getCreateTime
());
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
userTvDTO
,
userTv
);
this
.
userTvService
.
update
(
userTv
);
...
...
src/main/java/com/topdraw/exception/GlobeExceptionMsg.java
View file @
9c6f17c
...
...
@@ -47,4 +47,5 @@ public interface GlobeExceptionMsg {
String
OPEN_ID_IS_NULL
=
"openId is null"
;
String
UNION_ID_IS_NULL
=
"unionId is null"
;
String
ALREADY_BIND
=
"already bind"
;
String
WEIXIN_IS_NULL
=
"weixin is null"
;
}
...
...
Please
register
or
sign in
to post a comment