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
5a2e77e8
...
5a2e77e8eed3ec7e5f7b36319ffdfc1c0d3d6a06
authored
2022-01-29 11:38:28 +0800
by
xianghan@topdraw.cn
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.修改部分接口名称
2.修改部分接口保存逻辑
1 parent
635fea4d
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
139 additions
and
80 deletions
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/domain/MemberProfileBuild.java
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/service/MemberProfileService.java
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/service/impl/MemberProfileServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/module/member/rest/MemberController.java
member-service-impl/src/main/java/com/topdraw/business/module/member/service/impl/MemberServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/rest/UserWeixinController.java
member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/service/dto/UserWeixinDTO.java
member-service-impl/src/main/java/com/topdraw/business/process/domian/weixin/WeiXinUserBean.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/module/member/profile/domain/MemberProfileBuild.java
0 → 100644
View file @
5a2e77e
package
com
.
topdraw
.
business
.
module
.
member
.
profile
.
domain
;
import
com.topdraw.utils.StringUtils
;
import
java.sql.Timestamp
;
import
java.util.Objects
;
public
class
MemberProfileBuild
{
public
static
MemberProfile
build
(
Long
memberId
,
String
realname
,
Integer
gender
,
Timestamp
birthday
){
MemberProfile
memberProfile
=
build
(
memberId
,
realname
,
gender
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
birthday
);
return
memberProfile
;
}
public
static
MemberProfile
build
(){
MemberProfile
memberProfile
=
build
(
null
,
""
,
null
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
null
);
return
memberProfile
;
}
public
static
MemberProfile
build
(
Long
memberId
,
String
realName
,
Integer
sex
,
String
contry
,
String
district
,
String
city
,
String
idCard
,
String
province
,
String
email
,
String
description
,
String
phone
,
String
constellation
,
Timestamp
timestamp
)
{
if
(
memberId
==
null
)
throw
new
NullPointerException
(
"memberId is null"
);
MemberProfile
memberProfile
=
new
MemberProfile
();
memberProfile
.
setMemberId
(
memberId
);
memberProfile
.
setRealname
(
stringIsNull
(
realName
));
memberProfile
.
setGender
(
sex
==
null
?
0
:
sex
);
memberProfile
.
setCountry
(
stringIsNull
(
contry
));
memberProfile
.
setDistrict
(
stringIsNull
(
district
));
memberProfile
.
setCity
(
stringIsNull
(
city
));
memberProfile
.
setIdCard
(
stringIsNull
(
idCard
));
memberProfile
.
setProvince
(
stringIsNull
(
province
));
memberProfile
.
setEmail
(
stringIsNull
(
email
));
memberProfile
.
setDescription
(
stringIsNull
(
description
));
memberProfile
.
setPhone
(
stringIsNull
(
phone
));
memberProfile
.
setConstellation
(
stringIsNull
(
constellation
));
memberProfile
.
setBirthday
(
timestamp
);
return
memberProfile
;
}
private
static
String
stringIsNull
(
String
s
){
return
StringUtils
.
isBlank
(
s
)?
""
:
s
;
}
private
static
Object
objectIsNull
(
Object
s
){
return
Objects
.
nonNull
(
s
)?
null
:
s
;
}
}
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/service/MemberProfileService.java
View file @
5a2e77e
...
...
@@ -37,6 +37,8 @@ public interface MemberProfileService {
MemberProfile
create
(
MemberProfile
resources
);
MemberProfile
createDefault
(
MemberProfile
resources
);
void
update
(
MemberProfile
resources
);
void
delete
(
Long
id
);
...
...
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/service/impl/MemberProfileServiceImpl.java
View file @
5a2e77e
...
...
@@ -2,6 +2,7 @@ package com.topdraw.business.module.member.profile.service.impl;
import
com.topdraw.aspect.AsyncMqSend
;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
import
com.topdraw.business.module.member.profile.domain.MemberProfileBuild
;
import
com.topdraw.utils.ValidationUtil
;
import
com.topdraw.business.module.member.profile.repository.MemberProfileRepository
;
import
com.topdraw.business.module.member.profile.service.MemberProfileService
;
...
...
@@ -65,6 +66,16 @@ public class MemberProfileServiceImpl implements MemberProfileService {
}
@Override
public
MemberProfile
createDefault
(
MemberProfile
resources
)
{
Long
memberId
=
resources
.
getMemberId
();
String
realname
=
resources
.
getRealname
();
Integer
gender
=
resources
.
getGender
();
MemberProfile
memberProfile
=
MemberProfileBuild
.
build
();
MemberProfile
memberProfile1
=
this
.
MemberProfileRepository
.
save
(
memberProfile
);
return
memberProfile1
;
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@AsyncMqSend
()
public
void
update
(
MemberProfile
resources
)
{
...
...
member-service-impl/src/main/java/com/topdraw/business/module/member/rest/MemberController.java
View file @
5a2e77e
package
com
.
topdraw
.
business
.
module
.
member
.
rest
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.annotation.Log
;
import
com.topdraw.business.module.member.domain.Member
;
import
com.topdraw.business.module.member.service.MemberService
;
...
...
@@ -25,7 +26,7 @@ import java.util.Objects;
*/
@Api
(
tags
=
"Member管理"
)
@RestController
@RequestMapping
(
"/api/member"
)
@RequestMapping
(
"/
ucEngine/
api/member"
)
@CrossOrigin
public
class
MemberController
{
...
...
@@ -72,6 +73,7 @@ public class MemberController {
@Log
@PutMapping
(
value
=
"/update"
)
@ApiOperation
(
"修改Member"
)
@AnonymousAccess
public
ResultInfo
update
(
@Validated
@RequestBody
Member
resources
)
{
Long
memberId
=
resources
.
getId
();
Assert
.
notNull
(
memberId
,
"memberId can't be null"
);
...
...
@@ -80,10 +82,6 @@ public class MemberController {
String
code
=
memberDTO
.
getCode
();
Assert
.
notNull
(
code
,
"code can't be null"
);
resources
.
setCode
(
code
);
String
nickname
=
resources
.
getNickname
();
if
(!
StringUtils
.
isEmpty
(
nickname
))
{
resources
.
setNickname
(
Base64Util
.
encode
(
nickname
));
}
memberService
.
update
(
resources
);
}
return
ResultInfo
.
success
();
...
...
member-service-impl/src/main/java/com/topdraw/business/module/member/service/impl/MemberServiceImpl.java
View file @
5a2e77e
...
...
@@ -105,11 +105,10 @@ public class MemberServiceImpl implements MemberService {
member
.
setDueCouponAmount
(
defaultValue
);
member
.
setBlackStatus
(
0L
);
String
nickname
=
member
.
getNickname
();
if
(
StringUtils
.
isEmpty
(
nickname
))
{
nickname
=
"未设置"
;
}
if
(
StringUtils
.
isNotEmpty
(
nickname
))
{
String
base64Nickname
=
new
String
(
Base64
.
getEncoder
().
encode
(
nickname
.
getBytes
(
StandardCharsets
.
UTF_8
)));
member
.
setNickname
(
base64Nickname
);
}
return
member
;
}
...
...
member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/rest/UserWeixinController.java
View file @
5a2e77e
...
...
@@ -56,6 +56,16 @@ public class UserWeixinController {
@Log
@PutMapping
(
value
=
"/updateWeixinMemberProfile"
)
@ApiOperation
(
"修改UserWeixin"
)
@AnonymousAccess
public
ResultInfo
updateWeixinMemberProfile
(
@Validated
@RequestBody
UserWeixin
resources
)
{
UserWeixinService
.
update
(
resources
);
return
ResultInfo
.
success
();
}
@Log
@DeleteMapping
(
value
=
"/{id}"
)
@ApiOperation
(
"删除UserWeixin"
)
public
ResultInfo
delete
(
@PathVariable
Long
id
)
{
...
...
member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/service/dto/UserWeixinDTO.java
View file @
5a2e77e
...
...
@@ -94,11 +94,13 @@ public class UserWeixinDTO implements Serializable {
// 授权时间
private
Timestamp
authTime
;
private
Integer
sex
;
private
Integer
gender
;
private
String
country
;
private
String
province
;
private
String
city
;
private
Integer
sex
;
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/domian/weixin/WeiXinUserBean.java
View file @
5a2e77e
...
...
@@ -13,13 +13,13 @@ public class WeiXinUserBean {
private
Long
id
;
private
String
union
I
d
;
private
String
union
i
d
;
/** */
private
String
open
I
d
;
private
String
open
i
d
;
/** */
private
String
app
I
d
;
private
String
app
i
d
;
/** 加密后的appId,参数 */
private
String
wxAppid
;
...
...
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
View file @
5a2e77e
...
...
@@ -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.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
;
...
...
@@ -71,23 +72,24 @@ public class UserOperationController {
@PostMapping
(
value
=
"/createWeixinUserAndCreateMember"
)
@ApiOperation
(
"新增小屏账户同时创建会员信息"
)
@AnonymousAccess
public
ResultInfo
createWeixinUserAndCreateMember
(
@Validated
@RequestBody
WeiXinUserBea
n
resources
)
{
public
ResultInfo
createWeixinUserAndCreateMember
(
@Validated
@RequestBody
UserWeixi
n
resources
)
{
log
.
info
(
"Param ==> resource ==> [{}]"
,
resources
);
String
appId
=
resources
.
getApp
I
d
();
String
appId
=
resources
.
getApp
i
d
();
if
(
StringUtils
.
isBlank
(
appId
))
throw
new
NullPointerException
(
"appId is null !"
);
String
openId
=
resources
.
getOpen
I
d
();
String
openId
=
resources
.
getOpen
i
d
();
if
(
StringUtils
.
isBlank
(
openId
))
throw
new
NullPointerException
(
"openId is null !"
);
String
unionId
=
resources
.
getUnion
I
d
();
String
unionId
=
resources
.
getUnion
i
d
();
if
(
StringUtils
.
isBlank
(
unionId
))
throw
new
NullPointerException
(
"unionId is null !"
);
boolean
result
=
this
.
userTvOperationService
.
createWeixinUserAndCreateMember
(
resources
);
UserWeixinDTO
result
=
this
.
userTvOperationService
.
createWeixinUserAndCreateMember
(
resources
);
return
ResultInfo
.
success
(
result
);
}
...
...
@@ -187,7 +189,7 @@ public class UserOperationController {
@ApiOperation
(
"微信小程序绑定大屏"
)
@AnonymousAccess
public
ResultInfo
appletBind
(
@Validated
@RequestBody
BindBean
resources
)
{
String
unionId
=
resources
.
getUnion
I
d
();
String
unionId
=
resources
.
getUnion
i
d
();
if
(
StringUtils
.
isBlank
(
unionId
))
Assert
.
state
(
StrUtil
.
isNotBlank
(
unionId
),
"跨屏绑定,请先进行授权"
);
...
...
@@ -223,13 +225,13 @@ public class UserOperationController {
private
void
parseSubscribe
(
SubscribeBean
subscribeBean
)
throws
IOException
{
if
(
Objects
.
nonNull
(
subscribeBean
))
{
String
appId
=
subscribeBean
.
getApp
I
d
();
String
appId
=
subscribeBean
.
getApp
i
d
();
// appId不得为空
if
(
StringUtils
.
isBlank
(
appId
))
throw
new
BadRequestException
(
"appId 不存在!"
);
// openId
String
openId
=
subscribeBean
.
getOpen
I
d
();
String
openId
=
subscribeBean
.
getOpen
i
d
();
if
(
StringUtils
.
isBlank
(
openId
))
throw
new
BadRequestException
(
"openId 不存在!"
);
...
...
@@ -260,7 +262,7 @@ public class UserOperationController {
if
(
StringUtils
.
isBlank
(
unionId
))
throw
new
BadRequestException
(
"unionId 不存在!"
);
subscribeBean
.
setUnion
I
d
(
unionId
);
subscribeBean
.
setUnion
i
d
(
unionId
);
// 大屏账户信息
JSONObject
iptvUserInfo
=
null
;
...
...
@@ -302,14 +304,6 @@ 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
(
map
);
}
/**
* @param data
* @description 通过大屏关注的订阅号,因为订阅号不支持带参二维码,
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
5a2e77e
...
...
@@ -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.weixin.domain.UserWeixin
;
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
;
...
...
@@ -121,15 +122,8 @@ public interface UserOperationService {
*/
boolean
appletBind
(
BindBean
resources
);
/**
*
* @param bindBean
* @return
*/
Map
<
String
,
Object
>
checkBind
(
BindBean
bindBean
);
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
);
boolean
createWeixinUserAndCreateMember
(
WeiXinUserBea
n
resources
);
UserWeixinDTO
createWeixinUserAndCreateMember
(
UserWeixi
n
resources
);
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
5a2e77e
...
...
@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.topdraw.business.module.member.domain.Member
;
import
com.topdraw.business.module.member.domain.MemberBuilder
;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
import
com.topdraw.business.module.member.profile.domain.MemberProfileBuild
;
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
;
...
...
@@ -142,9 +143,9 @@ public class UserOperationServiceImpl implements UserOperationService {
*/
@Override
public
boolean
subscribe
(
SubscribeBean
resources
)
{
String
unionId
=
resources
.
getUnion
I
d
();
String
appId
=
resources
.
getApp
I
d
();
String
openId
=
resources
.
getOpen
I
d
();
String
unionId
=
resources
.
getUnion
i
d
();
String
appId
=
resources
.
getApp
i
d
();
String
openId
=
resources
.
getOpen
i
d
();
// 小屏账户
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
...
...
@@ -268,8 +269,8 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
public
boolean
unsubscribe
(
SubscribeBean
resources
)
{
String
appId
=
resources
.
getApp
I
d
();
String
openId
=
resources
.
getOpen
I
d
();
String
appId
=
resources
.
getApp
i
d
();
String
openId
=
resources
.
getOpen
i
d
();
// 修改关注状态 0:未关注
UserWeixinDTO
userWeixinDTO
=
this
.
doUpdateUserWeiXinStatus
(
appId
,
openId
,
UNSUBSCRIBE_STATUS
);
...
...
@@ -1242,9 +1243,9 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
public
Object
serviceLogin
(
WeiXinUserBean
resources
)
{
String
unionId
=
resources
.
getUnion
I
d
();
String
appId
=
resources
.
getApp
I
d
();
String
openId
=
resources
.
getOpen
I
d
();
String
unionId
=
resources
.
getUnion
i
d
();
String
appId
=
resources
.
getApp
i
d
();
String
openId
=
resources
.
getOpen
i
d
();
// 小屏账户
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
...
...
@@ -1331,32 +1332,6 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@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
);
if
(
Objects
.
isNull
(
memberDTO
.
getId
()))
{
log
.
error
(
"param => UserTv id ==> [{}]"
,
id
);
throw
new
EntityNotFoundException
(
MemberDTO
.
class
,
"id"
,
"小程序账户对应的会员不存在"
);
}
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
;
}
@Override
public
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
)
{
// 链接微信服务器
String
url
=
WeChatConstants
.
CODE2SESSION
.
replace
(
"APPID"
,
appId
)
...
...
@@ -1379,15 +1354,16 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
boolean
createWeixinUserAndCreateMember
(
WeiXinUserBea
n
resources
)
{
public
UserWeixinDTO
createWeixinUserAndCreateMember
(
UserWeixi
n
resources
)
{
String
appId
=
resources
.
getApp
I
d
();
String
openId
=
resources
.
getOpen
I
d
();
String
unionId
=
resources
.
getUnion
I
d
();
String
appId
=
resources
.
getApp
i
d
();
String
openId
=
resources
.
getOpen
i
d
();
String
unionId
=
resources
.
getUnion
i
d
();
// 检查账户是否存在
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
if
(
Objects
.
nonNull
(
userWeixinDTO
))
throw
new
BadRequestException
(
"账户已存在"
)
;
if
(
Objects
.
nonNull
(
userWeixinDTO
.
getId
()
))
return
userWeixinDTO
;
// 当前用户的任意微信app
UserWeixinDTO
userWeixinDTO1
=
this
.
findFirstByUnionId
(
unionId
);
...
...
@@ -1399,16 +1375,33 @@ public class UserOperationServiceImpl implements UserOperationService {
memberId
=
userWeixinDTO1
.
getMemberId
();
}
else
{
userWeixinDTO1
=
new
UserWeixinDTO
();
BeanUtils
.
copyProperties
(
resources
,
userWeixinDTO1
);
// 创建会员
memberId
=
this
.
doCreateMember
(
userWeixinDTO1
,
0
);
memberId
=
this
.
doCreateMember
(
userWeixinDTO1
,
vip
);
}
// 保存微信账户
this
.
doCreateUserWeiXin
(
userWeixinDTO1
,
memberId
);
userWeixinDTO1
=
this
.
doCreateUserWeiXin
(
userWeixinDTO1
,
memberId
);
return
true
;
// 创建会员属性信息
this
.
createMemberProfile
(
userWeixinDTO1
);
return
userWeixinDTO1
;
}
/**
*
* @param userWeixinDTO1
*/
private
void
createMemberProfile
(
UserWeixinDTO
userWeixinDTO1
)
{
Long
memberId
=
userWeixinDTO1
.
getMemberId
();
String
nickname
=
userWeixinDTO1
.
getNickname
();
Integer
sex
=
userWeixinDTO1
.
getGender
();
MemberProfile
memberProfile
=
MemberProfileBuild
.
build
(
memberId
,
nickname
,
sex
,
null
);
this
.
memberProfileService
.
create
(
memberProfile
);
}
private
UserWeixinDTO
findFirstByUnionId
(
String
unionId
)
{
...
...
Please
register
or
sign in
to post a comment