Commit 25346f63 by huangchengyi

1.0

parent c06206b6
......@@ -84,7 +84,6 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
}else {
_sql2 =fmt.Sprintf(_sql2_2,erp_company_code) //查询一个公司
}
fmt.Print(_sql2)
company_info,err := d.QueryMany(ctx,1,_sql2);
if err != nil {
......
......@@ -5,7 +5,6 @@ import (
"fmt"
"kaopu-server/internal/logic"
"kaopu-server/internal/model"
"math"
)
const (
......@@ -14,7 +13,7 @@ const (
_sql5 = "select count(1) yuqibi from lie_basic_detail where delay_day>0 and erp_company_code='%s'" //发生逾期总笔数
_sql6 = "select count(1) allbi from lie_basic_detail where return_amount>0 and erp_company_code='%s'" //收款总笔数
_sql8 = "select sum(delay_day) sum_delay_day from lie_basic_detail where delay_day>0 and erp_company_code='%s'" //每笔逾期账款的逾期时间合计
_sql9 = "select sum(return_time - business_time) sum_zhang from lie_basic_detail where erp_company_code='%s'" //每笔付款账期合计 应收日期在1/1-1/31的支付天数合计
_sql9 = "select sum(TIMESTAMPDIFF(DAY,FROM_UNIXTIME(business_time,'%Y-%m-%d'),FROM_UNIXTIME(return_time,'%Y-%m-%d'))) sum_zhang from lie_basic_detail where erp_company_code=" //每笔付款账期合计 应收日期在1/1-1/31的支付天数合计
_sql10 = "select sum(return_amount) sum_rongcha_huan from lie_basic_detail where delay_day<0 and erp_company_code='%s'" //容差范围内的收款(还款)金额 应收日期在1/1-1/31且逾期支付天数<容差值(目前为0)的下单金额合计
_sql11 = "select count(1) sum_rongcha_bi from lie_basic_detail where delay_day<0 and erp_company_code='%s'" //完成容差范围内收款的笔数 应收日期在1/1-1/31且0<逾期支付天数<容差值(目前为0)的下单订单数
_sql12 = "select sum(order_amount) sum_jiaohuo from lie_basic_detail where erp_company_code='%s'" //交货总金额 退货总金额+出库总金额
......@@ -111,21 +110,22 @@ func (d *dao) DongYuqiDivDay(ctx context.Context,y map[string]string,modelItems
//4 平均付款时间(天): 每笔付款账期合计/收款总笔数
func (d *dao) DongDivPayDay(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int) (ladder_rate string,ladder_score float64,err error) {
//每笔付款账期合计
c1,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql9,y["erp_company_code"]))
sql9 := _sql9+"'"+y["erp_company_code"]+"'"
c1,_ := d.QueryOne(ctx,2,sql9)
if c1["sum_zhang"] == "0" { //没有结果
chrate = 0
ladder_rate = "每笔付款账期合计:0"
}else{
//每笔付款账期合计算天,向下取整 1.1 =1
sum_zhang_day := math.Floor(logic.MyFloat64(c1["sum_zhang"])/86400)
//收款总笔数
c2,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql6,y["erp_company_code"]))
if c2["allbi"] == "0" { //没有结果
chrate = 0;
ladder_rate = "收款总笔数:0"
}else{
chrate = sum_zhang_day/logic.MyFloat64(c2["allbi"])
ladder_rate = logic.MyFloat64ToStr(sum_zhang_day)+"/"+c2["allbi"]+"="+logic.MyFloat64ToStr(chrate)
chrate = logic.MyFloat64(c1["sum_zhang"])/logic.MyFloat64(c2["allbi"])
ladder_rate = logic.MyFloat64ToStr(logic.MyFloat64(c1["sum_zhang"]))+"/"+c2["allbi"]+"="+logic.MyFloat64ToStr(chrate)
}
}
......
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