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
7b1f65a7
Commit
7b1f65a7
authored
Nov 06, 2017
by
Java—KA—李 青
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除58jr相关代码
parent
fd11fad2
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
0 additions
and
1219 deletions
+0
-1219
Jr58Controller.java
...ntgroup/xyqb/controller/external/user/Jr58Controller.java
+0
-291
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
ILkbUserService.java
...java/cn/quantgroup/xyqb/service/user/ILkbUserService.java
+0
-11
LkbUserviceImpl.java
...cn/quantgroup/xyqb/service/user/impl/LkbUserviceImpl.java
+0
-21
JR58GzipUtil.java
src/main/java/cn/quantgroup/xyqb/util/JR58GzipUtil.java
+0
-71
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/Jr58Controller.java
deleted
100644 → 0
View file @
fd11fad2
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/event/UserinfoChangedEvent.java
deleted
100644 → 0
View file @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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 @
fd11fad2
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/user/ILkbUserService.java
View file @
7b1f65a7
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterParam
;
import
cn.quantgroup.xyqb.model.jr58.Jr58RegisterResult
;
/**
/**
* @author mengfan.feng
* @author mengfan.feng
* @time 2015-08-19 17:44
* @time 2015-08-19 17:44
...
@@ -18,14 +15,6 @@ public interface ILkbUserService {
...
@@ -18,14 +15,6 @@ public interface ILkbUserService {
*/
*/
String
registerApp
(
String
phoneNo
,
String
password
);
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 @
7b1f65a7
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.Constants
;
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.http.IHttpService
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -59,32 +56,14 @@ public class LkbUserviceImpl implements ILkbUserService {
...
@@ -59,32 +56,14 @@ public class LkbUserviceImpl implements ILkbUserService {
.
build
();
.
build
();
String
response
=
httpService
.
get
(
clientUrl
+
registerApp
,
parameters
);
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
);
Map
<
String
,
String
>
result
=
JSONObject
.
parseObject
(
response
,
Map
.
class
);
if
(
result
==
null
||
"0"
.
equals
(
result
.
get
(
"flag"
)))
{
if
(
result
==
null
||
"0"
.
equals
(
result
.
get
(
"flag"
)))
{
LOGGER
.
warn
(
"向LKB注册用户失败, phoneNo:{}, password:{}"
,
phoneNo
,
password
);
LOGGER
.
warn
(
"向LKB注册用户失败, phoneNo:{}, password:{}"
,
phoneNo
,
password
);
return
""
;
return
""
;
}
}
//String uid = java.util.UUID.randomUUID().toString().replace("-","");
return
result
.
get
(
"uid"
);
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
@Override
@Async
@Async
public
void
userUpdate
(
String
uuid
,
String
name
,
String
idNo
)
{
public
void
userUpdate
(
String
uuid
,
String
name
,
String
idNo
)
{
...
...
src/main/java/cn/quantgroup/xyqb/util/JR58GzipUtil.java
deleted
100644 → 0
View file @
fd11fad2
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
();
}
}
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