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
635fea4d
...
635fea4d37574052509965115e4a32bfdf78c379
authored
2022-01-28 13:58:49 +0800
by
xianghan@topdraw.cn
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.新增保存小屏账户并创建会员信息的接口
1 parent
35cb731a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
31 deletions
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/rest/MemberProfileController.java
member-service-impl/src/main/java/com/topdraw/business/module/user/iptv/rest/UserTvController.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/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/MemberOperationServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
member-service-impl/src/main/java/com/topdraw/weixin/applet/WeiXinAppletUserParser.java
member-service-impl/src/main/java/com/topdraw/weixin/beans/DefaultWeiXinBeanDefinition.java
member-service-impl/src/test/java/com/topdraw/BaseTest.java
member-service-impl/src/main/java/com/topdraw/business/module/member/profile/rest/MemberProfileController.java
View file @
635fea4
package
com
.
topdraw
.
business
.
module
.
member
.
profile
.
rest
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO
;
import
com.topdraw.business.module.member.service.MemberService
;
import
com.topdraw.business.module.member.service.dto.MemberDTO
;
...
...
@@ -22,7 +23,7 @@ import java.util.Objects;
*/
@Api
(
tags
=
"MemberProfile管理"
)
@RestController
@RequestMapping
(
"/
api/M
emberProfile"
)
@RequestMapping
(
"/
ucEngine/api/m
emberProfile"
)
@CrossOrigin
public
class
MemberProfileController
{
...
...
@@ -46,6 +47,7 @@ public class MemberProfileController {
@Log
@PostMapping
(
value
=
"/create"
)
@ApiOperation
(
"新增MemberProfile"
)
@AnonymousAccess
public
ResultInfo
create
(
@Validated
@RequestBody
MemberProfile
resources
)
{
MemberProfileService
.
create
(
resources
);
return
ResultInfo
.
success
();
...
...
@@ -54,6 +56,7 @@ public class MemberProfileController {
@Log
@PutMapping
(
value
=
"/update"
)
@ApiOperation
(
"修改MemberProfile"
)
@AnonymousAccess
public
ResultInfo
update
(
@Validated
@RequestBody
MemberProfile
resources
)
{
Long
memberId
=
resources
.
getMemberId
();
Assert
.
notNull
(
memberId
,
"memberId can't be null"
);
...
...
member-service-impl/src/main/java/com/topdraw/business/module/user/iptv/rest/UserTvController.java
View file @
635fea4
package
com
.
topdraw
.
business
.
module
.
user
.
iptv
.
rest
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.common.ResultInfo
;
import
com.topdraw.annotation.Log
;
import
com.topdraw.business.module.user.iptv.domain.UserTv
;
...
...
@@ -17,7 +18,7 @@ import io.swagger.annotations.*;
*/
@Api
(
tags
=
"UserTv管理"
)
@RestController
@RequestMapping
(
"/
api/U
serTv"
)
@RequestMapping
(
"/
ucEngine/api/u
serTv"
)
public
class
UserTvController
{
@Autowired
...
...
@@ -36,8 +37,9 @@ public class UserTvController {
}
@Log
@PostMapping
@PostMapping
(
value
=
"/create"
)
@ApiOperation
(
"新增UserTv"
)
@AnonymousAccess
public
ResultInfo
create
(
@Validated
@RequestBody
UserTv
resources
)
{
UserTvService
.
create
(
resources
);
return
ResultInfo
.
success
();
...
...
@@ -46,6 +48,7 @@ public class UserTvController {
@Log
@PutMapping
@ApiOperation
(
"修改UserTv"
)
@AnonymousAccess
public
ResultInfo
update
(
@Validated
@RequestBody
UserTv
resources
)
{
UserTvService
.
update
(
resources
);
return
ResultInfo
.
success
();
...
...
member-service-impl/src/main/java/com/topdraw/business/module/user/weixin/rest/UserWeixinController.java
View file @
635fea4
package
com
.
topdraw
.
business
.
module
.
user
.
weixin
.
rest
;
import
com.topdraw.annotation.AnonymousAccess
;
import
com.topdraw.common.ResultInfo
;
import
com.topdraw.annotation.Log
;
import
com.topdraw.business.module.user.weixin.domain.UserWeixin
;
...
...
@@ -17,7 +18,7 @@ import io.swagger.annotations.*;
*/
@Api
(
tags
=
"UserWeixin管理"
)
@RestController
@RequestMapping
(
"/
api/U
serWeixin"
)
@RequestMapping
(
"/
ucEngine/api/u
serWeixin"
)
public
class
UserWeixinController
{
@Autowired
...
...
@@ -36,16 +37,18 @@ public class UserWeixinController {
}
@Log
@PostMapping
@PostMapping
(
value
=
"/create"
)
@ApiOperation
(
"新增UserWeixin"
)
@AnonymousAccess
public
ResultInfo
create
(
@Validated
@RequestBody
UserWeixin
resources
)
{
UserWeixinService
.
create
(
resources
);
return
ResultInfo
.
success
();
}
@Log
@PutMapping
@PutMapping
(
value
=
"/update"
)
@ApiOperation
(
"修改UserWeixin"
)
@AnonymousAccess
public
ResultInfo
update
(
@Validated
@RequestBody
UserWeixin
resources
)
{
UserWeixinService
.
update
(
resources
);
return
ResultInfo
.
success
();
...
...
member-service-impl/src/main/java/com/topdraw/business/process/rest/UserOperationController.java
View file @
635fea4
...
...
@@ -67,6 +67,30 @@ public class UserOperationController {
return
ResultInfo
.
success
(
result
);
}
@Log
(
"新增小屏账户同时创建会员信息"
)
@PostMapping
(
value
=
"/createWeixinUserAndCreateMember"
)
@ApiOperation
(
"新增小屏账户同时创建会员信息"
)
@AnonymousAccess
public
ResultInfo
createWeixinUserAndCreateMember
(
@Validated
@RequestBody
WeiXinUserBean
resources
)
{
log
.
info
(
"Param ==> resource ==> [{}]"
,
resources
);
String
appId
=
resources
.
getAppId
();
if
(
StringUtils
.
isBlank
(
appId
))
throw
new
NullPointerException
(
"appId is null !"
);
String
openId
=
resources
.
getOpenId
();
if
(
StringUtils
.
isBlank
(
openId
))
throw
new
NullPointerException
(
"openId is null !"
);
String
unionId
=
resources
.
getUnionId
();
if
(
StringUtils
.
isBlank
(
unionId
))
throw
new
NullPointerException
(
"unionId is null !"
);
boolean
result
=
this
.
userTvOperationService
.
createWeixinUserAndCreateMember
(
resources
);
return
ResultInfo
.
success
(
result
);
}
@Log
(
"获取大屏绑定的小屏会员列表"
)
@GetMapping
(
value
=
"/findBindByPlatformAccount/{platformAccount}"
)
@AnonymousAccess
...
...
@@ -319,6 +343,7 @@ public class UserOperationController {
@Log
(
"保存用户手机号信息"
)
@PostMapping
(
value
=
"/saveUserWeixinPhone"
)
@ApiOperation
(
"保存用户手机号信息"
)
@AnonymousAccess
public
ResultInfo
saveUserWeixinPhone
(
@RequestBody
WeiXinUserBean
resources
)
{
log
.
info
(
"resources :[{}]"
,
resources
);
MemberProfile
s
=
this
.
userTvOperationService
.
saveUserWeixinPhone
(
resources
);
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/UserOperationService.java
View file @
635fea4
...
...
@@ -130,4 +130,6 @@ public interface UserOperationService {
JSONObject
getUnionIdByAppIdAndOpenId
(
String
appId
,
String
secret
,
String
code
);
boolean
createWeixinUserAndCreateMember
(
WeiXinUserBean
resources
);
}
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/MemberOperationServiceImpl.java
View file @
635fea4
...
...
@@ -165,19 +165,22 @@ public class MemberOperationServiceImpl implements MemberOperationService {
* @return
*/
private
MemberProfileDTO
configMemberProfile
(
MemberProfileDTO
memberProfileDTO_0
,
MemberDTO
memberDTO
,
String
appid
)
{
if
(
Objects
.
isNull
(
memberProfileDTO_0
))
return
memberProfileDTO_0
;
MemberProfileDTO
memberProfileDTO
=
new
MemberProfileDTO
();
BeanUtils
.
copyProperties
(
memberProfileDTO_0
,
memberProfileDTO
);
// 真实姓名
String
realname
=
memberProfileDTO
.
getRealname
();
if
(
StringUtils
.
isNotBlank
(
realname
))
{
realname
=
new
String
(
Base64
.
get
Decoder
().
de
code
(
realname
.
getBytes
(
StandardCharsets
.
UTF_8
)));
realname
=
new
String
(
Base64
.
get
Encoder
().
en
code
(
realname
.
getBytes
(
StandardCharsets
.
UTF_8
)));
}
// 昵称
String
nickname
=
memberDTO
.
getNickname
();
if
(
StringUtils
.
isNotBlank
(
nickname
))
{
nickname
=
new
String
(
Base64
.
get
Decoder
().
de
code
(
nickname
.
getBytes
(
StandardCharsets
.
UTF_8
)));
nickname
=
new
String
(
Base64
.
get
Encoder
().
en
code
(
nickname
.
getBytes
(
StandardCharsets
.
UTF_8
)));
}
// vip
...
...
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
View file @
635fea4
...
...
@@ -5,18 +5,15 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpUtil
;
import
com.alibaba.druid.util.HttpClientUtils
;
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.domain.MemberConstant
;
import
com.topdraw.business.module.member.profile.domain.MemberProfile
;
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
;
import
com.topdraw.business.module.member.service.dto.MemberDTO
;
import
com.topdraw.business.module.member.service.dto.MemberQueryCriteria
;
import
com.topdraw.business.module.member.viphistory.domain.MemberVipHistory
;
import
com.topdraw.business.module.user.iptv.domain.UserConstant
;
import
com.topdraw.business.module.user.iptv.domain.UserTv
;
import
com.topdraw.business.module.user.iptv.service.UserTvService
;
...
...
@@ -36,11 +33,8 @@ import com.topdraw.business.process.service.UserOperationService;
import
com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper
;
import
com.topdraw.config.LocalConstants
;
import
com.topdraw.config.RedisKeyUtil
;
import
com.topdraw.config.ServiceEnvConfig
;
import
com.topdraw.exception.BadRequestException
;
import
com.topdraw.exception.EntityNotFoundException
;
import
com.topdraw.module.mq.DataSyncMsg
;
import
com.topdraw.module.mq.EntityType
;
import
com.topdraw.security.AESUtil
;
import
com.topdraw.util.IdWorker
;
import
com.topdraw.util.TimestampUtil
;
...
...
@@ -53,26 +47,18 @@ import com.topdraw.weixin.util.WeChatConstants;
import
com.topdraw.weixin.util.WeiXinRequestUtil
;
import
com.topdraw.weixin.util.WeixinUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.var
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
...
...
@@ -485,6 +471,19 @@ public class UserOperationServiceImpl implements UserOperationService {
}
/**
*
* @param userWeixinDTO
* @param vip
* @return
*/
private
Long
doCreateMember
(
UserWeixinDTO
userWeixinDTO
,
Integer
vip
)
{
UserWeixin
userWeixin
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
userWeixinDTO
,
userWeixin
);
Long
memberId
=
this
.
doCreateMember
(
userWeixin
,
vip
);
return
memberId
;
}
/**
* 创建会员
* @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建
* @param userWeixin
...
...
@@ -527,6 +526,16 @@ public class UserOperationServiceImpl implements UserOperationService {
return
memberId
;
}
private
UserWeixinDTO
doCreateUserWeiXin
(
UserWeixinDTO
userWeixin
,
Long
memberId
)
{
if
(
Objects
.
isNull
(
memberId
))
throw
new
NullPointerException
(
"memberId is null !"
);
UserWeixin
userWeixin1
=
new
UserWeixin
();
BeanUtils
.
copyProperties
(
userWeixin
,
userWeixin1
);
UserWeixinDTO
userWeixinDTO
=
this
.
doCreateUserWeiXin
(
userWeixin1
,
memberId
);
return
userWeixinDTO
;
}
/**
* 保存微信账户信息
* @param userWeixin
...
...
@@ -658,21 +667,29 @@ public class UserOperationServiceImpl implements UserOperationService {
}
if
(
StringUtils
.
isNotBlank
(
userInfo
))
{
String
phoneNumber
=
""
;
if
(
StringUtils
.
isNotBlank
(
encryptedData
))
{
JSONObject
userInfoJo
=
JSONObject
.
parseObject
(
userInfo
);
if
(
Objects
.
nonNull
(
userInfoJo
))
{
encryptedData
=
userInfoJo
.
getString
(
"encryptedData"
);
iv
=
userInfoJo
.
getString
(
"iv"
);
String
sessionkey
=
jsonObject
.
getString
(
"session_key"
);
String
userInfoWeixin
=
AESUtil
.
decryptJsUserInfo
(
encryptedData
,
iv
,
sessionkey
);
log
.
info
(
"userInfo:"
+
userInfo
);
userInfoWxJo
=
JSONObject
.
parseObject
(
userInfoWeixin
);
JSONObject
userInfoPhone
=
AESUtil
.
decryptJsUserPhone
(
encryptedData
,
iv
,
sessionkey
);
if
(
ObjectUtil
.
isNull
(
userInfoPhone
))
{
throw
new
BadRequestException
(
"decrypt phone error..."
);
}
phoneNumber
=
userInfoPhone
.
getString
(
"phoneNumber"
);
if
(
StringUtils
.
isBlank
(
phoneNumber
))
{
throw
new
BadRequestException
(
"phoneNumber is null..."
);
}
}
}
DefaultWeiXinBeanDefinition
weiXinBeanDefinition
=
new
DefaultWeiXinBeanDefinition
(
appId
,
code
,
unionId
,
openId
,
userInfoWxJo
);
new
DefaultWeiXinBeanDefinition
(
appId
,
code
,
unionId
,
openId
,
userInfoWxJo
,
phoneNumber
);
return
weiXinBeanDefinition
;
}
...
...
@@ -1360,6 +1377,44 @@ public class UserOperationServiceImpl implements UserOperationService {
return
jsonObject
;
}
@Override
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
boolean
createWeixinUserAndCreateMember
(
WeiXinUserBean
resources
)
{
String
appId
=
resources
.
getAppId
();
String
openId
=
resources
.
getOpenId
();
String
unionId
=
resources
.
getUnionId
();
UserWeixinDTO
userWeixinDTO
=
this
.
findFirstByUnionIdAndAppIdAndOpenId
(
unionId
,
appId
,
openId
);
if
(
Objects
.
nonNull
(
userWeixinDTO
))
throw
new
BadRequestException
(
"账户已存在"
);
// 当前用户的任意微信app
UserWeixinDTO
userWeixinDTO1
=
this
.
findFirstByUnionId
(
unionId
);
Long
memberId
=
null
;
Integer
vip
=
0
;
if
(
Objects
.
nonNull
(
userWeixinDTO1
.
getId
())
&&
Objects
.
nonNull
(
userWeixinDTO1
.
getMemberId
()))
{
memberId
=
userWeixinDTO1
.
getMemberId
();
}
else
{
userWeixinDTO1
=
new
UserWeixinDTO
();
BeanUtils
.
copyProperties
(
resources
,
userWeixinDTO1
);
// 创建会员
memberId
=
this
.
doCreateMember
(
userWeixinDTO1
,
0
);
}
// 保存微信账户
this
.
doCreateUserWeiXin
(
userWeixinDTO1
,
memberId
);
return
true
;
}
private
UserWeixinDTO
findFirstByUnionId
(
String
unionId
)
{
return
this
.
userWeixinService
.
findFirstByUnionId
(
unionId
);
}
/**
* 通过id检索大屏信息
* @param userIptvId
...
...
member-service-impl/src/main/java/com/topdraw/weixin/applet/WeiXinAppletUserParser.java
View file @
635fea4
...
...
@@ -132,7 +132,7 @@ public class WeiXinAppletUserParser implements WeiXinUserParser {
}
DefaultWeiXinBeanDefinition
weiXinBeanDefinition
=
new
DefaultWeiXinBeanDefinition
(
appId
,
code
,
unionId
,
openId
,
userInfoWxJo
);
new
DefaultWeiXinBeanDefinition
(
appId
,
code
,
unionId
,
openId
,
userInfoWxJo
,
null
);
return
weiXinBeanDefinition
;
}
...
...
member-service-impl/src/main/java/com/topdraw/weixin/beans/DefaultWeiXinBeanDefinition.java
View file @
635fea4
...
...
@@ -46,7 +46,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
public
DefaultWeiXinBeanDefinition
()
{
}
public
DefaultWeiXinBeanDefinition
(
String
appId
,
String
code
,
String
unionId
,
String
openId
,
JSONObject
userInfoWxJo
)
{
public
DefaultWeiXinBeanDefinition
(
String
appId
,
String
code
,
String
unionId
,
String
openId
,
JSONObject
userInfoWxJo
,
String
phone
)
{
this
.
userInfo
=
userInfoWxJo
;
if
(
userInfo
!=
null
)
{
...
...
@@ -91,6 +91,7 @@ public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
}
this
.
unionId
=
unionId
;
this
.
phoneNumber
=
phone
;
this
.
openId
=
openId
;
this
.
appid
=
appId
;
this
.
code
=
code
;
...
...
member-service-impl/src/test/java/com/topdraw/BaseTest.java
View file @
635fea4
...
...
@@ -9,15 +9,18 @@ import org.slf4j.LoggerFactory;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.sql.Timestamp
;
@SpringBootTest
(
classes
=
MemberServiceApplication
.
class
)
@RunWith
(
SpringRunner
.
class
)
public
class
BaseTest
{
public
Logger
LOG
=
LoggerFactory
.
getLogger
(
BaseTest
.
class
);
private
static
String
replaceUrl
(
String
body
,
String
ftpPath
)
{
boolean
contains
=
body
.
contains
(
"<source src="
);
if
(
contains
)
{
body
=
body
.
replaceAll
(
"(<source src=(.*?)/>)"
,
"<source src="
+
"\""
+
ftpPath
+
"\"/>"
);
body
=
body
.
replaceAll
(
"(<source src=(.*?)/>)"
,
"<source src="
+
"\""
+
ftpPath
+
"\"/>"
);
}
return
body
;
}
...
...
@@ -27,4 +30,6 @@ public class BaseTest {
DataSyncMsg
.
TaskTemplateParam
taskTemplateParam
=
JSONObject
.
parseObject
(
param
,
DataSyncMsg
.
TaskTemplateParam
.
class
);
System
.
out
.
println
(
taskTemplateParam
);
}
}
...
...
Please
register
or
sign in
to post a comment