count,err=engine.Table(charge.TableName()).Where("cid = ? and allocateyear < ? and createtime >= ? and createtime <= ?",cid,year,start,end).Sum(charge,"allocateexpense")
}elseifselectType=="current"{
count,err=engine.Table(charge.TableName()).Where("cid = ? and allocateyear >= ? and createtime >= ? and createtime <= ?",cid,year,start,end).Sum(charge,"allocateexpense")
}else{
count,err=engine.Table(charge.TableName()).Where("cid = ? and createtime >= ? and createtime <= ?",cid,start,end).Sum(charge,"allocateexpense")
total,_:=e.Table("propertytab").Join("INNER","contracttab","propertytab.contractid=contracttab.contractid and propertytab.cid=contracttab.cid").Where("propertytab.buildingid = ? and contracttab.enddate >? and propertytab.cid = ?",v.Buildingid,startdate,t.Cid).Count(p)
total,_:=e.Table("propertytab").Join("INNER","contracttab","propertytab.contractid=contracttab.contractid and propertytab.cid=contracttab.cid").Where("propertytab.buildingid = ? and contracttab.enddate >? and propertytab.cid = ?",v.Buildingid,startdate,t.Cid).Count(p)
//计算每栋楼的房间数
alltotal,_:=e.Table("propertytab").Where("isfree != '3' and propertytab.buildingid = ? and propertytab.cid = ?",v.Buildingid,t.Cid).Count(p)
alltotal,_:=e.Table("propertytab").Where("isfree != '3' and propertytab.buildingid = ? and propertytab.cid = ?",v.Buildingid,t.Cid).Count(p)
_,err:=e.Table("chargeallocationtab").Select("sum(allocateexpense) as paid_in_money").Where("allocateyear =? and allocatemonth >=? and cid = ?",i,settledate,t.Cid).Or("allocateyear =? and allocatemonth <=? and cid = ?",endtime,settledate,t.Cid).Get(ss)
_,err:=e.Table("chargeallocationtab").Select("sum(allocateexpense) as paid_in_money").Where("allocateyear =? and allocatemonth >=? and cid = ?",i,settledate,t.Cid).Or("allocateyear =? and allocatemonth <=? and cid = ?",endtime,settledate,t.Cid).Get(ss)
_,err=e.Table("propertytab").Select("propertytypetab.unitprice as unitprice,(SELECT SUM(constructionarea) FROM propertytab WHERE isfree != '3') as constructionarea").Join("INNER","buildingtab","propertytab.buildingid=buildingtab.buildingid and propertytab.cid=buildingtab.cid").Join("INNER","propertytypetab","propertytypetab.propertytypeid=buildingtab.propertytypeid and propertytypetab.cid=buildingtab.cid").Where("propertytab.cid = ?",t.Cid).Get(buildInfo)
_,err=e.Table("propertytab").Select("propertytypetab.unitprice as unitprice,(SELECT SUM(constructionarea) FROM propertytab WHERE isfree != '3') as constructionarea").Join("INNER","buildingtab","propertytab.buildingid=buildingtab.buildingid and propertytab.cid=buildingtab.cid").Join("INNER","propertytypetab","propertytypetab.propertytypeid=buildingtab.propertytypeid and propertytypetab.cid=buildingtab.cid").Where("propertytab.cid = ?",t.Cid).Get(buildInfo)
totalMoney,err=engine.Table(t.TableName()).Where(`cid = ? and (chargeway = "扫码" or chargeway = "微信" or chargeway = "支付宝") and chargetime = ?`,cid,date).Sum(t,"chargableexpense")
}else{
totalMoney,err=engine.Table(t.TableName()).Where("cid = ? and chargeway = ? and chargetime = ?",cid,chargeWay,date).Sum(t,"chargableexpense")
}
iferr!=nil{
fmt.Println("error here1:",err)
returnnil,err
}
offset:=(pageIndex-1)*pageSize
varcountint64
varchargeLi[]*Chargetab
ifchargeWay=="扫码"{
err=engine.Table(t.TableName()).Where("cid = ? and (chargeway = \"扫码\" or chargeway = \"微信\" or chargeway = \"支付宝\") and chargetime = ?",cid,date).Limit(pageSize,offset).Find(&chargeLi)
iferr!=nil{
returnnil,err
}
count,err=engine.Table(t.TableName()).Where("cid = ? and (chargeway = \"扫码\" or chargeway = \"微信\" or chargeway = \"支付宝\") and chargetime = ?",cid,date).Count()
iferr!=nil{
fmt.Println("error:",err)
returnnil,err
}
}else{
err=engine.Table(t.TableName()).Where("cid = ? and chargeway = ? and chargetime = ?",cid,chargeWay,date).Limit(pageSize,offset).Find(&chargeLi)
count,err=engine.Table(t.TableName()).Where("cid = ? and chargeway = ? and chargetime = ?",cid,chargeWay,date).Count()