|
|
@ -39,32 +39,61 @@ func InsertContracttab(ctx iris.Context) { |
|
|
|
if err != nil { |
|
|
|
data.Chargetime = utils.TimeFormat(time.Now(), "yyyy-MM-dd") |
|
|
|
} |
|
|
|
me := new(models.Contracttab) |
|
|
|
me = &data.Contracttab |
|
|
|
me.Chargableexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Cid = data.Cid |
|
|
|
me.Chargetype = data.Chargetype |
|
|
|
me.Chargeway = data.Contracttab.Chargeway |
|
|
|
lengthdate := 0.0 |
|
|
|
//下次的开始时间不能小于上次的缴费时间
|
|
|
|
if data.Begindate < data.Contracttab.Begdate { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, "开始时间不能小于上次的缴费时间!", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
switch data.Chargetype { |
|
|
|
case 1: |
|
|
|
start, err := time.Parse("2006-01-02", data.Begindate) |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
/******* |
|
|
|
*Chargetype : 物业费 |
|
|
|
*lengthdate : 缴费时长 |
|
|
|
**************/ |
|
|
|
lengthdate := "" |
|
|
|
if data.Months > 0{ |
|
|
|
lengthdate += utils.ValueToString(data.Months,"") + "月 " |
|
|
|
} |
|
|
|
if data.Days > 0{ |
|
|
|
lengthdate += utils.ValueToString(data.Days,"") + "天 " |
|
|
|
} |
|
|
|
fmt.Println("controller endate:", data.Enddate) |
|
|
|
end, err := time.Parse("2006-01-02", data.Enddate) |
|
|
|
//初始化合同
|
|
|
|
me := new(models.Contracttab) |
|
|
|
me.Cid = data.Cid |
|
|
|
me.Contractid = data.Contractid |
|
|
|
me.Chargetype = data.Chargetype |
|
|
|
me.Chargeway = data.Contracttab.Chargeway |
|
|
|
me.Mobile = data.Phone1 |
|
|
|
me.Remake = data.Contracttab.Remake |
|
|
|
me.Linkman = data.Contact |
|
|
|
me.Begdate = data.Begindate |
|
|
|
me.Enddate = data.Enddate |
|
|
|
me.Chargedexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Chargableexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Lengthdate = lengthdate |
|
|
|
me.Chargetime = data.Chargetime |
|
|
|
me.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") |
|
|
|
if utils.ValueIsEmpty(me.Createby) { |
|
|
|
me.Createby = user.Name |
|
|
|
} |
|
|
|
if utils.ValueIsEmpty(me.Contractid) { |
|
|
|
err = me.Add(data) |
|
|
|
} else { |
|
|
|
err = me.Update(data) |
|
|
|
} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
days := (end.Unix() - start.Unix()) / (86400*30) |
|
|
|
fmt.Println("days:", days) |
|
|
|
lengthdate = float64(days) |
|
|
|
supports.Ok(ctx, supports.OptionSuccess, "") |
|
|
|
case 2: |
|
|
|
//
|
|
|
|
lengthdate = data.Contracttab.Chargedexpense / data.Unitprice |
|
|
|
/******* |
|
|
|
*Chargetype : 电梯费 |
|
|
|
*lengthdate : 缴费时长 |
|
|
|
**************/ |
|
|
|
lengthdate := data.Contracttab.Chargedexpense / data.Unitprice |
|
|
|
//判断是否
|
|
|
|
access := new(models.Accesscardtab) |
|
|
|
access.Cid = user.Pid |
|
|
@ -90,9 +119,43 @@ func InsertContracttab(ctx iris.Context) { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
me := new(models.Contracttab) |
|
|
|
me.Cid = data.Cid |
|
|
|
me.Chargetype = data.Chargetype |
|
|
|
me.Chargeway = data.Contracttab.Chargeway |
|
|
|
me.Contractid = result.Contractid |
|
|
|
me.Chargableexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Chargedexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Mobile = data.Phone1 |
|
|
|
me.Linkman = data.Contact |
|
|
|
me.Begdate = data.Begindate |
|
|
|
begtime, _ := utils.TimeParseyyyyMMdd(data.Begindate) |
|
|
|
months := utils.ValueToInt(lengthdate,0) |
|
|
|
Begdate := begtime.AddDate(0, months, 0) |
|
|
|
me.Enddate = utils.TimeFormat(Begdate, "yyyy-MM-dd") |
|
|
|
me.Lengthdate = fmt.Sprintf("%0.0f",lengthdate) + " 月 " |
|
|
|
me.Chargetime = data.Chargetime |
|
|
|
me.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") |
|
|
|
if utils.ValueIsEmpty(me.Createby) { |
|
|
|
me.Createby = user.Name |
|
|
|
} |
|
|
|
if utils.ValueIsEmpty(me.Contractid) { |
|
|
|
err = me.Add(data) |
|
|
|
} else { |
|
|
|
err = me.Update(data) |
|
|
|
} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
supports.Ok(ctx, supports.OptionSuccess, "") |
|
|
|
case 3: |
|
|
|
lengthdate = data.Contracttab.Chargedexpense / data.Unitprice |
|
|
|
/******* |
|
|
|
*Chargetype : 车位费 |
|
|
|
*lengthdate : 缴费时长 |
|
|
|
**************/ |
|
|
|
lengthdate := data.Contracttab.Chargedexpense / data.Unitprice |
|
|
|
carport := new(models.Carporttab) |
|
|
|
carport.Cid = user.Pid |
|
|
|
carport.Cid = user.Pid |
|
|
@ -102,33 +165,39 @@ func InsertContracttab(ctx iris.Context) { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
me.Mobile = data.Phone1 |
|
|
|
me.Linkman = data.Contact |
|
|
|
me.Begdate = data.Begindate |
|
|
|
me.Lengthdate = utils.ValueToInt(fmt.Sprintf("%0.0f", lengthdate), 0) |
|
|
|
me.Chargetime = data.Chargetime |
|
|
|
//if data.Chargetype == 1 {
|
|
|
|
//
|
|
|
|
//} else {
|
|
|
|
// me.Lengthdate = utils.ValueToInt(fmt.Sprintf("%0.0f", lengthdate), 0)
|
|
|
|
//}
|
|
|
|
me.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") |
|
|
|
if utils.ValueIsEmpty(me.Createby) { |
|
|
|
me.Createby = user.Name |
|
|
|
} |
|
|
|
lengthdate = float64(me.Lengthdate) |
|
|
|
if utils.ValueIsEmpty(me.Contractid) { |
|
|
|
err = me.Add(data, lengthdate) |
|
|
|
} else { |
|
|
|
err = me.Update(data, lengthdate) |
|
|
|
} |
|
|
|
me := new(models.Contracttab) |
|
|
|
me.Cid = data.Cid |
|
|
|
me.Chargetype = data.Chargetype |
|
|
|
me.Chargeway = data.Contracttab.Chargeway |
|
|
|
me.Contractid = data.Contractid |
|
|
|
me.Chargableexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Chargedexpense = data.Contracttab.Chargedexpense |
|
|
|
me.Mobile = data.Phone1 |
|
|
|
me.Linkman = data.Contact |
|
|
|
me.Begdate = data.Begindate |
|
|
|
begtime, _ := utils.TimeParseyyyyMMdd(data.Begindate) |
|
|
|
months := utils.ValueToInt(lengthdate,0) |
|
|
|
Begdate := begtime.AddDate(0, months, 0) |
|
|
|
me.Enddate = utils.TimeFormat(Begdate, "yyyy-MM-dd") |
|
|
|
me.Lengthdate = fmt.Sprintf("%0.0f",lengthdate) + " 月 " |
|
|
|
me.Chargetime = data.Chargetime |
|
|
|
me.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") |
|
|
|
if utils.ValueIsEmpty(me.Createby) { |
|
|
|
me.Createby = user.Name |
|
|
|
} |
|
|
|
if utils.ValueIsEmpty(me.Contractid) { |
|
|
|
err = me.Add(data) |
|
|
|
} else { |
|
|
|
err = me.Update(data) |
|
|
|
} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
supports.Ok(ctx, supports.OptionSuccess, "") |
|
|
|
} |
|
|
|
supports.Ok(ctx, supports.OptionSuccess, "") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func UpdateContracttab(ctx iris.Context) { |
|
|
@ -171,13 +240,13 @@ func UpdateContracttab(ctx iris.Context) { |
|
|
|
lengthdate = data.Contracttab.Chargedexpense / data.Unitprice |
|
|
|
} |
|
|
|
|
|
|
|
me.Lengthdate = utils.ValueToInt(fmt.Sprintf("%0.0f", lengthdate), 0) |
|
|
|
me.Lengthdate = fmt.Sprintf("%0.0f", lengthdate) |
|
|
|
me.Chargetime = data.Chargetime |
|
|
|
me.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") |
|
|
|
if utils.ValueIsEmpty(me.Createby) { |
|
|
|
me.Createby = user.Name |
|
|
|
} |
|
|
|
err := me.Update(data, lengthdate) |
|
|
|
err := me.Update(data) |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, "更新失败", nil) |
|
|
|
return |
|
|
@ -301,7 +370,7 @@ func ExcelContracttab(ctx iris.Context) { |
|
|
|
glog.InfoExtln("导入合同", "err is:", err) |
|
|
|
} |
|
|
|
lengthdays := me.Chargedexpense / price.Unitprice / infodata.Constructionarea |
|
|
|
me.Lengthdate = utils.ValueToInt(fmt.Sprintf("%0.0f", lengthdays), 0) |
|
|
|
me.Lengthdate = fmt.Sprintf("%0.0f", lengthdays) |
|
|
|
glog.InfoExtln("导入合同", "Propertyid", infodata.Propertyid) |
|
|
|
glog.InfoExtln("导入合同", "tt1", tt1) |
|
|
|
glog.InfoExtln("导入合同", "tt2", tt2) |
|
|
@ -312,9 +381,9 @@ func ExcelContracttab(ctx iris.Context) { |
|
|
|
glog.InfoExtln("导入合同", "Lengthdate", me.Lengthdate) |
|
|
|
data.Chargetime = me.Chargetime |
|
|
|
if utils.ValueIsEmpty(infodata.Contractid) { |
|
|
|
err = me.Add(data, lengthdays) |
|
|
|
err = me.Add(data) |
|
|
|
} else { |
|
|
|
err = me.Update(data, lengthdays) |
|
|
|
err = me.Update(data) |
|
|
|
} |
|
|
|
|
|
|
|
if err != nil { |
|
|
|