Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
kaopu-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bc9d17b6
authored
Nov 27, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善有就更改,没有就添加
parent
b7d67be7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
226 additions
and
13 deletions
cmd/static/main.go
cmd/static/personal_credit.go
internal/dao/scores.go
cmd/static/main.go
View file @
bc9d17b6
...
@@ -56,13 +56,11 @@ func main() {
...
@@ -56,13 +56,11 @@ func main() {
for
_
,
v
:=
range
companyData
{
for
_
,
v
:=
range
companyData
{
insertScoreMsg
.
ComCreditsId
=
stringTurnInt64
(
v
[
"id"
])
insertScoreMsg
.
ComCreditsId
=
stringTurnInt64
(
v
[
"id"
])
getCompanyRunInfo
(
c
)
getCompanyRunInfo
(
c
)
CompanyInfo
()
CompanyInfo
()
EnterPriseCredit
()
AddScore
()
AddScore
()
HistoryBussiness
()
HistoryBussiness
()
//Personal
Credit()
EnterPrise
Credit
()
PersonalCredit
()
}
}
//赋值完关闭通道
//赋值完关闭通道
...
...
cmd/static/personal_credit.go
View file @
bc9d17b6
package
main
package
main
var
(
p_currentScore
float64
p_totalScore
[
11
]
float64
)
//个人征信(30分)
//个人征信(30分)
func
PersonalCredit
()
{
func
PersonalCredit
()
{
Age
()
Age
()
...
@@ -13,61 +19,248 @@ func PersonalCredit() {
...
@@ -13,61 +19,248 @@ func PersonalCredit() {
NumberOfCreditInquiryInThePastTwoMonths
()
NumberOfCreditInquiryInThePastTwoMonths
()
TotalCreditCardLimit
()
TotalCreditCardLimit
()
MaximumAmountOfSingleCreditCard
()
MaximumAmountOfSingleCreditCard
()
var
(
sumScore
float64
=
0
joinNum
float64
=
0
)
//查找出所有不是0的分值
for
i
:=
0
;
i
<
len
(
totalScore
)
;
i
++
{
if
totalScore
[
i
]
!=
0
{
joinNum
+=
1
sumScore
+=
totalScore
[
i
]
*
0.5
}
}
//经过权重计算之后的总分值
sumScore
=
sumScore
/
joinNum
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
sumScore
,
sumScore
,
sumScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
0
,
3
)
}
}
//年龄(1分)
//年龄(1分)
func
Age
()
{
func
Age
()
{
age
:=
stringTurnInt64
(
companySoreFields
[
"age"
])
if
age
>
30
&&
age
<
50
{
p_currentScore
=
1
}
else
{
p_currentScore
=
0
}
p_totalScore
[
0
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
17
)
}
}
//婚姻状况(1分)
//婚姻状况(1分)
func
MaritalStatus
()
{
func
MaritalStatus
()
{
marital_status
:=
stringTurnInt64
(
companySoreFields
[
"marital_status"
])
if
marital_status
==
1
{
p_currentScore
=
1
}
else
{
p_currentScore
=
0
}
p_totalScore
[
1
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
18
)
}
}
//违约账户比(2分)
//违约账户比(2分)
func
DefaultAccountRatio
()
{
func
DefaultAccountRatio
()
{
account_ratio
:=
stringTurnFloat64
(
companySoreFields
[
"account_ratio"
])
if
account_ratio
<
20
{
p_currentScore
=
2
}
else
{
p_currentScore
=
0
}
p_totalScore
[
2
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
19
)
}
}
//对外担保(5分)
//对外担保(5分)
func
ExternalGuarantee
()
{
func
ExternalGuarantee
()
{
guaranty
:=
stringTurnInt64
(
companySoreFields
[
"guaranty"
])
if
guaranty
==
1
{
p_currentScore
=
0
}
else
{
p_currentScore
=
5
}
p_totalScore
[
3
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
20
)
}
}
//近2年内30天内逾期次数(3分)
//近2年内30天内逾期次数(3分)
func
SumBeOverdueMonthTwoYesar
()
{
func
SumBeOverdueMonthTwoYesar
()
{
two_years_th_days_overdue_times
:=
stringTurnInt64
(
companySoreFields
[
"two_years_th_days_overdue_times"
])
if
two_years_th_days_overdue_times
<
1
{
p_currentScore
=
3
}
else
{
p_currentScore
=
0
}
p_totalScore
[
4
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
22
)
}
}
//近2年内最大逾期金额(3分)
//近2年内最大逾期金额(3分)
two_years_max_overdue_amount
func
MaxBeOverdueTwoYears
()
{
func
MaxBeOverdueTwoYears
()
{
two_years_max_overdue_amount
:=
stringTurnFloat64
(
companySoreFields
[
"two_years_max_overdue_amount"
])
if
two_years_max_overdue_amount
>=
10000
{
p_currentScore
=
0
}
else
if
two_years_max_overdue_amount
>=
5000
&&
two_years_max_overdue_amount
<
10000
{
p_currentScore
=
1
}
else
if
two_years_max_overdue_amount
>=
2000
&&
two_years_max_overdue_amount
<
5000
{
p_currentScore
=
2
}
else
if
two_years_max_overdue_amount
>=
0
&&
two_years_max_overdue_amount
<
2000
{
p_currentScore
=
3
}
p_totalScore
[
5
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
23
)
}
}
//是否存在当前逾期(3分)
//是否存在当前逾期(3分)
func
IsBeOverdue
()
{
func
IsBeOverdue
()
{
is_exist_now_overdue
:=
stringTurnInt64
(
companySoreFields
[
"is_exist_now_overdue"
])
if
is_exist_now_overdue
==
1
{
p_currentScore
=
0
}
else
{
p_currentScore
=
3
}
p_totalScore
[
6
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
24
)
}
}
//有无房贷(1分)
//有无房贷(1分)
func
IsMortgage
()
{
func
IsMortgage
()
{
presence_of_mortgage
:=
stringTurnInt64
(
companySoreFields
[
"presence_of_mortgage"
])
if
presence_of_mortgage
==
1
{
p_currentScore
=
0
}
else
{
p_currentScore
=
1
}
p_totalScore
[
7
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
25
)
}
}
//近两个月征信查询次数(5分)
//近两个月征信查询次数(5分)
func
NumberOfCreditInquiryInThePastTwoMonths
()
{
func
NumberOfCreditInquiryInThePastTwoMonths
()
{
two_months_credit_view_nums
:=
stringTurnInt64
(
companySoreFields
[
"two_months_credit_view_nums"
])
if
two_months_credit_view_nums
==
0
{
p_currentScore
=
5
}
else
if
two_months_credit_view_nums
==
1
{
p_currentScore
=
3
}
else
if
two_months_credit_view_nums
==
2
{
p_currentScore
=
2
}
else
if
two_months_credit_view_nums
==
3
{
p_currentScore
=
1
}
else
if
two_months_credit_view_nums
>=
4
{
p_currentScore
=
0
}
else
{
p_currentScore
=
0
}
p_totalScore
[
8
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
26
)
}
}
//信用卡总额度(3分)
//信用卡总额度(3分)
func
TotalCreditCardLimit
()
{
func
TotalCreditCardLimit
()
{
credit_card_total
:=
stringTurnInt64
(
companySoreFields
[
"credit_card_total"
])
if
credit_card_total
>=
200000
{
p_currentScore
=
3
}
else
{
p_currentScore
=
0
}
p_totalScore
[
9
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
27
)
}
}
//单张信用卡最高额度(3分)
//单张信用卡最高额度(3分)
func
MaximumAmountOfSingleCreditCard
()
{
func
MaximumAmountOfSingleCreditCard
()
{
maximum_credit_card_limit
:=
stringTurnInt64
(
companySoreFields
[
"maximum_credit_card_limit"
])
if
maximum_credit_card_limit
>=
100000
{
p_currentScore
=
3
}
else
{
p_currentScore
=
0
}
p_totalScore
[
10
]
=
p_currentScore
//设置分数
insertScoreMsg
.
FinalScore
,
insertScoreMsg
.
TotalScore
,
insertScoreMsg
.
CurrentScore
=
p_currentScore
,
p_currentScore
,
p_currentScore
insertScoreMsg
.
Weight
=
50
setInsertScoreChanFooter
(
1
,
3
,
28
)
}
}
internal/dao/scores.go
View file @
bc9d17b6
...
@@ -2,24 +2,47 @@ package dao
...
@@ -2,24 +2,47 @@ package dao
import
(
import
(
"context"
"context"
"fmt"
"github.com/bilibili/kratos/pkg/log"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/model"
"kaopu-server/internal/model"
"time"
"time"
)
)
//增加记录
//增加
或者修改
记录
func
(
d
*
dao
)
InsertScores
(
ctx
context
.
Context
,
score
model
.
Scores
)
(
insertId
int64
,
err
error
)
{
func
(
d
*
dao
)
InsertScores
(
ctx
context
.
Context
,
score
model
.
Scores
)
(
insertId
int64
,
err
error
)
{
insertSql
:=
"INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
var
(
exitId
int
execSql
string
affectNum
int64
)
err
=
d
.
db
.
QueryRow
(
ctx
,
"select id from lie_scores where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ? limit 0,1"
,
score
.
Type
,
score
.
ProjectPid
,
score
.
ProjectId
,
score
.
ComCreditsId
)
.
Scan
(
&
exitId
)
if
err
!=
nil
{
fmt
.
Print
(
err
)
fmt
.
Print
(
"save list fail"
)
}
row
,
err
:=
d
.
db
.
Exec
(
ctx
,
insertSql
,
score
.
Type
,
score
.
ProjectPid
,
score
.
ProjectId
,
score
.
TotalScore
,
score
.
CurrentScore
,
score
.
Weight
,
score
.
FinalScore
,
score
.
ComCreditsId
,
time
.
Now
()
.
Unix
())
if
exitId
==
0
{
execSql
=
"INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
row
,
err
:=
d
.
db
.
Exec
(
ctx
,
execSql
,
score
.
Type
,
score
.
ProjectPid
,
score
.
ProjectId
,
score
.
TotalScore
,
score
.
CurrentScore
,
score
.
Weight
,
score
.
FinalScore
,
score
.
ComCreditsId
,
time
.
Now
()
.
Unix
())
if
err
!=
nil
{
log
.
Error
(
"db.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
else
{
affectNum
,
_
=
row
.
LastInsertId
()
}
}
else
{
execSql
=
"update `lie_scores` set `type` = ?, `project_pid` = ?, `project_id` = ?, `total_score` = ?, `current_score` = ?, `weight` = ?, `final_score` = ?, `com_credits_id` = ?, `update_time` = ? where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ?"
row
,
err
:=
d
.
db
.
Exec
(
ctx
,
execSql
,
score
.
Type
,
score
.
ProjectPid
,
score
.
ProjectId
,
score
.
TotalScore
,
score
.
CurrentScore
,
score
.
Weight
,
score
.
FinalScore
,
score
.
ComCreditsId
,
time
.
Now
()
.
Unix
(),
score
.
Type
,
score
.
ProjectPid
,
score
.
ProjectId
,
score
.
ComCreditsId
)
if
err
!=
nil
{
log
.
Error
(
"db.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
else
{
affectNum
,
_
=
row
.
RowsAffected
()
}
if
err
!=
nil
{
log
.
Error
(
"db.DemoExec.Exec(%s) error(%v)"
,
insertSql
,
err
)
return
}
}
insertId
=
affectNum
row
.
LastInsertId
()
defer
d
.
db
.
Close
()
defer
d
.
db
.
Close
()
return
return
}
}
\ 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