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
a3b8095c
...
a3b8095ce2e05fdb52e1dbfd4c430d83aa789025
authored
2022-01-26 21:12:09 +0800
by
xianghan@topdraw.cn
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.添加checkBind接口
1 parent
b8ba18e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
47 deletions
member-service-impl/src/main/java/com/topdraw/business/process/domian/weixin/BindBean.java
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/domian/weixin/BindBean.java
0 → 100644
View file @
a3b8095
package
com
.
topdraw
.
business
.
process
.
domian
.
weixin
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Data
;
@Data
public
class
BindBean
extends
WeiXinUserBean
{
private
Long
platformUserId
;
}
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
View file @
a3b8095
package
com
.
topdraw
.
business
.
process
.
rest
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.annotation.Log
;
...
...
@@ -10,10 +11,12 @@ import com.topdraw.business.module.user.iptv.domain.UserTv;
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
;
import
com.topdraw.business.process.domian.weixin.WeiXinUserBean
;
import
com.topdraw.business.process.service.UserOperationService
;
import
com.topdraw.common.IResultInfo
;
import
com.topdraw.common.ResultInfo
;
import
com.topdraw.config.RedisKeyUtil
;
import
com.topdraw.exception.BadRequestException
;
...
...
@@ -28,6 +31,7 @@ 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.util.Assert
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -151,8 +155,16 @@ public class UserOperationController {
@PostMapping
(
"/appletBind"
)
@ApiOperation
(
"微信小程序绑定大屏"
)
@AnonymousAccess
public
ResultInfo
appletBind
(
@Validated
@RequestBody
WeiXinUserBean
resources
)
{
UserWeixinDTO
result
=
this
.
userTvOperationService
.
appletBind
(
resources
);
public
ResultInfo
appletBind
(
@Validated
@RequestBody
BindBean
resources
)
{
String
unionId
=
resources
.
getUnionId
();
if
(
StringUtils
.
isBlank
(
unionId
))
Assert
.
state
(
StrUtil
.
isNotBlank
(
unionId
),
"跨屏绑定,请先进行授权"
);
Long
platformUserId
=
resources
.
getPlatformUserId
();
if
(
Objects
.
isNull
(
platformUserId
))
Assert
.
state
(
StrUtil
.
isNotBlank
(
unionId
),
"大屏id不得为空"
);
boolean
result
=
this
.
userTvOperationService
.
appletBind
(
resources
);
return
ResultInfo
.
success
(
result
);
}
...
...
@@ -254,6 +266,14 @@ public class UserOperationController {
return
ResultInfo
.
success
(
result
);
}
@GetMapping
(
value
=
"/checkBind"
)
@ApiOperation
(
"校验是否绑定"
)
public
IResultInfo
checkBind
(
BindBean
bindBean
)
{
Assert
.
notNull
(
bindBean
.
getId
(),
"id can not be null"
);
Map
<
String
,
Object
>
map
=
this
.
userTvOperationService
.
checkBind
(
bindBean
);
return
ResultInfo
.
success
();
}
/**
* @param data
* @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码,
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
a3b8095
...
...
@@ -4,11 +4,13 @@ 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.dto.UserWeixinDTO
;
import
com.topdraw.business.process.domian.weixin.BindBean
;
import
com.topdraw.business.process.domian.weixin.BuyVipBean
;
import
com.topdraw.business.process.domian.weixin.SubscribeBean
;
import
com.topdraw.business.process.domian.weixin.WeiXinUserBean
;
import
java.util.List
;
import
java.util.Map
;
public
interface
UserOperationService
{
...
...
@@ -113,5 +115,12 @@ public interface UserOperationService {
* @param resources
* @return
*/
UserWeixinDTO
appletBind
(
WeiXinUserBean
resources
);
boolean
appletBind
(
BindBean
resources
);
/**
*
* @param bindBean
* @return
*/
Map
<
String
,
Object
>
checkBind
(
BindBean
bindBean
);
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
a3b8095
...
...
@@ -31,10 +31,7 @@ import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
import
com.topdraw.business.module.user.weixin.service.UserWeixinService
;
import
com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO
;
import
com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria
;
import
com.topdraw.business.process.domian.weixin.BuyVipBean
;
import
com.topdraw.business.process.domian.weixin.SubscribeBean
;
import
com.topdraw.business.process.domian.weixin.UserCollectionMq
;
import
com.topdraw.business.process.domian.weixin.WeiXinUserBean
;
import
com.topdraw.business.process.domian.weixin.*
;
import
com.topdraw.business.process.service.UserOperationService
;
import
com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper
;
import
com.topdraw.config.LocalConstants
;
...
...
@@ -625,6 +622,7 @@ public class UserOperationServiceImpl implements UserOperationService {
// 链接微信服务器
String
url
=
WeChatConstants
.
CODE2SESSION
.
replace
(
"APPID"
,
appId_
)
.
replace
(
"SECRET"
,
secret
).
replace
(
"JSCODE"
,
code
);
String
entityBody
=
HttpUtil
.
get
(
url
);
log
.
info
(
"entityBody [{}]"
,
entityBody
);
...
...
@@ -906,7 +904,6 @@ public class UserOperationServiceImpl implements UserOperationService {
*/
private
MemberDTO
bindIptvId
(
MemberDTO
memberDTO
,
Long
userIptvId
,
Integer
bindIptvPlatformType
)
{
//MemberDTO memberDTO = this.memberService.getByCode(resources.getCode());
if
(
memberDTO
!=
null
)
{
memberDTO
.
setUserIptvId
(
userIptvId
);
memberDTO
.
setBindIptvTime
(
TimestampUtil
.
now
());
...
...
@@ -1191,48 +1188,93 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@Override
public
UserWeixinDTO
appletBind
(
WeiXinUserBean
resources
)
{
/*Optional<UserWeixin> userWeixinOptional = userWeixinRepository.findById(criteria.getId());
if (!userWeixinOptional.isPresent()) {
throw new EntityNotFoundException(UserWeixin.class, "id", criteria.getId().toString());
public
boolean
appletBind
(
BindBean
resources
)
{
Long
id
=
resources
.
getId
();
Long
platformUserId
=
resources
.
getPlatformUserId
();
// 微信账户
UserWeixinDTO
userWeixinDTO
=
this
.
userWeixinService
.
findById
(
id
);
if
(
Objects
.
isNull
(
userWeixinDTO
.
getId
()))
{
log
.
error
(
"param ==> id ==> [{}]"
,
id
);
throw
new
EntityNotFoundException
(
UserWeixinDTO
.
class
,
"id"
,
userWeixinDTO
.
getId
().
toString
());
}
UserWeixin userWeixin = userWeixinOptional.get();
Member weixinMember = userWeixin.getMember();
String unionid = criteria.getUnionid();
Long personId = null;
// 前端先校验绑定状态,若已绑定会予以提示,进一步操作,可能会产生换绑
// 小屏账号关联person,且已进行了授权
if (ObjectUtil.isNull(weixinMember) && StrUtil.isNotBlank(unionid)) {
//第一次绑定
// 微信用户unionid为空,或者与传到unionid一致,否则报错
Assert.state(StrUtil.isBlank(userWeixin.getUnionid()) || ObjectUtil.equals(userWeixin.getUnionid(), unionid), "用户信息有误,请重新授权");
userWeixin.setUnionid(unionid);
Member member = getOrGenerateMobileMember(userWeixin, null);
personId = member.getId();
} else if (ObjectUtil.isNotNull(weixinMember)) {
personId = weixinMember.getId();
personCode = weixinMember.getCode();
// 会员
Long
memberId
=
userWeixinDTO
.
getMemberId
();
MemberDTO
memberDTO
=
this
.
findMemberById
(
memberId
);
if
(
Objects
.
isNull
(
memberDTO
.
getId
()))
{
log
.
error
(
"param ==> memberId ==> [{}]"
,
id
);
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"id"
,
memberId
.
toString
());
}
TvUserQueryCriteria tvUserQueryCriteria = new TvUserQueryCriteria();
tvUserQueryCriteria.setPlatformAccount(criteria.getPlatformUserId());
List<TvUserDTO> tvUsers = tvUserService.queryAll(tvUserQueryCriteria);
// 理论上,大屏账号在创建/修改时,会同步到此侧,查不到可能是传值有误,或还未同步过来
Assert.notEmpty(tvUsers, "大屏账号不存在,请检查或稍后重试");
TvUser tvUser = tvUserMapper.toEntity(tvUsers.get(0));
// 更新关联的大屏账号
// personService.updateBindTvUser(personCode, tvUser.getId());
weixinMember.setUserIptvId(tvUser.getId());
weixinMember.setBindIptvTime(new Timestamp(System.currentTimeMillis()));
weixinMember.setBindIptvPlatformType(1);
memberService.update(weixinMember);
userWeixin.setMemberId(personId);
update(userWeixin);*/
return
null
;
// 已绑定大屏
Long
userIptvId
=
memberDTO
.
getUserIptvId
();
if
(
Objects
.
nonNull
(
userIptvId
)
&&
userIptvId
==
platformUserId
)
{
throw
new
BadRequestException
(
"不能重复绑定同一个账户"
);
}
// 大屏账户
UserTvDTO
userTvDTO
=
this
.
findUserIptvById
(
platformUserId
);
if
(
Objects
.
nonNull
(
userTvDTO
.
getId
()))
{
// 主账户
String
priorityMemberCode
=
userTvDTO
.
getPriorityMemberCode
();
if
(
StringUtils
.
isEmpty
(
priorityMemberCode
))
{
String
code
=
memberDTO
.
getCode
();
userTvDTO
.
setPriorityMemberCode
(
code
);
// 更新大屏信息
this
.
doUpdateUserTv
(
userTvDTO
);
}
// 会员绑定大屏
this
.
bindIptvId
(
memberDTO
,
userTvDTO
);
}
return
true
;
}
@Override
public
Map
<
String
,
Object
>
checkBind
(
BindBean
bindBean
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Long
id
=
bindBean
.
getId
();
UserWeixinDTO
userWeixinDTO
=
this
.
userWeixinService
.
findById
(
id
);
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
()))
{
Long
memberId
=
userWeixinDTO
.
getMemberId
();
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
memberId
);
Long
userIptvId
=
memberDTO
.
getUserIptvId
();
if
(
Objects
.
nonNull
(
userIptvId
))
{
map
.
put
(
"isBind"
,
1
);
map
.
put
(
"platformUserId"
,
userIptvId
);
return
map
;
}
else
{
map
.
put
(
"isBind"
,
0
);
}
}
return
map
;
}
/**
* 通过id检索大屏信息
* @param userIptvId
* @return
*/
private
UserTvDTO
findUserIptvById
(
Long
userIptvId
)
{
UserTvDTO
userTvDTO
=
this
.
userTvService
.
findById
(
userIptvId
);
return
userTvDTO
;
}
/**
* 更新大屏
* @param userTvDTO
*/
private
void
doUpdateUserTv
(
UserTvDTO
userTvDTO
)
{
UserTv
userTv
=
new
UserTv
();
BeanUtils
.
copyProperties
(
userTvDTO
,
userTv
);
this
.
userTvService
.
update
(
userTv
);
}
/**
...
...
Please
register
or
sign in
to post a comment