Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
abffdac4
Commit
abffdac4
authored
May 11, 2021
by
于桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vcc来源专用的快速登录,增加vcc推广注册渠道ID
parent
85135b12
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
193 additions
and
18 deletions
+193
-18
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+60
-18
UserVccRegister.java
src/main/java/cn/quantgroup/xyqb/entity/UserVccRegister.java
+31
-0
VccRegisteredEventListener.java
.../cn/quantgroup/xyqb/event/VccRegisteredEventListener.java
+36
-0
UserRegisterParam.java
...main/java/cn/quantgroup/xyqb/model/UserRegisterParam.java
+1
-0
IUserRegisterService.java
...uantgroup/xyqb/service/register/IUserRegisterService.java
+2
-0
UserRegisterServiceImpl.java
...p/xyqb/service/register/impl/UserRegisterServiceImpl.java
+18
-0
IUserService.java
...in/java/cn/quantgroup/xyqb/service/user/IUserService.java
+4
-0
IUserVccRegisterService.java
...quantgroup/xyqb/service/user/IUserVccRegisterService.java
+11
-0
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+30
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
abffdac4
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
;
import
static
cn
.
quantgroup
.
xyqb
.
Constants
.
VERIFICATION_CODE_FINITE_COUNT_NEW
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.aspect.captcha.CaptchaFiniteValidator
;
import
cn.quantgroup.xyqb.aspect.captcha.CaptchaFiniteValidator
;
...
@@ -30,26 +54,8 @@ import cn.quantgroup.xyqb.session.XyqbSessionContextHolder;
...
@@ -30,26 +54,8 @@ import cn.quantgroup.xyqb.session.XyqbSessionContextHolder;
import
cn.quantgroup.xyqb.util.IpUtil
;
import
cn.quantgroup.xyqb.util.IpUtil
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSON
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.UnsupportedEncodingException
;
import
java.lang.reflect.Method
;
import
java.nio.charset.Charset
;
import
java.util.*
;
import
static
cn
.
quantgroup
.
xyqb
.
Constants
.
VERIFICATION_CODE_FINITE_COUNT_NEW
;
/**
/**
* Http服务接口:用户注册、登录、重置密码
* Http服务接口:用户注册、登录、重置密码
...
@@ -193,6 +199,42 @@ public class UserController implements IBaseController {
...
@@ -193,6 +199,42 @@ public class UserController implements IBaseController {
return
userService
.
loginFast
(
channelId
,
appChannel
,
createdFrom
,
btRegisterChannelId
,
dimension
,
clickId
,
request
,
merchant
,
phoneNo
);
return
userService
.
loginFast
(
channelId
,
appChannel
,
createdFrom
,
btRegisterChannelId
,
dimension
,
clickId
,
request
,
merchant
,
phoneNo
);
}
}
/**
* vcc来源专用的快速登录
* @see #loginFast(Long, String, Long, String, Long, String, String, HttpServletRequest)
*/
@LoginInterceptor
@RequestMapping
(
"/login/fast/vcc"
)
public
JsonResult
loginFastVcc
(
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
String
appChannel
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
createdFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"xyqb"
)
String
key
,
@RequestParam
(
required
=
false
)
Long
vccRegisterChannelId
,
// vcc推广注册渠道ID
@RequestParam
(
required
=
false
)
String
dimension
,
@RequestParam
(
name
=
"click_id"
,
required
=
false
)
String
clickId
,
HttpServletRequest
request
)
{
log
.
info
(
"login/fast -> channelId:{},appChannel:{},createdFrom:{},vccRegisterChannelId:{},key:{},dimension:{},clickId:{}"
,
channelId
,
appChannel
,
createdFrom
,
vccRegisterChannelId
,
key
,
dimension
,
clickId
);
Map
<
String
,
JsonResult
>
validMap
=
getHeaderParam
(
request
);
JsonResult
failResult
=
validMap
.
get
(
Constants
.
CHECK_FAIL
);
if
(
null
!=
failResult
)
{
return
failResult
;
}
JsonResult
successResult
=
validMap
.
get
(
"success"
);
String
phoneNo
=
successResult
.
getData
().
toString
();
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
log
.
info
(
"用户快速登录失败,手机号错误, createdFrom:{},phoneNo:{}"
,
createdFrom
,
phoneNo
);
throw
new
UserNotExistException
(
"手机号错误"
);
}
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"未知的连接"
,
null
);
}
String
verificationCode
=
successResult
.
getMsg
();
// 执行短信验证码检查
verifyPhoneAndCodeForOnce
(
phoneNo
,
verificationCode
);
return
userService
.
loginFastVcc
(
channelId
,
appChannel
,
createdFrom
,
vccRegisterChannelId
,
dimension
,
clickId
,
request
,
merchant
,
phoneNo
);
}
/**
/**
* 快速登录验证
* 快速登录验证
*
*
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserVccRegister.java
0 → 100644
View file @
abffdac4
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
java.io.Serializable
;
/**
* Created by Administrator on 2017/5/16.
*/
@Getter
@Setter
@ToString
@Entity
@Table
(
name
=
"user_vcc_register"
)
public
class
UserVccRegister
extends
BaseEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
@Column
(
name
=
"user_id"
)
private
Long
userId
;
@Column
(
name
=
"register_vcc_channel_id"
)
private
Long
vccRegisterChannelId
;
@Column
(
name
=
"is_active"
)
private
Boolean
isActive
=
Boolean
.
TRUE
;
}
src/main/java/cn/quantgroup/xyqb/event/VccRegisteredEventListener.java
0 → 100644
View file @
abffdac4
package
cn
.
quantgroup
.
xyqb
.
event
;
import
java.util.Objects
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserVccRegister
;
import
cn.quantgroup.xyqb.model.UserRegisterParam
;
import
cn.quantgroup.xyqb.service.user.IUserVccRegisterService
;
@Component
public
class
VccRegisteredEventListener
implements
ApplicationListener
<
RegisterEvent
>
{
@Autowired
private
IUserVccRegisterService
userVccRegisterService
;
@Override
public
void
onApplicationEvent
(
RegisterEvent
event
)
{
UserRegisterParam
userRegisterParam
=
event
.
getUserRegisterParam
();
User
user
=
userRegisterParam
.
getUser
();
Long
vccRegisterChannelId
=
userRegisterParam
.
getVccRegisterChannelId
();
// vcc推广时存在推广渠道ID时保存下来
if
(
Objects
.
isNull
(
user
)
||
Objects
.
isNull
(
vccRegisterChannelId
))
{
return
;
}
UserVccRegister
userVccRegister
=
new
UserVccRegister
();
userVccRegister
.
setUserId
(
user
.
getId
());
userVccRegister
.
setVccRegisterChannelId
(
vccRegisterChannelId
);
userVccRegister
.
setIsActive
(
true
);
userVccRegisterService
.
save
(
userVccRegister
);
}
}
src/main/java/cn/quantgroup/xyqb/model/UserRegisterParam.java
View file @
abffdac4
...
@@ -30,6 +30,7 @@ public class UserRegisterParam {
...
@@ -30,6 +30,7 @@ public class UserRegisterParam {
private
String
name
;
// 姓名
private
String
name
;
// 姓名
private
Long
channelId
;
// 业务渠道
private
Long
channelId
;
// 业务渠道
private
Long
btRegisterChannelId
;
// 白条渠道
private
Long
btRegisterChannelId
;
// 白条渠道
private
Long
vccRegisterChannelId
;
// VCC推荐渠道
private
String
dimension
;
// 维度
private
String
dimension
;
// 维度
private
Address
address
;
// 地址
private
Address
address
;
// 地址
private
String
contacts
;
// 联系人
private
String
contacts
;
// 联系人
...
...
src/main/java/cn/quantgroup/xyqb/service/register/IUserRegisterService.java
View file @
abffdac4
...
@@ -57,6 +57,8 @@ public interface IUserRegisterService {
...
@@ -57,6 +57,8 @@ public interface IUserRegisterService {
*/
*/
User
register
(
String
phoneNo
,
Long
channelId
,
Long
registerFrom
,
String
appChannel
,
Long
btRegisterChannelId
,
String
dimension
);
User
register
(
String
phoneNo
,
Long
channelId
,
Long
registerFrom
,
String
appChannel
,
Long
btRegisterChannelId
,
String
dimension
);
User
registerVcc
(
String
phoneNo
,
Long
channelId
,
Long
createdFrom
,
String
appChannel
,
Long
vccRegisterChannelId
,
String
dimension
);
/**
/**
* 替换InnerController.saveMulti里的userService.registerAndReturn
* 替换InnerController.saveMulti里的userService.registerAndReturn
* /innserapi/user/save_multi
* /innserapi/user/save_multi
...
...
src/main/java/cn/quantgroup/xyqb/service/register/impl/UserRegisterServiceImpl.java
View file @
abffdac4
...
@@ -136,6 +136,24 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
...
@@ -136,6 +136,24 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
return
user
;
return
user
;
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
User
registerVcc
(
String
phoneNo
,
Long
channelId
,
Long
registerFrom
,
String
appChannel
,
Long
vccRegisterChannelId
,
String
dimension
)
{
UserRegisterParam
userRegisterParam
=
UserRegisterParam
.
builder
()
.
registerFrom
(
registerFrom
)
.
phoneNo
(
phoneNo
)
.
channelId
(
channelId
)
.
vccRegisterChannelId
(
vccRegisterChannelId
)
.
dimension
(
dimension
)
.
sendSuccessSms
(
true
)
.
sendAppSms
(
true
)
.
sendSuccessMq
(
true
)
.
build
();
User
user
=
saveUser
(
userRegisterParam
);
applicationEventPublisher
.
publishEvent
(
new
RegisterEvent
(
this
,
userRegisterParam
));
return
user
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
User
register
(
Long
registeredFrom
,
Long
channelId
,
String
phoneNo
,
String
name
,
String
idNo
,
Address
addressObj
,
String
contacts
,
List
<
Contact
>
contactList
,
Long
btRegisterChannelId
)
{
public
User
register
(
Long
registeredFrom
,
Long
channelId
,
String
phoneNo
,
String
name
,
String
idNo
,
Address
addressObj
,
String
contacts
,
List
<
Contact
>
contactList
,
Long
btRegisterChannelId
)
{
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IUserService.java
View file @
abffdac4
...
@@ -82,6 +82,10 @@ public interface IUserService {
...
@@ -82,6 +82,10 @@ public interface IUserService {
String
dimension
,
String
clickId
,
HttpServletRequest
request
,
Merchant
merchant
,
String
dimension
,
String
clickId
,
HttpServletRequest
request
,
Merchant
merchant
,
String
phoneNo
);
String
phoneNo
);
JsonResult
loginFastVcc
(
Long
channelId
,
String
appChannel
,
Long
createdFrom
,
Long
vccRegisterChannelId
,
String
dimension
,
String
clickId
,
HttpServletRequest
request
,
Merchant
merchant
,
String
phoneNo
);
/**
/**
* 查询用户全量信息
* 查询用户全量信息
*
*
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IUserVccRegisterService.java
0 → 100644
View file @
abffdac4
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserVccRegister
;
/**
* Created by Administrator on 2017/5/16.
*/
public
interface
IUserVccRegisterService
{
UserVccRegister
save
(
UserVccRegister
userVccRegister
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
abffdac4
...
@@ -357,6 +357,36 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -357,6 +357,36 @@ public class UserServiceImpl implements IUserService, IBaseController {
return
new
JsonResult
(
session
);
return
new
JsonResult
(
session
);
}
}
@Override
@RedisLock
(
prefix
=
"lock:login:fast:"
,
key
=
"#this[8]"
)
public
JsonResult
loginFastVcc
(
Long
channelId
,
String
appChannel
,
Long
createdFrom
,
Long
vccRegisterChannelId
,
String
dimension
,
String
clickId
,
HttpServletRequest
request
,
Merchant
merchant
,
String
phoneNo
)
{
Boolean
register
=
false
;
User
user
=
findByPhoneWithCache
(
phoneNo
);
if
(
user
!=
null
&&
!
user
.
getEnable
())
{
log
.
info
(
"用户不存在,或者已经注销,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
if
(
user
==
null
)
{
// Service层会负责发送注册消息到LoanVest
user
=
userRegisterService
.
registerVcc
(
phoneNo
,
channelId
,
createdFrom
,
appChannel
,
vccRegisterChannelId
,
dimension
);
if
(
user
==
null
)
{
throw
new
UserNotExistException
(
"用户未找到"
);
}
//广点通转化注册 - 发送消息 - 方法内过滤
MqUtils
.
sendRegisterMessageForGdt
(
phoneNo
,
clickId
);
register
=
true
;
}
if
(!
wechatRelateUserIfNecessary
(
user
,
request
))
{
return
JsonResult
.
buildErrorStateResult
(
"登录时微信关联失败"
,
null
);
}
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
3
,
channelId
,
createdFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
());
AuthBean
session
=
sessionService
.
createSession
(
user
,
loginProperties
);
session
.
setRegister
(
register
);
lockIpv4Service
.
unLockPhone
(
phoneNo
);
return
new
JsonResult
(
session
);
}
/**
/**
* 如果必要的话,关联用户和微信
* 如果必要的话,关联用户和微信
*
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment