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
35cb731a
...
35cb731ab31d86a26c594d2e1880fa50f6b237a6
authored
2022-01-27 19:08:09 +0800
by
xianghan@topdraw.cn
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.修改部分保存逻辑
1 parent
48a55ab0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
15 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 @
35cb731
...
...
@@ -8,6 +8,7 @@ import com.topdraw.annotation.Log;
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.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
;
...
...
@@ -49,6 +50,10 @@ public class UserOperationController {
@Autowired
private
UserOperationService
userTvOperationService
;
@Autowired
private
UserWeixinService
userWeixinService
;
@Autowired
private
WeiXinRequestUtil
weixinRequestUtil
;
@Autowired
private
RedisUtils
redisUtils
;
@Log
(
"新增大屏账户同时创建会员信息"
)
...
...
@@ -175,6 +180,7 @@ public class UserOperationController {
@ApiOperation
(
"微信公众号关注"
)
@AnonymousAccess
public
ResultInfo
subscribe
(
@Validated
@RequestBody
SubscribeBeanEvent
data
)
throws
IOException
{
String
content
=
data
.
getContent
();
SubscribeBean
subscribeBean
=
JSONUtil
.
parseMsg2Object
(
content
,
SubscribeBean
.
class
);
...
...
@@ -185,6 +191,11 @@ public class UserOperationController {
}
/**
*
* @param subscribeBean
* @throws IOException
*/
private
void
parseSubscribe
(
SubscribeBean
subscribeBean
)
throws
IOException
{
if
(
Objects
.
nonNull
(
subscribeBean
))
{
...
...
@@ -211,15 +222,14 @@ public class UserOperationController {
if
(
ObjectUtil
.
notEqual
(
appType
,
WeChatConstants
.
WX_SUBSCRIPTION
))
throw
new
BadRequestException
(
"非订阅号"
);
// 用户类型
// JSONObject userInfo = weixinRequestUtil.getUserInfo(wxInfoMap, openId);
JSONObject
userInfo
=
new
JSONObject
();
userInfo
.
put
(
"unionid"
,
"oqDha5idQxR0WGPW2qHi-meHRtyg"
);
log
.
info
(
"userInfo is : {}"
,
userInfo
.
toJSONString
());
unionId
=
userInfo
.
get
(
"unionid"
).
toString
();
UserWeixinDTO
userWeixinDTO
=
this
.
userWeixinService
.
findFirstByAppIdAndOpenId
(
appId
,
openId
);
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
()))
{
unionId
=
userWeixinDTO
.
getUnionid
();
}
else
{
JSONObject
userInfo
=
this
.
weixinRequestUtil
.
getUserInfo
(
wxInfoMap
,
openId
);
unionId
=
userInfo
.
getString
(
"unionid"
);
}
if
(
StringUtils
.
isBlank
(
unionId
))
throw
new
BadRequestException
(
"unionid 不存在!"
);
}
// unionId不得为空
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
35cb731
package
com
.
topdraw
.
business
.
process
.
service
;
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
;
...
...
@@ -42,6 +43,9 @@ public interface UserOperationService {
/**
* 微信公众号关注
* 1.团粉,会员vip=0,则修改为vip=1
* 2.判断是否通过扫描大屏的二维码进行关注的,如果是需要绑定大屏账户,将对应会员中iptvUserId绑定大屏对应的id
* 3.修改微信账户的status字段为1(已关注)
* @param resources
* @return
*/
...
...
@@ -123,4 +127,7 @@ public interface UserOperationService {
* @return
*/
Map
<
String
,
Object
>
checkBind
(
BindBean
bindBean
);
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
);
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
35cb731
...
...
@@ -196,7 +196,7 @@ public class UserOperationServiceImpl implements UserOperationService {
throw
new
BadRequestException
(
"大屏信息不存在!"
);
}
// 大屏
账户绑定小屏会员的code
// 大屏
是否绑定主账号
this
.
bondPriorityMember
(
userTvDTO
,
memberDTO_0
,
"auto"
);
// 小屏会员绑定大屏账户id
...
...
@@ -980,6 +980,7 @@ public class UserOperationServiceImpl implements UserOperationService {
// 保存、修改会员加密信息
return
this
.
doSaveOrUpdateMemberProfile
(
weiXinBeanDefinition
,
resources
);
}
@Override
...
...
@@ -1033,6 +1034,7 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
public
boolean
deleteAllCollection
(
String
content
)
{
try
{
log
.
info
(
"receive UserCollection delete all message, content {}"
,
content
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
String
platformAccount
=
jsonObject
.
getString
(
"platformAccount"
);
...
...
@@ -1041,12 +1043,15 @@ public class UserOperationServiceImpl implements UserOperationService {
Long
id
=
userTvDTO
.
getId
();
List
<
UserCollection
>
userCollections
=
this
.
userCollectionService
.
findByUserIdAndType
(
id
,
type
);
if
(
userCollections
==
null
||
userCollections
.
isEmpty
())
{
return
false
;
}
for
(
UserCollection
userCollection
:
userCollections
)
{
this
.
userCollectionDetailService
.
deleteAllByUserCollectionId
(
userCollection
.
getId
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CollectionDeleteConsumer || UserCollection delete all error || {}"
,
e
.
toString
(),
e
);
}
...
...
@@ -1122,46 +1127,63 @@ public class UserOperationServiceImpl implements UserOperationService {
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
content
);
String
platformAccount
=
jsonObject
.
getString
(
"platformAccount"
);
String
data
=
jsonObject
.
getString
(
"data"
);
if
(
StringUtils
.
isBlank
(
data
)
||
!
data
.
startsWith
(
"["
))
{
if
(
StringUtils
.
isBlank
(
data
)
||
!
data
.
startsWith
(
"["
))
return
false
;
}
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
Long
tvUserId
=
userTvDTO
.
getId
();
List
<
UserCollectionMq
>
userCollectionMqList
=
JSONObject
.
parseArray
(
data
,
UserCollectionMq
.
class
);
if
(
userCollectionMqList
==
null
||
userCollectionMqList
.
isEmpty
())
{
if
(
userCollectionMqList
==
null
||
userCollectionMqList
.
isEmpty
())
return
false
;
}
Map
<
Long
,
List
<
UserCollectionMq
>>
collect
=
userCollectionMqList
.
stream
().
collect
(
Collectors
.
groupingBy
(
UserCollectionMq:
:
getUserCollectionId
));
for
(
Map
.
Entry
<
Long
,
List
<
UserCollectionMq
>>
entry
:
collect
.
entrySet
())
{
List
<
UserCollectionMq
>
value
=
entry
.
getValue
();
UserCollectionMq
userCollectionMq
=
value
.
get
(
0
);
if
(
StringUtils
.
isBlank
(
userCollectionMq
.
getName
()))
{
if
(
StringUtils
.
isBlank
(
userCollectionMq
.
getName
()))
userCollectionMq
.
setName
(
"DEFAULT"
);
}
UserCollection
userCollection
=
this
.
userCollectionService
.
findFirstByUserIdAndTypeAndName
(
tvUserId
,
userCollectionMq
.
getType
(),
userCollectionMq
.
getName
()).
orElseGet
(
UserCollection:
:
new
);
userCollection
.
setAppId
(
userCollectionMq
.
getAppId
())
.
setUserId
(
tvUserId
)
.
setName
(
userCollectionMq
.
getName
())
.
setType
(
userCollectionMq
.
getType
())
.
setCount
(
userCollection
.
getCount
()
==
null
?
value
.
size
()
:
userCollection
.
getCount
()
+
value
.
size
());
UserCollection
userCollectionSave
=
this
.
userCollectionService
.
save
(
userCollection
);
for
(
UserCollectionMq
collectionMq
:
value
)
{
UserCollectionDetail
userCollectionDetail
=
collectionMq2DetailMapper
.
toEntity
(
collectionMq
);
Optional
<
UserCollectionDetail
>
userCollectionDetailOptional
=
userCollectionDetailRepository
.
findByDetailIdAndDetailTypeAndUserCollectionId
(
userCollectionDetail
.
getDetailId
(),
userCollectionDetail
.
getDetailType
(),
userCollectionSave
.
getId
());
//观影记录同一天只存一条记录
if
(
userCollectionDetailOptional
.
isPresent
()
&&
DateUtil
.
isSameDay
(
new
Date
(
userCollectionDetailOptional
.
get
().
getCreateTime
().
getTime
()),
new
Date
()))
{
userCollectionDetail
.
setId
(
userCollectionDetailOptional
.
get
().
getId
());
}
else
{
userCollectionDetail
.
setId
(
null
)
.
setUserCollectionId
(
userCollectionSave
.
getId
());
}
userCollectionDetailRepository
.
save
(
userCollectionDetail
);
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"CollectionAddConsumer || UserCollection add error || {}"
,
e
.
toString
(),
e
);
}
...
...
@@ -1170,23 +1192,34 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
public
List
<
MemberDTO
>
findBindByPlatformAccount
(
String
platformAccount
)
{
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findByPlatformAccount
(
platformAccount
);
if
(
Objects
.
nonNull
(
userTvDTO
.
getId
()))
{
Long
id
=
userTvDTO
.
getId
();
String
priorityMemberCode
=
userTvDTO
.
getPriorityMemberCode
();
List
<
MemberDTO
>
memberDTOList
=
this
.
memberService
.
findByUserIptvId
(
id
);
if
(!
CollectionUtils
.
isEmpty
(
memberDTOList
))
{
for
(
MemberDTO
memberDTO
:
memberDTOList
)
{
String
code
=
memberDTO
.
getCode
();
if
(
code
.
equalsIgnoreCase
(
priorityMemberCode
))
{
memberDTO
.
setIptvMajor
(
IPTV_MAJOR
[
1
]);
}
else
{
memberDTO
.
setIptvMajor
(
IPTV_MAJOR
[
0
]);
}
}
}
return
memberDTOList
;
}
return
null
;
}
...
...
@@ -1306,6 +1339,27 @@ public class UserOperationServiceImpl implements UserOperationService {
return
map
;
}
@Override
public
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
)
{
// 链接微信服务器
String
url
=
WeChatConstants
.
CODE2SESSION
.
replace
(
"APPID"
,
appId
)
.
replace
(
"SECRET"
,
secret
).
replace
(
"JSCODE"
,
code
);
String
entityBody
=
HttpUtil
.
get
(
url
);
log
.
info
(
"entityBody [{}]"
,
entityBody
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
entityBody
);
String
errCode
=
jsonObject
.
getString
(
"errcode"
);
if
(
StringUtils
.
isNotEmpty
(
errCode
))
{
String
nameStr
=
jsonObject
.
getString
(
"errmsg"
);
throw
new
BadRequestException
(
nameStr
);
}
return
jsonObject
;
}
/**
* 通过id检索大屏信息
* @param userIptvId
...
...
Please
register
or
sign in
to post a comment