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
60b8b824
...
60b8b824da5589211d1dbd44fe6287f0c2eb5131
authored
2022-06-16 10:12:44 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.修改会员信息修改、账号信息修改的方式
1 parent
9c38b950
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
162 additions
and
42 deletions
src/main/java/com/topdraw/business/module/user/iptv/repository/UserTvRepository.java
src/main/java/com/topdraw/business/module/user/iptv/service/UserTvService.java
src/main/java/com/topdraw/business/module/user/iptv/service/impl/UserTvServiceImpl.java
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
src/main/java/com/topdraw/business/module/user/iptv/repository/UserTvRepository.java
View file @
60b8b82
...
...
@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
java.time.LocalDateTime
;
import
java.util.Optional
;
...
...
@@ -24,4 +25,35 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif
@Modifying
@Query
(
value
=
"UPDATE `uc_user_tv` SET `vis_user_id` = ?2, `update_time` = ?3 WHERE `id` = ?1"
,
nativeQuery
=
true
)
Integer
updateUserTvVisUserId
(
Long
id
,
Long
visUserId
,
LocalDateTime
now
);
@Modifying
@Query
(
value
=
"UPDATE `uc_user_tv` SET `member_id` = ?2, `update_time` = now() WHERE `platform_account` = ?1"
,
nativeQuery
=
true
)
void
updateMemberId
(
String
platformAccount
,
Long
memberId
);
@Modifying
@Query
(
value
=
"UPDATE `uc_user_tv` SET `priority_member_code` = ?2, `update_time` = now() WHERE `platform_account` = ?1"
,
nativeQuery
=
true
)
void
updatePriorityMemberCode
(
String
platformAccount
,
String
priorityMemberCode
);
@Modifying
@Query
(
value
=
"UPDATE `uc_user_tv` SET "
+
" `cellphone` = :#{#resources.cellphone}, "
+
" `username` = :#{#resources.username}, "
+
" `nickname` = :#{#resources.nickname}, "
+
" `image` = :#{#resources.image}, "
+
" `platform` = :#{#resources.platform}, "
+
" `login_days` = :#{#resources.loginDays}, "
+
" `continue_days` = :#{#resources.continueDays}, "
+
" `active_time` = :#{#resources.activeTime}, "
+
" `groups` = :#{#resources.groups}, "
+
" `tags` = :#{#resources.tags}, "
+
" `login_type` = :#{#resources.loginType}, "
+
" `status` = :#{#resources.status}, "
+
" `description` = :#{#resources.description}, "
+
" `create_by` = :#{#resources.createBy}, "
+
" `update_by` = :#{#resources.updateBy}, "
+
" `priority_member_code` = :#{#resources.priorityMemberCode}, "
+
" `vis_user_id` = :#{#resources.visUserId}, "
+
" `update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}"
,
nativeQuery
=
true
)
void
updateUserTvByPlatformAccount
(
@Param
(
"resources"
)
UserTv
userTv
);
}
...
...
src/main/java/com/topdraw/business/module/user/iptv/service/UserTvService.java
View file @
60b8b82
...
...
@@ -88,4 +88,24 @@ public interface UserTvService {
*/
UserTvDTO
asyncUpdateUserTvVisUserId
(
UserTv
resources
);
/**
*
* @param platformAccount
* @param id
*/
void
updateMemberId
(
String
platformAccount
,
Long
id
);
/**
*
* @param platformAccount
* @param priorityMemberCode
*/
void
updatePriorityMemberCode
(
String
platformAccount
,
String
priorityMemberCode
);
/**
*
* @param userTv
*/
void
updateUserTvByPlatformAccount
(
UserTv
userTv
);
}
...
...
src/main/java/com/topdraw/business/module/user/iptv/service/impl/UserTvServiceImpl.java
View file @
60b8b82
...
...
@@ -44,6 +44,25 @@ public class UserTvServiceImpl implements UserTvService {
@Autowired
private
UserTvRepository
userTvRepository
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateMemberId
(
String
platformAccount
,
Long
memberId
)
{
this
.
userTvRepository
.
updateMemberId
(
platformAccount
,
memberId
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updatePriorityMemberCode
(
String
platformAccount
,
String
priorityMemberCode
)
{
this
.
userTvRepository
.
updatePriorityMemberCode
(
platformAccount
,
priorityMemberCode
);
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateUserTvByPlatformAccount
(
UserTv
userTv
)
{
this
.
userTvRepository
.
updateUserTvByPlatformAccount
(
userTv
);
}
/**
* 获取大屏账户对应的会员
* <Waring>
...
...
src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
60b8b82
...
...
@@ -2,6 +2,9 @@ package com.topdraw.business.process.service.impl;
import
com.topdraw.business.module.member.domain.Member
;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
import
com.topdraw.business.module.member.profile.service.MemberProfileService
;
import
com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO
;
import
com.topdraw.business.module.member.service.MemberService
;
import
com.topdraw.business.module.member.service.dto.MemberDTO
;
import
com.topdraw.business.module.user.iptv.domain.UserTv
;
...
...
@@ -37,6 +40,8 @@ public class UserOperationServiceImpl implements UserOperationService {
private
UserTvService
userTvService
;
@Autowired
private
UserWeixinService
userWeixinService
;
@Autowired
private
MemberProfileService
memberProfileService
;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncMemberAndUserWeixin4Iptv
(
MemberAndWeixinUserDTO
memberAndWeixinUserDTO
)
{
...
...
@@ -139,13 +144,18 @@ public class UserOperationServiceImpl implements UserOperationService {
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncMemberAndUserTv4Iptv
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
log
.
info
(
"同步小屏侧过来的大屏账号和会员, memberAndUserTvDTO ==>> {}"
,
memberAndUserTvDTO
);
UserTvDTO
userTvDTO
=
memberAndUserTvDTO
.
getUserTvDTO
();
MemberDTO
memberDTO
=
memberAndUserTvDTO
.
getMemberDTO
();
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
log
.
info
(
"同步小屏侧过来的大屏账号, platformAccount ==>> {}"
,
platformAccount
);
UserTvDTO
_userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
isNull
(
_userTvDTO
))
{
// log.info("查询数据对应的大屏账号信息, _userTvDTO ==>> {}", _userTvDTO);
if
(
Objects
.
isNull
(
_userTvDTO
))
{
log
.
info
(
"大屏账号不存在, 创建会员并新增账号"
);
memberDTO
.
setId
(
null
);
// 创建大屏会员
MemberDTO
_memberDTO
=
this
.
createMember
(
memberDTO
);
...
...
@@ -155,46 +165,72 @@ public class UserOperationServiceImpl implements UserOperationService {
}
else
{
String
code
=
memberDTO
.
getCode
();
MemberDTO
_memberDTO
=
this
.
memberService
.
findByCode
(
code
);
if
(
Objects
.
nonNull
(
_memberDTO
.
getId
()))
{
this
.
updateMember
(
_memberDTO
,
memberDTO
);
}
else
{
Long
memberId
=
_userTvDTO
.
getMemberId
();
if
(
Objects
.
isNull
(
memberId
))
{
memberDTO
.
setId
(
null
);
MemberDTO
_memberDTO0
=
this
.
createMember
(
memberDTO
);
userTvDTO
.
setMemberId
(
_memberDTO0
.
getId
());
// 创建大屏会员
MemberDTO
_memberDTO
=
this
.
createMember
(
memberDTO
);
userTvDTO
.
setMemberId
(
_memberDTO
.
getId
());
log
.
info
(
"大屏账号存在, 但无会员信息,新增会员信息并修改大屏账号"
);
// this.userTvService.updateMemberId(platformAccount, _memberDTO.getId());
}
else
{
MemberProfileDTO
memberProfileDTO
=
this
.
memberProfileService
.
findByMemberId
(
memberId
);
if
(
Objects
.
isNull
(
memberProfileDTO
))
{
MemberDTO
memberDTO1
=
this
.
memberService
.
findById
(
memberId
);
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
this
.
memberProfileService
.
createDefault
(
member
);
}
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
}
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
_userTvDTO
,
userTv
);
this
.
userTvService
.
updateUserTvByPlatformAccount
(
userTv
);
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncAppletBind
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
log
.
info
(
"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
))
{
if
(
Objects
.
nonNull
(
_userTvDTO
.
getId
()
))
{
//
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
// userTvDTO.getPriorityMemberCode();
// this.updateUserTv(_userTvDTO, userTvDTO);
// 修改大屏账号的主会员
String
priorityMemberCode
=
userTvDTO
.
getPriorityMemberCode
();
log
.
info
(
"修改大屏账号的主会员, 主会员priorityMemberCode ==>> {}"
,
priorityMemberCode
);
if
(
StringUtils
.
isNotBlank
(
priorityMemberCode
))
{
this
.
userTvService
.
updatePriorityMemberCode
(
platformAccount
,
priorityMemberCode
);
}
String
code
=
memberDTO
.
getCode
();
MemberDTO
_memberDTO
=
this
.
memberService
.
findByCode
(
code
);
memberDTO
.
setUserIptvId
(
_userTvDTO
.
getId
());
log
.
info
(
"修改会员对应绑定的大屏账号id, memberId ==>> {} || userTvId ==>> {}"
,
_memberDTO
.
getId
(),
_userTvDTO
.
getId
());
this
.
memberService
.
updateUserIptvIdById
(
_memberDTO
.
getId
(),
_userTvDTO
.
getId
(),
LocalDateTime
.
now
());
//this.updateMember(_memberDTO, memberDTO);
}
else
{
throw
new
EntityNotFoundException
(
UserTvDTO
.
class
,
"id"
,
GlobeExceptionMsg
.
IPTV_IS_NULL
);
log
.
error
(
"asyncAppletBind ==>> 小程序绑定大屏异常,大屏账号不存在, platformAccount ==>> {}"
,
platformAccount
);
}
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncUnbind
(
MemberAndUserTvDTO
memberAndUserTvDTO
)
{
UserTvDTO
userTvDTO
=
memberAndUserTvDTO
.
getUserTvDTO
();
...
...
@@ -318,7 +354,11 @@ public class UserOperationServiceImpl implements UserOperationService {
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
UserTvDTO
_userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
log
.
info
(
"db result ==>> _userTvDTO ==>> {}"
,
_userTvDTO
);
this
.
updateUserTv
(
_userTvDTO
,
userTvDTO
);
// this.updateUserTv(_userTvDTO, userTvDTO);
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
userTvDTO
,
userTv
);
this
.
userTvService
.
updateUserTvByPlatformAccount
(
userTv
);
}
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
...
...
@@ -336,56 +376,70 @@ public class UserOperationServiceImpl implements UserOperationService {
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
Exception
.
class
)
public
void
asyncSubscribe
(
MemberAndWeixinUserDTO
memberAndWeixinUserDTO
)
{
log
.
info
(
"微信关注业务开始"
);
UserWeixinDTO
userWeixinDTO
=
memberAndWeixinUserDTO
.
getUserWeixinDTO
();
log
.
info
(
"小屏侧传过来的微信账号信息 ==>> userWeixinDTO ==>> {}"
,
userWeixinDTO
);
String
openid
=
userWeixinDTO
.
getOpenid
();
String
unionid
=
userWeixinDTO
.
getUnionid
();
String
appid
=
userWeixinDTO
.
getAppid
();
MemberDTO
memberDTO
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"小屏侧传过来的会员信息 ==>> memberDTO ==>> {}"
,
memberDTO
);
UserWeixinDTO
_userWeixinDTO
=
this
.
userWeixinService
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionid
,
appid
,
openid
);
// 有账号
if
(
Objects
.
nonNull
(
_userWeixinDTO
.
getId
()))
{
log
.
info
(
"账号存在,检查会员是否存在"
);
UserWeixinDTO
_userWeixinDTO0
=
this
.
userWeixinService
.
findFirstByAppIdAndOpenId
(
appid
,
openid
);
// 会员存在
if
(
Objects
.
nonNull
(
_userWeixinDTO0
.
getMemberId
()))
{
log
.
info
(
"会员存在,修改账号的关注状态, 关注状态 status ==>> {}"
,
userWeixinDTO
.
getStatus
());
// 账号存在,修改账号和会员
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
MemberDTO
_memberDTO
=
this
.
memberService
.
findById
(
_userWeixinDTO
.
getMemberId
());
MemberDTO
memberDTO0
=
memberAndWeixinUserDTO
.
getMemberDTO
();
memberDTO0
.
setUserIptvId
(
_memberDTO
.
getUserIptvId
());
log
.
info
(
"会员存在,修改会员的绑定和vip标识"
,
userWeixinDTO
.
getStatus
());
this
.
updateMember
(
_memberDTO
,
memberDTO0
);
// 有账号无会员
}
else
{
log
.
info
(
"当前账号会员不存在"
);
// 是否存在会员
UserWeixinDTO
userWeixinDTO1
=
this
.
userWeixinService
.
findFirstByUnionId
(
unionid
);
log
.
info
(
"检查是否有其他账号存在, 其他账号信息 ==>> {}"
,
userWeixinDTO1
);
// 有其他账号
if
(
Objects
.
nonNull
(
userWeixinDTO1
.
getId
()))
{
log
.
info
(
"存在其他账号,检查其他账号是否有会员"
);
Long
memberId
=
userWeixinDTO1
.
getMemberId
();
if
(
Objects
.
nonNull
(
memberId
))
{
userWeixinDTO
.
setMemberId
(
memberId
);
MemberDTO
memberDTO0
=
this
.
memberService
.
findById
(
memberId
);
log
.
info
(
"其他账号有会员,会员信息 ==>> {}"
,
memberDTO0
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"开始同步会员信息"
);
this
.
updateMember
(
memberDTO0
,
memberDTO1
);
}
else
{
log
.
info
(
"其他账号无会员"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
}
log
.
info
(
"开始修改账号信息"
);
this
.
updateWeixin
(
_userWeixinDTO
,
userWeixinDTO
);
}
...
...
@@ -393,41 +447,56 @@ public class UserOperationServiceImpl implements UserOperationService {
// 无账号
}
else
{
log
.
info
(
"当前账号不存在,检查其他账号是否存在"
);
// 是否存在会员
UserWeixinDTO
userWeixinDTO1
=
this
.
userWeixinService
.
findFirstByUnionId
(
unionid
);
// 有其他账号
if
(
Objects
.
nonNull
(
userWeixinDTO1
.
getId
()))
{
log
.
info
(
"其他账号存在, 其他账号信息 ==>> {}"
,
userWeixinDTO1
);
log
.
info
(
"检查其他账号是否有会员"
);
Long
memberId
=
userWeixinDTO1
.
getMemberId
();
if
(
Objects
.
nonNull
(
memberId
))
{
userWeixinDTO
.
setMemberId
(
memberId
);
MemberDTO
memberDTO0
=
this
.
memberService
.
findById
(
memberId
);
log
.
info
(
"其他账号有会员,会员信息 ==>> {}"
,
memberDTO0
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
log
.
info
(
"开始同步会员信息"
);
this
.
updateMember
(
memberDTO0
,
memberDTO1
);
}
else
{
log
.
info
(
"其他账号无会员"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
}
else
{
log
.
info
(
"无其他账号存在"
);
MemberDTO
memberDTO1
=
memberAndWeixinUserDTO
.
getMemberDTO
();
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO1
,
member
);
member
.
setId
(
null
);
log
.
info
(
"为当前账号创建会员,会员信息 ==>> {}"
,
member
);
MemberDTO
_memberDTO1
=
this
.
memberService
.
create
(
member
);
userWeixinDTO
.
setMemberId
(
_memberDTO1
.
getId
());
}
log
.
info
(
"开始创建微信账号"
);
this
.
createWeixin
(
userWeixinDTO
);
}
...
...
@@ -480,6 +549,7 @@ public class UserOperationServiceImpl implements UserOperationService {
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO
,
member
);
log
.
info
(
"会员入库结果 ==>> member ==>> {}"
,
member
);
return
this
.
memberService
.
update
(
member
);
}
...
...
@@ -506,6 +576,8 @@ public class UserOperationServiceImpl implements UserOperationService {
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
weixinDTO
,
userWeixin
);
log
.
info
(
"账号入库结果 ==>> userWeixin ==>> {}"
,
userWeixin
);
this
.
userWeixinService
.
update
(
userWeixin
);
}
...
...
@@ -514,27 +586,4 @@ public class UserOperationServiceImpl implements UserOperationService {
BeanUtils
.
copyProperties
(
userTvDTO
,
userTv
);
this
.
userTvService
.
create
(
userTv
);
}
private
void
updateUserTv
(
UserTvDTO
_userTvDTO
,
UserTvDTO
userTvDTO
){
userTvDTO
.
setId
(
_userTvDTO
.
getId
());
Long
memberId
=
_userTvDTO
.
getMemberId
();
if
(
Objects
.
isNull
(
memberId
)){
String
memberCode
=
userTvDTO
.
getMemberCode
();
if
(
StringUtils
.
isNotBlank
(
memberCode
))
{
MemberDTO
memberDTO
=
this
.
memberService
.
findByCode
(
memberCode
);
userTvDTO
.
setMemberId
(
memberDTO
.
getId
());
}
}
else
{
userTvDTO
.
setMemberId
(
memberId
);
}
userTvDTO
.
setPlatformAccount
(
_userTvDTO
.
getPlatformAccount
());
userTvDTO
.
setCreateTime
(
_userTvDTO
.
getCreateTime
());
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
userTvDTO
,
userTv
);
log
.
info
(
"updateUserTv ==>> userTv ==>> {}"
,
userTv
);
this
.
userTvService
.
update
(
userTv
);
}
}
...
...
Please
register
or
sign in
to post a comment