Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
finance-api
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Data-王博
finance-api
Commits
9c57af10
Commit
9c57af10
authored
Mar 20, 2017
by
Data-王博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
湖北消金 - 增加了处理提前还款 与湖北消金最后一期差一分钱问题,对账的系统做兼容
parent
1be28704
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
7 deletions
+135
-7
SystemToolsController.java
...uantgroup/financial/controller/SystemToolsController.java
+1
-1
HuBeiJsonBean.java
...n/quantgroup/financial/model/huibeicfc/HuBeiJsonBean.java
+20
-0
HuBeiReturnDiscScheduler.java
...ntgroup/financial/scheduler/HuBeiReturnDiscScheduler.java
+1
-0
HuBeiServiceImpl.java
...n/quantgroup/financial/service/impl/HuBeiServiceImpl.java
+26
-6
IMailService.java
...ava/cn/quantgroup/financial/service/sys/IMailService.java
+1
-0
MailServiceImpl.java
...uantgroup/financial/service/sys/impl/MailServiceImpl.java
+4
-0
HubeiCFCUtil.java
src/main/java/cn/quantgroup/financial/util/HubeiCFCUtil.java
+82
-0
No files found.
src/main/java/cn/quantgroup/financial/controller/SystemToolsController.java
View file @
9c57af10
...
...
@@ -35,7 +35,7 @@ public class SystemToolsController {
public
@ResponseBody
JsonResult
paymentNotify
(
@RequestParam
(
"mailId"
)
Long
mailId
){
Integer
row
=
null
;
if
(
mailId
!=
null
){
//
row = mailService.deleteMailInfo(mailId);
row
=
mailService
.
deleteMailInfo
(
mailId
);
}
return
JsonResult
.
SUCCESS
(
row
);
}
...
...
src/main/java/cn/quantgroup/financial/model/huibeicfc/HuBeiJsonBean.java
View file @
9c57af10
...
...
@@ -67,6 +67,10 @@ public class HuBeiJsonBean implements Serializable{
//主动还款申请日期
private
String
applyRepayDate
;
private
BigDecimal
loanAmount
;
//借款金额
private
Integer
totalTerm
;
//总期数
public
String
getShouldRepayDate
()
{
return
shouldRepayDate
;
}
...
...
@@ -234,4 +238,20 @@ public class HuBeiJsonBean implements Serializable{
public
void
setApplyRepayDate
(
String
applyRepayDate
)
{
this
.
applyRepayDate
=
applyRepayDate
;
}
public
BigDecimal
getLoanAmount
()
{
return
loanAmount
;
}
public
void
setLoanAmount
(
BigDecimal
loanAmount
)
{
this
.
loanAmount
=
loanAmount
;
}
public
Integer
getTotalTerm
()
{
return
totalTerm
;
}
public
void
setTotalTerm
(
Integer
totalTerm
)
{
this
.
totalTerm
=
totalTerm
;
}
}
src/main/java/cn/quantgroup/financial/scheduler/HuBeiReturnDiscScheduler.java
View file @
9c57af10
...
...
@@ -68,6 +68,7 @@ public class HuBeiReturnDiscScheduler {
return
;
}
List
<
HuBeiHistory
>
huBeiHistoryList
=
iHuBeiService
.
getReturnDisc
(
sendDebitDoc
);
huBeiHistoryList
=
iHuBeiService
.
getReturnDisc
(
sendDebitDoc
);
//保存并推送回盘文件
saveAndPushReturnDisc
(
huBeiHistoryList
);
}
catch
(
Exception
e
)
{
...
...
src/main/java/cn/quantgroup/financial/service/impl/HuBeiServiceImpl.java
View file @
9c57af10
...
...
@@ -339,6 +339,10 @@ public class HuBeiServiceImpl implements IHuBeiService {
if
(
repayDate
!=
null
&&
repayDate
.
before
(
deadline
)){
continue
;
}
BigDecimal
computeRepayAmount
=
HubeiCFCUtil
.
getShouldRepay
(
jsonBean
.
getLoanAmount
(),
jsonBean
.
getTotalTerm
(),
history
.
getCurrTermNo
());
if
(
computeRepayAmount
!=
null
&&
computeRepayAmount
.
subtract
(
jsonBean
.
getRepayTotalAmount
()).
abs
().
compareTo
(
new
BigDecimal
(
"0.01"
))==
0
){
jsonBean
.
setRepayTotalAmount
(
computeRepayAmount
);
}
}
//应扣不等于实扣 需要发送异常邮件
//提前还款没有实扣
...
...
@@ -346,7 +350,7 @@ public class HuBeiServiceImpl implements IHuBeiService {
if
(
jsonBean
!=
null
&&
jsonBean
.
getRepayAmount
()!=
null
&&
jsonBean
.
getReallyRepayAmount
()!=
null
){
if
(
jsonBean
.
getReallyRepayAmount
().
compareTo
(
BigDecimal
.
ZERO
)!=
0
&&
jsonBean
.
getRepayAmount
().
compareTo
(
jsonBean
.
getReallyRepayAmount
())!=
0
){
errorHuBeiHistoryList
.
add
(
history
);
if
(
jsonBean
.
getRepayAmount
().
subtract
(
jsonBean
.
getReallyRepayAmount
()).
compareTo
(
new
BigDecimal
(
"0.01"
))>
0
){
if
(
jsonBean
.
getRepayAmount
().
subtract
(
jsonBean
.
getReallyRepayAmount
()).
abs
().
compareTo
(
new
BigDecimal
(
"0.01"
))>
0
){
continue
;
}
else
{
//差值在一分钱以内 则发错误邮件同时校准跟湖北保持一致 方便后续对账。
...
...
@@ -550,24 +554,36 @@ public class HuBeiServiceImpl implements IHuBeiService {
}).
collect
(
Collectors
.
toCollection
(
ArrayList:
:
new
));
Collections
.
sort
(
repayOfflineRecordList
,
new
RepayOfflineCompartor
());
if
(!
CollectionUtils
.
isEmpty
(
repayOfflineRecordList
)){
RepayOfflineRecord
repay
XyqbDetail
=
repayOfflineRecordList
.
get
(
0
);
RepayOfflineRecord
repay
OfflineRecord
=
repayOfflineRecordList
.
get
(
0
);
//应还日或者逾期 湖北不能接收再提前还款
if
(
repayOfflineRecord
List
.
size
()==
1
&&
repayXyqbDetail
.
getCurrTerm
().
compareTo
(
history
.
getCurrTermNo
())==
0
){
if
(
repayOfflineRecord
.
getCurrTerm
().
compareTo
(
history
.
getCurrTermNo
())==
0
){
RepaymentPlanDetail
repaymentPlanDetail
=
noYetContractMapRepayPlan
.
get
(
history
.
getContactNo
());
if
(
repaymentPlanDetail
!=
null
){
//湖北罚息
BigDecimal
hubeiOverdueInterest
=
HubeiCFCUtil
.
caculateOverDueFee
(
repaymentPlanDetail
.
getDeadLine
(),
repayXyqbDetail
.
getUpdatedAt
(),
repaymentPlanDetail
.
getPrincipal
());
BigDecimal
hubeiOverdueInterest
=
HubeiCFCUtil
.
caculateOverDueFee
(
repaymentPlanDetail
.
getDeadLine
(),
repayOfflineRecord
.
getUpdatedAt
(),
repaymentPlanDetail
.
getPrincipal
());
//批扣
BigDecimal
reallyRepayAmount
=
repaymentPlanDetail
.
getPrincipal
().
add
(
repaymentPlanDetail
.
getInterest
()).
add
(
hubeiOverdueInterest
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
returnHuBeiHistoryList
.
add
(
deitHuiBeiHistory
(
history
,
sendHuBeiDocName
.
getCreateTime
(),
reallyRepayAmount
));
}
if
(
repayOfflineRecordList
.
size
()>
1
){
//应还日提前还款了多期 第一期放在批扣中 其他的放在异常文件中
repayOfflineRecordList
.
remove
(
0
);
if
(!
CollectionUtils
.
isEmpty
(
repayOfflineRecordList
)){
List
<
HuBeiHistory
>
advanceHistoryList
=
advanceOfflineHuiBeiHistory
(
repayOfflineRecordList
);
if
(!
CollectionUtils
.
isEmpty
(
advanceHistoryList
)){
errorHuBeiHistoryList
.
addAll
(
advanceHistoryList
);
}
}
}
}
else
{
//这部分
//这部分
提前还款的
List
<
HuBeiHistory
>
advanceHistoryList
=
advanceOfflineHuiBeiHistory
(
repayOfflineRecordList
);
if
(!
CollectionUtils
.
isEmpty
(
advanceHistoryList
)){
error
HuBeiHistoryList
.
addAll
(
advanceHistoryList
);
return
HuBeiHistoryList
.
addAll
(
advanceHistoryList
);
}
}
continue
;
}
}
...
...
@@ -766,6 +782,8 @@ public class HuBeiServiceImpl implements IHuBeiService {
huBeiJsonBean
.
setChannel
(
HubeiCFCField
.
repayChannel
);
huBeiJsonBean
.
setApplyRepayDate
(
applyRepayDateFormat
);
huBeiJsonBean
.
setRepayTotalAmount
(
reallyPayment
.
setScale
(
2
,
RoundingMode
.
HALF_UP
));
huBeiJsonBean
.
setLoanAmount
(
paymentDetail
.
getTotalPrincipal
());
huBeiJsonBean
.
setTotalTerm
(
paymentDetail
.
getContractTotalTerm
());
advanceHuiBeiHistory
.
setHappenTime
(
new
Date
());
advanceHuiBeiHistory
.
setData
(
huBeiJsonBean
);
advanceHuiBeiList
.
add
(
advanceHuiBeiHistory
);
...
...
@@ -824,6 +842,8 @@ public class HuBeiServiceImpl implements IHuBeiService {
HuBeiJsonBean
huBeiJsonBean
=
new
HuBeiJsonBean
();
HubeiCFCUtil
.
copy
(
advanceHuiBeiHistory
,
huBeiJsonBean
);
huBeiJsonBean
.
setRepayType
(
HubeiCFCField
.
repayType
);
huBeiJsonBean
.
setLoanAmount
(
paymentDetail
.
getTotalPrincipal
());
huBeiJsonBean
.
setTotalTerm
(
paymentDetail
.
getContractTotalTerm
());
Date
repayDate
=
repayXyqbDetail
.
getPayCenterRepayAt
();
//yyyy-MM-dd 还款日期
Calendar
deadLine
=
Calendar
.
getInstance
();
...
...
src/main/java/cn/quantgroup/financial/service/sys/IMailService.java
View file @
9c57af10
...
...
@@ -20,6 +20,7 @@ public interface IMailService {
DataSource
getDataSource
(
String
content
,
String
fileName
);
Long
saveMailInfo
(
MailInfo
mailInfo
);
Integer
deleteMailInfo
(
Long
mailId
);
File
createAttachMailFile
(
String
fileContent
,
String
fileName
);
}
src/main/java/cn/quantgroup/financial/service/sys/impl/MailServiceImpl.java
View file @
9c57af10
...
...
@@ -247,6 +247,10 @@ public class MailServiceImpl implements IMailService {
return
systemDao
.
saveMailInfo
(
mailInfo
);
}
@Override
public
Integer
deleteMailInfo
(
Long
mailId
)
{
return
systemDao
.
deleteMailInfo
(
mailId
);
}
/**
...
...
src/main/java/cn/quantgroup/financial/util/HubeiCFCUtil.java
View file @
9c57af10
...
...
@@ -204,6 +204,88 @@ public class HubeiCFCUtil {
return
calendar
.
getTime
();
}
public
static
BigDecimal
getShouldRepay
(
BigDecimal
loanAmount
,
Integer
term
,
Integer
currentTerm
){
if
(
loanAmount
==
null
||
term
==
null
||
currentTerm
==
null
){
return
null
;
}
BigDecimal
monthRate
=
new
BigDecimal
(
"0.1401"
).
divide
(
new
BigDecimal
(
"12"
));
if
(
term
.
equals
(
currentTerm
)){
//最后一期
BigDecimal
principal
=
getMonthPrincipal
(
loanAmount
,
term
,
currentTerm
);
return
principal
.
add
(
getMonthInterest
(
principal
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
else
{
BigDecimal
dd
=
new
BigDecimal
(
Math
.
pow
(
monthRate
.
add
(
new
BigDecimal
(
"1"
)).
doubleValue
(),
term
));
BigDecimal
ff
=
new
BigDecimal
(
Math
.
pow
(
monthRate
.
add
(
new
BigDecimal
(
"1"
)).
doubleValue
(),
term
)).
subtract
(
new
BigDecimal
(
"1"
));
BigDecimal
PrincialAndInterst
=
loanAmount
.
multiply
(
monthRate
).
multiply
(
dd
).
divide
(
ff
,
6
,
RoundingMode
.
HALF_UP
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
return
PrincialAndInterst
;
}
}
public
static
BigDecimal
getMonthInterest
(
BigDecimal
remainPrincipal
){
BigDecimal
monthRate
=
new
BigDecimal
(
"0.1401"
).
divide
(
new
BigDecimal
(
"12"
));
BigDecimal
interest
=
remainPrincipal
.
multiply
(
monthRate
);
return
interest
;
}
public
static
BigDecimal
getMonthInterest
(
BigDecimal
loanAmount
,
Integer
term
,
Integer
currentTerm
){
BigDecimal
monthRate
=
new
BigDecimal
(
"0.1401"
).
divide
(
new
BigDecimal
(
"12"
));
if
(
term
.
equals
(
currentTerm
)){
BigDecimal
remainAmount
=
getMonthPrincipal
(
loanAmount
,
term
,
currentTerm
);
BigDecimal
interest
=
remainAmount
.
multiply
(
monthRate
);
return
interest
.
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
else
{
//剩余本金
BigDecimal
remainAmount
=
loanAmount
;
for
(
int
i
=
currentTerm
-
1
;
i
>
0
;
i
--){
remainAmount
=
remainAmount
.
subtract
(
getMonthPrincipal
(
loanAmount
,
term
,
i
));
}
BigDecimal
interest
=
remainAmount
.
multiply
(
monthRate
);
return
interest
.
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
}
public
static
BigDecimal
getMonthPrincipal
(
BigDecimal
loanAmount
,
Integer
term
,
Integer
currentTerm
){
if
(
currentTerm
.
equals
(
new
Integer
(
0
))){
return
BigDecimal
.
ZERO
;
}
//剩余本金
BigDecimal
remainAmount
=
loanAmount
;
for
(
int
i
=
currentTerm
-
1
;
i
>
0
;
i
--){
remainAmount
=
remainAmount
.
subtract
(
getMonthPrincipal
(
loanAmount
,
term
,
i
));
}
if
(
term
.
equals
(
currentTerm
)){
return
remainAmount
.
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
else
{
BigDecimal
interest
=
getMonthInterest
(
remainAmount
);
BigDecimal
repayAmout
=
getShouldRepay
(
loanAmount
,
term
,
currentTerm
);
BigDecimal
monthPrincipal
=
repayAmout
.
subtract
(
interest
);
return
monthPrincipal
.
setScale
(
2
,
RoundingMode
.
HALF_UP
);
}
}
public
static
void
main
(
String
[]
args
)
{
for
(
int
i
=
1
;
i
<=
3
;
i
++){
BigDecimal
loanAmout
=
new
BigDecimal
(
"5000"
);
BigDecimal
repayAmount
=
getShouldRepay
(
loanAmout
,
3
,
i
);
// BigDecimal principal = getMonthPrincipal(loanAmout,3,i);
// BigDecimal interest = getMonthInterest(loanAmout,3,i);
logger
.
info
(
"repayAmount={}"
,
repayAmount
);
// logger.info("principal={}",principal);
// logger.info("interest={}",interest);
}
}
public
static
double
getPerMonthPrincipalInterest
(
double
invest
,
double
yearRate
,
int
totalmonth
)
{
double
monthRate
=
yearRate
/
12
;
BigDecimal
monthIncome
=
new
BigDecimal
(
invest
)
.
multiply
(
new
BigDecimal
(
monthRate
*
Math
.
pow
(
1
+
monthRate
,
totalmonth
)))
.
divide
(
new
BigDecimal
(
Math
.
pow
(
1
+
monthRate
,
totalmonth
)
-
1
),
2
,
BigDecimal
.
ROUND_DOWN
);
return
monthIncome
.
doubleValue
();
}
public
static
String
getDocName
(
HubeiCFCDataType
hubeiCFCDataType
,
Byte
seqNo
){
Calendar
calendar
=
Calendar
.
getInstance
();
// calendar.set(Calendar.DATE,calendar.get(Calendar.DATE)-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