Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
holmes
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
QA
holmes
Commits
b43bc524
Commit
b43bc524
authored
Apr 30, 2021
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增新橙mock
parent
a9a25331
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
1708 additions
and
0 deletions
+1708
-0
InterceptorConfig.java
src/main/java/cn/qg/holmes/config/InterceptorConfig.java
+7
-0
EncryptFactory.java
src/main/java/cn/qg/holmes/encrypt/EncryptFactory.java
+2
-0
XinchengEncryptConvertor.java
...n/java/cn/qg/holmes/encrypt/XinchengEncryptConvertor.java
+49
-0
Base64.java
src/main/java/cn/qg/holmes/encrypt/xincheng/Base64.java
+580
-0
ConfigureEncryptAndDecrypt.java
...g/holmes/encrypt/xincheng/ConfigureEncryptAndDecrypt.java
+9
-0
ConvertUtils.java
...main/java/cn/qg/holmes/encrypt/xincheng/ConvertUtils.java
+351
-0
Digest.java
src/main/java/cn/qg/holmes/encrypt/xincheng/Digest.java
+163
-0
RSA.java
src/main/java/cn/qg/holmes/encrypt/xincheng/RSA.java
+318
-0
CashOrder.java
src/main/java/cn/qg/holmes/entity/xincheng/CashOrder.java
+19
-0
RepaymentVo.java
src/main/java/cn/qg/holmes/entity/xincheng/RepaymentVo.java
+27
-0
XinchengInterceptor.java
...in/java/cn/qg/holmes/interceptor/XinchengInterceptor.java
+183
-0
No files found.
src/main/java/cn/qg/holmes/config/InterceptorConfig.java
View file @
b43bc524
package
cn
.
qg
.
holmes
.
config
;
package
cn
.
qg
.
holmes
.
config
;
import
cn.qg.holmes.interceptor.RuleEngineInterceptor
;
import
cn.qg.holmes.interceptor.RuleEngineInterceptor
;
import
cn.qg.holmes.interceptor.XinchengInterceptor
;
import
cn.qg.holmes.interceptor.YeebaoInterceptor
;
import
cn.qg.holmes.interceptor.YeebaoInterceptor
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -23,9 +24,15 @@ public class InterceptorConfig implements WebMvcConfigurer {
...
@@ -23,9 +24,15 @@ public class InterceptorConfig implements WebMvcConfigurer {
return
new
RuleEngineInterceptor
();
return
new
RuleEngineInterceptor
();
}
}
@Bean
public
XinchengInterceptor
xinchengInterceptor
()
{
return
new
XinchengInterceptor
();
}
@Override
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
yeebaoInterceptor
()).
addPathPatterns
(
"/tzt-api/**"
,
"/balance-board/**"
);
registry
.
addInterceptor
(
yeebaoInterceptor
()).
addPathPatterns
(
"/tzt-api/**"
,
"/balance-board/**"
);
registry
.
addInterceptor
(
ruleEngineInterceptor
()).
addPathPatterns
(
"/rule_engine/**"
);
registry
.
addInterceptor
(
ruleEngineInterceptor
()).
addPathPatterns
(
"/rule_engine/**"
);
registry
.
addInterceptor
(
xinchengInterceptor
()).
addPathPatterns
(
"/webservice/api/lhp/**"
);
}
}
}
}
src/main/java/cn/qg/holmes/encrypt/EncryptFactory.java
View file @
b43bc524
...
@@ -12,6 +12,8 @@ public class EncryptFactory {
...
@@ -12,6 +12,8 @@ public class EncryptFactory {
if
(
"yeebao"
.
equals
(
type
))
{
if
(
"yeebao"
.
equals
(
type
))
{
// return new YeebaoEncryptConvertor();
// return new YeebaoEncryptConvertor();
return
ApplicationContextUtils
.
getBean
(
"yeebaoEncryptConvertor"
);
return
ApplicationContextUtils
.
getBean
(
"yeebaoEncryptConvertor"
);
}
else
if
(
"xincheng"
.
equals
(
type
))
{
return
ApplicationContextUtils
.
getBean
(
"xinchengEncryptConvertor"
);
}
else
{
}
else
{
log
.
info
(
"请输入正确的加密类型类型!"
);
log
.
info
(
"请输入正确的加密类型类型!"
);
return
null
;
return
null
;
...
...
src/main/java/cn/qg/holmes/encrypt/XinchengEncryptConvertor.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
encrypt
;
import
cn.qg.holmes.encrypt.xincheng.Base64
;
import
cn.qg.holmes.encrypt.xincheng.RSA
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.base.Charsets
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.Map
;
@Slf4j
@Component
public
class
XinchengEncryptConvertor
implements
EncryptConvertor
{
@Value
(
"${xincheng.fund.public.key}"
)
private
String
xinchengPublicKey
;
@Value
(
"${xincheng.lhp.private.key}"
)
private
String
lhpPrivateKey
;
@Override
public
String
encrypt
(
String
response
)
{
String
encodeData
;
try
{
encodeData
=
new
String
(
Base64
.
encodeBase64
(
RSA
.
encryptByPrivateKey
(
response
.
getBytes
(),
lhpPrivateKey
)),
Charsets
.
UTF_8
);
}
catch
(
Exception
e
)
{
log
.
error
(
"encrypt,encrypt request is error "
,
e
);
throw
new
RuntimeException
(
"加密失败!"
);
}
return
encodeData
;
}
@Override
public
String
decrypt
(
String
request
)
{
String
decodeData
;
Map
<
String
,
Object
>
requestMap
=
JSON
.
parseObject
(
request
,
Map
.
class
);
String
requestStr
=
JSON
.
toJSONString
(
requestMap
.
get
(
"content"
));
try
{
decodeData
=
new
String
(
RSA
.
decryptByPublicKey
(
Base64
.
decodeBase64
(
requestStr
.
getBytes
()),
xinchengPublicKey
),
Charsets
.
UTF_8
);
}
catch
(
Exception
e
)
{
log
.
error
(
"decrypt, decrypt response is error "
,
e
);
throw
new
RuntimeException
(
"解密新橙响应结果失败!"
);
}
return
decodeData
;
}
}
src/main/java/cn/qg/holmes/encrypt/xincheng/Base64.java
0 → 100644
View file @
b43bc524
This diff is collapsed.
Click to expand it.
src/main/java/cn/qg/holmes/encrypt/xincheng/ConfigureEncryptAndDecrypt.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
encrypt
.
xincheng
;
public
class
ConfigureEncryptAndDecrypt
{
public
static
final
String
CHAR_ENCODING
=
"UTF-8"
;
public
static
final
String
AES_ALGORITHM
=
"AES/ECB/PKCS5Padding"
;
public
static
final
String
RSA_ALGORITHM
=
"RSA/ECB/PKCS1Padding"
;
public
static
final
String
RSA_KEY_ALGORITHM
=
"RSA"
;
public
static
final
String
SIGN_ALGORITHM
=
"SHA1WithRSA"
;
}
src/main/java/cn/qg/holmes/encrypt/xincheng/ConvertUtils.java
0 → 100644
View file @
b43bc524
This diff is collapsed.
Click to expand it.
src/main/java/cn/qg/holmes/encrypt/xincheng/Digest.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
encrypt
.
xincheng
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
public
class
Digest
{
public
static
final
String
ENCODE
=
"UTF-8"
;
public
static
String
signMD5
(
String
aValue
,
String
encoding
)
{
try
{
byte
[]
input
=
aValue
.
getBytes
(
encoding
);
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
return
ConvertUtils
.
toHex
(
md
.
digest
(
input
));
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
public
static
String
hmacSign
(
String
aValue
)
{
try
{
byte
[]
input
=
aValue
.
getBytes
();
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
return
ConvertUtils
.
toHex
(
md
.
digest
(
input
));
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
public
static
String
hmacSign
(
String
aValue
,
String
aKey
)
{
return
hmacSign
(
aValue
,
aKey
,
ENCODE
);
}
public
static
String
hmacSign
(
String
aValue
,
String
aKey
,
String
encoding
)
{
byte
k_ipad
[]
=
new
byte
[
64
];
byte
k_opad
[]
=
new
byte
[
64
];
byte
keyb
[];
byte
value
[];
try
{
keyb
=
aKey
.
getBytes
(
encoding
);
value
=
aValue
.
getBytes
(
encoding
);
}
catch
(
UnsupportedEncodingException
e
)
{
keyb
=
aKey
.
getBytes
();
value
=
aValue
.
getBytes
();
}
Arrays
.
fill
(
k_ipad
,
keyb
.
length
,
64
,
(
byte
)
54
);
Arrays
.
fill
(
k_opad
,
keyb
.
length
,
64
,
(
byte
)
92
);
for
(
int
i
=
0
;
i
<
keyb
.
length
;
i
++)
{
k_ipad
[
i
]
=
(
byte
)(
keyb
[
i
]
^
0x36
);
k_opad
[
i
]
=
(
byte
)(
keyb
[
i
]
^
0x5c
);
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
"MD5"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
md
.
update
(
k_ipad
);
md
.
update
(
value
);
byte
dg
[]
=
md
.
digest
();
md
.
reset
();
md
.
update
(
k_opad
);
md
.
update
(
dg
,
0
,
16
);
dg
=
md
.
digest
();
return
ConvertUtils
.
toHex
(
dg
);
}
public
static
String
hmacSHASign
(
String
aValue
,
String
aKey
,
String
encoding
)
{
byte
k_ipad
[]
=
new
byte
[
64
];
byte
k_opad
[]
=
new
byte
[
64
];
byte
keyb
[];
byte
value
[];
try
{
keyb
=
aKey
.
getBytes
(
encoding
);
value
=
aValue
.
getBytes
(
encoding
);
}
catch
(
UnsupportedEncodingException
e
)
{
keyb
=
aKey
.
getBytes
();
value
=
aValue
.
getBytes
();
}
Arrays
.
fill
(
k_ipad
,
keyb
.
length
,
64
,
(
byte
)
54
);
Arrays
.
fill
(
k_opad
,
keyb
.
length
,
64
,
(
byte
)
92
);
for
(
int
i
=
0
;
i
<
keyb
.
length
;
i
++)
{
k_ipad
[
i
]
=
(
byte
)(
keyb
[
i
]
^
0x36
);
k_opad
[
i
]
=
(
byte
)(
keyb
[
i
]
^
0x5c
);
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
"SHA"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
md
.
update
(
k_ipad
);
md
.
update
(
value
);
byte
dg
[]
=
md
.
digest
();
md
.
reset
();
md
.
update
(
k_opad
);
md
.
update
(
dg
,
0
,
20
);
dg
=
md
.
digest
();
return
ConvertUtils
.
toHex
(
dg
);
}
public
static
String
digest
(
String
aValue
)
{
return
digest
(
aValue
,
ENCODE
);
}
public
static
String
digest
(
String
aValue
,
String
encoding
)
{
aValue
=
aValue
.
trim
();
byte
value
[];
try
{
value
=
aValue
.
getBytes
(
encoding
);
}
catch
(
UnsupportedEncodingException
e
)
{
value
=
aValue
.
getBytes
();
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
"SHA"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
ConvertUtils
.
toHex
(
md
.
digest
(
value
));
}
public
static
String
digest
(
String
aValue
,
String
alg
,
String
encoding
)
{
aValue
=
aValue
.
trim
();
byte
value
[];
try
{
value
=
aValue
.
getBytes
(
encoding
);
}
catch
(
UnsupportedEncodingException
e
)
{
value
=
aValue
.
getBytes
();
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
alg
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
ConvertUtils
.
toHex
(
md
.
digest
(
value
));
}
public
static
String
udpSign
(
String
aValue
)
{
try
{
byte
[]
input
=
aValue
.
getBytes
(
"UTF-8"
);
MessageDigest
md
=
MessageDigest
.
getInstance
(
"SHA1"
);
return
new
String
(
Base64
.
encode
(
md
.
digest
(
input
)),
ENCODE
);
}
catch
(
Exception
e
)
{
return
null
;
}
}
}
src/main/java/cn/qg/holmes/encrypt/xincheng/RSA.java
0 → 100644
View file @
b43bc524
This diff is collapsed.
Click to expand it.
src/main/java/cn/qg/holmes/entity/xincheng/CashOrder.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
entity
.
xincheng
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
@Data
public
class
CashOrder
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
private
String
orderNo
;
private
BigDecimal
monthlyRate
;
private
BigDecimal
amount
;
private
BigDecimal
term
;
private
Date
orderDate
;
}
src/main/java/cn/qg/holmes/entity/xincheng/RepaymentVo.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
entity
.
xincheng
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
RepaymentVo
{
private
BigDecimal
serviceFee
;
private
BigDecimal
overdueFee
;
private
String
orderNo
;
private
BigDecimal
repayPrincipal
;
private
BigDecimal
alreadyRepayInterest
;
private
BigDecimal
otherFee
;
private
BigDecimal
alreadyRepayPrincipal
;
private
BigDecimal
repayAmount
;
private
BigDecimal
alreadyOverdueFee
;
private
BigDecimal
alreadyServiceFee
;
private
String
dueTime
;
private
String
canRepayTime
;
private
BigDecimal
alreadyOtherFee
;
private
String
successTime
;
private
Integer
overdueDay
;
private
Integer
termNo
;
private
BigDecimal
repayInterest
;
private
String
statusCode
;
}
src/main/java/cn/qg/holmes/interceptor/XinchengInterceptor.java
0 → 100644
View file @
b43bc524
package
cn
.
qg
.
holmes
.
interceptor
;
import
cn.qg.holmes.encrypt.EncryptConvertor
;
import
cn.qg.holmes.encrypt.EncryptFactory
;
import
cn.qg.holmes.entity.mock.Mock
;
import
cn.qg.holmes.entity.xincheng.CashOrder
;
import
cn.qg.holmes.entity.xincheng.RepaymentVo
;
import
cn.qg.holmes.mapper.mock.MockMapper
;
import
cn.qg.holmes.utils.HttpClientUtils
;
import
cn.qg.holmes.utils.RedisUtils
;
import
cn.quantgroup.calculator.model.RepaymentPrincipalAndInterest
;
import
cn.quantgroup.calculator.service.RepaymentInteService
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.lang.Nullable
;
import
org.springframework.web.servlet.HandlerInterceptor
;
import
org.springframework.web.servlet.ModelAndView
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
cn
.
qg
.
holmes
.
interceptor
.
InterceptorUtils
.*;
public
class
XinchengInterceptor
implements
HandlerInterceptor
{
@Autowired
MockMapper
mockMapper
;
@Autowired
RedisUtils
redisUtils
;
@Override
public
boolean
preHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
)
throws
Exception
{
String
uri
=
request
.
getRequestURI
();
Map
<
String
,
String
[]>
parameterMap
=
request
.
getParameterMap
();
QueryWrapper
<
Mock
>
mockQueryWrapper
=
new
QueryWrapper
<>();
mockQueryWrapper
.
eq
(
"url"
,
uri
);
Mock
mock
=
mockMapper
.
selectOne
(
mockQueryWrapper
);
EncryptConvertor
encryptConvertor
=
EncryptFactory
.
produce
(
"xincheng"
);
String
responseStr
=
null
;
if
(
mock
.
getFlag
().
equals
(
1
))
{
responseStr
=
mock
.
getSuccess
();
}
else
if
(
mock
.
getFlag
().
equals
(
0
))
{
responseStr
=
mock
.
getFail
();
}
// 解析请求
Map
<
String
,
Object
>
requestMap
=
JSON
.
parseObject
(
encryptConvertor
.
decrypt
(
JSON
.
toJSONString
(
convertParameterMap
(
parameterMap
))),
Map
.
class
);
Map
<
String
,
Object
>
responseMap
=
JSON
.
parseObject
(
responseStr
,
Map
.
class
);
// 进件
if
(
uri
.
equals
(
"/webservice/api/lhp/v1/credit/creditApply"
))
{
redisUtils
.
set
(
requestMap
.
get
(
"orderNo"
).
toString
(),
requestMap
);
}
// 还款试算
if
(
uri
.
equals
(
"/webservice/api/lhp/v1/loan/calculator"
))
{
String
amount
=
requestMap
.
get
(
"trialAmount"
).
toString
();
String
term
=
requestMap
.
get
(
"terms"
).
toString
();
Map
<
String
,
Object
>
caculatorMap
=
getLoanCaculatorResult
(
amount
,
term
);
constructResponse
(
response
,
encryptConvertor
.
encrypt
(
JSON
.
toJSONString
(
caculatorMap
)),
"application/json; charset=utf-8"
);
return
false
;
}
// 还款计划
if
(
uri
.
equals
(
"/webservice/api/lhp/v1/loan/repay/plan"
))
{
String
orderNo
=
requestMap
.
get
(
"orderNo"
).
toString
();
Map
<
String
,
Object
>
redisValue
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
redisUtils
.
get
(
orderNo
)),
Map
.
class
);
Map
<
String
,
Object
>
loanInfo
=
JSONObject
.
parseObject
(
redisValue
.
get
(
"loanInfo"
).
toString
(),
Map
.
class
);
String
amount
=
loanInfo
.
get
(
"amount"
).
toString
();
String
term
=
loanInfo
.
get
(
"term"
).
toString
();
List
<
RepaymentVo
>
repaymentVoList
=
getRepaymentPlanList
(
orderNo
,
amount
,
term
,
new
Date
());
Map
<
String
,
Object
>
repayPlanMap
=
new
HashMap
<>();
repayPlanMap
.
put
(
"data"
,
repaymentVoList
);
repayPlanMap
.
put
(
"msg"
,
"OK"
);
repayPlanMap
.
put
(
"code"
,
0
);
constructResponse
(
response
,
encryptConvertor
.
encrypt
(
JSON
.
toJSONString
(
repayPlanMap
)),
"application/json; charset=utf-8"
);
return
false
;
}
responseMap
=
disposeResponseMap
(
requestMap
,
responseMap
);
constructResponse
(
response
,
encryptConvertor
.
encrypt
(
JSON
.
toJSONString
(
responseMap
)),
"application/json; charset=utf-8"
);
return
false
;
}
@Override
public
void
postHandle
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
@Nullable
ModelAndView
modelAndView
)
{
}
@Override
public
void
afterCompletion
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
@Nullable
Exception
ex
)
{
}
/**
* 生成还款计划
* @param orderNo
* @param contractLoanAmount
* @param contractTerm
* @param createRepaymentAt
* @return
*/
public
static
List
<
RepaymentVo
>
getRepaymentPlanList
(
String
orderNo
,
String
contractLoanAmount
,
String
contractTerm
,
Date
createRepaymentAt
)
{
List
<
RepaymentVo
>
repaymentVoList
=
new
ArrayList
<>();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
createDateStr
=
simpleDateFormat
.
format
(
createRepaymentAt
);
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"fundCorpProductId"
,
"100053"
);
params
.
put
(
"stage"
,
"0"
);
params
.
put
(
"amount"
,
contractLoanAmount
);
params
.
put
(
"term"
,
contractTerm
);
params
.
put
(
"date"
,
createDateStr
);
String
response
=
HttpClientUtils
.
doPost
(
"https://mo-trade-qa.liangkebang.net/middle_office/finance/build_repayment_plan"
,
params
);
Map
<
String
,
String
>
caculMap
=
JSON
.
parseObject
(
response
,
Map
.
class
);
List
<
Map
>
repayList
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
caculMap
.
get
(
"data"
)),
Map
.
class
);
for
(
Map
map:
repayList
)
{
RepaymentVo
repaymentVo
=
new
RepaymentVo
();
repaymentVo
.
setOrderNo
(
orderNo
);
repaymentVo
.
setTermNo
((
Integer
)
map
.
get
(
"term"
));
Map
<
String
,
Object
>
subjectMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
.
get
(
"subject"
)),
Map
.
class
);
repaymentVo
.
setRepayPrincipal
((
BigDecimal
)
subjectMap
.
get
(
"principal"
));
repaymentVo
.
setRepayInterest
((
BigDecimal
)
subjectMap
.
get
(
"interest"
));
repaymentVo
.
setServiceFee
((
BigDecimal
)
subjectMap
.
get
(
"guarantee"
));
}
return
repaymentVoList
;
}
// 生成还款试算
public
static
Map
<
String
,
Object
>
getLoanCaculatorResult
(
String
amount
,
String
term
)
throws
Exception
{
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
createDateStr
=
simpleDateFormat
.
format
(
new
Date
());
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"fundCorpProductId"
,
"100053"
);
params
.
put
(
"stage"
,
"0"
);
params
.
put
(
"amount"
,
amount
);
params
.
put
(
"term"
,
term
);
params
.
put
(
"date"
,
createDateStr
);
String
response
=
HttpClientUtils
.
doPost
(
"https://mo-trade-qa.liangkebang.net/middle_office/finance/build_repayment_plan"
,
params
);
Map
<
String
,
String
>
caculMap
=
JSON
.
parseObject
(
response
,
Map
.
class
);
List
<
Map
>
repayList
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
caculMap
.
get
(
"data"
)),
Map
.
class
);
List
<
Map
<
String
,
Object
>>
caculList
=
new
ArrayList
<>();
for
(
Map
map:
repayList
)
{
Map
<
String
,
Object
>
repay
=
new
HashMap
<>();
repay
.
put
(
"termNo"
,
map
.
get
(
"term"
));
Map
<
String
,
Object
>
subjectMap
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
.
get
(
"subject"
)),
Map
.
class
);
repay
.
put
(
"principal"
,
subjectMap
.
get
(
"principal"
));
repay
.
put
(
"interest"
,
subjectMap
.
get
(
"interest"
));
repay
.
put
(
"serviceFee"
,
subjectMap
.
get
(
"guarantee"
));
repay
.
put
(
"totalAmount"
,
subjectMap
.
get
(
"requiredRepayment"
));
repay
.
put
(
"otherFee"
,
0.00
);
repay
.
put
(
"deadline"
,
simpleDateFormat
.
parse
(
subjectMap
.
get
(
"deadline"
).
toString
()).
getTime
()/
1000
);
caculList
.
add
(
repay
);
}
Integer
interestAmount
=
0
;
Integer
serviceFeeAmount
=
0
;
Integer
principalAmount
=
0
;
Integer
totalRepayAmount
=
0
;
Integer
otherFeeAmount
=
0
;
for
(
Map
map2:
caculList
)
{
interestAmount
+=
Integer
.
parseInt
(
map2
.
get
(
"interest"
).
toString
());
serviceFeeAmount
+=
Integer
.
parseInt
(
map2
.
get
(
"serviceFee"
).
toString
());
principalAmount
+=
Integer
.
parseInt
(
map2
.
get
(
"principal"
).
toString
());
totalRepayAmount
+=
Integer
.
parseInt
(
map2
.
get
(
"totalAmount"
).
toString
());
}
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"serviceFeeAmount"
,
serviceFeeAmount
);
dataMap
.
put
(
"interestAmount"
,
interestAmount
);
dataMap
.
put
(
"principalAmount"
,
principalAmount
);
dataMap
.
put
(
"totalRepayAmount"
,
totalRepayAmount
);
dataMap
.
put
(
"otherFeeAmount"
,
otherFeeAmount
);
dataMap
.
put
(
"plans"
,
caculList
);
resultMap
.
put
(
"msg"
,
"OK"
);
resultMap
.
put
(
"code"
,
0
);
resultMap
.
put
(
"data"
,
dataMap
);
return
resultMap
;
}
}
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