Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
financial-tools
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
QG
financial-tools
Commits
886187e4
Commit
886187e4
authored
Oct 09, 2016
by
Java-范 志勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
d899d4ff
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
76 additions
and
106 deletions
+76
-106
RepayHandler.java
src/main/java/cn/gq/financial/app/handler/RepayHandler.java
+4
-4
RepayHandlerAsync.java
...n/java/cn/gq/financial/app/handler/RepayHandlerAsync.java
+3
-8
TotalAmountCheck.java
src/main/java/cn/gq/financial/checkout/TotalAmountCheck.java
+43
-42
LocalDataSourceMapper.xml
...n/gq/financial/db/local/mapping/LocalDataSourceMapper.xml
+0
-0
Bill.java
src/main/java/cn/gq/financial/model/bill/Bill.java
+15
-7
UMPayBill.java
src/main/java/cn/gq/financial/model/bill/UMPayBill.java
+0
-10
WXBill.java
src/main/java/cn/gq/financial/model/bill/WXBill.java
+0
-10
YeepayBill.java
src/main/java/cn/gq/financial/model/bill/YeepayBill.java
+0
-10
BillParsers.java
src/main/java/cn/gq/financial/utils/BillParsers.java
+10
-14
mybatis-local-repayment-config.xml
src/main/resources/mybatis-local-repayment-config.xml
+1
-1
No files found.
src/main/java/cn/gq/financial/app/handler/RepayHandler.java
View file @
886187e4
...
...
@@ -25,7 +25,7 @@ import cn.gq.financial.utils.BillParsers;
@Component
public
class
RepayHandler
{
static
int
ITEM_SIZE
=
1
0000
;
static
int
ITEM_SIZE
=
3
0000
;
@Autowired
private
ThreadPoolTaskExecutor
threadPoolTaskExecutor
;
...
...
@@ -58,7 +58,7 @@ public class RepayHandler {
List
<
Bill
>
bills
)
{
if
(
bills
.
size
()<
ITEM_SIZE
)
{
count
=
new
CountDownLatch
(
1
);
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
bills
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
,
financialRepayDetailService
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
bills
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
}
else
{
int
group
=
bills
.
size
()/
ITEM_SIZE
;
int
cnt
=
group
;
...
...
@@ -69,11 +69,11 @@ public class RepayHandler {
int
i
=
0
;
for
(
i
=
0
;
i
<
group
;
i
++)
{
List
<
Bill
>
subList
=
bills
.
subList
(
i
*
ITEM_SIZE
,
(
i
+
1
)*
ITEM_SIZE
);
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
,
financialRepayDetailService
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
}
if
(
bills
.
size
()%
ITEM_SIZE
!=
0
){
List
<
Bill
>
subList
=
bills
.
subList
(
i
*
ITEM_SIZE
,
bills
.
size
());
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
,
repayDetailMapper
,
financialRepayDetailService
));
threadPoolTaskExecutor
.
execute
(
new
RepayHandlerAsync
(
subList
,
clazz
,
paycenterService
,
bizRepayDetailService
,
count
));
}
}
}
...
...
src/main/java/cn/gq/financial/app/handler/RepayHandlerAsync.java
View file @
886187e4
...
...
@@ -36,23 +36,16 @@ public class RepayHandlerAsync implements Runnable {
private
CountDownLatch
count
;
private
FinancialRepayDetailMapper
repayDetailMapper
;
private
FinancialRepayDetailService
financialRepayDetailService
;
public
RepayHandlerAsync
(
List
<
Bill
>
bills
,
Class
<?
extends
Bill
>
clazz
,
PaycenterService
paycenterService
,
BizRepayDetailService
bizRepayDetailService
,
CountDownLatch
count
,
FinancialRepayDetailMapper
repayDetailMapper
,
FinancialRepayDetailService
financialRepayDetailService
)
{
CountDownLatch
count
)
{
super
();
this
.
bills
=
bills
;
this
.
clazz
=
clazz
;
this
.
paycenterService
=
paycenterService
;
this
.
bizRepayDetailService
=
bizRepayDetailService
;
this
.
count
=
count
;
this
.
repayDetailMapper
=
repayDetailMapper
;
this
.
financialRepayDetailService
=
financialRepayDetailService
;
}
public
void
handler
()
{
try
{
LOGGER
.
info
(
"##Thread-->{}开始处理账单##"
,
Thread
.
currentThread
().
getName
());
...
...
@@ -102,6 +95,8 @@ public class RepayHandlerAsync implements Runnable {
for
(
RepayDetailFinancial
detail
:
list
)
{
detail
.
setPayAccount
(
bill
.
getPayAccount
());
detail
.
setMonth
(
bill
.
getMonth
());
// 设置交易时间
detail
.
setRepaidAt
(
bill
.
getTrandingDate
());
if
(
1
==
detail
.
getActivityRelief
().
compareTo
(
BigDecimal
.
ZERO
)){
detail
.
setActivityRelief
(
detail
.
getActivityRelief
().
multiply
(
Constants
.
MINUS_ONE
));
}
...
...
src/main/java/cn/gq/financial/checkout/TotalAmountCheck.java
View file @
886187e4
...
...
@@ -16,46 +16,47 @@ import java.util.Set;
*/
public
class
TotalAmountCheck
{
static
String
[]
lost
=
{
"1470995273554"
,
"1470995273550"
,
"1470995273567"
};
static
Set
<
String
>
lostSet
=
new
HashSet
<>();
static
String
payAprroach
=
"微信"
;
static
String
payAccount
=
"微信-白条账户"
;
static
Integer
month
=
9
;
static
String
SRC_BILL_PATH
=
"E:\\WX_BILL_BAITIAO"
;
static
Class
<?
extends
Bill
>
clazz
=
null
;
static
{
for
(
String
lostId
:
lost
){
lostSet
.
add
(
lostId
);
}
switch
(
payAprroach
)
{
case
"微信"
:
clazz
=
WXBill
.
class
;
break
;
case
"易宝"
:
clazz
=
YeepayBill
.
class
;
break
;
case
"联动"
:
clazz
=
UMPayBill
.
class
;
break
;
}
}
public
static
void
main
(
String
args
[])
throws
Exception
{
List
<
Bill
>
bills
=
RepayHandler
.
getBillsFromFile
(
SRC_BILL_PATH
,
clazz
,
payAccount
,
month
);
BigDecimal
total
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
bills
.
size
();
i
++)
{
if
(!
lostSet
.
contains
(
bills
.
get
(
i
).
getOrderId
()))
{
total
=
total
.
add
(
bills
.
get
(
i
).
getIncome
());
}
else
{
System
.
out
.
println
(
bills
.
get
(
i
).
getOrderId
().
concat
(
"--"
).
concat
(
bills
.
get
(
i
).
getIncome
().
toString
()));
}
}
System
.
out
.
println
(
total
);
}
static
String
[]
lost
=
{
"1470995273554"
,
"1470995273550"
,
"1470995273567"
};
static
Set
<
String
>
lostSet
=
new
HashSet
<>();
static
String
payAprroach
=
"微信"
;
static
String
payAccount
=
"微信-白条账户"
;
static
Integer
month
=
9
;
static
String
SRC_BILL_PATH
=
"E:\\WX_BILL_BAITIAO"
;
static
Class
<?
extends
Bill
>
clazz
=
null
;
static
{
for
(
String
lostId
:
lost
)
{
lostSet
.
add
(
lostId
);
}
switch
(
payAprroach
)
{
case
"微信"
:
clazz
=
WXBill
.
class
;
break
;
case
"易宝"
:
clazz
=
YeepayBill
.
class
;
break
;
case
"联动"
:
clazz
=
UMPayBill
.
class
;
break
;
}
}
public
static
void
main
(
String
args
[])
throws
Exception
{
List
<
Bill
>
bills
=
RepayHandler
.
getBillsFromFile
(
SRC_BILL_PATH
,
clazz
,
payAccount
,
month
);
BigDecimal
total
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
bills
.
size
();
i
++)
{
if
(!
lostSet
.
contains
(
bills
.
get
(
i
).
getOrderId
()))
{
total
=
total
.
add
(
bills
.
get
(
i
).
getIncome
());
}
else
{
System
.
out
.
println
(
bills
.
get
(
i
).
getOrderId
().
concat
(
"--"
).
concat
(
bills
.
get
(
i
).
getIncome
().
toString
()));
}
}
System
.
out
.
println
(
total
);
}
}
src/main/java/cn/gq/financial/db/local/mapping/
Mal
lDataSourceMapper.xml
→
src/main/java/cn/gq/financial/db/local/mapping/
Loca
lDataSourceMapper.xml
View file @
886187e4
File moved
src/main/java/cn/gq/financial/model/bill/Bill.java
View file @
886187e4
package
cn
.
gq
.
financial
.
model
.
bill
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* 第三方支付平台对账单的要素集合,具体平台的账单继承本类
* @author Administrator
*
* @author Administrator
*/
public
abstract
class
Bill
{
protected
Integer
month
;
protected
Date
trandingDate
;
protected
String
payAccount
;
// 支付账户
protected
String
orderId
;
// 商户订单号
protected
BigDecimal
income
=
BigDecimal
.
ZERO
;
// 收入
...
...
@@ -20,7 +23,7 @@ public abstract class Bill {
protected
BigDecimal
cost
=
BigDecimal
.
ZERO
;
protected
BigDecimal
poundage
=
BigDecimal
.
ZERO
;
public
Integer
getMonth
()
{
return
month
;
}
...
...
@@ -68,7 +71,12 @@ public abstract class Bill {
public
void
setPayAccount
(
String
payAccount
)
{
this
.
payAccount
=
payAccount
;
}
public
Date
getTrandingDate
()
{
return
trandingDate
;
}
public
void
setTrandingDate
(
Date
trandingDate
)
{
this
.
trandingDate
=
trandingDate
;
}
}
src/main/java/cn/gq/financial/model/bill/UMPayBill.java
View file @
886187e4
...
...
@@ -13,20 +13,10 @@ public class UMPayBill extends Bill {
public
static
String
TRANS_FAIL
=
"-1"
;
private
Date
trandingDate
;
private
String
phoneNo
;
private
String
transStatus
;
//交易状态,TRANS_SUCCESS,TRANS_FAIL
public
Date
getTrandingDate
()
{
return
trandingDate
;
}
public
void
setTrandingDate
(
Date
trandingDate
)
{
this
.
trandingDate
=
trandingDate
;
}
public
String
getPhoneNo
()
{
return
phoneNo
;
}
...
...
src/main/java/cn/gq/financial/model/bill/WXBill.java
View file @
886187e4
...
...
@@ -10,8 +10,6 @@ import java.util.Date;
*/
public
class
WXBill
extends
Bill
{
private
Date
trandingDate
;
private
String
wxOrderId
;
private
String
pubWXAccount
;
...
...
@@ -28,14 +26,6 @@ public class WXBill extends Bill {
this
.
rate
=
rate
;
}
public
Date
getTrandingDate
()
{
return
trandingDate
;
}
public
void
setTrandingDate
(
Date
trandingDate
)
{
this
.
trandingDate
=
trandingDate
;
}
public
String
getWxOrderId
()
{
return
wxOrderId
;
}
...
...
src/main/java/cn/gq/financial/model/bill/YeepayBill.java
View file @
886187e4
...
...
@@ -12,22 +12,12 @@ public class YeepayBill extends Bill {
public
static
String
REPAY
=
"收款"
;
public
static
String
PAY
=
"委托结算"
;
private
Date
tradingDate
;
//交易时间
private
String
accountType
;
//账户类型
private
String
bizType
;
//业务类型
private
String
remak
;
//备注信息
public
Date
getTradingDate
()
{
return
tradingDate
;
}
public
void
setTradingDate
(
Date
tradingDate
)
{
this
.
tradingDate
=
tradingDate
;
}
public
String
getAccountType
()
{
return
accountType
;
}
...
...
src/main/java/cn/gq/financial/utils/BillParsers.java
View file @
886187e4
...
...
@@ -79,7 +79,7 @@ public class BillParsers {
String
[]
split
=
line
.
split
(
","
);
bill
.
setOrderId
(
split
[
3
].
trim
());
bill
.
setIncome
(
new
BigDecimal
(
split
[
6
]).
divide
(
BigDecimal
.
TEN
).
divide
(
BigDecimal
.
TEN
));
bill
.
setTrandingDate
(
DateUtils
.
parseDate
(
split
[
4
],
PARSE_PATTERN_2
));
bill
.
setTrandingDate
(
DateUtils
.
parseDate
(
split
[
5
],
PARSE_PATTERN_2
));
bill
.
setOrderId
(
split
[
3
].
trim
());
bill
.
setPhoneNo
(
split
[
2
].
trim
());
bill
.
setTransStatus
(
split
[
11
].
trim
());
...
...
@@ -104,7 +104,7 @@ public class BillParsers {
while
(
StringUtils
.
isNoneBlank
(
line
=
reader
.
readLine
()))
{
if
(
line
.
startsWith
(
"总交易单数"
))
break
;
//账单条目结束
String
[]
split
=
line
.
split
(
","
);
if
(
"SUCCESS"
.
equals
(
split
[
9
]))
{
if
(
split
.
length
>
9
&&
"SUCCESS"
.
equals
(
split
[
9
]))
{
WXBill
bill
=
createWXBill
(
split
);
bills
.
add
(
bill
);
}
...
...
@@ -142,7 +142,8 @@ public class BillParsers {
BigDecimal
rate
=
new
BigDecimal
(
str
).
divide
(
BigDecimal
.
TEN
).
divide
(
BigDecimal
.
TEN
);
bill
.
setRate
(
rate
);
}
// 设置交易时间
bill
.
setTrandingDate
(
DateUtils
.
parseDate
(
split
[
0
],
PARSE_PATTERN_1
));
return
bill
;
}
...
...
@@ -151,7 +152,7 @@ public class BillParsers {
if
(
contents
==
null
||
contents
.
length
==
0
)
{
throw
new
IllegalArgumentException
(
"Invalid contents: "
+
StringUtils
.
join
(
contents
,
","
));
}
yeepayBill
.
setTradingDate
(
DateUtils
.
parseDate
(
contents
[
1
],
"yyyy-MM-dd HH:mm:ss.SSS"
));
yeepayBill
.
setTra
n
dingDate
(
DateUtils
.
parseDate
(
contents
[
1
],
"yyyy-MM-dd HH:mm:ss.SSS"
));
yeepayBill
.
setAccountType
(
contents
[
2
]);
yeepayBill
.
setBizType
(
contents
[
3
]);
if
(
StringUtils
.
isNotBlank
(
contents
[
4
]))
{
...
...
@@ -174,15 +175,10 @@ public class BillParsers {
String
lineContent
=
reader
.
readLine
();
String
[]
split
;
List
<
YeepayBill
>
bills
=
new
ArrayList
<>();
int
flag
=
0
;
while
(
StringUtils
.
isNotBlank
(
lineContent
))
{
if
(
flag
>
0
)
{
split
=
StringUtils
.
splitPreserveAllTokens
(
lineContent
,
","
);
YeepayBill
bill
=
setYeePayBillProps
(
split
);
bills
.
add
(
bill
);
}
lineContent
=
reader
.
readLine
();
flag
++;
while
(
StringUtils
.
isNotBlank
(
reader
.
readLine
()))
{
split
=
StringUtils
.
splitPreserveAllTokens
(
lineContent
,
","
);
YeepayBill
bill
=
setYeePayBillProps
(
split
);
bills
.
add
(
bill
);
}
return
bills
;
}
...
...
@@ -212,7 +208,7 @@ public class BillParsers {
private
static
YeepayBill
createYeepayBill
(
Row
row
)
{
YeepayBill
bill
=
new
YeepayBill
();
bill
.
setTradingDate
(
row
.
getCell
(
1
).
getDateCellValue
());
bill
.
setTra
n
dingDate
(
row
.
getCell
(
1
).
getDateCellValue
());
bill
.
setAccountType
(
row
.
getCell
(
2
).
getStringCellValue
());
bill
.
setBizType
(
row
.
getCell
(
3
).
getStringCellValue
());
if
(
StringUtils
.
isNotBlank
(
row
.
getCell
(
4
).
getStringCellValue
()))
{
...
...
src/main/resources/mybatis-local-repayment-config.xml
View file @
886187e4
...
...
@@ -4,6 +4,6 @@
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper
resource=
"cn/gq/financial/db/local/mapping/
Mal
lDataSourceMapper.xml"
/>
<mapper
resource=
"cn/gq/financial/db/local/mapping/
Loca
lDataSourceMapper.xml"
/>
</mappers>
</configuration>
\ No newline at end of file
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