Commit 5c13062a by Joneq

修改逾期金额率

parent fb8bdfdb
Showing with 53 additions and 9 deletions
...@@ -32,12 +32,14 @@ const ( ...@@ -32,12 +32,14 @@ const (
bank_sql6 = "select * from lie_basic_month_tolerance where erp_company_code='%s' and month in(%s)" //获取详情 bank_sql6 = "select * from lie_basic_month_tolerance where erp_company_code='%s' and month in(%s)" //获取详情
bank_sql7 = "SELECT ((t.my_rate+1)/(t.plat_rate+1))-1 as delay_rate FROM " + //平台逾期金额率
"( " + bank_sql7 = "SELECT ( sum(delay_amount)/sum(receive_amount) ) as plat_rate from lie_basic_month where MONTH in (%s)"
"SELECT " + //客户近6个月平均逾期金额率
" (SELECT sum(delay_amount)/sum(receive_amount) from lie_basic_month_tolerance where erp_company_code = '%s' and MONTH in (%s)) my_rate, " + bank_sql8 = "SELECT ( SELECT SUM(delay_amount) / SUM(receive_amount) FROM lie_basic_month_tolerance WHERE erp_company_code = '%s' AND MONTH IN (%s)) AS my_rate "
" (SELECT sum(delay_amount)/sum(receive_amount) from lie_basic_month_tolerance where MONTH in (%s)) plat_rate " + //平台完成账期订单金额
")t " bank_sql10 = "SELECT (sum(receive_amount)) as success_money from lie_basic_month_tolerance where MONTH in (%s)"
//近6个月平台账期金额
bank_sql11 = "SELECT sum(receive_amount) as sum_money from lie_basic_month_tolerance where MONTH in (%s)"
) )
//计算逾期金额率:延期支付时间超过平均账期的金额/收款总额: //计算逾期金额率:延期支付时间超过平均账期的金额/收款总额:
...@@ -195,10 +197,21 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems [] ...@@ -195,10 +197,21 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems []
s1 = c1["return_amount"] s1 = c1["return_amount"]
s2 = c1["unload_amount"] s2 = c1["unload_amount"]
case 44: //近6个月逾期变化率 case 44: //近6个月逾期变化率
sql7 := fmt.Sprintf(bank_sql7,y["erp_company_code"],month_six,month_six) sql8 := fmt.Sprintf(bank_sql8,y["erp_company_code"],month_six)
c3,_ := d.QueryOne(ctx,3,sql7) c3,_ := d.QueryOne(ctx,3,sql8)
if c3["delay_rate"] == "" { //近6月逾期金额率
if c3["my_rate"] == "" {
c3["my_rate"] = "0"
}
//获取平台6个月加权平均逾期金额率
c3["plat_rate"] = d.GetPlatRate(ctx,3,month_six,y["erp_company_code"])
if c3["plat_rate"] == "" {
c3["delay_rate"] = "0" 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"]); ladder_rate = logic.MyFloat64(c3["delay_rate"]);
...@@ -268,3 +281,34 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si ...@@ -268,3 +281,34 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si
return return
} }
//平台6个月加权平均逾期金额率算法为:
// (第1月的平台逾期率*第1月平台完成账期订单金额+第2月的平台逾期率*第2月平台完成账期订单金额+第3月的平台逾期率*第3月平台完成账期订单金额.......)/近6个月平台账期订单金额
func (d *dao) GetPlatRate(ctx context.Context,db int,monthsix,erpcompany_code string)(plat_rate string){
var plat_rate_float float64
plat_rate_float = 0;
sql11 := fmt.Sprintf(bank_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(bank_sql7,current_month)
sql10 := fmt.Sprintf(bank_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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment