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
20b615eb
authored
Jan 08, 2020
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改动态评分
parent
1e9478f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
12 deletions
internal/dao/bank_dong.go
internal/dao/dong_mod.go
internal/dao/bank_dong.go
View file @
20b615eb
...
...
@@ -116,9 +116,6 @@ func (d *dao) BankDongMain(ctx context.Context,project_id int,erp_company_code s
}
month_six
=
strings
.
TrimRight
(
month_six
,
","
)
// 六个月sql
d
.
QueryOne
(
ctx
,
3
,
"update lie_scores set current_score = 0,current_score =0,total_score=0,final_score=0 where type = 2 and month in ("
+
month_six
+
")"
)
fmt
.
Println
(
"update lie_scores set current_score = 0,current_score =0,total_score=0,final_score=0 where type = 2 and month in ("
+
month_six
+
")"
)
for
_
,
v
:=
range
company_info
{
//循环当前公司,计算各个公司对应分数
if
v
[
"erp_company_code"
]
==
""
{
continue
;
...
...
internal/dao/dong_mod.go
View file @
20b615eb
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"kaopu-server/internal/logic"
"kaopu-server/internal/model"
"strings"
"time"
)
...
...
@@ -30,12 +31,13 @@ const (
_sql6
=
"select * from lie_basic_month where erp_company_code='%s' and month in(%s)"
//获取详情
_sql7
=
"SELECT ((t.my_rate+1)/(t.plat_rate+1))-1 as delay_rate FROM "
+
"( "
+
"SELECT "
+
" (SELECT sum(delay_amount)/sum(receive_amount) from lie_basic_month where erp_company_code = '%s' and MONTH in (%s)) my_rate, "
+
" (SELECT sum(delay_amount)/sum(receive_amount) from lie_basic_month where MONTH in (%s)) plat_rate "
+
")t "
_sql7
=
"SELECT ( sum(delay_amount)/sum(receive_amount) ) as plat_rate from lie_basic_month where MONTH in (%s)"
//客户近6个月平均逾期金额率
_sql8
=
"SELECT ( SELECT SUM(delay_amount) / SUM(receive_amount) FROM lie_basic_month WHERE erp_company_code = '%s' AND MONTH IN (%s)) AS my_rate "
//平台完成账期订单金额
_sql10
=
"SELECT (sum(receive_amount)) as success_money from lie_basic_month where MONTH in (%s)"
//近6个月平台账期金额
_sql11
=
"SELECT sum(receive_amount) as sum_money from lie_basic_month where MONTH in (%s)"
)
/*
...
...
@@ -47,6 +49,14 @@ func (d *dao) DongRate(ctx context.Context,y map[string]string,modelItems []map[
score_one
float64
=
0
;
//对应梯度分数
s1
,
s2
string
//拼接六个月月份字符串
)
companyMonthInfoSql
:=
fmt
.
Sprintf
(
"select * from lie_basic_month where erp_company_code = '%s' and month in (%s)"
,
y
[
"erp_company_code"
],
month_six
)
monthInfo
,
_
:=
d
.
QueryOne
(
ctx
,
1
,
companyMonthInfoSql
)
if
len
(
monthInfo
)
==
0
{
logic
.
LogWrite
(
"没有订单数据跳过:"
+
y
[
"erp_company_code"
],
"dong_error"
,
1
)
return
}
sqla
:=
fmt
.
Sprintf
(
_sql4
,
y
[
"erp_company_code"
],
month_six
)
c1
,
_
:=
d
.
QueryOne
(
ctx
,
1
,
sqla
)
...
...
@@ -76,10 +86,20 @@ func (d *dao) DongRate(ctx context.Context,y map[string]string,modelItems []map[
s1
=
c1
[
"return_amount"
]
s2
=
c1
[
"unload_amount"
]
case
44
:
//近6个月逾期变化率
sql7
:=
fmt
.
Sprintf
(
_sql7
,
y
[
"erp_company_code"
],
month_six
,
month_six
)
c3
,
_
:=
d
.
QueryOne
(
ctx
,
1
,
sql7
)
if
c3
[
"delay_rate"
]
==
""
{
sql8
:=
fmt
.
Sprintf
(
_sql8
,
y
[
"erp_company_code"
],
month_six
)
c3
,
_
:=
d
.
QueryOne
(
ctx
,
1
,
sql8
)
//近6月逾期金额率
if
c3
[
"my_rate"
]
==
""
{
c3
[
"my_rate"
]
=
"0"
}
//获取平台6个月加权平均逾期金额率
c3
[
"plat_rate"
]
=
d
.
GetBankPlatRate
(
ctx
,
1
,
month_six
,
y
[
"erp_company_code"
])
if
c3
[
"plat_rate"
]
==
""
{
c3
[
"delay_rate"
]
=
"0"
}
else
{
c3
[
"delay_rate"
]
=
logic
.
MyFloat64ToStr
(
1
-
(
logic
.
MyFloat64
(
c3
[
"my_rate"
])
/
logic
.
MyFloat64
(
c3
[
"plat_rate"
]
)))
}
ladder_rate
=
logic
.
MyFloat64
(
c3
[
"delay_rate"
]);
...
...
@@ -160,5 +180,36 @@ ear := time.Now().Format("2006")
*/
//平台6个月加权平均逾期金额率算法为:
// (第1月的平台逾期率*第1月平台完成账期订单金额+第2月的平台逾期率*第2月平台完成账期订单金额+第3月的平台逾期率*第3月平台完成账期订单金额.......)/近6个月平台账期订单金额
func
(
d
*
dao
)
GetBankPlatRate
(
ctx
context
.
Context
,
db
int
,
monthsix
,
erpcompany_code
string
)(
plat_rate
string
){
var
plat_rate_float
float64
plat_rate_float
=
0
;
sql11
:=
fmt
.
Sprintf
(
_sql11
,
monthsix
)
sumMoney
,
_
:=
d
.
QueryOne
(
ctx
,
db
,
sql11
)
if
sumMoney
[
"sum_money"
]
==
""
{
sumMoney
[
"sum_money"
]
=
"0"
plat_rate
=
"0"
return
}
for
_
,
current_month
:=
range
strings
.
Split
(
monthsix
,
","
){
sql7
:=
fmt
.
Sprintf
(
_sql7
,
current_month
)
sql10
:=
fmt
.
Sprintf
(
_sql10
,
current_month
)
current_rate
,
_
:=
d
.
QueryOne
(
ctx
,
db
,
sql7
)
current_money
,
_
:=
d
.
QueryOne
(
ctx
,
db
,
sql10
)
plat_rate_float
+=
logic
.
MyFloat64
(
current_rate
[
"plat_rate"
])
*
logic
.
MyFloat64
(
current_money
[
"success_money"
])
}
plat_rate
=
logic
.
MyFloat64ToStr
(
plat_rate_float
/
logic
.
MyFloat64
(
sumMoney
[
"sum_money"
]))
return
}
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