Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-platform
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
qa-platform
Commits
55a3881a
Commit
55a3881a
authored
Aug 21, 2020
by
黎博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增分配资产计划
parent
220e8aa0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
8 deletions
+167
-8
MainProcess.java
src/main/java/cn/qg/qaplatform/process/xyqb/MainProcess.java
+88
-4
GenUserDataService.java
...ain/java/cn/qg/qaplatform/service/GenUserDataService.java
+5
-0
GenUserDataServiceImpl.java
...cn/qg/qaplatform/service/impl/GenUserDataServiceImpl.java
+43
-2
xyqb.java
src/test/java/cn/qg/qaplatform/test/xyqb.java
+31
-2
No files found.
src/main/java/cn/qg/qaplatform/process/xyqb/MainProcess.java
View file @
55a3881a
...
@@ -3,6 +3,7 @@ package cn.qg.qaplatform.process.xyqb;
...
@@ -3,6 +3,7 @@ package cn.qg.qaplatform.process.xyqb;
import
cn.qg.qaplatform.utils.DBUtils
;
import
cn.qg.qaplatform.utils.DBUtils
;
import
cn.qg.qaplatform.utils.EncryptUtils
;
import
cn.qg.qaplatform.utils.EncryptUtils
;
import
cn.qg.qaplatform.utils.HttpClientUtils
;
import
cn.qg.qaplatform.utils.HttpClientUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -10,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -10,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -36,11 +39,10 @@ public class MainProcess {
...
@@ -36,11 +39,10 @@ public class MainProcess {
params
.
put
(
"click_id"
,
""
);
params
.
put
(
"click_id"
,
""
);
Map
<
String
,
Object
>
header
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
header
=
new
HashMap
<
String
,
Object
>();
header
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
header
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
log
.
info
(
"请求url:"
+
url
+
"\n请求头:"
+
header
+
"\n请求参数:"
+
params
);
String
verification
=
EncryptUtils
.
base64Encrypt
(
phoneNo
);
String
verification
=
EncryptUtils
.
base64Encrypt
(
phoneNo
);
header
.
put
(
"Authorization"
,
verification
);
header
.
put
(
"Authorization"
,
verification
);
JSONObject
result
=
HttpClientUtils
.
doPost
(
url
,
params
,
header
);
JSONObject
result
=
HttpClientUtils
.
doPost
(
url
,
params
,
header
);
log
.
info
(
"
响应结果
:"
+
result
);
log
.
info
(
"
登录响应结果为
:"
+
result
);
Map
map
=
(
Map
)
result
.
get
(
"data"
);
Map
map
=
(
Map
)
result
.
get
(
"data"
);
String
token
=
map
.
get
(
"token"
).
toString
();
String
token
=
map
.
get
(
"token"
).
toString
();
return
token
;
return
token
;
...
@@ -307,14 +309,14 @@ public class MainProcess {
...
@@ -307,14 +309,14 @@ public class MainProcess {
* @throws SQLException
* @throws SQLException
* @return
* @return
*/
*/
public
static
Map
getUserAccountId
(
String
namespace
,
String
userId
,
String
productId
)
throws
SQLException
{
public
static
Long
getUserAccountId
(
String
namespace
,
String
userId
,
String
productId
)
throws
SQLException
{
String
sql
=
"select id from quota_account where user_id = "
+
userId
+
" and product_id = "
+
productId
;
String
sql
=
"select id from quota_account where user_id = "
+
userId
+
" and product_id = "
+
productId
;
DBUtils
dbUtils
=
new
DBUtils
(
namespace
,
"xyqb"
,
"qa"
,
"qatest"
);
DBUtils
dbUtils
=
new
DBUtils
(
namespace
,
"xyqb"
,
"qa"
,
"qatest"
);
List
result
=
dbUtils
.
queryForList
(
sql
);
List
result
=
dbUtils
.
queryForList
(
sql
);
Map
resMap
=
(
Map
)
result
.
get
(
0
);
Map
resMap
=
(
Map
)
result
.
get
(
0
);
Long
accountId
=
(
Long
)
resMap
.
get
(
"id"
);
Long
accountId
=
(
Long
)
resMap
.
get
(
"id"
);
log
.
info
(
"查询accountId:"
+
result
);
log
.
info
(
"查询accountId:"
+
result
);
return
resMap
;
return
accountId
;
}
}
/**
/**
...
@@ -539,4 +541,86 @@ public class MainProcess {
...
@@ -539,4 +541,86 @@ public class MainProcess {
return
false
;
return
false
;
}
}
/**
* 登录资金方OP
*/
public
static
String
loginFundOP
(
String
namespace
)
{
String
url
=
"http://opapi-"
+
namespace
+
".liangkebang.net"
+
"/user/login"
;
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"auth"
,
"dXNlcj1xYSZwYXNzd29yZD1xYXRlc3Q="
);
String
params
=
JSON
.
toJSONString
(
map
);
JSONObject
result
=
HttpClientUtils
.
doPostJson
(
url
,
params
);
Map
data
=
(
Map
)
result
.
get
(
"data"
);
String
fundOpToken
=
data
.
get
(
"token"
).
toString
();
log
.
info
(
"登录资金方OP:"
+
result
);
return
fundOpToken
;
}
/**
* 分配资产计划
*/
public
static
boolean
setFundPlan
(
String
namespace
,
Integer
fundId
,
String
fundOpToken
)
{
String
url
=
"http://opapi-"
+
namespace
+
".liangkebang.net"
+
"/clotho/funds/plan/funding/plan/save"
;
Date
date
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
today
=
formatter
.
format
(
date
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"fundCorpId"
,
fundId
);
params
.
put
(
"planDate"
,
today
);
params
.
put
(
"maxAssignAmount"
,
10000000
);
params
.
put
(
"maxLoanAmount"
,
10000000
);
params
.
put
(
"maxLoanPeople"
,
100
);
params
.
put
(
"maxAssignPeople"
,
100
);
params
.
put
(
"priorityLevel"
,
1
);
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"x-auth-token"
,
fundOpToken
);
JSONObject
result
=
HttpClientUtils
.
doPost
(
url
,
params
,
headers
);
log
.
info
(
"分配资金方的结果为:"
+
result
);
if
(
result
.
get
(
"code"
).
equals
(
"0000"
))
{
return
true
;
}
return
false
;
}
/**
* 打开推送放款
*/
public
static
boolean
unblockLoan
(
String
namespace
,
Integer
fundId
,
String
fundOpToken
)
{
String
url
=
"http://opapi-"
+
namespace
+
".liangkebang.net"
+
"/clotho/funds/plan/funding/switch/"
+
fundId
+
"/loan/auto_lock"
;
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"to"
,
true
);
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"x-auth-token"
,
fundOpToken
);
JSONObject
result
=
HttpClientUtils
.
doPost
(
url
,
params
,
headers
);
log
.
info
(
"打开推送放款:"
+
result
);
if
(
result
.
get
(
"code"
).
equals
(
"0000"
))
{
return
true
;
}
return
false
;
}
/**
* 判断是否已经分配资金方
*/
public
static
boolean
assignFundOrNot
(
String
namespace
,
Integer
fundId
,
String
fundOpToken
)
throws
URISyntaxException
{
boolean
flag
=
false
;
String
url
=
"http://opapi-"
+
namespace
+
".liangkebang.net"
+
"/clotho/funds/plan/funding/asset/week/0"
;
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"x-auth-token"
,
fundOpToken
);
JSONObject
result
=
HttpClientUtils
.
doGetReturnJson
(
url
,
null
,
headers
);
System
.
out
.
println
(
result
);
Map
data
=
(
Map
)
result
.
get
(
"data"
);
List
<
Map
>
dataList
=
(
List
<
Map
>)
data
.
get
(
fundId
.
toString
());
Date
date
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
today
=
formatter
.
format
(
date
);
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
if
(
dataList
.
get
(
i
).
get
(
"planDate"
).
toString
().
equals
(
today
))
{
flag
=
true
;
}
}
System
.
out
.
println
(
"资金方是否已经分配:"
+
flag
);
return
flag
;
}
}
}
src/main/java/cn/qg/qaplatform/service/GenUserDataService.java
View file @
55a3881a
...
@@ -7,6 +7,11 @@ import java.sql.SQLException;
...
@@ -7,6 +7,11 @@ import java.sql.SQLException;
public
interface
GenUserDataService
{
public
interface
GenUserDataService
{
/**
* 分配资金方
*/
boolean
assignFundCorp
(
String
namespace
,
Integer
fundId
);
/**
/**
* 授信
* 授信
* @param applyLoanInfo 造数据的相关信息
* @param applyLoanInfo 造数据的相关信息
...
...
src/main/java/cn/qg/qaplatform/service/impl/GenUserDataServiceImpl.java
View file @
55a3881a
...
@@ -9,8 +9,11 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -9,8 +9,11 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
sun.applet.Main
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.print.URIException
;
import
java.net.URISyntaxException
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -25,6 +28,40 @@ public class GenUserDataServiceImpl implements GenUserDataService {
...
@@ -25,6 +28,40 @@ public class GenUserDataServiceImpl implements GenUserDataService {
@Autowired
@Autowired
QueryBasicLoanStatusDataService
queryBasicLoanStatusDataService
;
QueryBasicLoanStatusDataService
queryBasicLoanStatusDataService
;
/**
* 分配资产计划
* @param namespace
* @param fundId
* @return
*/
@Override
public
boolean
assignFundCorp
(
String
namespace
,
Integer
fundId
)
{
// 登录资金方OP
String
fundOpToken
=
MainProcess
.
loginFundOP
(
namespace
);
boolean
isAleadyAssign
=
false
;
// 检查是否已分配资产计划
try
{
isAleadyAssign
=
MainProcess
.
assignFundOrNot
(
namespace
,
fundId
,
fundOpToken
);
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
boolean
assignResult
=
false
;
boolean
unblockResult
=
false
;
// 如果未分配
if
(!
isAleadyAssign
)
{
// 分配资产计划
assignResult
=
MainProcess
.
setFundPlan
(
namespace
,
fundId
,
fundOpToken
);
// 打开推送放款
unblockResult
=
MainProcess
.
unblockLoan
(
namespace
,
fundId
,
fundOpToken
);
if
(
assignResult
&&
unblockResult
)
{
return
true
;
}
return
false
;
}
else
{
return
true
;
}
}
/**
/**
* 授信
* 授信
* @param applyLoanInfo 造数据的相关信息
* @param applyLoanInfo 造数据的相关信息
...
@@ -111,8 +148,7 @@ public class GenUserDataServiceImpl implements GenUserDataService {
...
@@ -111,8 +148,7 @@ public class GenUserDataServiceImpl implements GenUserDataService {
String
orderNo
=
authResult
.
get
(
"order_no"
).
toString
().
trim
();
String
orderNo
=
authResult
.
get
(
"order_no"
).
toString
().
trim
();
String
productId
=
authResult
.
get
(
"product_id"
).
toString
();
String
productId
=
authResult
.
get
(
"product_id"
).
toString
();
// 查询accountId
// 查询accountId
Map
accountMap
=
MainProcess
.
getUserAccountId
(
namespace
,
userId
,
productId
);
Long
accountId
=
MainProcess
.
getUserAccountId
(
namespace
,
userId
,
productId
);
Long
accountId
=
(
Long
)
accountMap
.
get
(
"id"
);
// 绑卡
// 绑卡
String
payToken
=
MainProcess
.
bindCard
(
namespace
,
token
,
accountId
);
String
payToken
=
MainProcess
.
bindCard
(
namespace
,
token
,
accountId
);
// 绑卡发送短信
// 绑卡发送短信
...
@@ -189,6 +225,11 @@ public class GenUserDataServiceImpl implements GenUserDataService {
...
@@ -189,6 +225,11 @@ public class GenUserDataServiceImpl implements GenUserDataService {
@Override
@Override
public
boolean
genLoanUser
(
ApplyLoanInfo
applyLoanInfo
)
throws
Exception
{
public
boolean
genLoanUser
(
ApplyLoanInfo
applyLoanInfo
)
throws
Exception
{
Integer
status
=
applyLoanInfo
.
getStatus
();
Integer
status
=
applyLoanInfo
.
getStatus
();
String
namespace
=
applyLoanInfo
.
getNamespace
();
Integer
fundId
=
applyLoanInfo
.
getFundId
();
boolean
assignFundResult
=
assignFundCorp
(
namespace
,
fundId
);
log
.
info
(
"分配资金方的结果为:"
+
assignFundResult
);
/**
/**
* 0 - 审核通过
* 0 - 审核通过
...
...
src/test/java/cn/qg/qaplatform/test/xyqb.java
View file @
55a3881a
...
@@ -609,12 +609,41 @@ public class xyqb {
...
@@ -609,12 +609,41 @@ public class xyqb {
System
.
out
.
println
(
"推送放款Enable:"
+
result
);
System
.
out
.
println
(
"推送放款Enable:"
+
result
);
}
}
/**
* 判断是否已经分配资金方
*/
public
static
boolean
assignFundOrNot
()
throws
URISyntaxException
{
boolean
flag
=
false
;
String
url
=
"http://opapi-"
+
namespace
+
".liangkebang.net"
+
"/clotho/funds/plan/funding/asset/week/0"
;
Map
<
String
,
Object
>
headers
=
new
HashMap
<>();
headers
.
put
(
"x-auth-token"
,
fundOpToken
);
JSONObject
result
=
HttpClientUtils
.
doGetReturnJson
(
url
,
null
,
headers
);
System
.
out
.
println
(
result
);
Map
data
=
(
Map
)
result
.
get
(
"data"
);
List
<
Map
>
dataList
=
(
List
<
Map
>)
data
.
get
(
fundId
.
toString
());
Date
date
=
new
Date
();
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
today
=
formatter
.
format
(
date
);
for
(
int
i
=
0
;
i
<
dataList
.
size
();
i
++)
{
if
(
dataList
.
get
(
i
).
get
(
"planDate"
).
toString
().
equals
(
today
))
{
flag
=
true
;
}
}
System
.
out
.
println
(
"资金方是否已经分配:"
+
flag
);
return
flag
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 分配资金方
// 分配资金方
loginFundOP
();
loginFundOP
();
setFundPlan
();
boolean
result
=
assignFundOrNot
();
unblockLoan
();
if
(!
result
)
{
setFundPlan
();
unblockLoan
();
}
// 授信
// login();
// login();
// checkUserId();
// checkUserId();
// syncSessionToXyqb();
// syncSessionToXyqb();
...
...
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