Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
asset-distribution
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-spider
asset-distribution
Commits
b3d1d9a1
Commit
b3d1d9a1
authored
Oct 25, 2020
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
账单分期需求
parent
2a70e4d0
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
163 additions
and
82 deletions
+163
-82
AidCommonCallbackController.java
.../distribution/controller/AidCommonCallbackController.java
+72
-71
CheckController.java
...tgroup/asset/distribution/controller/CheckController.java
+8
-0
RetryController.java
...tgroup/asset/distribution/controller/RetryController.java
+50
-11
AssetForm.java
...m/quantgroup/asset/distribution/model/form/AssetForm.java
+9
-0
DateUtil.java
...java/com/quantgroup/asset/distribution/util/DateUtil.java
+24
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/controller/AidCommonCallbackController.java
View file @
b3d1d9a1
This diff is collapsed.
Click to expand it.
src/main/java/com/quantgroup/asset/distribution/controller/CheckController.java
View file @
b3d1d9a1
...
...
@@ -44,4 +44,12 @@ public class CheckController {
public
GlobalResponse
test
()
{
return
GlobalResponse
.
success
(
map
);
}
/**
* 检查是否下线
* @return
*/
public
static
boolean
isOffLine
()
{
return
map
!=
null
&&
map
.
size
()
>
0
;
}
}
src/main/java/com/quantgroup/asset/distribution/controller/RetryController.java
View file @
b3d1d9a1
...
...
@@ -2,11 +2,15 @@ package com.quantgroup.asset.distribution.controller;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
com.quantgroup.asset.distribution.service.redis.IRedisService
;
import
com.quantgroup.asset.distribution.util.DateUtil
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -34,6 +38,8 @@ public class RetryController {
private
IDistributeFailLogRepository
distributeFailLogRepository
;
@Autowired
private
IAssetService
assetService
;
@Autowired
private
IRedisService
<
String
>
redisService
;
@RequestMapping
(
"/orders"
)
public
GlobalResponse
retryOrders
(
String
startTime
,
String
endTime
)
{
...
...
@@ -41,20 +47,53 @@ public class RetryController {
Page
<
DistributeFailLog
>
pageableFailAuditLog
=
distributeFailLogRepository
.
findByCreatedAtBetweenAndEnable
(
Timestamp
.
valueOf
(
startTime
),
Timestamp
.
valueOf
(
endTime
),
true
,
new
PageRequest
(
0
,
1000
));
List
<
DistributeFailLog
>
distributeFailLogList
=
pageableFailAuditLog
.
getContent
();
if
(
CollectionUtils
.
isNotEmpty
(
distributeFailLogList
))
{
log
.
info
(
"分发失败查询数量为:{}"
,
distributeFailLogList
.
size
());
pageableFailAuditLog
.
forEach
(
distributeFailLog
->
{
AssetForm
assetForm
=
JSON
.
parseObject
(
distributeFailLog
.
getContext
(),
AssetForm
.
class
);
// 重新审核
assetService
.
assetsIn
(
assetForm
);
distributeFailLog
.
setEnable
(
false
);
distributeFailLogRepository
.
save
(
distributeFailLog
);
});
}
retryDistributeFailLogList
(
distributeFailLogList
);
}
catch
(
Exception
e
)
{
log
.
error
(
"资产分发失败订单重新分发异常!"
,
e
);
}
return
GlobalResponse
.
success
();
}
@Async
@RequestMapping
(
"/repeat_db_distribute"
)
public
void
repeatDBAudit
()
{
try
{
boolean
b
=
redisService
.
setIfAbsent
(
"ASSET_DISTRIBUTION:REPEAT_DB_ATTRIBUTE:99AMU"
,
"1"
,
1
,
TimeUnit
.
DAYS
);
if
(!
b
)
{
return
;
}
String
startTime
=
DateUtil
.
getStrFormatDate
(
"yyyy-MM-dd HH:mm:ss"
,
-
7
);
String
endTime
=
DateUtil
.
timestamp2Str
(
System
.
currentTimeMillis
()
+
""
,
"yyyy-MM-dd HH:mm:ss"
);
int
i
=
1
;
while
(
i
>
0
&&
!
CheckController
.
isOffLine
())
{
Page
<
DistributeFailLog
>
pageableFailDistributeLog
=
distributeFailLogRepository
.
findByCreatedAtBetweenAndEnable
(
Timestamp
.
valueOf
(
startTime
),
Timestamp
.
valueOf
(
endTime
),
true
,
new
PageRequest
(
0
,
50
));
List
<
DistributeFailLog
>
distributeFailLogList
=
pageableFailDistributeLog
.
getContent
();
retryDistributeFailLogList
(
distributeFailLogList
);
TimeUnit
.
SECONDS
.
sleep
(
30
);
++
i
;
if
(
distributeFailLogList
==
null
||
distributeFailLogList
.
size
()
<
50
)
{
i
=
-
1
;
}
}
// 删除锁
redisService
.
del
(
"RULE_ENGINE:REPEAT_DB_AUDIT:88C1K"
);
log
.
info
(
"数据库审核失败订单重审完成!"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"重复审核数据库失败订单任务出现异常!"
,
e
);
}
}
private
void
retryDistributeFailLogList
(
List
<
DistributeFailLog
>
distributeFailLogList
)
{
if
(
CollectionUtils
.
isNotEmpty
(
distributeFailLogList
))
{
log
.
info
(
"分发失败查询数量为:{}"
,
distributeFailLogList
.
size
());
distributeFailLogList
.
forEach
(
distributeFailLog
->
{
AssetForm
assetForm
=
JSON
.
parseObject
(
distributeFailLog
.
getContext
(),
AssetForm
.
class
);
// 重新审核
assetService
.
assetsIn
(
assetForm
);
distributeFailLog
.
setEnable
(
false
);
distributeFailLogRepository
.
save
(
distributeFailLog
);
});
}
}
}
src/main/java/com/quantgroup/asset/distribution/model/form/AssetForm.java
View file @
b3d1d9a1
...
...
@@ -58,6 +58,12 @@ public class AssetForm implements Serializable{
private
String
amountTermLimits
;
private
String
fundRate
;
private
String
moreOrderTag
;
private
String
allowInstalment
;
private
String
allowInstalmentTerms
;
public
Asset
transToAsset
()
{
Asset
asset
=
new
Asset
();
...
...
@@ -94,6 +100,9 @@ public class AssetForm implements Serializable{
notifyMap
.
put
(
"financeProducts"
,
this
.
financeProducts
);
notifyMap
.
put
(
"amountTermLimits"
,
this
.
amountTermLimits
);
notifyMap
.
put
(
"fundRate"
,
fundRate
);
notifyMap
.
put
(
"callbackUrl"
,
callbackUrl
);
notifyMap
.
put
(
"allowInstalment"
,
allowInstalment
);
notifyMap
.
put
(
"allowInstalmentTerms"
,
allowInstalmentTerms
);
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
// 目前通知资金方可能有3个模型分
...
...
src/main/java/com/quantgroup/asset/distribution/util/DateUtil.java
View file @
b3d1d9a1
package
com
.
quantgroup
.
asset
.
distribution
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
...
...
@@ -9,6 +11,7 @@ import java.util.Date;
/**
* Created by renfeng on 2019/7/22.
*/
@Slf4j
public
class
DateUtil
{
...
...
@@ -38,4 +41,25 @@ public class DateUtil {
public
static
Long
transStringToLong
(
String
dateTime
,
String
pattern
)
{
return
Timestamp
.
valueOf
(
LocalDateTime
.
parse
(
dateTime
,
DateTimeFormatter
.
ofPattern
(
pattern
))).
getTime
();
}
/**
* 获取格式化日期
*
* @param pattern
* @param add
* @return
*/
public
static
String
getStrFormatDate
(
String
pattern
,
int
add
)
{
return
LocalDateTime
.
now
().
plusDays
(
add
).
format
(
DateTimeFormatter
.
ofPattern
(
pattern
));
}
public
static
String
timestamp2Str
(
String
longmills
,
String
pattern
)
{
try
{
Timestamp
ts
=
new
Timestamp
(
Long
.
parseLong
(
longmills
));
return
new
SimpleDateFormat
(
pattern
).
format
(
ts
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Timestamp转String异常,格式 : {}"
,
pattern
,
e
);
return
null
;
}
}
}
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