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
e33e7a1b
...
e33e7a1b2ceab638524b3e5ae6919ff2c4fe2029
authored
2022-03-02 19:54:10 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.扫码关注功能修复,解决老用户先关注后绑定无法免费看的问题修订
1 parent
fc3fe125
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
127 deletions
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
View file @
e33e7a1
...
...
@@ -61,6 +61,8 @@ public class UserOperationController {
private
MemberService
memberService
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
private
UserOperationService
userOperationService
;
private
static
final
String
SUBSCRIBE
=
"subscribe"
;
private
static
final
String
UNSUBSCRIBE
=
"unsubscribe"
;
...
...
@@ -170,7 +172,6 @@ public class UserOperationController {
}
return
ResultInfo
.
success
();
}
...
...
@@ -246,7 +247,6 @@ public class UserOperationController {
@AnonymousAccess
public
ResultInfo
subscribe
(
@Validated
@RequestBody
SubscribeBeanEvent
data
)
throws
IOException
{
String
content
=
data
.
getContent
();
log
.
info
(
"subscribe ==> input ==> [{}]"
,
content
);
SubscribeBean
subscribeBean
=
JSONUtil
.
parseMsg2Object
(
content
,
SubscribeBean
.
class
);
...
...
@@ -255,7 +255,6 @@ public class UserOperationController {
return
ResultInfo
.
success
(
result
);
}
/**
*
* @param subscribeBean
...
...
@@ -297,9 +296,11 @@ public class UserOperationController {
if
(
StringUtils
.
isNotBlank
(
content
))
{
// 大屏信息
iptvUserInfo
=
JSONObject
.
parseObject
(
content
);
}
else
{
String
eventKey
=
subscribeBean
.
getEventKey
();
log
.
info
(
" eventKey ==> [{}] "
,
eventKey
);
if
(
StringUtils
.
isNotBlank
(
eventKey
))
{
// 用户扫描带参二维码关注。发消息
...
...
@@ -310,8 +311,9 @@ public class UserOperationController {
}
// 用户自己搜索关注就没有大屏信息
的话
,否则表示扫码关注
// 用户自己搜索关注就没有大屏信息,否则表示扫码关注
if
(
Objects
.
nonNull
(
iptvUserInfo
))
{
subscribeBean
.
setIptvUserInfo
(
iptvUserInfo
);
String
headimgurl
=
iptvUserInfo
.
get
(
"headimgurl"
).
toString
();
...
...
@@ -383,96 +385,49 @@ public class UserOperationController {
// 保存大小屏信息到redis同时返回小屏信息
UserWeixinDTO
userWeixinDTO
=
this
.
userTvOperationService
.
saveUserInfo
(
data
);
if
(
Objects
.
isNull
(
userWeixinDTO
)
||
Objects
.
isNull
(
userWeixinDTO
.
getId
()))
{
result
=
UNSUBSCRIBE
;
}
Integer
status
=
userWeixinDTO
.
getStatus
();
log
.
info
(
"saveUserInfo ==>> status ==>> [{}]"
,
status
);
if
(
status
!=
SUBSCRIBE_STATUS
)
{
// 小屏用户不存在或者关注状态为未关注(0),返回未关注
if
(
Objects
.
isNull
(
userWeixinDTO
)
||
Objects
.
isNull
(
userWeixinDTO
.
getId
())
||
userWeixinDTO
.
getStatus
()
!=
SUBSCRIBE_STATUS
)
{
result
=
UNSUBSCRIBE
;
return
ResultInfo
.
success
(
result
);
}
/***************************************************************************************/
// 关注未绑定
if
(
result
.
equalsIgnoreCase
(
SUBSCRIBE
))
{
// 小屏会员
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
userWeixinDTO
.
getMemberId
());
// 考虑老用户先关注后扫码的情况,即使关注了也要进行绑定检查
SubscribeBean
subscribeBean
=
new
SubscribeBean
();
subscribeBean
.
setUnionid
(
userWeixinDTO
.
getUnionid
());
subscribeBean
.
setAppId
(
userWeixinDTO
.
getAppid
());
subscribeBean
.
setAppid
(
userWeixinDTO
.
getAppid
());
subscribeBean
.
setOpenId
(
userWeixinDTO
.
getOpenid
());
subscribeBean
.
setNickname
(
userWeixinDTO
.
getNickname
());
subscribeBean
.
setHeadimgurl
(
userWeixinDTO
.
getHeadimgurl
());
try
{
// 解析
this
.
parseSubscribe
(
subscribeBean
);
log
.
info
(
"saveUserInfo ==>> subscribeBean ==>> [{}]"
,
subscribeBean
);
// redis中的大小屏信息
String
content
=
(
String
)
this
.
redisUtils
.
get
(
RedisKeyUtil
.
genSeSuSubscribeKey
(
unionid
));
JSONObject
iptvUserInfo
=
JSONObject
.
parseObject
(
content
);
JSONObject
iptvUserInfo
=
subscribeBean
.
getIptvUserInfo
();
String
platformAccount
=
iptvUserInfo
.
getString
(
"platformAccount"
);
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
userWeixinDTO
.
getMemberId
());
TempIptvUser
tempIptvUser
=
new
TempIptvUser
();
tempIptvUser
.
setPlatformAccount
(
platformAccount
);
tempIptvUser
.
setMemberCode
(
memberDTO
.
getCode
());
this
.
unbindPriorityCode
(
memberDTO
);
log
.
info
(
"subscribe again start subscribeBean ==>> [{}]"
,
subscribeBean
);
this
.
userTvOperationService
.
subscribe
(
subscribeBean
);
log
.
info
(
"subscribe again end !!!!"
);
// 大屏账户
String
platformAccount
=
iptvUserInfo
.
getString
(
"platformAccount"
);
try
{
String
headimgurl
=
iptvUserInfo
.
get
(
"headimgurl"
).
toString
();
String
nickname
=
iptvUserInfo
.
get
(
"nickname"
).
toString
();
if
(
StringUtils
.
isNotBlank
(
nickname
))
{
String
nicknameDecode
=
URLDecoder
.
decode
(
nickname
,
"UTF-8"
);
String
nicknameEncode
=
Base64Util
.
encode
(
nicknameDecode
);
memberDTO
.
setNickname
(
nicknameEncode
);
}
}
catch
(
IOException
e
)
{
if
(
StringUtils
.
isNotBlank
(
headimgurl
))
{
String
headimgurlDecode
=
URLDecoder
.
decode
(
headimgurl
,
"UTF-8"
);
memberDTO
.
setAvatarUrl
(
headimgurlDecode
);
}
}
catch
(
Exception
e
)
{
log
.
info
(
"headimgurl , nickname ===>> encode error!"
);
e
.
printStackTrace
();
}
}
return
ResultInfo
.
success
(
result
);
}
/**
*
* @param memberDTO_0
*/
private
void
unbindPriorityCode
(
MemberDTO
memberDTO_0
)
{
String
code1
=
memberDTO_0
.
getCode
();
UserTvDTO
userTvDTO1
=
this
.
userTvService
.
findByPriorityMemberCode
(
code1
);
if
(
Objects
.
nonNull
(
userTvDTO1
)
&&
Objects
.
nonNull
(
userTvDTO1
.
getId
()))
{
userTvDTO1
.
setPriorityMemberCode
(
null
);
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
userTvDTO1
,
userTv
);
this
.
userTvService
.
update
(
userTv
);
// 大小屏绑定
this
.
userOperationService
.
bind
(
memberDTO
,
platformAccount
);
}
/****************************************************************************************/
}
/**
* 检查是否绑定当前大屏账户
* @param subscribeBean
* @param userWeixinDTO
* @return
*/
private
boolean
checkBind
(
SubscribeBean
subscribeBean
,
UserWeixinDTO
userWeixinDTO
)
{
boolean
result
=
false
;
JSONObject
iptvUserInfo
=
subscribeBean
.
getIptvUserInfo
();
if
(
Objects
.
nonNull
(
iptvUserInfo
))
{
String
platformAccount
=
iptvUserInfo
.
getString
(
"platformAccount"
);
Long
memberId
=
userWeixinDTO
.
getMemberId
();
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
memberId
);
if
(
Objects
.
nonNull
(
memberDTO
.
getUserIptvId
())
&&
StringUtils
.
isNotBlank
(
platformAccount
))
{
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findById
(
memberDTO
.
getUserIptvId
());
String
platformAccount1
=
userTvDTO
.
getPlatformAccount
();
if
(
platformAccount
.
equalsIgnoreCase
(
platformAccount1
))
{
result
=
true
;
}
}
}
return
result
;
return
ResultInfo
.
success
(
result
);
}
@PostMapping
(
value
=
"/saveUserWeixinPhone"
)
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
e33e7a1
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
import
com.topdraw.business.module.member.service.dto.MemberDTO
;
import
com.topdraw.business.module.user.iptv.domain.UserTv
;
import
com.topdraw.business.module.user.iptv.service.dto.UserTvDTO
;
import
com.topdraw.business.module.user.weixin.domain.UserWeixin
;
import
com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO
;
import
com.topdraw.business.process.domian.weixin.BindBean
;
...
...
@@ -140,4 +141,11 @@ public interface UserOperationService {
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
);
UserWeixinDTO
createWeixinUserAndCreateMember
(
UserWeixin
resources
);
void
bind
(
String
memberCode
,
String
platformAccount
);
void
bind
(
MemberDTO
memberDTO
,
UserTvDTO
userTvDTO
);
void
bind
(
MemberDTO
memberDTO
,
String
platformAccount
);
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
e33e7a1
...
...
@@ -182,27 +182,12 @@ public class UserOperationServiceImpl implements UserOperationService {
if
(
Objects
.
nonNull
(
iptvUserInfo
))
{
// 小屏会员
MemberDTO
memberDTO
_0
=
this
.
findMemberByAppIdAndOpenId
(
appId
,
openId
);
MemberDTO
memberDTO
=
this
.
findMemberByAppIdAndOpenId
(
appId
,
openId
);
// 账户
String
platformAccount
=
iptvUserInfo
.
getString
(
"platformAccount"
);
// 大屏账户
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
isNull
(
userTvDTO
))
{
throw
new
BadRequestException
(
"大屏信息不存在!"
);
}
memberDTO_0
.
setPlatformAccount
(
platformAccount
);
// 大屏是否绑定主账号
this
.
bondPriorityMember
(
userTvDTO
,
memberDTO_0
,
"auto"
);
// 小屏会员绑定大屏账户id
MemberDTO
memberDTO_1
=
this
.
bindIptvId
(
memberDTO_0
,
userTvDTO
);
// 修改会员
this
.
doUpdateMemberByMemberDTO
(
memberDTO_1
);
this
.
bind
(
memberDTO
,
platformAccount
);
}
...
...
@@ -393,17 +378,18 @@ public class UserOperationServiceImpl implements UserOperationService {
* 修改会员vip状态
*/
private
void
doUpdateMemberVip
(
MemberDTO
memberDTO
,
Integer
vip1
)
{
if
(
memberDTO
!=
null
)
{
Integer
vip
=
memberDTO
.
getVip
();
vip
=
(
vip
==
null
?
0
:
vip
);
// 未购买付费会员
if
(
vip
<=
1
)
{
Integer
vip
=
memberDTO
.
getVip
();
vip
=
(
vip
==
null
?
0
:
vip
);
// 未购买付费会员
if
(
vip
<=
1
)
{
memberDTO
.
setVip
(
vip1
);
memberDTO
.
setVip
(
vip1
);
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO
,
member
);
this
.
memberService
.
update
(
member
);
Member
member
=
new
Member
();
BeanUtils
.
copyProperties
(
memberDTO
,
member
);
this
.
memberService
.
update
(
member
);
}
}
}
...
...
@@ -535,6 +521,12 @@ public class UserOperationServiceImpl implements UserOperationService {
return
memberId
;
}
/**
*
* @param userWeixin
* @param vip
* @return
*/
private
Member
doCreateMemberAndReturnMember
(
UserWeixin
userWeixin
,
Integer
vip
)
{
Member
memberReturn
=
null
;
...
...
@@ -874,7 +866,11 @@ public class UserOperationServiceImpl implements UserOperationService {
this
.
changeMainAccount
(
userTv
);
}
/**
*
* @param memberCode
* @return
*/
private
UserTvDTO
findByPriorityMemberCode
(
String
memberCode
)
{
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findByPriorityMemberCode
(
memberCode
);
return
userTvDTO
;
...
...
@@ -1067,9 +1063,10 @@ public class UserOperationServiceImpl implements UserOperationService {
/**
* 绑定会员中的userIptvId字段
* @param resources
* @param memberDTO
* @param userTvDTO
*/
private
MemberDTO
bindIptvId
(
MemberDTO
resources
,
UserTvDTO
userTvDTO
)
{
private
MemberDTO
bindIptvId
(
MemberDTO
memberDTO
,
UserTvDTO
userTvDTO
)
{
String
platform
=
userTvDTO
.
getPlatform
();
// 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通
Integer
bindIptvPlatformType
=
0
;
...
...
@@ -1089,23 +1086,9 @@ public class UserOperationServiceImpl implements UserOperationService {
bindIptvPlatformType
=
PLATFORM_LIST
[
1
];
}
return
this
.
bindIptvId
(
resources
,
userTvDTO
.
getId
(),
bindIptvPlatformType
);
}
/**
* 绑定会员中的userIptvId字段
* @param userIptvId
* @param bindIptvPlatformType
*/
private
MemberDTO
bindIptvId
(
MemberDTO
memberDTO
,
Long
userIptvId
,
Integer
bindIptvPlatformType
)
{
if
(
memberDTO
!=
null
)
{
memberDTO
.
setUserIptvId
(
userIptvId
);
memberDTO
.
setBindIptvTime
(
LocalDateTime
.
now
());
memberDTO
.
setBindIptvPlatformType
(
bindIptvPlatformType
);
this
.
doUpdateMemberByMemberDTO
(
memberDTO
);
}
memberDTO
.
setUserIptvId
(
userTvDTO
.
getId
());
memberDTO
.
setBindIptvTime
(
LocalDateTime
.
now
());
memberDTO
.
setBindIptvPlatformType
(
bindIptvPlatformType
);
return
memberDTO
;
}
...
...
@@ -1495,6 +1478,7 @@ public class UserOperationServiceImpl implements UserOperationService {
// 会员绑定大屏
this
.
bindIptvId
(
memberDTO
,
userTvDTO
);
this
.
doUpdateMemberByMemberDTO
(
memberDTO
);
return
true
;
}
...
...
@@ -1580,6 +1564,42 @@ public class UserOperationServiceImpl implements UserOperationService {
return
userWeixinDTO1
;
}
@Override
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
void
bind
(
String
memberCode
,
String
platformAccount
)
{
MemberDTO
memberDTO
=
this
.
memberService
.
getByCode
(
memberCode
);
this
.
bind
(
memberDTO
,
platformAccount
);
}
@Override
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
void
bind
(
MemberDTO
memberDTO
,
UserTvDTO
userTvDTO
)
{
String
platformAccount
=
userTvDTO
.
getPlatformAccount
();
// 绑定
this
.
bind
(
memberDTO
,
platformAccount
);
}
@Override
public
void
bind
(
MemberDTO
memberDTO
,
String
platformAccount
)
{
// 大屏账户
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
isNull
(
userTvDTO
))
{
throw
new
BadRequestException
(
"大屏信息不存在!"
);
}
// mq同步数据时使用
memberDTO
.
setPlatformAccount
(
platformAccount
);
// 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表
this
.
bondPriorityMember
(
userTvDTO
,
memberDTO
,
"auto"
);
// 构建小屏会员对象,绑定user_iptv_id字段
MemberDTO
memberDTO0
=
this
.
bindIptvId
(
memberDTO
,
userTvDTO
);
// 修改会员
this
.
doUpdateMemberByMemberDTO
(
memberDTO0
);
}
/**
*
* @param userWeixinDTO1
...
...
Please
register
or
sign in
to post a comment