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
502c3c50
Commit
502c3c50
authored
Nov 08, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/20171030
parents
af0f5572
b290d05e
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
200 additions
and
1379 deletions
+200
-1379
pom.xml
pom.xml
+1
-1
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+2
-7
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+1
-0
Jr58Controller.java
...ntgroup/xyqb/controller/external/user/Jr58Controller.java
+0
-291
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+8
-2
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+1
-0
UserinfoChangedEvent.java
...n/java/cn/quantgroup/xyqb/event/UserinfoChangedEvent.java
+0
-23
Jr58DataSender.java
...in/java/cn/quantgroup/xyqb/event/jr58/Jr58DataSender.java
+0
-67
Jr58MessageSigner.java
...java/cn/quantgroup/xyqb/event/jr58/Jr58MessageSigner.java
+0
-46
Jr58Notifier.java
...main/java/cn/quantgroup/xyqb/event/jr58/Jr58Notifier.java
+0
-42
Jr58Authorization.java
...java/cn/quantgroup/xyqb/model/jr58/Jr58Authorization.java
+0
-250
Jr58RegisterParam.java
...java/cn/quantgroup/xyqb/model/jr58/Jr58RegisterParam.java
+0
-40
Jr58RegisterResult.java
...ava/cn/quantgroup/xyqb/model/jr58/Jr58RegisterResult.java
+0
-20
Jr58Service.java
...ain/java/cn/quantgroup/xyqb/service/jr58/Jr58Service.java
+0
-42
Jr58ServiceImpl.java
...cn/quantgroup/xyqb/service/jr58/impl/Jr58ServiceImpl.java
+0
-295
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+185
-129
ILkbUserService.java
...java/cn/quantgroup/xyqb/service/user/ILkbUserService.java
+0
-11
LkbUserviceImpl.java
...cn/quantgroup/xyqb/service/user/impl/LkbUserviceImpl.java
+0
-24
JR58GzipUtil.java
src/main/java/cn/quantgroup/xyqb/util/JR58GzipUtil.java
+0
-71
xyqb.properties
src/main/resources/config/dev/xyqb.properties
+1
-8
application.properties
src/main/resources/config/release01/application.properties
+1
-1
xyqb.properties
src/main/resources/config/release01/xyqb.properties
+0
-4
xyqb.properties
src/main/resources/config/test/xyqb.properties
+0
-5
No files found.
pom.xml
View file @
502c3c50
...
...
@@ -373,7 +373,7 @@
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-sms-sdk
</artifactId>
<version>
1.0.5
-SNAPSHOT
</version>
<version>
2.0.0.3
-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
502c3c50
...
...
@@ -44,13 +44,7 @@ public interface Constants {
* redis中token的key值前缀
*/
String
SESSION_PREFIX
=
"spring:session:sessions:"
;
interface
Jr58
{
int
ERROR_PHONE_NUMBER
=
20007
;
// 手机号码格式不正确
int
ERROR_ID_CARD
=
20009
;
// 身份证格式不正确
int
ERROR_ACCOUNT
=
20010
;
// 授权账号为空
int
ERROR_AUTH_TYPE
=
20011
;
// 授权类型为空
}
Long
ONE_DAY
=
24
*
60
*
60L
;
interface
Channel
{
long
LKB
=
1
;
// 量化派
...
...
@@ -63,6 +57,7 @@ public interface Constants {
interface
Session
{
String
USER_SESSION_CACHE
=
"user:session:"
;
String
USER_SESSION_ID_CACHE
=
"userid-sessionvalue:cache:"
;
String
USER_SESSION_KEY_SET
=
"userid-keys:set:"
;
Long
ONE_DAY
=
24
*
60
*
60L
;
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
502c3c50
...
...
@@ -71,6 +71,7 @@ public class AppController implements IBaseController {
* 第三方用户登录
*/
@RequestMapping
(
"/login"
)
@LogHttpCaller
public
JsonResult
login
(
String
phoneNo
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
registerFrom
,
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/Jr58Controller.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UuidPhoneMapping
;
import
cn.quantgroup.xyqb.event.UserinfoChangedEvent
;
import
cn.quantgroup.xyqb.exception.IdCardException
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.Tuple
;
import
cn.quantgroup.xyqb.model.jr58.Jr58Authorization
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
cn.quantgroup.xyqb.service.auth.IAuthApiService
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.jr58.Jr58Service
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUuidPhoneMappingService
;
import
cn.quantgroup.xyqb.util.JR58GzipUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Strings
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisherAware
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.context.request.WebRequest
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
cn
.
quantgroup
.
xyqb
.
Constants
.
Jr58
;
/**
* @author mengfan.feng
* @time 2015-09-09 15:32
*/
@RestController
@RequestMapping
(
"/jr58"
)
public
class
Jr58Controller
implements
ApplicationEventPublisherAware
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Jr58Controller
.
class
);
private
static
final
String
ENTRY_POINT_URL_TEMPLATE
=
"%s/app-landing?registerFrom=175&channelId=1&token=%s"
;
private
static
List
<
String
>
authorizationTypeList
=
new
ArrayList
<>();
static
{
//授权类型
authorizationTypeList
.
add
(
"1"
);
authorizationTypeList
.
add
(
"2"
);
}
@Value
(
"${xyqb.url}"
)
private
String
xyqbUrl
;
@Autowired
private
IAuthApiService
authApiService
;
// @Value("${xyqb.entrypoint.jr58}")
// private String xyqbEntryPointForJr58;
@Value
(
"${lkb.url}"
)
private
String
lkbUrl
;
@Value
(
"${lkb.entrypoint.jr58}"
)
private
String
lkbEntryPointForJr58
;
@Autowired
private
IUserService
xyqbUserService
;
@Autowired
private
IIdCardService
idCardService
;
@Autowired
private
Jr58Service
jr58Service
;
@Autowired
private
IUuidPhoneMappingService
uuidPhoneMappingService
;
private
ApplicationEventPublisher
applicationEventPublisher
;
@RequestMapping
(
"/register"
)
Map
<
String
,
Object
>
register
(
Jr58RegisterParam
param
)
{
LOGGER
.
info
(
"保存58金融用户信息, param:{}"
,
param
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
/********************* 校验参数 ************************/
if
(!
ValidationUtil
.
validatePhoneNo
(
param
.
getPhone
()))
{
result
.
put
(
"errorcode"
,
Jr58
.
ERROR_PHONE_NUMBER
);
return
result
;
}
if
(
StringUtils
.
isBlank
(
param
.
getAccount
()))
{
LOGGER
.
error
(
"58金融授权账号-account={}"
,
param
.
getAccount
());
result
.
put
(
"errorcode"
,
Jr58
.
ERROR_ACCOUNT
);
return
result
;
}
if
(
StringUtils
.
isBlank
(
param
.
getAuthorizationType
())
||
!
authorizationTypeList
.
contains
(
param
.
getAuthorizationType
()))
{
LOGGER
.
error
(
"58金融授权类型-authorization={} "
,
param
.
getAuthorizationType
());
result
.
put
(
"errorcode"
,
Jr58
.
ERROR_AUTH_TYPE
);
return
result
;
}
try
{
param
.
setIdCardInfo
(
idCardService
.
getIdCardInfoWithExceptions
(
param
.
getIdcard
()));
}
catch
(
IdCardException
|
ParseException
e
)
{
result
.
put
(
"errorcode"
,
Jr58
.
ERROR_ID_CARD
);
return
result
;
}
try
{
if
(
StringUtils
.
isNotBlank
(
param
.
getWbUserName
()))
{
param
.
setWbUserName
(
URLDecoder
.
decode
(
param
.
getWbUserName
(),
"UTF-8"
));
}
if
(
StringUtils
.
isNotBlank
(
param
.
getEmail
()))
{
param
.
setEmail
(
URLDecoder
.
decode
(
param
.
getEmail
(),
"UTF-8"
));
}
if
(
StringUtils
.
isNotBlank
(
param
.
getName
()))
{
param
.
setName
(
URLDecoder
.
decode
(
param
.
getName
(),
"UTF-8"
));
}
if
(
StringUtils
.
isNotBlank
(
param
.
getInfo
()))
{
param
.
setInfo
(
URLDecoder
.
decode
(
param
.
getInfo
(),
"UTF-8"
));
}
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"URLDecoder error"
,
e
);
}
String
uuid
=
jr58Service
.
register
(
param
);
applicationEventPublisher
.
publishEvent
(
new
UserinfoChangedEvent
(
this
,
uuid
,
Constants
.
Channel
.
JR58
));
User
user
=
xyqbUserService
.
findByUuidWithCache
(
uuid
);
LOGGER
.
info
(
"58金融运营商授权状态更新开始"
);
try
{
jr58Service
.
getRidOfFillingProfile
(
user
,
param
.
getAccount
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"58金融运营商授权状态更新失败,异常信息如下所示:error={}"
,
e
.
getMessage
(),
e
);
}
jr58Service
.
pushAuthorizationStatus
(
uuid
,
param
.
getAccount
(),
param
.
getAuthorizationType
());
LOGGER
.
info
(
"58金融运营商授权状态更新结束"
);
result
.
put
(
"customerid"
,
uuid
);
result
.
put
(
"success"
,
true
);
result
.
put
(
"result"
,
1
);
result
.
put
(
"errorcode"
,
0
);
result
.
put
(
"monitorPhone"
,
param
.
getMonitorPhone
());
//58金融用于监控接口是否正常,无其他意义
LOGGER
.
info
(
"返还给58用户, result:{}"
,
result
);
return
result
;
}
@RequestMapping
(
"/index"
)
public
ResponseEntity
index
(
WebRequest
request
)
throws
MissingServletRequestParameterException
,
UnsupportedEncodingException
{
String
userId
=
request
.
getParameter
(
"userId"
);
String
from
=
Strings
.
nullToEmpty
(
request
.
getParameter
(
"from"
));
LOGGER
.
info
(
"收到来自58金融入口的请求, userId:{}, from:{}"
,
userId
,
from
);
if
(
StringUtils
.
isEmpty
(
userId
))
{
return
new
ResponseEntity
(
HttpStatus
.
BAD_REQUEST
);
}
String
uuid
=
userId
.
toLowerCase
();
Tuple
<
String
,
User
>
entryUrlAndUser
=
getEntryPointUrl
(
uuid
,
from
);
String
entryPointUrl
=
entryUrlAndUser
.
getKey
();
LOGGER
.
info
(
"将来自58金融入口的用户导流至 {}"
,
entryPointUrl
);
HttpHeaders
responseHeaders
=
new
HttpHeaders
();
responseHeaders
.
set
(
"Location"
,
entryPointUrl
);
return
new
ResponseEntity
(
responseHeaders
,
HttpStatus
.
FOUND
);
}
private
Tuple
<
String
,
User
>
getEntryPointUrl
(
String
uuid
,
String
from
)
{
// 找到uuid,但是用户不在user表中,说明是老系统用户
User
userInXyqb
=
xyqbUserService
.
findByUuidWithCache
(
uuid
);
if
(
userInXyqb
!=
null
)
{
String
token
=
authApiService
.
login
(
userInXyqb
.
getPhoneNo
(),
Constants
.
Channel
.
JR58
,
"xyqb"
);
return
new
Tuple
<>(
String
.
format
(
ENTRY_POINT_URL_TEMPLATE
,
xyqbUrl
,
token
),
userInXyqb
);
}
UuidPhoneMapping
phoneMapping
=
uuidPhoneMappingService
.
findByUuid
(
uuid
);
String
phoneNo
=
null
;
if
(
phoneMapping
!=
null
)
{
phoneNo
=
phoneMapping
.
getPhoneNo
();
}
else
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - uuid对应的UuidPhoneMapping为空"
);
}
// 手机号在新系统中存在,说明之前已经注册过
userInXyqb
=
xyqbUserService
.
findByPhoneWithCache
(
phoneNo
);
if
(
userInXyqb
!=
null
)
{
String
token
=
authApiService
.
login
(
phoneNo
,
Constants
.
Channel
.
JR58
,
"xyqb"
);
return
new
Tuple
<>(
String
.
format
(
ENTRY_POINT_URL_TEMPLATE
,
xyqbUrl
,
token
),
userInXyqb
);
}
else
{
// 注册过
userInXyqb
=
xyqbUserService
.
registerAndReturn
(
phoneNo
,
"abc1234$"
,
Constants
.
Channel
.
JR58
);
String
token
=
authApiService
.
login
(
phoneNo
,
Constants
.
Channel
.
JR58
,
"xyqb"
);
return
new
Tuple
<>(
String
.
format
(
ENTRY_POINT_URL_TEMPLATE
,
xyqbUrl
,
token
),
userInXyqb
);
}
}
@Override
public
void
setApplicationEventPublisher
(
ApplicationEventPublisher
applicationEventPublisher
)
{
this
.
applicationEventPublisher
=
applicationEventPublisher
;
}
/**
* 58金融运营商授权数据导入接口
*
* @param authorizationData 入参
* @return JsonResult
*/
@RequestMapping
(
value
=
"/import_authorization_data"
,
method
=
RequestMethod
.
POST
)
public
JsonResult
importAuthorizationData
(
@RequestBody
Jr58Authorization
authorizationData
)
{
String
authorizationDataStr
=
null
;
LOGGER
.
info
(
"推送的运营商数据userId={}"
,
authorizationData
.
getUserId
());
LOGGER
.
info
(
"推送的运营商数据sourceFrom={}"
,
authorizationData
.
getSourceFrom
());
if
(
StringUtils
.
isEmpty
(
authorizationData
.
getAuthorizationData
()))
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - authorizationData不能为空"
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入接口 - authorizationData不能为空"
,
null
);
}
//try {
authorizationDataStr
=
JR58GzipUtil
.
bytesTogzip
(
Base64
.
decodeBase64
(
authorizationData
.
getAuthorizationData
()),
"utf-8"
);
//authorizationDataStr = JR58GzipUtil.bytesTogzip(new BASE64Decoder().decodeBuffer(authorizationData.getAuthorizationData()), "utf-8");
LOGGER
.
info
(
"推送的运营商数据authorizationDataStr={}"
,
authorizationDataStr
);
/*} catch (IOException e) {
LOGGER.error("58金融生成借款申请失败,base64转换失败");
return JsonResult.buildErrorStateResult("58金融导入运营商授权数据失败",null);
}*/
//authorizationData.setOperator_data(new Gson().fromJson(authorizationDataStr, Jr58Authorization.OperatorData.class));
authorizationData
.
setOperator_data
(
JSONObject
.
parseObject
(
authorizationDataStr
,
Jr58Authorization
.
OperatorData
.
class
));
if
(
authorizationData
==
null
)
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - 入参不完整"
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入 - 入参不完整"
,
null
);
}
String
userId
=
authorizationData
.
getUserId
();
String
phoneNo
=
null
;
if
(
authorizationData
.
getOperator_data
()
!=
null
&&
authorizationData
.
getOperator_data
().
getOriginalData
()
!=
null
)
{
phoneNo
=
authorizationData
.
getOperator_data
().
getOriginalData
().
getPhone
();
}
if
(
phoneNo
==
null
)
{
LOGGER
.
info
(
"推送的运营商数据authorizationData={}"
,
authorizationData
.
getAuthorizationData
());
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - phoneNo不能为空"
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入接口 - 入参不完整"
,
null
);
}
LOGGER
.
info
(
"收到来自58金融运营商授权导入请求, userId:{}"
,
userId
);
if
(
StringUtils
.
isEmpty
(
authorizationData
.
getSourceFrom
()))
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - sourceFrom不能为空"
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入接口 - sourceFrom不能为空"
,
null
);
}
if
(
StringUtils
.
isEmpty
(
userId
))
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - userId不能为空"
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入接口 - userId不能为空"
,
null
);
}
if
(
"1"
.
equals
(
authorizationData
.
getSourceFrom
())
&&
(
null
==
authorizationData
.
getOperator_data
()
||
null
==
authorizationData
.
getOperator_data
().
getOriginalData
()))
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - 入参不完整, sourceFrom : {}, authorizationDataStr={}"
,
authorizationData
.
getSourceFrom
(),
authorizationDataStr
);
return
JsonResult
.
buildErrorStateResult
(
"58金融运营商授权数据导入接口 - 入参不完整"
,
null
);
}
String
uuid
=
userId
.
toLowerCase
();
Tuple
<
String
,
User
>
entryUrlAndUser
=
getEntryPointUrl
(
uuid
,
String
.
valueOf
(
Constants
.
Channel
.
JR58
));
User
user
=
entryUrlAndUser
.
getValue
();
// 用户不存在
if
(
user
==
null
)
{
LOGGER
.
error
(
"58金融运营商授权数据导入接口 - 用户不存在,userId=[{}]"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
"用户不存在,userId="
+
userId
,
null
);
}
// 推送授权to风控
jr58Service
.
pushAuthorizationData
(
authorizationData
);
LOGGER
.
info
(
"58金融运营商数据导入结束"
);
return
JsonResult
.
buildSuccessResult
(
"success"
,
null
);
}
}
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
502c3c50
...
...
@@ -163,10 +163,11 @@ public class SmsController implements IBaseController {
private
JsonResult
sendVerificationCode2Voice
(
String
phoneNo
,
String
usage
)
{
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getVerificationCount
>
5
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
}
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
...
...
@@ -224,6 +225,8 @@ public class SmsController implements IBaseController {
}
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationPhoneCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getPhoneVerificationCount
>
PHONE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
}
...
...
@@ -239,6 +242,7 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_SMS_DEVICE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天短信验证码上限"
,
null
);
}
...
...
@@ -279,6 +283,7 @@ public class SmsController implements IBaseController {
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getVerificationCount
>
PHONE_VOICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
}
...
...
@@ -294,12 +299,13 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_VOICE_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_VOICE_DEVICE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天语音验证码上限"
,
null
);
}
}
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
502c3c50
...
...
@@ -337,6 +337,7 @@ public class UserController implements IBaseController {
* @param channelId
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/register"
)
@LogHttpCaller
public
JsonResult
register
(
@RequestParam
String
phoneNo
,
@RequestParam
String
password
,
...
...
src/main/java/cn/quantgroup/xyqb/event/UserinfoChangedEvent.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
event
;
import
lombok.Getter
;
import
lombok.ToString
;
import
org.springframework.context.ApplicationEvent
;
/**
* @author mengfan.feng
* @time 2015-09-15 15:05
*/
@Getter
@ToString
public
class
UserinfoChangedEvent
extends
ApplicationEvent
{
private
final
String
uuid
;
private
final
Long
channelId
;
public
UserinfoChangedEvent
(
Object
source
,
String
uuid
,
Long
channelId
)
{
super
(
source
);
this
.
uuid
=
uuid
;
this
.
channelId
=
channelId
;
}
}
src/main/java/cn/quantgroup/xyqb/event/jr58/Jr58DataSender.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
event
.
jr58
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableMap
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
@Service
public
class
Jr58DataSender
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Jr58DataSender
.
class
);
@Autowired
private
Jr58MessageSigner
jr58MessageSigner
;
@Autowired
private
IHttpService
httpService
;
@Value
(
"${jr58.notify.userinfo}"
)
private
String
jr58nNotifyUserinfo
;
/**
* 向58金融同步用户信息
*
* @param uuid
*/
@Async
public
void
sendUserinfo
(
String
uuid
)
{
try
{
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"salaryWay"
,
0
);
json
.
put
(
"loanPurpose"
,
"12"
);
json
.
put
(
"job"
,
0
);
json
.
put
(
"account"
,
1000
);
json
.
put
(
"salary"
,
0
);
json
.
put
(
"hourse"
,
1
);
json
.
put
(
"isShebao"
,
0
);
json
.
put
(
"education"
,
""
);
json
.
put
(
"isCreditCard"
,
"0"
);
json
.
put
(
"isOtherLoanOrg"
,
"0"
);
String
userinfo
=
json
.
toString
();
String
param
=
uuid
+
"|1|"
+
userinfo
;
String
sign
=
jr58MessageSigner
.
sign
(
param
);
Map
<
String
,
String
>
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"customerId"
,
uuid
)
.
put
(
"authorState"
,
"100"
)
.
put
(
"baseFlag"
,
"1"
)
.
put
(
"userinfo"
,
userinfo
)
.
put
(
"sign"
,
sign
)
.
build
();
httpService
.
post
(
jr58nNotifyUserinfo
,
parameters
);
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"向58金融同步用户信息"
,
e
);
}
}
}
src/main/java/cn/quantgroup/xyqb/event/jr58/Jr58MessageSigner.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
event
.
jr58
;
import
cn.quantgroup.cloudconfig.SafeValue
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
import
java.security.Signature
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.util.Base64
;
@Service
public
class
Jr58MessageSigner
{
private
PrivateKey
generatedSigningKey
;
@SafeValue
(
"jr58.sign.key"
)
private
String
signingKeySpec
;
@PostConstruct
private
void
init
()
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
signingKeySpec
))
return
;
byte
[]
keyBytes
=
Base64
.
getDecoder
().
decode
(
signingKeySpec
);
PKCS8EncodedKeySpec
pkcs8KeySpec
=
new
PKCS8EncodedKeySpec
(
keyBytes
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
generatedSigningKey
=
keyFactory
.
generatePrivate
(
pkcs8KeySpec
);
}
public
String
sign
(
String
s
)
throws
Exception
{
if
(
generatedSigningKey
==
null
)
return
""
;
byte
[]
data
=
s
.
getBytes
();
Signature
signature
=
Signature
.
getInstance
(
"MD5withRSA"
);
signature
.
initSign
(
generatedSigningKey
);
signature
.
update
(
data
);
byte
[]
signedBytes
=
signature
.
sign
();
return
Base64
.
getEncoder
().
encodeToString
(
signedBytes
);
}
}
src/main/java/cn/quantgroup/xyqb/event/jr58/Jr58Notifier.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
event
.
jr58
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.event.UserinfoChangedEvent
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.stereotype.Service
;
@Service
public
class
Jr58Notifier
implements
ApplicationListener
<
UserinfoChangedEvent
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Jr58Notifier
.
class
);
@Autowired
private
Jr58DataSender
jr58DataSender
;
@Autowired
private
IUserService
userService
;
@Override
public
void
onApplicationEvent
(
UserinfoChangedEvent
event
)
{
LOGGER
.
info
(
"向58金融同步信息, event:{}"
,
event
);
String
uuid
=
event
.
getUuid
();
Long
channelId
=
event
.
getChannelId
();
if
(
StringUtils
.
isEmpty
(
uuid
)
||
channelId
==
null
||
channelId
!=
Constants
.
Channel
.
JR58
)
{
return
;
}
User
user
=
userService
.
findByUuidWithCache
(
uuid
);
if
(
user
==
null
||
user
.
getRegisteredFrom
()
!=
Constants
.
Channel
.
JR58
)
{
return
;
}
jr58DataSender
.
sendUserinfo
(
uuid
);
}
}
src/main/java/cn/quantgroup/xyqb/model/jr58/Jr58Authorization.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
model
.
jr58
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* Created by Rocky on 2016/8/17.
*/
@Getter
@Setter
@ToString
public
class
Jr58Authorization
{
private
String
userId
;
private
String
sourceFrom
;
private
String
authorizationData
;
private
OperatorData
operator_data
;
@Getter
@Setter
public
static
class
OperatorData
{
private
OriginalData
originalData
;
private
ReportData
reportData
;
@Getter
@Setter
public
static
class
OriginalData
{
private
String
phone
;
private
PhoneData
phoneData
;
private
PhoneBillDataList
[]
phoneBillDataList
;
private
PhoneCallLogList
[]
phoneCallLogList
;
private
PhoneSmsLogList
[]
phoneSmsLogList
;
@Getter
@Setter
public
static
class
PhoneData
{
private
Long
id
;
private
String
phoneNum
;
private
String
serialNo
;
private
String
realName
;
private
String
idCard
;
private
String
sourceName
;
private
String
authorizeChannel
;
private
String
createTime
;
private
String
updateTime
;
}
@Getter
@Setter
public
static
class
PhoneBillDataList
{
private
String
localPhone
;
private
String
totalCost
;
private
String
planCost
;
private
String
yearMnth
;
private
String
authorizeChannel
;
}
@Getter
@Setter
public
static
class
PhoneCallLogList
{
private
String
localPhone
;
private
String
callPhone
;
private
String
callId
;
private
String
cost
;
private
String
callType
;
private
String
callStyle
;
private
String
callDuration
;
private
String
callTime
;
private
String
callAddress
;
private
String
authorizeChannel
;
}
@Getter
@Setter
public
static
class
PhoneSmsLogList
{
private
String
localPhone
;
private
String
otherPhone
;
private
String
sendId
;
private
String
totalCost
;
private
String
sendAddress
;
private
String
sendTime
;
private
String
authorizeChannel
;
}
}
@Getter
@Setter
public
static
class
ReportData
{
private
String
localPhone
;
private
Behavior
behavior
;
private
Check
check
;
private
CallList
[]
callList
;
private
ContactList
[]
contactList
;
private
OperatorList
[]
operatorList
;
private
RegionList
[]
regionList
;
private
ServiceList
[]
serviceList
;
private
TripConsumeList
[]
tripConsumeList
;
@Getter
@Setter
public
static
class
Behavior
{
private
String
localPhone
;
private
String
friendCircle
;
private
String
localLivingYear
;
private
String
powerOff
;
private
String
callMacao
;
private
String
call110
;
private
String
call120
;
private
String
callLawyer
;
private
String
callCourt
;
private
String
callLoan
;
private
String
callBank
;
private
String
callCredit
;
private
String
useTime
;
private
String
contactAmount
;
private
String
contactFrequency
;
private
String
livingLocation
;
private
String
workingLocation
;
private
String
nightUse
;
private
String
authorizeChannel
;
}
@Getter
@Setter
public
static
class
Check
{
private
String
localPhone
;
private
String
idCardValidate
;
private
String
operatorBinding
;
private
String
nameOperatorMatch
;
private
String
idcardOperatorMatch
;
private
String
nameIdcardBlack
;
private
String
namePhoneBlack
;
private
String
callContact
;
private
String
callHome
;
private
String
callWork
;
private
String
authorizeChannel
;
}
@Getter
@Setter
public
static
class
CallList
{
private
String
localPhone
;
private
String
phoneNum
;
private
String
attribution
;
private
String
contactName
;
private
String
needsType
;
private
String
callCount
;
private
String
callInCount
;
private
String
callOutCount
;
private
String
callTime
;
private
String
callInTime
;
private
String
callOutTime
;
private
String
relationSpeculate
;
private
String
contact1week
;
private
String
contact1month
;
private
String
contact3month
;
private
String
contact3monthMore
;
private
String
contactEarlyMorning
;
private
String
contactMorning
;
private
String
contactNoon
;
private
String
contactAfternoon
;
private
String
contactNight
;
private
String
contactWeekday
;
private
String
contactWeekend
;
private
String
contactHoliday
;
private
String
contactAllDay
;
private
String
authorizeChannel
;
}
@Setter
@Getter
public
static
class
ContactList
{
}
@Getter
@Setter
public
static
class
OperatorList
{
private
String
localPhone
;
private
String
operatorName
;
private
String
operatorZh
;
private
String
phoneNum
;
private
String
attribution
;
private
String
mnth
;
private
String
callCount
;
private
String
callInCount
;
private
String
callOutCount
;
private
String
callInTime
;
private
String
callOutTime
;
private
String
flow
;
private
String
smsCount
;
private
String
totalAmount
;
private
String
authorizeChannel
;
}
@Getter
@Setter
public
static
class
RegionList
{
private
String
localphone
;
private
String
regionName
;
private
String
numCount
;
private
String
callInCount
;
private
String
callOutCount
;
private
String
callInTime
;
private
String
callOutTime
;
private
String
callInAvg
;
private
String
callOutAvg
;
private
String
callInCountPct
;
private
String
callOutCountPct
;
private
String
callInTimePct
;
private
String
callOutTimePct
;
private
String
authorizeChannel
;
}
@Setter
@Getter
public
static
class
ServiceList
{
private
String
localPhone
;
private
String
companyName
;
private
String
companyType
;
private
String
contactTimes
;
private
String
contactMonth
;
private
String
contactTimesMonth
;
private
String
authorizeChannel
;
}
@Setter
@Getter
public
static
class
TripConsumeList
{
}
}
}
}
src/main/java/cn/quantgroup/xyqb/model/jr58/Jr58RegisterParam.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
model
.
jr58
;
import
cn.quantgroup.xyqb.model.IdCardInfo
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* @author mengfan.feng
* @time 2015-09-09 15:46
*/
@Getter
@Setter
@ToString
public
class
Jr58RegisterParam
{
private
String
wbId
;
// 58官方注册id
private
String
wbUserName
;
// 58用户名
private
String
customerId
;
// 量化派用户id
private
String
name
;
// 用户姓名
private
String
idcard
;
// 身份证号
private
String
email
;
// 用户邮箱
private
String
phone
;
// 手机号码
private
String
info
;
// 用户附加信息(用户是学生,那他的学校、专业之类;用户是上班族:公司之类)
private
String
roleId
;
// 角色id(用户职业:例如学生、上班族、企业主、网上店主)
private
String
flag
;
// 是否第一次登陆,第一次登陆:0;非第一次登陆:1,默认0
private
String
city
;
// 城市
private
String
accessMode
;
// 接入模式,openApi(目前的方式) weixin h5
private
String
appId
;
// 客户提供的appId
private
IdCardInfo
idCardInfo
;
// 证件信息
private
String
edu
;
// 学历 学历:B:硕士及以上 C:本科 D:专科 E::中专、高中 G:初中及以下
private
String
income
;
// 收入情况:3000以下:M1 3000~10000 :M2 10000~20000 : M3 20000以上 :M4
private
String
marry
;
// 婚姻状况 :A:已婚 B:未婚 C:离异 D:丧偶
private
String
monitorPhone
;
// 58监控请求属性,不存
/**** 授权*****/
private
String
account
;
//授权账号
private
String
authorizationType
;
//授权类型(运营商:1,支付宝:2)
/**** 授权*****/
}
src/main/java/cn/quantgroup/xyqb/model/jr58/Jr58RegisterResult.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
model
.
jr58
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
/**
* @author mengfan.feng
* @time 2015-09-11 09:54
*/
@Getter
@Setter
@ToString
public
class
Jr58RegisterResult
{
private
String
errorcode
;
private
Boolean
success
;
private
Boolean
hasUser
;
private
String
customerid
;
}
src/main/java/cn/quantgroup/xyqb/service/jr58/Jr58Service.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
service
.
jr58
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.jr58.Jr58Authorization
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
java.io.UnsupportedEncodingException
;
/**
* @author mengfan.feng
* @time 2015-09-09 16:43
*/
public
interface
Jr58Service
{
/**
* 用户注册
*
* @param param
* @return
*/
String
register
(
Jr58RegisterParam
param
);
/**
* 避免填写资料
*/
void
getRidOfFillingProfile
(
User
user
,
String
phoneNo
)
throws
UnsupportedEncodingException
;
/**
* 推送授权数据
*/
void
pushAuthorizationData
(
Jr58Authorization
authorizationData
);
/**
* 推送授权开始的状态
*
* @param userId
* @param account
* @param authorizationType
*/
void
pushAuthorizationStatus
(
String
userId
,
String
account
,
String
authorizationType
);
}
src/main/java/cn/quantgroup/xyqb/service/jr58/impl/Jr58ServiceImpl.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
service
.
jr58
.
impl
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserJr58
;
import
cn.quantgroup.xyqb.model.IdCardInfo
;
import
cn.quantgroup.xyqb.model.IdType
;
import
cn.quantgroup.xyqb.model.UserRegisterMqMessage
;
import
cn.quantgroup.xyqb.model.UserStatistics
;
import
cn.quantgroup.xyqb.model.jr58.Jr58Authorization
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserJr58Repository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.jr58.Jr58Service
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.util.GZipUtil
;
import
cn.quantgroup.xyqb.util.MqUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
javax.transaction.Transactional
;
import
java.io.UnsupportedEncodingException
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.util.Base64
;
import
java.util.Map
;
/**
* @author mengfan.feng
* @time 2015-09-09 16:46
*/
@Service
public
class
Jr58ServiceImpl
implements
Jr58Service
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Jr58ServiceImpl
.
class
);
@Autowired
private
ILkbUserService
lkbUserService
;
@Autowired
private
IUserJr58Repository
userJr58Repository
;
@Autowired
private
IHttpService
httpService
;
@Value
(
"${xyqb.api.url}"
)
private
String
apiUrl
;
@Value
(
"${lkb.import.url}"
)
private
String
pushImportForJr58Url
;
@Autowired
private
IUserRepository
userRepository
;
@Autowired
private
IUserDetailRepository
userDetailRepository
;
@Autowired
private
IIdCardService
idCardService
;
@Override
@Transactional
(
value
=
Transactional
.
TxType
.
REQUIRED
)
public
String
register
(
Jr58RegisterParam
param
)
{
String
uuid
;
User
user
=
userRepository
.
findByPhoneNo
(
param
.
getPhone
());
/***************** 用户是否在新系统存在 ********************/
if
(
user
!=
null
)
{
uuid
=
user
.
getUuid
();
return
uuid
;
}
/***************** 向老系统注册用户 ********************/
Jr58RegisterResult
result
=
lkbUserService
.
registerJr58
(
param
);
if
(
result
==
null
||
!
"0"
.
equals
(
result
.
getErrorcode
()))
{
LOGGER
.
warn
(
"向LKB注册58金融用户失败, param:{}"
,
param
);
return
""
;
}
/***************** 用户已经在老系统存在 ********************/
uuid
=
result
.
getCustomerid
();
/*if (result.getHasUser()) {
LOGGER.info("该用户已经在LKB系统中存在, uuid:{}", uuid);
return uuid;
}*/
/***************** 新用户 ********************/
LOGGER
.
info
(
"Save User:{}"
,
uuid
);
user
=
this
.
saveUser
(
param
,
uuid
);
if
(
user
==
null
)
{
throw
new
RuntimeException
(
"保存用户信息出错"
);
}
LOGGER
.
info
(
"Save UserDetail:{}"
,
user
.
getId
());
this
.
saveUserDetail
(
param
,
user
.
getId
());
LOGGER
.
info
(
"Save UserJr58:{}"
,
user
.
getId
());
this
.
saveUserJr58
(
param
,
user
.
getId
());
//增加登陆统计发送
UserStatistics
statistics
=
new
UserStatistics
(
user
,
null
,
2
,
user
.
getRegisteredFrom
());
MqUtils
.
sendLoanVest
(
statistics
);
LOGGER
.
info
(
"用户注册成功, registerFrom:{}, phoneNo:{}"
,
Constants
.
Channel
.
JR58
,
param
.
getPhone
());
//增加用户注册广播
UserRegisterMqMessage
registerMqMessage
=
new
UserRegisterMqMessage
(
user
);
MqUtils
.
sendRegisterMessage
(
registerMqMessage
);
return
uuid
;
}
@Override
public
void
getRidOfFillingProfile
(
User
user
,
String
phoneNo
)
throws
UnsupportedEncodingException
{
if
(
user
==
null
)
{
LOGGER
.
info
(
"58用户不存在"
);
return
;
}
Map
<
String
,
String
>
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"userId"
,
user
.
getId
().
toString
())
.
put
(
"key"
,
"abc1234"
)
.
put
(
"phoneNo"
,
phoneNo
)
.
build
();
LOGGER
.
info
(
"调用58保存用户贷款信息接口开始"
);
httpService
.
get
(
apiUrl
+
"/ex/auth-58/info"
,
parameters
);
LOGGER
.
info
(
"调用58保存用户贷款信息接口结束"
);
}
/**
* Save UserJr58
*
* @param param
* @param userId
*/
private
void
saveUserJr58
(
Jr58RegisterParam
param
,
Long
userId
)
{
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
UserJr58
userJr58
=
new
UserJr58
();
userJr58
.
setUserId
(
userId
);
userJr58
.
setWbId
(
param
.
getWbId
());
userJr58
.
setWbUserName
(
param
.
getWbUserName
());
userJr58
.
setCustomerId
(
param
.
getCustomerId
());
userJr58
.
setName
(
param
.
getName
());
userJr58
.
setIdcard
(
param
.
getIdcard
());
userJr58
.
setEmail
(
StringUtils
.
substring
(
param
.
getEmail
(),
0
,
50
));
userJr58
.
setPhone
(
param
.
getPhone
());
userJr58
.
setInfo
(
param
.
getInfo
());
userJr58
.
setRoleId
(
param
.
getRoleId
());
userJr58
.
setFlag
(
param
.
getFlag
());
userJr58
.
setCity
(
param
.
getCity
());
userJr58
.
setAccessMode
(
param
.
getAccessMode
());
userJr58
.
setAppId
(
param
.
getAppId
());
userJr58
.
setCreatedAt
(
currentTime
);
userJr58
.
setUpdatedAt
(
currentTime
);
userJr58
.
setEdu
(
param
.
getEdu
());
userJr58
.
setIncome
(
param
.
getIncome
());
userJr58
.
setMarry
(
param
.
getMarry
());
userJr58Repository
.
saveAndFlush
(
userJr58
);
}
/**
* Save UserDetail
*
* @param param
* @param userId
*/
private
void
saveUserDetail
(
Jr58RegisterParam
param
,
Long
userId
)
{
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
IdCardInfo
idCardInfo
=
param
.
getIdCardInfo
();
UserDetail
userDetail
=
new
UserDetail
();
userDetail
.
setUserId
(
userId
);
userDetail
.
setName
(
param
.
getName
());
userDetail
.
setPhoneNo
(
param
.
getPhone
());
userDetail
.
setIdNo
(
param
.
getIdcard
());
Timestamp
time
=
new
Timestamp
(
System
.
currentTimeMillis
());
userDetail
.
setCreatedAt
(
time
);
userDetail
.
setUpdatedAt
(
time
);
userDetail
.
setIdType
(
IdType
.
ID_CARD
);
try
{
userDetail
.
setGender
(
idCardService
.
getIdCardInfo
(
param
.
getIdcard
()).
getGender
());
}
catch
(
ParseException
e
)
{
LOGGER
.
error
(
"根据身份证获取性别出错,错误信息:"
+
e
);
}
userDetail
.
setEmail
(
StringUtils
.
substring
(
param
.
getEmail
(),
0
,
30
));
userDetailRepository
.
saveAndFlush
(
userDetail
);
}
/**
* Save User
*
* @param param
* @param uuid
*/
private
User
saveUser
(
Jr58RegisterParam
param
,
String
uuid
)
{
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
User
user
=
new
User
();
user
.
setPhoneNo
(
param
.
getPhone
());
user
.
setCreatedAt
(
currentTime
);
user
.
setUpdatedAt
(
currentTime
);
user
.
setEnable
(
true
);
user
.
setRegisteredFrom
(
Constants
.
Channel
.
JR58
);
user
.
setUuid
(
uuid
);
user
.
setPassword
(
""
);
user
=
userRepository
.
save
(
user
);
return
userRepository
.
saveAndFlush
(
user
);
}
/**
* 推送授权数据
*/
@Async
public
void
pushAuthorizationData
(
Jr58Authorization
authorizationData
)
{
LOGGER
.
info
(
"运营商授权数据推送到lkb开始"
);
Map
<
String
,
String
>
parameters
=
null
;
String
url
=
""
;
//量化派数据
if
(
"0"
.
equals
(
authorizationData
.
getSourceFrom
()))
{
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
)
.
put
(
"loginName"
,
authorizationData
.
getOperator_data
().
getOriginalData
().
getPhone
())
.
put
(
"currentUser"
,
authorizationData
.
getUserId
())
.
put
(
"userSource"
,
"YUNYINGSHANG"
)
.
build
();
url
=
pushImportForJr58Url
+
"/SpiderServer/api/dataTransfer/saveUserAuthInfo.json"
;
}
else
if
(
"1"
.
equals
(
authorizationData
.
getSourceFrom
()))
{
//读秒数据
//String graspingJson = Constants.GSON.toJson(authorizationData.getOperator_data());
String
graspingJson
=
JSONObject
.
toJSONString
(
authorizationData
.
getOperator_data
());
byte
[]
graspingJsonBytes
=
GZipUtil
.
compressToByte
(
graspingJson
);
String
authorizationDataStr
=
Base64
.
getEncoder
().
encodeToString
(
graspingJsonBytes
);
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
)
.
put
(
"data"
,
authorizationDataStr
)
.
put
(
"currentUser"
,
authorizationData
.
getUserId
())
.
put
(
"source"
,
"58"
)
.
build
();
url
=
pushImportForJr58Url
+
"/SpiderServer/api/dataTransfer/receive.json"
;
}
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
try
{
String
response
=
httpService
.
post
(
url
,
parameters
);
if
(
response
.
contains
(
",\"status\":1,"
))
{
LOGGER
.
info
(
"运营商授权数据推送到lkb成功"
);
break
;
}
else
{
Thread
.
sleep
(
2000
);
LOGGER
.
error
(
"运营商授权数据推送到lkb中失败 - {} ,userId ={}, response = {} url ={}"
,
i
+
1
,
authorizationData
.
getUserId
(),
response
,
url
);
}
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"运营商授权数据推送到失败 url ={}"
,
url
);
}
}
LOGGER
.
info
(
"运营商授权数据推送到lkb结束"
);
}
@Async
@Override
public
void
pushAuthorizationStatus
(
String
userId
,
String
account
,
String
authorizationType
)
{
LOGGER
.
info
(
"通知lkb授权成功- 开始"
);
Map
<
String
,
String
>
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
)
.
put
(
"loginName"
,
account
)
.
put
(
"currentUser"
,
userId
)
.
put
(
"userSource"
,
"YUNYINGSHANG"
)
.
build
();
String
url
=
pushImportForJr58Url
+
"/SpiderServer/api/dataTransfer/saveUserAuthInfo.json"
;
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
try
{
String
response
=
httpService
.
post
(
url
,
parameters
);
if
(
response
.
contains
(
",\"status\":1,"
))
{
LOGGER
.
info
(
"通知lkb授权成功"
);
break
;
}
else
{
Thread
.
sleep
(
2000
);
LOGGER
.
error
(
"通知lkb授权失败 - {} ,userId ={}, response = {} url ={}"
,
i
+
1
,
userId
,
response
,
url
);
}
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"通知lkb授权失败 url ={}"
,
url
);
}
}
LOGGER
.
info
(
"通知lkb授权- 结束"
);
}
}
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
502c3c50
...
...
@@ -9,21 +9,26 @@ import cn.quantgroup.xyqb.model.session.SessionStruct;
import
cn.quantgroup.xyqb.model.session.SessionValue
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.session.aspect.UserBtRegisterFill
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.impl.UserServiceImpl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Joiner
;
import
jdk.nashorn.internal.parser.JSONParser
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.SetOperations
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
javax.persistence.Cacheable
;
import
java.sql.Timestamp
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -33,138 +38,189 @@ import java.util.concurrent.TimeUnit;
@Service
public
class
SessionServiceImpl
implements
ISessionService
{
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Override
public
AuthBean
createSession
(
Long
channelId
,
Long
createdFrom
,
String
appChannel
,
User
user
,
Merchant
merchant
)
{
AuthBean
authBean
=
new
AuthBean
();
LoginProperties
properties
=
new
LoginProperties
();
properties
.
setAppChannel
(
appChannel
);
if
(
null
!=
merchant
){
properties
.
setMerchantName
(
merchant
.
getName
());
@Autowired
@Qualifier
(
"stringRedisTemplate"
)
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Autowired
private
IUserService
userService
;
@Override
public
AuthBean
createSession
(
Long
channelId
,
Long
createdFrom
,
String
appChannel
,
User
user
,
Merchant
merchant
)
{
AuthBean
authBean
=
new
AuthBean
();
LoginProperties
properties
=
new
LoginProperties
();
properties
.
setAppChannel
(
appChannel
);
if
(
null
!=
merchant
)
{
properties
.
setMerchantName
(
merchant
.
getName
());
}
properties
.
setChannelId
(
channelId
);
properties
.
setCreatedFrom
(
createdFrom
);
//找到用户
String
sessionId
=
findSessionIdByUserIdLoginProperties
(
user
.
getId
(),
properties
);
// String sessionId = sessionService.findSessionIdByUserIdAndMerchant(user.getId(), merchant);
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotEmpty
(
sessionId
))
{
SessionStruct
sessionStruct
=
findSessionBySessionId
(
sessionId
);
sessionStruct
.
setAttribute
(
"channelId"
,
String
.
valueOf
(
channelId
));
sessionStruct
.
setAttribute
(
"createdFrom"
,
String
.
valueOf
(
createdFrom
));
sessionStruct
.
setAttribute
(
"appChannel"
,
String
.
valueOf
(
appChannel
));
authBean
.
setPhoneNo
(
user
.
getPhoneNo
());
authBean
.
setToken
(
sessionStruct
.
getSid
());
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
log
.
info
(
"用户登录成功, loginFrom:{}, phoneNo:{},appChannel:{}"
,
createdFrom
,
user
.
getPhoneNo
(),
appChannel
);
return
authBean
;
}
SessionStruct
sessionStruct
=
createSessionAndPersist
(
user
,
properties
);
authBean
.
setPhoneNo
(
user
.
getPhoneNo
());
authBean
.
setToken
(
sessionStruct
.
getSid
());
log
.
info
(
"用户登录成功, loginFrom:{}, phoneNo:{},appChannel:{}"
,
createdFrom
,
user
.
getPhoneNo
(),
appChannel
);
return
authBean
;
}
@Override
public
SessionStruct
createSessionAndPersist
(
User
user
,
LoginProperties
properties
)
{
SessionStruct
sessionStruct
;
//获取sessionid
String
sessionId
=
findSessionIdByUserIdLoginProperties
(
user
.
getId
(),
properties
);
if
(
StringUtils
.
length
(
sessionId
)
==
36
)
{
sessionStruct
=
findSessionBySessionId
(
sessionId
);
if
(
sessionStruct
==
null
)
{
sessionStruct
=
newSession
(
user
,
properties
);
}
else
{
sessionStruct
.
getValues
().
setLoginProperties
(
properties
);
}
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
}
else
{
sessionStruct
=
newSession
(
user
,
properties
);
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
}
return
sessionStruct
;
}
properties
.
setChannelId
(
channelId
);
properties
.
setCreatedFrom
(
createdFrom
);
//找到用户
String
sessionId
=
findSessionIdByUserIdLoginProperties
(
user
.
getId
(),
properties
);
// String sessionId = sessionService.findSessionIdByUserIdAndMerchant(user.getId(), merchant);
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isNotEmpty
(
sessionId
))
{
SessionStruct
sessionStruct
=
findSessionBySessionId
(
sessionId
);
sessionStruct
.
setAttribute
(
"channelId"
,
String
.
valueOf
(
channelId
));
sessionStruct
.
setAttribute
(
"createdFrom"
,
String
.
valueOf
(
createdFrom
));
sessionStruct
.
setAttribute
(
"appChannel"
,
String
.
valueOf
(
appChannel
));
authBean
.
setPhoneNo
(
user
.
getPhoneNo
());
authBean
.
setToken
(
sessionStruct
.
getSid
());
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
log
.
info
(
"用户登录成功, loginFrom:{}, phoneNo:{},appChannel:{}"
,
createdFrom
,
user
.
getPhoneNo
(),
appChannel
);
return
authBean
;
@Override
public
String
findSessionIdByUserIdLoginProperties
(
Long
userId
,
LoginProperties
properties
)
{
return
stringRedisTemplate
.
opsForValue
().
get
(
generateLoginPropertiesKey
(
userId
,
properties
));
}
private
String
generateLoginPropertiesKey
(
Long
userId
,
LoginProperties
properties
)
{
if
(
"baitiao"
.
equals
(
properties
.
getMerchantName
()))
{
return
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":"
+
properties
.
getMerchantName
()
+
":"
+
properties
.
getCreatedFrom
();
}
else
{
return
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":"
+
properties
.
getMerchantName
();
}
}
SessionStruct
sessionStruct
=
createSessionAndPersist
(
user
,
properties
);
authBean
.
setPhoneNo
(
user
.
getPhoneNo
());
authBean
.
setToken
(
sessionStruct
.
getSid
());
log
.
info
(
"用户登录成功, loginFrom:{}, phoneNo:{},appChannel:{}"
,
createdFrom
,
user
.
getPhoneNo
(),
appChannel
);
return
authBean
;
}
@Override
public
SessionStruct
createSessionAndPersist
(
User
user
,
LoginProperties
properties
)
{
SessionStruct
sessionStruct
;
//获取sessionid
String
sessionId
=
findSessionIdByUserIdLoginProperties
(
user
.
getId
(),
properties
);
if
(
StringUtils
.
length
(
sessionId
)
==
36
)
{
sessionStruct
=
findSessionBySessionId
(
sessionId
);
if
(
sessionStruct
==
null
)
{
sessionStruct
=
newSession
(
user
,
properties
);
}
else
{
sessionStruct
.
getValues
().
setLoginProperties
(
properties
);
}
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
}
else
{
sessionStruct
=
newSession
(
user
,
properties
);
persistSession
(
sessionStruct
.
getSid
(),
sessionStruct
.
getValues
());
@Override
public
String
findSessionValueBySessionId
(
String
sessionId
)
{
String
result
=
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
Session
.
USER_SESSION_CACHE
+
sessionId
);
return
StringUtils
.
defaultString
(
result
,
""
);
}
return
sessionStruct
;
}
@Override
public
String
findSessionIdByUserIdLoginProperties
(
Long
userId
,
LoginProperties
properties
)
{
return
stringRedisTemplate
.
opsForValue
().
get
(
generateLoginPropertiesKey
(
userId
,
properties
));
}
private
String
generateLoginPropertiesKey
(
Long
userId
,
LoginProperties
properties
)
{
if
(
"baitiao"
.
equals
(
properties
.
getMerchantName
()))
{
return
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":"
+
properties
.
getMerchantName
()
+
":"
+
properties
.
getCreatedFrom
();
}
else
{
return
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":"
+
properties
.
getMerchantName
();
@Override
public
SessionStruct
newSession
(
User
user
,
LoginProperties
loginProperties
)
{
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
SessionStruct
sessionStruct
=
new
SessionStruct
();
SessionValue
sessionValue
=
new
SessionValue
();
sessionStruct
.
setSid
(
UUID
.
randomUUID
().
toString
());
sessionValue
.
setCreatedAt
(
now
);
sessionValue
.
setLastAccessTime
(
now
);
sessionValue
.
setUser
(
user
);
sessionValue
.
setLoginProperties
(
loginProperties
);
Map
<
String
,
String
>
values
=
new
HashMap
<>();
sessionValue
.
setValues
(
values
);
sessionStruct
.
setValues
(
sessionValue
);
return
sessionStruct
;
}
}
@Override
public
String
findSessionValueBySessionId
(
String
sessionId
)
{
String
result
=
stringRedisTemplate
.
opsForValue
().
get
(
Constants
.
Session
.
USER_SESSION_CACHE
+
sessionId
);
return
StringUtils
.
defaultString
(
result
,
""
);
}
@Override
public
SessionStruct
newSession
(
User
user
,
LoginProperties
loginProperties
)
{
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
SessionStruct
sessionStruct
=
new
SessionStruct
();
SessionValue
sessionValue
=
new
SessionValue
();
sessionStruct
.
setSid
(
UUID
.
randomUUID
().
toString
());
sessionValue
.
setCreatedAt
(
now
);
sessionValue
.
setLastAccessTime
(
now
);
sessionValue
.
setUser
(
user
);
sessionValue
.
setLoginProperties
(
loginProperties
);
Map
<
String
,
String
>
values
=
new
HashMap
<>();
sessionValue
.
setValues
(
values
);
sessionStruct
.
setValues
(
sessionValue
);
return
sessionStruct
;
}
@Override
@UserBtRegisterFill
public
void
persistSession
(
String
token
,
SessionValue
sessionValue
)
{
Timestamp
current
=
new
Timestamp
(
System
.
currentTimeMillis
());
sessionValue
.
setLastAccessTime
(
current
);
String
json
=
JSON
.
toJSONString
(
sessionValue
);
stringRedisTemplate
.
opsForValue
().
set
(
Constants
.
Session
.
USER_SESSION_CACHE
+
token
,
json
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
String
key
=
generateLoginPropertiesKey
(
sessionValue
.
getUser
().
getId
(),
sessionValue
.
getLoginProperties
());
stringRedisTemplate
.
opsForValue
().
set
(
key
,
token
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
}
@Override
public
SessionStruct
findSessionBySessionId
(
String
sessionId
)
{
String
sessionValue
=
findSessionValueBySessionId
(
sessionId
);
if
(
StringUtils
.
isEmpty
(
sessionValue
))
{
return
null
;
@Override
@UserBtRegisterFill
public
void
persistSession
(
String
token
,
SessionValue
sessionValue
)
{
Timestamp
current
=
new
Timestamp
(
System
.
currentTimeMillis
());
sessionValue
.
setLastAccessTime
(
current
);
String
json
=
JSON
.
toJSONString
(
sessionValue
);
stringRedisTemplate
.
opsForValue
().
set
(
Constants
.
Session
.
USER_SESSION_CACHE
+
token
,
json
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
String
key
=
generateLoginPropertiesKey
(
sessionValue
.
getUser
().
getId
(),
sessionValue
.
getLoginProperties
());
stringRedisTemplate
.
opsForValue
().
set
(
key
,
token
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
setUserIdTokenKeys
(
sessionValue
.
getUser
().
getId
(),
key
);
}
try
{
SessionValue
value
=
JSON
.
parseObject
(
sessionValue
,
SessionValue
.
class
);
if
(
null
==
value
)
{
return
null
;
}
SessionStruct
struct
=
new
SessionStruct
();
struct
.
setSid
(
sessionId
);
struct
.
setValues
(
value
);
return
struct
;
}
catch
(
Exception
ex
)
{
return
null
;
/**
* 设置用户token集合方便注销使用
*
* @param userId
* @param key
*/
private
void
setUserIdTokenKeys
(
long
userId
,
String
key
)
{
if
(
0L
!=
userId
)
{
try
{
stringRedisTemplate
.
opsForSet
().
add
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
,
key
);
stringRedisTemplate
.
expire
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"存储用户注销件失败,userId:{},Exception:{}"
,
userId
,
e
);
}
}
}
@Override
public
SessionStruct
findSessionBySessionId
(
String
sessionId
)
{
String
sessionValue
=
findSessionValueBySessionId
(
sessionId
);
if
(
StringUtils
.
isEmpty
(
sessionValue
))
{
return
null
;
}
try
{
SessionValue
value
=
JSON
.
parseObject
(
sessionValue
,
SessionValue
.
class
);
if
(
null
==
value
)
{
return
null
;
}
SessionStruct
struct
=
new
SessionStruct
();
struct
.
setSid
(
sessionId
);
struct
.
setValues
(
value
);
return
struct
;
}
catch
(
Exception
ex
)
{
return
null
;
}
}
@Override
@CacheEvict
(
value
=
"userextinfocache"
,
key
=
"'extinfo' + #userId"
,
cacheManager
=
"cacheManager"
)
public
void
deleteByUserId
(
long
userId
)
{
//1.删除session关联
Set
useIdKeys
=
stringRedisTemplate
.
opsForSet
().
members
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
);
if
(!
CollectionUtils
.
isEmpty
(
useIdKeys
))
{
useIdKeys
.
forEach
(
key
->
{
log
.
info
(
"删除用户userId={}的缓存信息"
,
userId
);
stringRedisTemplate
.
delete
(
String
.
valueOf
(
key
));
});
//2.删除session缓存健
stringRedisTemplate
.
delete
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
);
}
//3.删除用户查询缓存
User
user
=
userService
.
findById
(
userId
);
if
(
null
!=
user
)
{
deleteUserCatch
(
user
);
}
}
}
/**
* 删除注销后缓存查询结果
*
* @param user
*/
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #user.phoneNo"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #user.uuid"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"addresscache"
,
key
=
"'address' + #user.id"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact' + #user.id"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"userSpouseCache"
,
key
=
"'spouse' + #user.id"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"btRegisterCache"
,
key
=
"'userId' + #user.id"
,
cacheManager
=
"cacheManager"
)})
private
void
deleteUserCatch
(
User
user
)
{
@Override
public
void
deleteByUserId
(
long
userId
)
{
String
pattern
=
Constants
.
Session
.
USER_SESSION_ID_CACHE
+
":"
+
String
.
valueOf
(
userId
)
+
":*"
;
Set
<
String
>
keys
=
stringRedisTemplate
.
keys
(
pattern
);
if
(!
CollectionUtils
.
isEmpty
(
keys
))
{
log
.
info
(
"删除用户userId={}的缓存信息,个数:{},keys={}"
,
userId
,
keys
.
size
(),
Joiner
.
on
(
","
).
join
(
keys
));
}
stringRedisTemplate
.
delete
(
keys
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/ILkbUserService.java
View file @
502c3c50
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult
;
/**
* @author mengfan.feng
* @time 2015-08-19 17:44
...
...
@@ -18,14 +15,6 @@ public interface ILkbUserService {
*/
String
registerApp
(
String
phoneNo
,
String
password
);
/**
* 58金融用户注册
*
* @param param
* @return
*/
Jr58RegisterResult
registerJr58
(
Jr58RegisterParam
param
);
/**
* 同步用户信息
*
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/LkbUserviceImpl.java
View file @
502c3c50
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -39,9 +36,6 @@ public class LkbUserviceImpl implements ILkbUserService {
@Value
(
"${lkb.client.user.register.app}"
)
private
String
registerApp
;
@Value
(
"${lkb.client.user.register.58jr}"
)
private
String
register58jr
;
@Value
(
"${lkb.client.user.update}"
)
private
String
userUpdate
;
...
...
@@ -59,32 +53,14 @@ public class LkbUserviceImpl implements ILkbUserService {
.
build
();
String
response
=
httpService
.
get
(
clientUrl
+
registerApp
,
parameters
);
//Map<String, String> result = GSON.fromJson(response, Map.class);
Map
<
String
,
String
>
result
=
JSONObject
.
parseObject
(
response
,
Map
.
class
);
if
(
result
==
null
||
"0"
.
equals
(
result
.
get
(
"flag"
)))
{
LOGGER
.
warn
(
"向LKB注册用户失败, phoneNo:{}, password:{}"
,
phoneNo
,
password
);
return
""
;
}
//String uid = java.util.UUID.randomUUID().toString().replace("-","");
return
result
.
get
(
"uid"
);
}
@Override
public
Jr58RegisterResult
registerJr58
(
Jr58RegisterParam
param
)
{
Map
<
String
,
String
>
parameters
=
ImmutableMap
.<
String
,
String
>
builder
()
.
put
(
"wbId"
,
param
.
getWbId
())
.
put
(
"customerId"
,
param
.
getCustomerId
())
.
put
(
"name"
,
param
.
getName
())
.
put
(
"idcard"
,
param
.
getIdcard
())
.
put
(
"email"
,
StringUtils
.
substring
(
param
.
getEmail
(),
0
,
30
))
.
put
(
"phone"
,
param
.
getPhone
())
.
build
();
String
response
=
httpService
.
get
(
clientUrl
+
register58jr
,
parameters
);
//return GSON.fromJson(response, Jr58RegisterResult.class);
return
JSONObject
.
parseObject
(
response
,
Jr58RegisterResult
.
class
);
}
@Override
@Async
public
void
userUpdate
(
String
uuid
,
String
name
,
String
idNo
)
{
...
...
src/main/java/cn/quantgroup/xyqb/util/JR58GzipUtil.java
deleted
100644 → 0
View file @
af0f5572
package
cn
.
quantgroup
.
xyqb
.
util
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.nio.charset.Charset
;
import
java.util.zip.GZIPInputStream
;
import
java.util.zip.GZIPOutputStream
;
public
class
JR58GzipUtil
{
public
static
String
bytesTogzip
(
byte
[]
bytes
,
String
encode
)
{
if
(
bytes
==
null
||
bytes
.
length
==
0
)
{
return
null
;
}
ByteArrayInputStream
byteArrayIn
=
null
;
GZIPInputStream
in
=
null
;
ByteArrayOutputStream
byteArrayout
=
new
ByteArrayOutputStream
();
PrintStream
out
=
new
PrintStream
(
byteArrayout
);
try
{
byteArrayIn
=
new
ByteArrayInputStream
(
bytes
);
in
=
new
GZIPInputStream
(
byteArrayIn
);
byte
[]
b
=
new
byte
[
1024
];
int
readlen
=
0
;
;
while
((
readlen
=
in
.
read
(
b
))
!=
-
1
)
{
out
.
write
(
b
,
0
,
readlen
);
}
out
.
flush
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
out
.
close
();
in
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
System
.
out
.
println
(
"解密后的数据:"
);
return
new
String
(
byteArrayout
.
toByteArray
(),
Charset
.
forName
(
encode
));
}
public
static
byte
[]
gzipTobytes
(
String
str
,
String
encode
)
{
if
(
str
==
null
||
str
.
length
()
==
0
)
{
return
null
;
}
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
GZIPOutputStream
gzip
=
null
;
try
{
gzip
=
new
GZIPOutputStream
(
out
);
gzip
.
write
(
str
.
getBytes
(
encode
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
gzip
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
out
.
toByteArray
();
}
}
src/main/resources/config/dev/xyqb.properties
View file @
502c3c50
...
...
@@ -17,7 +17,7 @@ xyqb.filter.allowedHeaders=Origin, No-Cache, x-auth-token, X-Requested-With, If-
xyqb.data.redis.defaultExpiration
=
3600
# redis
xyqb.redis.master.host
=
192.168.4.
22
xyqb.redis.master.host
=
192.168.4.
153
xyqb.redis.master.port
=
6379
xyqb.redis.master.name
=
xyqb.redis.sentinel1.host
=
...
...
@@ -33,7 +33,6 @@ sms.is.debug=1
# LKB client
lkb.client.url
=
http://192.168.4.193:8083/LKBClient/openapi
lkb.client.user.register.app
=
/new/register/registerApp.json
lkb.client.user.register.58jr
=
/new/register/jr58/saveUserInfo.json
lkb.client.user.update
=
/new/register/updateUser.json
...
...
@@ -42,18 +41,12 @@ lkb.import.url=http://spider.quantgroup.cn
# LKB
lkb.url
=
http://192.168.192.251:8081/LKB
lkb.entrypoint.jr58
=
/jr58/arc_all.html
# xyqb
xyqb.url
=
http://192.168.192.163:8999
xyqb.api.url
=
http://192.168.192.163:9004
# JR58
jr58.sign.key
=
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKG/Y0J/c+JguU6cPdFHRC9eHrkgaZ9bpYpeQVujBpL+OkA8pAQTZ1XhoLZu/IH4Rv2kx85e8WVF7FxIFkgqJobjvai2XsD7QRYHGb6EEsqjROPndxnlpLeXmyp+WvbPhtRMoLyP3bZncaR1xsPkmW4ajXSUCa4+qlEfrEMskG79AgMBAAECgYAYmA5StSh8unJSxqULpkdy4F/RjGEjDv9by7sqYN6GCUv4KoBR8lVbFKSoOLYCWSsKND0BXyRbXsdyvK9Op8IVsKIbUnpen5V2cgNrVhlomy7E7RFSdoyFcRuWzck0NGtjJLPzi4qztiKprFH8yMf3tfD8aEKMo7pFpqetGfkezQJBANZTUTiGePRsiO7igin92jf9pWeSiI9OecQ/9hxwIlXXxQAwMUcvvyjoKfp6TRs3HlYugoiP/5VwTWRM/iTbf18CQQDBMtpKI5NtgrpfqbN2czP35S7VOnYO0QofEEuLj3oVCo2CxXfz0cViY/ng3BFk/oTykbMmS/TxCD5VHi17QRsjAkEAv9/3ZtN8ldZVAQhn35AUPOwnmIHnH+TxvnBEtVDubEuvYmvCsihcyxKOAmBbh3HhBua8leXUusS/hHwpSnX3oQJAc4eLTYZUpMnl1UrPjGd7jiO4i72310hduxGtezlDEc4LrUWUY3Lvi9SpGjO/GxuwOLWz4ZTOVkxNqeyv2eKm7QJAQHvgO0ciDFuFuhahFli7ktyZcn5CV8PPkQrbMXUFrMbX3AP61HPyH9EGCqBvsdyRYqPxFseDFY3yYveOWMPq0Q==
jr58.notify.userinfo
=
http://xfd.test.58v5.cn/customer/quantgroup_user_info
# 图形验证码
# 是否启用超级验证码 "__SUPERQG__", 用于测试环境自动化测试, 线上环境可忽略此参数
xyqb.auth.captcha.super.enable
=
1
...
...
src/main/resources/config/release01/application.properties
View file @
502c3c50
server.port
=
9001
security.sessions
=
if_required
server.session-timeout
=
51840
00
server.session-timeout
=
864
00
spring.aop.proxy-target-class
=
true
src/main/resources/config/release01/xyqb.properties
View file @
502c3c50
...
...
@@ -20,18 +20,14 @@ sms.is.debug=0
# LKB client
lkb.client.url
=
http://openapi.quantgroup.cn/LKBClient/openapi
lkb.client.user.register.app
=
/new/register/registerApp.json
lkb.client.user.register.58jr
=
/new/register/jr58/saveUserInfo.json
lkb.client.user.update
=
/new/register/updateUser.json
# LKB import
lkb.import.url
=
http://spider.quantgroup.cn
# LKB
lkb.url
=
http://58.xyqb.com/LKB
lkb.entrypoint.jr58
=
/jr58/arc_all.html
# xyqb
xyqb.url
=
https://m.xyqb.com
xyqb.api.url
=
http://api.xyqb.com
# JR58
jr58.notify.userinfo
=
http://dk.58.com/customer/quantgroup_user_info
#sdk
model.quantgroup.url
=
http://model.quantgroup.cn
xyqb.auth.url
=
http://auth.xyqb.com
...
...
src/main/resources/config/test/xyqb.properties
View file @
502c3c50
...
...
@@ -23,19 +23,14 @@ sms.is.debug=1
# LKB client
lkb.client.url
=
http://192.168.192.251:8082/LKBClient/openapi
lkb.client.user.register.app
=
/new/register/registerApp.json
lkb.client.user.register.58jr
=
/new/register/jr58/saveUserInfo.json
lkb.client.user.update
=
/new/register/updateUser.json
# LKB import
lkb.import.url
=
http://spider.quantgroup.cn
# LKB
lkb.url
=
http://192.168.192.251:8081/LKB
lkb.entrypoint.jr58
=
/jr58/arc_all.html
# xyqb
xyqb.url
=
http://192.168.192.206:8999
xyqb.api.url
=
http://192.168.192.206:9004
# JR58
jr58.sign.key
=
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKG/Y0J/c+JguU6cPdFHRC9eHrkgaZ9bpYpeQVujBpL+OkA8pAQTZ1XhoLZu/IH4Rv2kx85e8WVF7FxIFkgqJobjvai2XsD7QRYHGb6EEsqjROPndxnlpLeXmyp+WvbPhtRMoLyP3bZncaR1xsPkmW4ajXSUCa4+qlEfrEMskG79AgMBAAECgYAYmA5StSh8unJSxqULpkdy4F/RjGEjDv9by7sqYN6GCUv4KoBR8lVbFKSoOLYCWSsKND0BXyRbXsdyvK9Op8IVsKIbUnpen5V2cgNrVhlomy7E7RFSdoyFcRuWzck0NGtjJLPzi4qztiKprFH8yMf3tfD8aEKMo7pFpqetGfkezQJBANZTUTiGePRsiO7igin92jf9pWeSiI9OecQ/9hxwIlXXxQAwMUcvvyjoKfp6TRs3HlYugoiP/5VwTWRM/iTbf18CQQDBMtpKI5NtgrpfqbN2czP35S7VOnYO0QofEEuLj3oVCo2CxXfz0cViY/ng3BFk/oTykbMmS/TxCD5VHi17QRsjAkEAv9/3ZtN8ldZVAQhn35AUPOwnmIHnH+TxvnBEtVDubEuvYmvCsihcyxKOAmBbh3HhBua8leXUusS/hHwpSnX3oQJAc4eLTYZUpMnl1UrPjGd7jiO4i72310hduxGtezlDEc4LrUWUY3Lvi9SpGjO/GxuwOLWz4ZTOVkxNqeyv2eKm7QJAQHvgO0ciDFuFuhahFli7ktyZcn5CV8PPkQrbMXUFrMbX3AP61HPyH9EGCqBvsdyRYqPxFseDFY3yYveOWMPq0Q==
jr58.notify.userinfo
=
http://xfd.test.58v5.cn/customer/quantgroup_user_info
# 图形验证码
# 是否启用超级验证码 "__SUPERQG__", 用于测试环境自动化测试, 线上环境可忽略此参数
xyqb.auth.captcha.super.enable
=
1
...
...
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