From 76302a53967adf49e2b20b7ee1edcd09d0cc9db7 Mon Sep 17 00:00:00 2001 From: zhangxin Date: Fri, 19 Mar 2021 10:07:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=88=E5=90=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=92=8C=E6=9B=B4=E6=96=B0=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/models/contracttab.go | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/web/models/contracttab.go b/web/models/contracttab.go index 782b33c..673a755 100644 --- a/web/models/contracttab.go +++ b/web/models/contracttab.go @@ -72,21 +72,22 @@ func (t *Contracttab) Add(me *ContractInfo, lengthdate float64) error { if utils.ValueIsEmpty(t.Begdate) { t.Begdate = utils.TimeFormat(time.Now(), "yyyy-MM-dd") //根据缴费金额计算出截止日期 - addlenght := fmt.Sprintf("%0.1f", lengthdate) + addlenght := fmt.Sprintf("%0.2f", lengthdate) addmonths := strings.Split(addlenght, ".") - adddays := utils.ValueToInt(addmonths[1], 0)*3 - 1 + adds := utils.ValueToFloat(addmonths[1], 0.0) * 0.3 + adddays := utils.ValueToInt(adds, 0) - 1 endTime := time.Now().AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) t.Enddate = utils.TimeFormat(endTime, "yyyy-MM-dd") } else { begtime, _ := utils.TimeParseyyyyMMdd(t.Begdate) //根据缴费金额计算出截止日期 - addlenght := fmt.Sprintf("%0.1f", lengthdate) + addlenght := fmt.Sprintf("%0.2f", lengthdate) addmonths := strings.Split(addlenght, ".") - adddays := utils.ValueToInt(addmonths[1], 0)*3 - 1 + adds := utils.ValueToFloat(addmonths[1], 0.0) * 0.3 + adddays := utils.ValueToInt(adds, 0) - 1 endTime := begtime.AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) t.Enddate = utils.TimeFormat(endTime, "yyyy-MM-dd") } - _, err = session.Table("contracttab").Insert(t) if err != nil { session.Rollback() @@ -262,27 +263,17 @@ func (t *Contracttab) Update(me *ContractInfo, lengthdate float64) error { return err } t.Serialnumber = serialnumber - //begtime, _ := utils.TimeParseyyyyMMdd(t.Enddate) - // - //Begdate := begtime.AddDate(0, 0, 1) - //t.Begdate = utils.TimeFormat(Begdate, "yyyy-MM-dd") - ////根据缴费金额计算出截止日期 - //addlenght := fmt.Sprintf("%0.1f", lengthdate) - //addmonths := strings.Split(addlenght, ".") - //adddays := utils.ValueToInt(addmonths[1], 0)*3 - 1 - //endTime := Begdate.AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) - //t.Enddate = utils.TimeFormat(endTime, "yyyy-MM-dd") - if utils.ValueIsEmpty(t.Begdate) { begtime, _ := utils.TimeParseyyyyMMdd(t.Enddate) Begdate := begtime.AddDate(0, 0, 1) t.Begdate = utils.TimeFormat(Begdate, "yyyy-MM-dd") //根据缴费金额计算出截止日期 - addlenght := fmt.Sprintf("%0.1f", lengthdate) + addlenght := fmt.Sprintf("%0.2f", lengthdate) addmonths := strings.Split(addlenght, ".") - adddays := utils.ValueToInt(addmonths[1], 0)*3 - 1 - endTime := Begdate.AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) + adds := utils.ValueToFloat(addmonths[1], 0.0) * 0.3 + adddays := utils.ValueToInt(adds, 0) - 1 + endTime := time.Now().AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) t.Enddate = utils.TimeFormat(endTime, "yyyy-MM-dd") } else { begtime, _ := utils.TimeParseyyyyMMdd(t.Begdate) @@ -293,10 +284,11 @@ func (t *Contracttab) Update(me *ContractInfo, lengthdate float64) error { begtime = databaseBegtime } t.Begdate = utils.TimeFormat(begtime, "yyyy-MM-dd") - addlenght := fmt.Sprintf("%0.1f", lengthdate) + addlenght := fmt.Sprintf("%0.2f", lengthdate) addmonths := strings.Split(addlenght, ".") - adddays := utils.ValueToInt(addmonths[1], 0)*3 - 1 - endTime := begtime.AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) + adds := utils.ValueToFloat(addmonths[1], 0.0) * 0.3 + adddays := utils.ValueToInt(adds, 0) - 1 + endTime := time.Now().AddDate(0, utils.ValueToInt(addmonths[0], 0), adddays) t.Enddate = utils.TimeFormat(endTime, "yyyy-MM-dd") } _, err = session.Table("contracttab").Cols("linkman", "mobile", "begdate", "enddate", "createtime", "createby", "lengthdate", "chargableexpense", "chargedexpense", "remake", "chargetime", "chargeway", "serialnumber").Where("cid = ? and contractid = ?", t.Cid, t.Contractid).Update(t)