Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
customer-service
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
QG
customer-service
Commits
beb0581e
Commit
beb0581e
authored
Dec 31, 2019
by
xiaozhe.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加还款记录查询接口
parent
c3d647ea
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
347 additions
and
3 deletions
+347
-3
pom.xml
pom.xml
+15
-0
RestConfig.java
...n/java/cn/quantgroup/customer/config/rest/RestConfig.java
+71
-3
BusinessException.java
...a/cn/quantgroup/customer/exception/BusinessException.java
+38
-0
RepayRest.java
src/main/java/cn/quantgroup/customer/rest/RepayRest.java
+39
-0
RepayOrderQuery.java
...quantgroup/customer/rest/param/repay/RepayOrderQuery.java
+12
-0
IRepayService.java
...in/java/cn/quantgroup/customer/service/IRepayService.java
+7
-0
IUserService.java
...ain/java/cn/quantgroup/customer/service/IUserService.java
+2
-0
IXyqbService.java
...ain/java/cn/quantgroup/customer/service/IXyqbService.java
+7
-0
RestTemplateServiceImpl.java
...tgroup/customer/service/http/RestTemplateServiceImpl.java
+2
-0
RepayServiceImpl.java
...cn/quantgroup/customer/service/impl/RepayServiceImpl.java
+50
-0
UserSdkImpl.java
...java/cn/quantgroup/customer/service/impl/UserSdkImpl.java
+37
-0
UserServiceImpl.java
.../cn/quantgroup/customer/service/impl/UserServiceImpl.java
+21
-0
XyqbServiceImpl.java
.../cn/quantgroup/customer/service/impl/XyqbServiceImpl.java
+46
-0
No files found.
pom.xml
View file @
beb0581e
...
...
@@ -197,6 +197,21 @@
<artifactId>
fastjson
</artifactId>
<version>
1.2.62
</version>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
quantgroup-user-sdk
</artifactId>
<version>
1.1.0
</version>
<exclusions>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
brave-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
shutdown-spring-boot-starter
</artifactId>
...
...
src/main/java/cn/quantgroup/customer/config/rest/RestConfig.java
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
config
.
rest
;
import
cn.quantgroup.tech.brave.service.ITechHttpClient
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.config.CookieSpecs
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.config.Registry
;
import
org.apache.http.config.RegistryBuilder
;
import
org.apache.http.conn.ConnectionKeepAliveStrategy
;
import
org.apache.http.conn.socket.ConnectionSocketFactory
;
import
org.apache.http.conn.socket.LayeredConnectionSocketFactory
;
import
org.apache.http.conn.socket.PlainConnectionSocketFactory
;
import
org.apache.http.conn.ssl.AllowAllHostnameVerifier
;
import
org.apache.http.conn.ssl.NoopHostnameVerifier
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.conn.ssl.TrustStrategy
;
import
org.apache.http.impl.client.DefaultServiceUnavailableRetryStrategy
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.cookie.Cookie
;
import
org.apache.http.cookie.CookieOrigin
;
import
org.apache.http.cookie.CookieSpecProvider
;
import
org.apache.http.impl.client.*
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.apache.http.impl.cookie.BestMatchSpecFactory
;
import
org.apache.http.impl.cookie.BrowserCompatSpec
;
import
org.apache.http.impl.cookie.BrowserCompatSpecFactory
;
import
org.apache.http.ssl.SSLContextBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpRequest
;
...
...
@@ -26,6 +38,9 @@ import org.springframework.web.client.RestTemplate;
import
javax.net.ssl.SSLContext
;
import
java.io.IOException
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
import
java.security.NoSuchAlgorithmException
;
import
static
cn
.
quantgroup
.
customer
.
constant
.
Constant
.
HTTP
;
import
static
cn
.
quantgroup
.
customer
.
constant
.
Constant
.
HTTPS
;
...
...
@@ -33,7 +48,14 @@ import static cn.quantgroup.customer.constant.Constant.HTTPS;
@Configuration
public
class
RestConfig
{
@Bean
private
static
final
int
SO_TIME_OUT
=
60
*
1000
;
private
static
final
int
TIME_OUT
=
15
*
1000
;
@Autowired
@Qualifier
(
"techHttpClient"
)
private
ITechHttpClient
techHttpClient
;
@Bean
(
"commonRestTemplate"
)
public
RestTemplate
sslRestTemplate
()
{
SSLContext
sslContext
;
try
{
...
...
@@ -100,4 +122,50 @@ public class RestConfig {
}
}
@Bean
(
name
=
"httpClient"
)
public
CloseableHttpClient
httpClient
()
throws
KeyStoreException
,
NoSuchAlgorithmException
,
KeyManagementException
{
// socket factory
ConnectionSocketFactory
plainSocketFactory
=
new
PlainConnectionSocketFactory
();
SSLContext
sslContext
=
new
org
.
apache
.
http
.
conn
.
ssl
.
SSLContextBuilder
().
loadTrustMaterial
(
null
,
(
x509Certificates
,
authType
)
->
true
).
build
();
LayeredConnectionSocketFactory
sslSocketFactory
=
new
SSLConnectionSocketFactory
(
sslContext
,
new
AllowAllHostnameVerifier
());
Registry
<
ConnectionSocketFactory
>
socketFactoryRegistry
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
.
register
(
"http"
,
plainSocketFactory
)
.
register
(
"https"
,
sslSocketFactory
).
build
();
// cookie specification
Registry
<
CookieSpecProvider
>
cookieSpecProviderRegistry
=
RegistryBuilder
.<
CookieSpecProvider
>
create
()
.
register
(
CookieSpecs
.
BEST_MATCH
,
new
BestMatchSpecFactory
())
.
register
(
CookieSpecs
.
BROWSER_COMPATIBILITY
,
new
BrowserCompatSpecFactory
())
.
register
(
"easy"
,
httpContext
->
new
BrowserCompatSpec
()
{
public
void
validate
(
Cookie
cookie
,
CookieOrigin
origin
)
{
}
}).
build
();
// connection manager
PoolingHttpClientConnectionManager
connectionManager
=
new
PoolingHttpClientConnectionManager
(
socketFactoryRegistry
);
connectionManager
.
setMaxTotal
(
10000
);
connectionManager
.
setDefaultMaxPerRoute
(
1000
);
// retry handler
org
.
apache
.
http
.
client
.
HttpRequestRetryHandler
retryHandler
=
new
StandardHttpRequestRetryHandler
(
3
,
false
);
// keep alive strategy
ConnectionKeepAliveStrategy
keepAliveStrategy
=
new
DefaultConnectionKeepAliveStrategy
();
// httpclient
return
techHttpClient
.
createHttpClientBuilder
()
.
setConnectionManager
(
connectionManager
)
.
setRetryHandler
(
retryHandler
)
.
setKeepAliveStrategy
(
keepAliveStrategy
).
setDefaultRequestConfig
(
RequestConfig
.
custom
()
.
setConnectTimeout
(
TIME_OUT
)
.
setSocketTimeout
(
SO_TIME_OUT
)
.
setConnectionRequestTimeout
(
TIME_OUT
)
.
build
())
.
setDefaultCookieSpecRegistry
(
cookieSpecProviderRegistry
).
build
();
}
}
src/main/java/cn/quantgroup/customer/exception/BusinessException.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
exception
;
import
cn.quantgroup.customer.enums.ErrorCodeEnum
;
public
class
BusinessException
extends
RuntimeException
{
private
Long
code
;
private
ErrorCodeEnum
type
;
public
BusinessException
()
{
super
();
}
public
BusinessException
(
ErrorCodeEnum
type
)
{
super
(
type
.
getMessage
());
this
.
code
=
type
.
getCode
();
this
.
type
=
type
;
}
public
BusinessException
(
Long
code
,
String
message
)
{
super
(
message
);
this
.
code
=
code
;
}
public
BusinessException
(
String
message
)
{
super
(
message
);
}
public
Long
getCode
()
{
return
code
;
}
public
ErrorCodeEnum
getType
()
{
return
type
;
}
}
src/main/java/cn/quantgroup/customer/rest/RepayRest.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
rest
;
import
cn.quantgroup.customer.enums.ErrorCodeEnum
;
import
cn.quantgroup.customer.rest.param.repay.RepayOrderQuery
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.service.IRepayService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
static
cn
.
quantgroup
.
customer
.
constant
.
Constant
.
GSON
;
@Slf4j
@RestController
@RequestMapping
(
"/repay"
)
public
class
RepayRest
{
private
final
IRepayService
repayService
;
@Autowired
public
RepayRest
(
IRepayService
repayService
)
{
this
.
repayService
=
repayService
;
}
@GetMapping
(
"/repayment/repay_orders"
)
public
JsonResult
repayOrders
(
String
phoneNo
,
String
idNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
)
&&
StringUtils
.
isEmpty
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
ErrorCodeEnum
.
PARAM_ERROR
.
getMessage
(),
ErrorCodeEnum
.
PARAM_ERROR
.
getCode
());
}
RepayOrderQuery
repayOrderQuery
=
new
RepayOrderQuery
();
repayOrderQuery
.
setPhoneNo
(
phoneNo
);
repayOrderQuery
.
setIdNo
(
idNo
);
String
response
=
repayService
.
findRepayOrders
(
repayOrderQuery
);
return
GSON
.
fromJson
(
response
,
JsonResult
.
class
);
}
}
src/main/java/cn/quantgroup/customer/rest/param/repay/RepayOrderQuery.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
rest
.
param
.
repay
;
import
lombok.Data
;
import
lombok.ToString
;
@Data
@ToString
public
class
RepayOrderQuery
{
private
String
phoneNo
;
private
String
idNo
;
private
Long
userId
;
}
src/main/java/cn/quantgroup/customer/service/IRepayService.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
service
;
import
cn.quantgroup.customer.rest.param.repay.RepayOrderQuery
;
public
interface
IRepayService
{
String
findRepayOrders
(
RepayOrderQuery
repayOrderQuery
);
}
src/main/java/cn/quantgroup/customer/service/IUserService.java
View file @
beb0581e
...
...
@@ -15,4 +15,6 @@ public interface IUserService extends UserDetailsService {
String
modifyPhoneFeedback
(
ModifyPhoneFeedback
modifyPhoneFeedback
);
String
findUuidByIdNo
(
String
idNo
);
}
src/main/java/cn/quantgroup/customer/service/IXyqbService.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
service
;
import
cn.quantgroup.customer.rest.param.repay.RepayOrderQuery
;
public
interface
IXyqbService
{
String
findRepayOrders
(
RepayOrderQuery
repayOrderQuery
);
}
src/main/java/cn/quantgroup/customer/service/http/RestTemplateServiceImpl.java
View file @
beb0581e
...
...
@@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
...
...
@@ -27,6 +28,7 @@ public class RestTemplateServiceImpl implements IHttpService {
private
static
final
String
LEFT_BRACES
=
"{"
,
RIGHT_BRACES
=
"}"
,
Q_MARK
=
"?"
;
@Autowired
@Qualifier
(
"commonRestTemplate"
)
private
RestTemplate
restTemplate
;
...
...
src/main/java/cn/quantgroup/customer/service/impl/RepayServiceImpl.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.quantgroup.customer.enums.ErrorCodeEnum
;
import
cn.quantgroup.customer.exception.BusinessException
;
import
cn.quantgroup.customer.rest.param.repay.RepayOrderQuery
;
import
cn.quantgroup.customer.service.IRepayService
;
import
cn.quantgroup.customer.service.IUserService
;
import
cn.quantgroup.customer.service.IXyqbService
;
import
cn.quantgroup.user.retbean.XUser
;
import
cn.quantgroup.user.vo.UserSysResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Slf4j
@Service
(
"repayService"
)
public
class
RepayServiceImpl
implements
IRepayService
{
private
final
IUserService
userService
;
private
final
UserSdkImpl
userSdk
;
private
final
IXyqbService
xyqbService
;
@Autowired
public
RepayServiceImpl
(
IUserService
userService
,
UserSdkImpl
userSdk
,
IXyqbService
xyqbService
)
{
this
.
userService
=
userService
;
this
.
userSdk
=
userSdk
;
this
.
xyqbService
=
xyqbService
;
}
@Override
public
String
findRepayOrders
(
RepayOrderQuery
repayOrderQuery
)
{
String
phoneNo
=
repayOrderQuery
.
getPhoneNo
();
String
idNo
=
repayOrderQuery
.
getIdNo
();
if
(
StringUtils
.
isEmpty
(
phoneNo
)
&&
StringUtils
.
isEmpty
(
idNo
))
{
throw
new
BusinessException
(
ErrorCodeEnum
.
PARAM_ERROR
);
}
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
String
uuid
=
userService
.
findUuidByIdNo
(
idNo
);
UserSysResult
<
XUser
>
userUserSysResult
=
userSdk
.
getService
().
findUserByUuid
(
uuid
);
if
(!
userUserSysResult
.
isSuccess
())
{
throw
new
BusinessException
(
ErrorCodeEnum
.
RETURN_ERROR
);
}
Long
userId
=
userUserSysResult
.
getData
().
getId
();
repayOrderQuery
.
setUserId
(
userId
);
}
return
xyqbService
.
findRepayOrders
(
repayOrderQuery
);
}
}
src/main/java/cn/quantgroup/customer/service/impl/UserSdkImpl.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.quantgroup.user.IUserSdkService
;
import
cn.quantgroup.user.UserSdkServiceFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
@Service
@Slf4j
public
class
UserSdkImpl
{
@Autowired
@Qualifier
(
"httpClient"
)
private
CloseableHttpClient
httpClient
;
@Value
(
"${passportapi.http}"
)
private
String
passportapiHttp
;
private
IUserSdkService
userSdkService
;
@PostConstruct
private
void
init
()
{
userSdkService
=
UserSdkServiceFactory
.
generateSDKService
(
passportapiHttp
,
httpClient
);
}
public
IUserSdkService
getService
()
{
return
userSdkService
;
}
}
src/main/java/cn/quantgroup/customer/service/impl/UserServiceImpl.java
View file @
beb0581e
...
...
@@ -8,6 +8,7 @@ import cn.quantgroup.customer.repo.UserRepo;
import
cn.quantgroup.customer.rest.param.phone.ModifyPhoneAudit
;
import
cn.quantgroup.customer.rest.param.phone.ModifyPhoneFeedback
;
import
cn.quantgroup.customer.rest.param.phone.ModifyPhoneQuery
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.service.IUserService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
cn.quantgroup.riskcontrol.model.AuthenticationUserDetail
;
...
...
@@ -105,4 +106,24 @@ public class UserServiceImpl implements IUserService {
throw
new
NetCommunicationException
(
ErrorCodeEnum
.
NET_ERROR
.
getMessage
());
}
}
@Override
public
String
findUuidByIdNo
(
String
idNo
)
{
String
url
=
userSysUrl
+
"/innerapi/fetchUuid"
;
try
{
Map
<
String
,
Object
>
param
=
Maps
.
newHashMap
();
param
.
put
(
"idNo"
,
idNo
);
Map
<
String
,
String
>
header
=
Maps
.
newHashMap
();
header
.
put
(
"Content-type"
,
"application/json"
);
String
result
=
httpService
.
post
(
url
,
header
,
param
);
log
.
info
(
"[user][query uuid by idNo ] 请求业务系统返回值:{}"
,
result
);
JsonResult
jsonResult
=
GSON
.
fromJson
(
result
,
JsonResult
.
class
);
Object
uuid
=
jsonResult
.
getData
();
return
String
.
valueOf
(
uuid
);
}
catch
(
Exception
e
)
{
log
.
error
(
"[user][query uuid by idNo ] 网络通讯异常,idNo:{},ex:{}"
,
idNo
,
ExceptionUtils
.
getStackTrace
(
e
));
throw
new
NetCommunicationException
(
ErrorCodeEnum
.
NET_ERROR
.
getMessage
());
}
}
}
src/main/java/cn/quantgroup/customer/service/impl/XyqbServiceImpl.java
0 → 100644
View file @
beb0581e
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.quantgroup.customer.rest.param.repay.RepayOrderQuery
;
import
cn.quantgroup.customer.service.IXyqbService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
import
java.util.Objects
;
@Slf4j
@Service
(
"xyqbService"
)
public
class
XyqbServiceImpl
implements
IXyqbService
{
@Value
(
"${api.http}"
)
private
String
xyqbSysUrl
;
private
final
IHttpService
httpService
;
@Autowired
public
XyqbServiceImpl
(
IHttpService
httpService
)
{
this
.
httpService
=
httpService
;
}
@Override
public
String
findRepayOrders
(
RepayOrderQuery
repayOrderQuery
)
{
String
phoneNo
=
repayOrderQuery
.
getPhoneNo
();
Long
userId
=
repayOrderQuery
.
getUserId
();
String
url
=
xyqbSysUrl
+
"/ex/repayment/repay_orders"
;
Map
<
String
,
Object
>
param
=
Maps
.
newHashMap
();
if
(
StringUtils
.
isNotEmpty
(
phoneNo
))
{
param
.
put
(
"phoneNo"
,
phoneNo
);
}
if
(
Objects
.
nonNull
(
userId
))
{
param
.
put
(
"userId"
,
userId
);
}
String
response
=
httpService
.
get
(
url
,
param
);
log
.
info
(
"[xyqb][query repay orders ] param:{},请求业务系统返回值:{}"
,
param
,
response
);
return
response
;
}
}
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