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
73c1fe8e
authored
Dec 31, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
判断sql插入限制
parent
c67d41ab
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
135 additions
and
7 deletions
cmd/main.go
internal/dao/bank_dong.go
internal/dao/com_credits.go
internal/dao/common.go
internal/logic/tianyancha.go
cmd/main.go
View file @
73c1fe8e
This diff is collapsed.
Click to expand it.
internal/dao/bank_dong.go
View file @
73c1fe8e
...
@@ -205,7 +205,7 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems []
...
@@ -205,7 +205,7 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems []
case
48
:
// 账期使用倍数统计
case
48
:
// 账期使用倍数统计
last_month
:=
time
.
Now
()
.
Format
(
"2006"
)
+
time
.
Now
()
.
AddDate
(
0
,
-
1
,
0
)
.
Format
(
"01"
)
last_month
:=
time
.
Now
()
.
Format
(
"2006"
)
+
time
.
Now
()
.
AddDate
(
0
,
-
1
,
0
)
.
Format
(
"01"
)
sql6
:=
fmt
.
Sprintf
(
bank_sql6
,
y
[
"erp_company_code"
],
last_month
)
sql6
:=
fmt
.
Sprintf
(
bank_sql6
,
y
[
"erp_company_code"
],
last_month
)
c3
,
_
:=
d
.
QueryOne
(
ctx
,
1
,
sql6
)
c3
,
_
:=
d
.
QueryOne
(
ctx
,
3
,
sql6
)
if
c3
==
nil
||
c3
[
"period_use_times_six"
]
==
""
{
if
c3
==
nil
||
c3
[
"period_use_times_six"
]
==
""
{
ladder_rate
=
0
;
ladder_rate
=
0
;
remark
=
"0"
remark
=
"0"
...
@@ -256,7 +256,7 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si
...
@@ -256,7 +256,7 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si
logic
.
LogWrite
(
"统计动态分数完成,供应商id:"
+
logic
.
MyInt64ToStr
(
com_credits_id
)
+
"总动态分:"
+
logic
.
MyFloat64ToStr
(
sum_dong_score
),
"dong_sum"
,
1
)
logic
.
LogWrite
(
"统计动态分数完成,供应商id:"
+
logic
.
MyInt64ToStr
(
com_credits_id
)
+
"总动态分:"
+
logic
.
MyFloat64ToStr
(
sum_dong_score
),
"dong_sum"
,
1
)
//最后累计总分评分
//最后累计总分评分
affectNum
,
_
=
d
.
UpdateMoveSumScores
(
ctx
,
com_credit
)
affectNum
,
_
=
d
.
Update
Bank
MoveSumScores
(
ctx
,
com_credit
)
return
return
}
}
internal/dao/com_credits.go
View file @
73c1fe8e
...
@@ -15,7 +15,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin
...
@@ -15,7 +15,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin
var
(
var
(
rows
*
sql
.
Rows
rows
*
sql
.
Rows
)
)
if
rows
,
err
=
d
.
db
.
Query
(
ctx
,
"SELECT "
+
SqlField
+
" FROM lie_com_credits where
status = 5 or status = 10
"
);
err
!=
nil
{
if
rows
,
err
=
d
.
db
.
Query
(
ctx
,
"SELECT "
+
SqlField
+
" FROM lie_com_credits where
id >=4907
"
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
err
=
errors
.
WithStack
(
err
)
return
return
}
}
...
@@ -66,6 +66,12 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi
...
@@ -66,6 +66,12 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi
return
return
}
}
func
(
d
*
dao
)
UpdateComCredits
(
ctx
context
.
Context
,
com_credits
model
.
ComCredits
)(
Id
int64
,
err
error
)
{
func
(
d
*
dao
)
UpdateComCredits
(
ctx
context
.
Context
,
com_credits
model
.
ComCredits
)(
Id
int64
,
err
error
)
{
var
(
var
(
...
@@ -141,5 +147,104 @@ func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]strin
...
@@ -141,5 +147,104 @@ func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]strin
//------------------银行方法-----------------//
//修改银行动态总分记录
func
(
d
*
dao
)
UpdateBankMoveSumScores
(
ctx
context
.
Context
,
com_credits
model
.
ComCredits
)
(
insertId
int64
,
err
error
)
{
var
(
execSql
string
)
execSql
=
"update `lie_com_credits` set `dynamic_credit_score` = ? where id = ? "
row
,
err
:=
d
.
db_bank
.
Exec
(
ctx
,
execSql
,
com_credits
.
DynamicCreditScore
,
com_credits
.
Id
)
if
err
!=
nil
{
log
.
Error
(
"UpdateMoveSumScoresdb.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
d
.
UpdateBankComCredits
(
ctx
,
com_credits
)
row
.
RowsAffected
()
return
}
func
(
d
*
dao
)
UpdateBankComCredits
(
ctx
context
.
Context
,
com_credits
model
.
ComCredits
)(
Id
int64
,
err
error
)
{
var
(
rows
*
sql
.
Rows
res
map
[
string
]
string
)
//获取当前条的数据
if
rows
,
err
=
d
.
db_bank
.
Query
(
ctx
,
"select "
+
SqlField
+
" from lie_com_credits where id = ?"
,
com_credits
.
Id
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
defer
rows
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
return
}
twoMap
,
err
:=
GetAllParam
(
rows
)
for
_
,
v
:=
range
twoMap
{
res
=
v
break
}
//修改相应的参数
total_credit_score
:=
logic
.
StringTurnFloat64
(
res
[
"static_credit_score"
])
+
logic
.
StringTurnFloat64
(
res
[
"dynamic_credit_score"
])
grade
,
_
:=
d
.
GetBankGrade
(
ctx
,
total_credit_score
)
execSql
:=
"update `lie_com_credits` set `static_credit_score` = ?,`dynamic_credit_score` = ?, `total_credit_score` = ? , `ichunt_hunting_core` = ? , `recom_time_limit` = ? ,`recommended_amount` = ? ,`status` = 10 where id = ? "
row
,
err
:=
d
.
db_bank
.
Exec
(
ctx
,
execSql
,
logic
.
StringTurnFloat64
(
res
[
"static_credit_score"
]),
logic
.
StringTurnFloat64
(
res
[
"dynamic_credit_score"
]),
total_credit_score
,
grade
[
"grade"
],
grade
[
"recommended_limit"
],
logic
.
StringTurnFloat64
(
grade
[
"recommended_amount"
]),
com_credits
.
Id
)
if
err
!=
nil
{
log
.
Error
(
"UpdateComCreditsdb.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
row
.
RowsAffected
()
return
}
func
(
d
*
dao
)
GetBankGrade
(
ctx
context
.
Context
,
sumScore
float64
)(
res
map
[
string
]
string
,
err
error
)
{
var
(
rows
*
sql
.
Rows
)
//获取当前条的数据
if
rows
,
err
=
d
.
db_bank
.
Query
(
ctx
,
"select "
+
SqlField
+
" from lie_grade where status = 1 and min_score <= ? and max_score > ?"
,
sumScore
,
sumScore
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
return
}
twoMap
,
err
:=
GetAllParam
(
rows
)
for
_
,
v
:=
range
twoMap
{
res
=
v
break
}
return
}
//------------------银行方法-----------------//
internal/dao/common.go
View file @
73c1fe8e
...
@@ -94,11 +94,30 @@ func (d *dao)QueryMany(ctx context.Context,db int,sql_str string)(res []map[stri
...
@@ -94,11 +94,30 @@ func (d *dao)QueryMany(ctx context.Context,db int,sql_str string)(res []map[stri
var
(
var
(
rows1
*
sql
.
Rows
rows1
*
sql
.
Rows
)
)
//查询项目配置
if
rows1
,
err
=
d
.
db
.
Query
(
ctx
,
sql_str
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
//fmt.Print(sql_str)
return
if
db
==
1
{
//查询项目配置
if
rows1
,
err
=
d
.
db
.
Query
(
ctx
,
sql_str
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
}
else
if
db
==
3
{
//查询项目配置
if
rows1
,
err
=
d
.
db_bank
.
Query
(
ctx
,
sql_str
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
}
else
{
//查询项目配置
if
rows1
,
err
=
d
.
db2
.
Query
(
ctx
,
sql_str
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
}
}
defer
rows1
.
Close
()
defer
rows1
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"error1001:"
+
sql_str
,
err
)
fmt
.
Println
(
"error1001:"
+
sql_str
,
err
)
...
...
internal/logic/tianyancha.go
View file @
73c1fe8e
...
@@ -113,6 +113,10 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
...
@@ -113,6 +113,10 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
returnData
[
"tianyancha_json"
]
+=
"||||"
+
string
(
respBody
)
returnData
[
"tianyancha_json"
]
+=
"||||"
+
string
(
respBody
)
}
}
if
len
(
returnData
[
"tianyancha_json"
])
>
130000
{
returnData
[
"tianyancha_json"
]
=
"字符串过长"
}
var
changeInfoNum
int64
var
changeInfoNum
int64
changeInfoNum
=
0
changeInfoNum
=
0
for
_
,
v
:=
range
totalNum
.
Result
.
Items
{
for
_
,
v
:=
range
totalNum
.
Result
.
Items
{
...
...
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