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
e06828ab
Commit
e06828ab
authored
Jul 17, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sign contracts after login.
parent
6f33ba2a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
81 deletions
+142
-81
ContractTemplateConfiguration.java
...group/xyqb/config/data/ContractTemplateConfiguration.java
+42
-0
WechatConfiguration.java
...a/cn/quantgroup/xyqb/config/data/WechatConfiguration.java
+0
-2
AppController.java
...antgroup/xyqb/controller/internal/user/AppController.java
+44
-34
BlackHoleRegisteredEventListener.java
...antgroup/xyqb/event/BlackHoleRegisteredEventListener.java
+29
-24
UserTagLoginEventListener.java
...a/cn/quantgroup/xyqb/event/UserTagLoginEventListener.java
+11
-1
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+16
-20
No files found.
src/main/java/cn/quantgroup/xyqb/config/data/ContractTemplateConfiguration.java
0 → 100644
View file @
e06828ab
package
cn
.
quantgroup
.
xyqb
.
config
.
data
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.ctrip.framework.apollo.ConfigService
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
ContractTemplateConfiguration
{
private
final
Map
<
String
,
List
<
Long
>>
templateMap
;
public
ContractTemplateConfiguration
()
{
String
data
=
ConfigService
.
getAppConfig
().
getProperty
(
"template.data"
,
"[]"
);
templateMap
=
JSON
.
parseObject
(
data
,
new
TypeReference
<
HashMap
<
String
,
List
<
Long
>>>()
{
});
}
/**
* 获取指定租户下指定registeredFrom的合同模版,如果没有配置,那么取租户下默认模板
* @param tenantId 租户id
* @param registeredFrom 来源
* @return List<Long>
*/
public
List
<
Long
>
getByTenantIdAndRegisteredFrom
(
Integer
tenantId
,
Long
registeredFrom
)
{
String
key
=
tenantId
+
"_"
+
registeredFrom
;
List
<
Long
>
result
=
new
ArrayList
<>();
if
(
templateMap
.
containsKey
(
key
))
{
result
=
templateMap
.
get
(
key
);
}
else
{
if
(
templateMap
.
containsKey
(
tenantId
.
toString
()))
{
result
=
templateMap
.
get
(
tenantId
.
toString
());
}
}
return
result
;
}
}
src/main/java/cn/quantgroup/xyqb/config/data/WechatConfiguration.java
View file @
e06828ab
...
@@ -3,13 +3,11 @@ package cn.quantgroup.xyqb.config.data;
...
@@ -3,13 +3,11 @@ package cn.quantgroup.xyqb.config.data;
import
cn.quantgroup.xyqb.exception.BizException
;
import
cn.quantgroup.xyqb.exception.BizException
;
import
cn.quantgroup.xyqb.exception.BizExceptionEnum
;
import
cn.quantgroup.xyqb.exception.BizExceptionEnum
;
import
cn.quantgroup.xyqb.model.WechatConfigBean
;
import
cn.quantgroup.xyqb.model.WechatConfigBean
;
import
cn.quantgroup.xyqb.util.StringUtils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.ctrip.framework.apollo.ConfigService
;
import
com.ctrip.framework.apollo.ConfigService
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/AppController.java
View file @
e06828ab
package
cn
.
quantgroup
.
xyqb
.
controller
.
internal
.
user
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
internal
.
user
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.entity.Merchant
;
import
cn.quantgroup.xyqb.entity.Merchant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserTag
;
import
cn.quantgroup.xyqb.event.UserLoginEvent
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.AuthBean
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.LoginProperties
;
import
cn.quantgroup.xyqb.model.LoginProperties
;
...
@@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -27,6 +29,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestHeader
;
...
@@ -34,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -34,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.persistence.PersistenceException
;
import
javax.persistence.PersistenceException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -61,6 +65,10 @@ public class AppController implements IBaseController {
...
@@ -61,6 +65,10 @@ public class AppController implements IBaseController {
@Autowired
@Autowired
private
IUserRegisterService
userRegisterService
;
private
IUserRegisterService
userRegisterService
;
@Resource
private
ApplicationEventPublisher
applicationEventPublisher
;
@Value
(
"${sc.is.open:false}"
)
@Value
(
"${sc.is.open:false}"
)
private
Boolean
scIsOpen
;
private
Boolean
scIsOpen
;
...
@@ -74,7 +82,7 @@ public class AppController implements IBaseController {
...
@@ -74,7 +82,7 @@ public class AppController implements IBaseController {
@RequestParam
(
required
=
false
)
Long
registerFrom
,
@RequestParam
(
required
=
false
)
Long
registerFrom
,
@RequestParam
(
required
=
true
)
Long
channelId
,
@RequestParam
(
required
=
true
)
Long
channelId
,
@RequestParam
(
required
=
true
)
String
appChannel
,
@RequestParam
(
required
=
true
)
String
appChannel
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
...
@@ -82,12 +90,12 @@ public class AppController implements IBaseController {
...
@@ -82,12 +90,12 @@ public class AppController implements IBaseController {
}
}
JsonResult
result
=
null
;
JsonResult
result
=
null
;
Authentication
authentication
=
AuthorityManager
.
authentication
();
Authentication
authentication
=
AuthorityManager
.
authentication
();
if
(
authentication
.
isAuthenticated
())
{
if
(
authentication
.
isAuthenticated
())
{
String
phoneNumber
=
ObjectUtils
.
getDisplayString
(
authentication
.
getCredentials
());
String
phoneNumber
=
ObjectUtils
.
getDisplayString
(
authentication
.
getCredentials
());
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNumber
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNumber
))
{
result
=
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
result
=
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
else
{
}
else
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNumber
,
tenantId
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNumber
,
tenantId
);
// 默认为已注册
// 默认为已注册
Boolean
isRegister
=
false
;
Boolean
isRegister
=
false
;
if
(
user
==
null
)
{
if
(
user
==
null
)
{
...
@@ -105,9 +113,9 @@ public class AppController implements IBaseController {
...
@@ -105,9 +113,9 @@ public class AppController implements IBaseController {
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
Merchant
merchant
=
merchantService
.
findMerchantByName
(
key
);
if
(
merchant
==
null
)
{
if
(
merchant
==
null
)
{
result
=
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
result
=
JsonResult
.
buildErrorStateResult
(
"无效的商户"
,
null
);
}
else
{
}
else
{
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
AUTHLOGIN
.
ordinal
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
AUTHLOGIN
.
ordinal
(),
tenantId
);
LoginInfo
.
LoginContext
context
=
new
LoginInfo
.
LoginContext
();
LoginInfo
.
LoginContext
context
=
new
LoginInfo
.
LoginContext
();
context
.
setChannelId
(
channelId
);
context
.
setChannelId
(
channelId
);
context
.
setCreatedFrom
(
registerFrom
);
context
.
setCreatedFrom
(
registerFrom
);
...
@@ -122,7 +130,7 @@ public class AppController implements IBaseController {
...
@@ -122,7 +130,7 @@ public class AppController implements IBaseController {
}
}
}
}
}
}
}
else
{
}
else
{
result
=
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
result
=
JsonResult
.
buildErrorStateResult
(
"登录失败"
,
null
);
}
}
return
result
;
return
result
;
...
@@ -155,13 +163,13 @@ public class AppController implements IBaseController {
...
@@ -155,13 +163,13 @@ public class AppController implements IBaseController {
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
log
.
info
(
"第三方用户登录 [AppController] login --> loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}"
,
registerFrom
,
channelId
,
btRegisterChannelId
,
IpUtil
.
getRemoteIP
(
request
),
idNo
,
name
);
log
.
info
(
"第三方用户登录 [AppController] login --> loginFrom:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}"
,
registerFrom
,
channelId
,
btRegisterChannelId
,
IpUtil
.
getRemoteIP
(
request
),
idNo
,
name
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
user
=
userRegisterService
.
register
(
registerFrom
,
phoneNo
,
name
,
channelId
,
btRegisterChannelId
);
user
=
userRegisterService
.
register
(
registerFrom
,
phoneNo
,
name
,
channelId
,
btRegisterChannelId
);
}
}
...
@@ -177,7 +185,7 @@ public class AppController implements IBaseController {
...
@@ -177,7 +185,7 @@ public class AppController implements IBaseController {
}
}
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGIN
.
ordinal
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGIN
.
ordinal
(),
tenantId
);
log
.
info
(
"第三方用户登录成功 [AppController] login --> loginFrom:{}, phoneNo:{},appChannel:{}"
,
registerFrom
,
phoneNo
,
appChannel
);
log
.
info
(
"第三方用户登录成功 [AppController] login --> loginFrom:{}, phoneNo:{},appChannel:{}"
,
registerFrom
,
phoneNo
,
appChannel
);
return
JsonResult
.
buildSuccessResult
(
"登录成功"
,
bean
);
return
JsonResult
.
buildSuccessResult
(
"登录成功"
,
bean
);
}
}
...
@@ -210,7 +218,7 @@ public class AppController implements IBaseController {
...
@@ -210,7 +218,7 @@ public class AppController implements IBaseController {
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
...
@@ -220,14 +228,14 @@ public class AppController implements IBaseController {
...
@@ -220,14 +228,14 @@ public class AppController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
log
.
info
(
"第三方用户登录 [AppController] loginSuper --> loginFrom:{},phoneNo:{},appChannel:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}"
,
registerFrom
,
phoneNo
,
appChannel
,
channelId
,
btRegisterChannelId
,
IpUtil
.
getRemoteIP
(
request
),
idNo
,
name
);
log
.
info
(
"第三方用户登录 [AppController] loginSuper --> loginFrom:{},phoneNo:{},appChannel:{},channelId:{},btRegisterChannelId:{} requestIp:{},idNo:{},name:{}"
,
registerFrom
,
phoneNo
,
appChannel
,
channelId
,
btRegisterChannelId
,
IpUtil
.
getRemoteIP
(
request
),
idNo
,
name
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
boolean
isRegister
=
false
;
boolean
isRegister
=
false
;
if
(
user
==
null
)
{
if
(
user
==
null
)
{
try
{
try
{
user
=
userRegisterService
.
register
(
registerFrom
,
phoneNo
,
name
,
channelId
,
btRegisterChannelId
);
user
=
userRegisterService
.
register
(
registerFrom
,
phoneNo
,
name
,
channelId
,
btRegisterChannelId
);
isRegister
=
true
;
isRegister
=
true
;
}
catch
(
PersistenceException
e
)
{
}
catch
(
PersistenceException
e
)
{
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
}
}
}
}
if
(
user
==
null
)
{
if
(
user
==
null
)
{
...
@@ -243,15 +251,15 @@ public class AppController implements IBaseController {
...
@@ -243,15 +251,15 @@ public class AppController implements IBaseController {
log
.
info
(
"=addLoginInfo end"
);
log
.
info
(
"=addLoginInfo end"
);
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGIN
.
ordinal
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGIN
.
ordinal
(),
tenantId
);
log
.
info
(
"=createSession end"
);
log
.
info
(
"=createSession end"
);
LoginInfo
loginInfo
=
new
LoginInfo
();
LoginInfo
loginInfo
=
new
LoginInfo
();
loginInfo
.
setUser
(
new
UserRet
(
user
));
loginInfo
.
setUser
(
new
UserRet
(
user
));
loginInfo
.
setHasPassword
(
user
.
getHasPassword
());
loginInfo
.
setHasPassword
(
user
.
getHasPassword
());
loginInfo
.
setToken
(
bean
.
getToken
());
loginInfo
.
setToken
(
bean
.
getToken
());
if
(
isRegister
)
{
if
(
isRegister
)
{
loginInfo
.
setRegister
(
true
);
loginInfo
.
setRegister
(
true
);
}
else
{
}
else
{
loginInfo
.
setRegister
(
false
);
loginInfo
.
setRegister
(
false
);
}
}
LoginInfo
.
LoginContext
context
=
new
LoginInfo
.
LoginContext
();
LoginInfo
.
LoginContext
context
=
new
LoginInfo
.
LoginContext
();
...
@@ -265,27 +273,27 @@ public class AppController implements IBaseController {
...
@@ -265,27 +273,27 @@ public class AppController implements IBaseController {
// 登陆是否上报神策
// 登陆是否上报神策
if
(
scIsOpen
)
{
if
(
scIsOpen
)
{
try
{
try
{
String
scDeviceId
=
request
.
getHeader
(
"scDeviceId"
);
String
scDeviceId
=
request
.
getHeader
(
"scDeviceId"
);
if
(!
StringUtils
.
isEmpty
(
scDeviceId
))
{
if
(!
StringUtils
.
isEmpty
(
scDeviceId
))
{
iSensorsAnalytics
.
trackSignUp
(
user
.
getUuid
(),
scDeviceId
);
iSensorsAnalytics
.
trackSignUp
(
user
.
getUuid
(),
scDeviceId
);
}
}
String
terminal
=
request
.
getHeader
(
"terminal"
);
String
terminal
=
request
.
getHeader
(
"terminal"
);
String
channel
=
request
.
getHeader
(
"channel"
);
String
channel
=
request
.
getHeader
(
"channel"
);
log
.
info
(
"--------手机号{}-------scDeviceId{},terminal{},channel{},是否注册{}"
,
phoneNo
,
scDeviceId
,
terminal
,
channel
,
isRegister
);
log
.
info
(
"--------手机号{}-------scDeviceId{},terminal{},channel{},是否注册{}"
,
phoneNo
,
scDeviceId
,
terminal
,
channel
,
isRegister
);
if
(!
StringUtils
.
isEmpty
(
terminal
)&&
"APP"
.
equals
(
terminal
)||!
StringUtils
.
isEmpty
(
channel
)&&(
"214"
.
equals
(
channel
)||
"217"
.
equals
(
channel
)))
{
if
(!
StringUtils
.
isEmpty
(
terminal
)
&&
"APP"
.
equals
(
terminal
)
||
!
StringUtils
.
isEmpty
(
channel
)
&&
(
"214"
.
equals
(
channel
)
||
"217"
.
equals
(
channel
)))
{
if
(
isRegister
)
{
if
(
isRegister
)
{
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
.
setEventName
(
"App_RegisterEvent"
)
.
setEventName
(
"App_RegisterEvent"
)
.
build
();
.
build
();
iSensorsAnalytics
.
track
(
userRecord
);
iSensorsAnalytics
.
track
(
userRecord
);
}
else
{
}
else
{
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
.
setEventName
(
"App_LoginEvent"
)
.
setEventName
(
"App_LoginEvent"
)
.
build
();
.
build
();
iSensorsAnalytics
.
track
(
userRecord
);
iSensorsAnalytics
.
track
(
userRecord
);
}
}
iSensorsAnalytics
.
flush
();
iSensorsAnalytics
.
flush
();
}
else
{
}
else
{
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
EventRecord
userRecord
=
EventRecord
.
builder
().
setDistinctId
(
user
.
getUuid
()).
isLoginId
(
Boolean
.
TRUE
)
.
setEventName
(
"PD_WUXIEC_UserLoginVccorCash"
)
.
setEventName
(
"PD_WUXIEC_UserLoginVccorCash"
)
.
addProperty
(
"son_channel_id"
,
user
.
getRegisteredFrom
())
.
addProperty
(
"son_channel_id"
,
user
.
getRegisteredFrom
())
...
@@ -321,7 +329,7 @@ public class AppController implements IBaseController {
...
@@ -321,7 +329,7 @@ public class AppController implements IBaseController {
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appChannel
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
@RequestHeader
(
value
=
Constants
.
X_AUTH_TENANT
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
//默认羊小咩租户
//默认羊小咩租户
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
if
(
TenantUtil
.
validationTenantIdIsNullOrZero
(
tenantId
))
{
...
@@ -331,7 +339,7 @@ public class AppController implements IBaseController {
...
@@ -331,7 +339,7 @@ public class AppController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
log
.
info
(
"第三方用户登录 [AppController] login2 --> loginFrom:{},channelId:{}, requestIp:{}"
,
registerFrom
,
channelId
,
IpUtil
.
getRemoteIP
(
request
));
log
.
info
(
"第三方用户登录 [AppController] login2 --> loginFrom:{},channelId:{}, requestIp:{}"
,
registerFrom
,
channelId
,
IpUtil
.
getRemoteIP
(
request
));
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
,
tenantId
);
if
(
user
==
null
)
{
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_PASSWORD_ERROR
,
null
);
}
}
...
@@ -340,9 +348,11 @@ public class AppController implements IBaseController {
...
@@ -340,9 +348,11 @@ public class AppController implements IBaseController {
}
}
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
null
,
""
,
tenantId
);
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
4
,
channelId
,
registerFrom
,
appChannel
,
null
,
""
,
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGINTWO
.
ordinal
(),
tenantId
);
AuthBean
bean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
SUPERLOGINTWO
.
ordinal
(),
tenantId
);
// 不同渠道用户补签不同模板合同
userService
.
channelUserSignContract
(
user
,
registerFrom
,
tenantId
);
applicationEventPublisher
.
publishEvent
(
new
UserLoginEvent
(
this
,
UserTag
.
builder
()
.
userId
(
user
.
getId
()).
registeredFrom
(
registerFrom
).
tenantId
(
tenantId
).
build
()));
log
.
info
(
"第三方用户登录成功 [AppController] login2 --> loginFrom:{}, phoneNo:{},appChannel:{}"
,
registerFrom
,
phoneNo
,
appChannel
);
log
.
info
(
"第三方用户登录成功 [AppController] login2 --> loginFrom:{}, phoneNo:{},appChannel:{}"
,
registerFrom
,
phoneNo
,
appChannel
);
return
JsonResult
.
buildSuccessResult
(
"登录成功"
,
bean
);
return
JsonResult
.
buildSuccessResult
(
"登录成功"
,
bean
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/event/BlackHoleRegisteredEventListener.java
View file @
e06828ab
package
cn
.
quantgroup
.
xyqb
.
event
;
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.config.data.ContractTemplateConfiguration
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -29,12 +31,8 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
...
@@ -29,12 +31,8 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
@Resource
@Resource
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
// 用户注册合同中心模版id
@Autowired
@Value
(
"#{'${register.templateids}'.split(',')}"
)
private
ContractTemplateConfiguration
contractTemplateConfiguration
;
private
List
<
Long
>
templateIds
;
@Resource
private
IUserService
userService
;
@Override
@Override
...
@@ -44,23 +42,30 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
...
@@ -44,23 +42,30 @@ public class BlackHoleRegisteredEventListener implements ApplicationListener<Reg
LocalDate
signDate
=
LocalDate
.
now
();
LocalDate
signDate
=
LocalDate
.
now
();
String
dateStr
=
signDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
));
String
dateStr
=
signDate
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
));
int
day
=
signDate
.
getDayOfMonth
();
int
day
=
signDate
.
getDayOfMonth
();
// 信用钱包服务与隐私协议
List
<
Long
>
templates
=
contractTemplateConfiguration
.
getByTenantIdAndRegisteredFrom
(
user
.
getTenantId
(),
user
.
getRegisteredFrom
());
templateIds
.
forEach
(
id
->
{
if
(
CollectionUtils
.
isNotEmpty
(
templates
))
{
JSONObject
fields
=
new
JSONObject
();
fields
.
put
(
"phoneNo"
,
user
.
getPhoneNo
());
fields
.
put
(
"genarateDateStr"
,
dateStr
);
fields
.
put
(
"day"
,
day
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"mustReal"
,
false
);
json
.
put
(
"templateId"
,
id
);
json
.
put
(
"fields"
,
fields
);
JSONArray
array
=
new
JSONArray
();
JSONArray
array
=
new
JSONArray
();
array
.
add
(
json
);
templates
.
forEach
(
templateId
->
{
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
if
(
templateId
==
8
||
templateId
==
280
)
{
array
.
toString
());
JSONObject
fields
=
new
JSONObject
();
});
fields
.
put
(
"phoneNo"
,
user
.
getPhoneNo
());
// 不同渠道签署不同的合同模板
fields
.
put
(
"genarateDateStr"
,
dateStr
);
userService
.
channelUserSignContract
(
user
,
null
,
user
.
getTenantId
());
fields
.
put
(
"day"
,
day
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"mustReal"
,
false
);
json
.
put
(
"templateId"
,
templateId
);
json
.
put
(
"fields"
,
fields
);
array
.
add
(
json
);
}
else
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"userId"
,
user
.
getId
());
json
.
put
(
"templateId"
,
templateId
);
array
.
add
(
json
);
}
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
());
});
}
}
}
}
}
src/main/java/cn/quantgroup/xyqb/event/UserTagLoginEventListener.java
View file @
e06828ab
package
cn
.
quantgroup
.
xyqb
.
event
;
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserTag
;
import
cn.quantgroup.xyqb.entity.UserTag
;
import
cn.quantgroup.xyqb.repository.IUserTagRepository
;
import
cn.quantgroup.xyqb.repository.IUserTagRepository
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -17,9 +19,13 @@ public class UserTagLoginEventListener implements ApplicationListener<UserLoginE
...
@@ -17,9 +19,13 @@ public class UserTagLoginEventListener implements ApplicationListener<UserLoginE
@Autowired
@Autowired
private
IUserTagRepository
userTagRepository
;
private
IUserTagRepository
userTagRepository
;
@Autowired
private
IUserService
userService
;
/**
/**
* 逻辑 每次登录发送UserLoginEvent,落user_tag表
* 逻辑 每次登录发送UserLoginEvent,落user_tag表
* 如果没有就新增,如果有就更新
* 如果没有就新增,如果有就更新;
* 新增一个逻辑:合同补签,登录的时候跟注册渠道不同,判断是否需要补签合同,如果需要,则补签
*
*
* @param userLoginEvent UserLoginEvent
* @param userLoginEvent UserLoginEvent
*/
*/
...
@@ -41,6 +47,10 @@ public class UserTagLoginEventListener implements ApplicationListener<UserLoginE
...
@@ -41,6 +47,10 @@ public class UserTagLoginEventListener implements ApplicationListener<UserLoginE
preTag
.
setUpdatedAt
(
userTag
.
getUpdatedAt
()
==
null
?
LocalDateTime
.
now
()
:
userTag
.
getUpdatedAt
());
preTag
.
setUpdatedAt
(
userTag
.
getUpdatedAt
()
==
null
?
LocalDateTime
.
now
()
:
userTag
.
getUpdatedAt
());
userTagRepository
.
save
(
preTag
);
userTagRepository
.
save
(
preTag
);
User
user
=
userService
.
findById
(
preTag
.
getUserId
(),
preTag
.
getTenantId
());
//补签合同,如果需要补签
userService
.
channelUserSignContract
(
user
,
userTag
.
getRegisteredFrom
(),
userTag
.
getTenantId
());
}
}
}
}
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
e06828ab
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.service.user.impl;
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.service.user.impl;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.lock.RedisLock
;
import
cn.quantgroup.xyqb.aspect.lock.RedisLock
;
import
cn.quantgroup.xyqb.config.data.ContractTemplateConfiguration
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp
;
import
cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp
;
...
@@ -109,8 +110,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -109,8 +110,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Value
(
"${sc.is.open:false}"
)
@Value
(
"${sc.is.open:false}"
)
private
Boolean
scIsOpen
;
private
Boolean
scIsOpen
;
@
Value
(
"${channel.register.template:null}"
)
@
Autowired
private
String
channelTemplate
;
private
ContractTemplateConfiguration
contractTemplateConfiguration
;
@Resource
@Resource
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
private
RabbitTemplate
registeredNotifyBlackHoleRabbitTemplate
;
...
@@ -549,26 +550,21 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -549,26 +550,21 @@ public class UserServiceImpl implements IUserService, IBaseController {
* @param loginFrom
* @param loginFrom
*/
*/
public
void
channelUserSignContract
(
User
user
,
Long
loginFrom
,
Integer
tenantId
)
{
public
void
channelUserSignContract
(
User
user
,
Long
loginFrom
,
Integer
tenantId
)
{
if
(
Objects
.
isNull
(
user
)
||
StringUtils
.
isBlank
(
channelTemplate
)
)
{
if
(
Objects
.
isNull
(
user
))
{
return
;
return
;
}
}
// 如果登录来源和注册来源相同,不用补签合同
// 如果登录来源和注册来源相同,不用补签合同
if
(
Objects
.
nonNull
(
loginFrom
)
&&
Objects
.
equals
(
user
.
getRegisteredFrom
(),
loginFrom
))
{
if
(
Objects
.
nonNull
(
loginFrom
)
&&
Objects
.
equals
(
user
.
getRegisteredFrom
(),
loginFrom
))
{
return
;
return
;
}
}
Map
<
String
,
Long
>
channelMap
=
JSON
.
parseObject
(
channelTemplate
,
new
TypeReference
<
HashMap
<
String
,
Long
>>()
{
List
<
Long
>
templates
=
contractTemplateConfiguration
.
getByTenantIdAndRegisteredFrom
(
tenantId
,
loginFrom
);
});
Long
templateId
=
channelMap
.
get
(
String
.
valueOf
(
user
.
getRegisteredFrom
()));
boolean
needCheck
=
false
;
if
(
Objects
.
nonNull
(
loginFrom
)
&&
!
Objects
.
equals
(
user
.
getRegisteredFrom
(),
loginFrom
))
{
templateId
=
channelMap
.
get
(
String
.
valueOf
(
loginFrom
));
needCheck
=
true
;
}
if
(
Objects
.
isNull
(
templateId
))
{
if
(
CollectionUtils
.
isEmpty
(
templates
))
{
return
;
return
;
}
}
if
(
needCheck
)
{
templates
.
forEach
(
templateId
->{
ContractRecordReq
contractRecordReq
=
new
ContractRecordReq
();
ContractRecordReq
contractRecordReq
=
new
ContractRecordReq
();
contractRecordReq
.
setTemplateId
(
templateId
);
contractRecordReq
.
setTemplateId
(
templateId
);
contractRecordReq
.
setUserId
(
user
.
getId
());
contractRecordReq
.
setUserId
(
user
.
getId
());
...
@@ -577,12 +573,12 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -577,12 +573,12 @@ public class UserServiceImpl implements IUserService, IBaseController {
if
(
Objects
.
nonNull
(
data
))
{
if
(
Objects
.
nonNull
(
data
))
{
return
;
return
;
}
}
}
JSONObject
json
=
new
JSONObject
();
JSONObject
json
=
new
JSONObject
(
);
json
.
put
(
"userId"
,
user
.
getId
()
);
json
.
put
(
"userId"
,
user
.
getId
()
);
json
.
put
(
"templateId"
,
templateId
);
json
.
put
(
"templateId"
,
templateId
);
JSONArray
array
=
new
JSONArray
(
);
JSONArray
array
=
new
JSONArray
(
);
array
.
add
(
json
);
array
.
add
(
json
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
()
);
registeredNotifyBlackHoleRabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
array
.
toString
()
);
}
);
}
}
}
}
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