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
fc3fe125
...
fc3fe12569a27e0ca7a653f0bfa3ab828164ab14
authored
2022-03-02 11:40:46 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.扫码关注功能修复,解决老用户先关注后绑定无法免费看的问题
1 parent
4a2d1bd7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
54 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/resources/config/application-dev.yml
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
View file @
fc3fe12
...
...
@@ -2,7 +2,7 @@ package com.topdraw.business.process.rest;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
...
...
@@ -15,7 +15,6 @@ import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import
com.topdraw.business.module.user.weixin.service.UserWeixinService
;
import
com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO
;
import
com.topdraw.business.process.domian.TempIptvUser
;
import
com.topdraw.business.process.domian.UnbindGroup
;
import
com.topdraw.business.process.domian.weixin.BindBean
;
import
com.topdraw.business.process.domian.weixin.SubscribeBean
;
import
com.topdraw.business.process.domian.weixin.SubscribeBeanEvent
;
...
...
@@ -24,6 +23,7 @@ import com.topdraw.business.process.service.UserOperationService;
import
com.topdraw.common.ResultInfo
;
import
com.topdraw.config.RedisKeyUtil
;
import
com.topdraw.exception.BadRequestException
;
import
com.topdraw.exception.EntityNotFoundException
;
import
com.topdraw.util.Base64Util
;
import
com.topdraw.util.JSONUtil
;
import
com.topdraw.utils.RedisUtils
;
...
...
@@ -35,15 +35,12 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.io.IOException
;
import
java.net.URLDecoder
;
import
java.util.Base64
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -65,6 +62,10 @@ public class UserOperationController {
@Autowired
private
RedisUtils
redisUtils
;
private
static
final
String
SUBSCRIBE
=
"subscribe"
;
private
static
final
String
UNSUBSCRIBE
=
"unsubscribe"
;
private
static
final
Integer
SUBSCRIBE_STATUS
=
1
;
@PostMapping
(
value
=
"/createUserAndCreateMember"
)
@ApiOperation
(
"新增大屏账户同时创建会员信息"
)
@AnonymousAccess
...
...
@@ -157,7 +158,6 @@ public class UserOperationController {
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
resources
,
userTv
);
String
unionid
=
resources
.
getUnionid
();
// Long memberId = resources.getMemberId();
String
memberCode1
=
resources
.
getMemberCode
();
if
(
Objects
.
nonNull
(
memberCode1
))
{
...
...
@@ -168,12 +168,9 @@ public class UserOperationController {
this
.
userTvOperationService
.
unbind
(
userTv
);
}
}
else
{
this
.
userTvOperationService
.
unbindByUnionId
(
userTv
,
unionid
);
}
return
ResultInfo
.
success
();
}
...
...
@@ -319,13 +316,13 @@ public class UserOperationController {
String
headimgurl
=
iptvUserInfo
.
get
(
"headimgurl"
).
toString
();
String
nickname
=
iptvUserInfo
.
get
(
"nickname"
).
toString
();
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
nickname
))
{
if
(
StringUtils
.
isNotBlank
(
nickname
))
{
String
nicknameDecode
=
URLDecoder
.
decode
(
nickname
,
"UTF-8"
);
String
nicknameEncode
=
Base64Util
.
encode
(
nicknameDecode
);
subscribeBean
.
setNickname
(
nicknameEncode
);
}
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotBlank
(
headimgurl
))
{
if
(
StringUtils
.
isNotBlank
(
headimgurl
))
{
String
headimgurlDecode
=
URLDecoder
.
decode
(
headimgurl
,
"UTF-8"
);
subscribeBean
.
setHeadimgurl
(
headimgurlDecode
);
}
...
...
@@ -355,6 +352,16 @@ public class UserOperationController {
* 再将服务号信息和大屏参数缓存下来(该接口的功能)
* 然后跳转到订阅号关注页
* 关注后回调处理时,根据unionid进行相关逻辑
*
* 业务场景:
* 1.未关注-绑定
* 新用户
* 2.先关注-绑定
* 1).未绑定
* 2).已绑定
* 2.1).已绑定当前大屏账户
* 2.2).换绑
* 2.2.1).
* @author Hongyan Wang
* @date 2021/8/24 4:54 下午
*/
...
...
@@ -371,9 +378,101 @@ public class UserOperationController {
String
unionid
=
json
.
getString
(
"unionid"
);
Assert
.
state
(
StrUtil
.
isNotBlank
(
unionid
),
"unionid不可为空"
);
String
s
=
this
.
userTvOperationService
.
saveUserInfo
(
data
);
// 大屏侧通过返回值来展示对应的小程序页面
String
result
=
SUBSCRIBE
;
return
ResultInfo
.
success
(
s
);
// 保存大小屏信息到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
)
{
result
=
UNSUBSCRIBE
;
}
if
(
result
.
equalsIgnoreCase
(
SUBSCRIBE
))
{
// 考虑老用户先关注后扫码的情况,即使关注了也要进行绑定检查
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
);
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 !!!!"
);
}
catch
(
IOException
e
)
{
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
);
}
}
/**
* 检查是否绑定当前大屏账户
* @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
;
}
@PostMapping
(
value
=
"/saveUserWeixinPhone"
)
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
fc3fe12
...
...
@@ -78,7 +78,7 @@ public interface UserOperationService {
* @param data
* @return
*/
String
saveUserInfo
(
String
data
);
UserWeixinDTO
saveUserInfo
(
String
data
);
/**
* 获取用户授权并解析、保存用户手机号
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
fc3fe12
...
...
@@ -78,8 +78,6 @@ public class UserOperationServiceImpl implements UserOperationService {
@Autowired
private
RedissonClient
redissonClient
;
@Autowired
private
MemberService
memberService
;
@Autowired
private
UserTvService
userTvService
;
...
...
@@ -179,9 +177,6 @@ public class UserOperationServiceImpl implements UserOperationService {
}
// 关注历史记录
this
.
doInsertSubscribeHistory
(
appId
,
openId
,
WeChatConstants
.
EVENT_SUBSCRIBE
);
// 大屏信息
JSONObject
iptvUserInfo
=
resources
.
getIptvUserInfo
();
if
(
Objects
.
nonNull
(
iptvUserInfo
))
{
...
...
@@ -211,6 +206,9 @@ public class UserOperationServiceImpl implements UserOperationService {
}
// 关注历史记录,用于恢复VIP等级(0:普通 1:团粉 其他:会员(过期后vip恢复到最高等级))
this
.
doInsertSubscribeHistory
(
appId
,
openId
,
WeChatConstants
.
EVENT_SUBSCRIBE
);
return
true
;
}
...
...
@@ -350,13 +348,12 @@ public class UserOperationServiceImpl implements UserOperationService {
* @return
*/
@Override
public
String
saveUserInfo
(
String
data
)
{
public
UserWeixinDTO
saveUserInfo
(
String
data
)
{
log
.
info
(
"result ====>> [{}]"
,
data
);
JSONObject
json
=
JSONObject
.
parseObject
(
data
);
String
unionId
=
json
.
getString
(
"unionid"
);
String
result
=
""
;
// 订阅号appid
String
appId
=
json
.
getString
(
"dyAppid"
);
...
...
@@ -369,41 +366,19 @@ public class UserOperationServiceImpl implements UserOperationService {
log
.
info
(
"H5 save in redis contentJsonStr ====>> [{}]"
,
contentJsonStr
);
// 若未传dyAppId。不走下面的流程
if
(
StrUtil
.
isNotBlank
(
appId
))
result
=
this
.
checkWeiXinUserAndSubscribeStatus
(
appId
,
unionId
);
if
(
StrUtil
.
isNotBlank
(
appId
))
{
UserWeixinDTO
userWeixinDTO
=
this
.
findUserWeiXinByUnionIdAndAppId
(
unionId
,
appId
);
return
userWeixinDTO
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
" saveUserInfo get an error || data: {} || msg: {} "
,
data
,
e
.
getMessage
());
}
log
.
info
(
"result ====>> [{}]"
,
result
);
return
result
;
return
null
;
}
/**
* 检查微信账户和关注状态
* @param appId
* @param unionid
* @return
*/
private
String
checkWeiXinUserAndSubscribeStatus
(
String
appId
,
String
unionid
)
{
UserWeixinDTO
userWeixinDTO
=
this
.
findUserWeiXinByUnionIdAndAppId
(
unionid
,
appId
);
if
(
Objects
.
isNull
(
userWeixinDTO
.
getId
()))
{
return
UNSUBSCRIBE
;
}
Integer
status
=
userWeixinDTO
.
getStatus
();
if
(
status
==
UNSUBSCRIBE_STATUS
)
{
return
UNSUBSCRIBE
;
}
return
SUBSCRIBE
;
}
/**
*
* @param unionid
...
...
member-service-impl/src/main/resources/config/application-dev.yml
View file @
fc3fe12
...
...
@@ -47,21 +47,27 @@ spring:
file-size-threshold
:
2KB
max-file-size
:
100MB
max-request-size
:
200MB
# redis
redis
:
#数据库索引
database
:
0
host
:
122.112.214.149
# host: 139.196.4.234
port
:
6379
password
:
redis123
#连接超时时间
timeout
:
5000
rabbitmq
:
host
:
139.196.145.150
# rabbitmq的连接地址
# host: 139.196.145.150 # rabbitmq的连接地址
# port: 5672 # rabbitmq的连接端口号
# virtual-host: member_center # rabbitmq的虚拟host
# username: admin # rabbitmq的用户名
# password: Topdraw1qaz # rabbitmq的密码
# publisher-confirms: true #如果对异步消息需要回调必须设置为true
host
:
122.112.214.149
# rabbitmq的连接地址
port
:
5672
# rabbitmq的连接端口号
virtual-host
:
member_center
# rabbitmq的虚拟host
username
:
admin
# rabbitmq的用户名
password
:
Topdraw1qaz
# rabbitmq的密码
virtual-host
:
member_center
# rabbitmq的虚拟host
hhh
username
:
guest
# rabbitmq的用户名
password
:
guest
# rabbitmq的密码
publisher-confirms
:
true
#如果对异步消息需要回调必须设置为true
#jwt。依赖的common中有需要jwt的部分属性。
...
...
Please
register
or
sign in
to post a comment