|
|
@ -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) |
|
|
|