Browse Source

修改GetChargeStatisticData业务逻辑

pull/2/head
zhangxin 4 years ago
parent
commit
8400698dc6
1 changed files with 14 additions and 17 deletions
  1. +14
    -17
      web/models/chargeallocationtab.go

+ 14
- 17
web/models/chargeallocationtab.go View File

@ -1,6 +1,7 @@
package models
import (
"errors"
"fmt"
"github.com/go-xorm/xorm"
"lapp_-wy/db"
@ -152,7 +153,7 @@ func ChargeShareTheMonth(session *xorm.Session, cid int, chargenr int, begdate s
}
// 获取当年物业费和陈欠物业费统计数据
func (t *Chargeallocationtab) GetChargeStatisticData(cid int, year int) (result *response.ChargeStatisticResponse, err error) {
func (t *Chargeallocationtab) GetChargeStatisticData(cid int, year int, start string, end string, selectType string) (result *response.ChargeStatisticResponse, err error) {
result = new(response.ChargeStatisticResponse)
engine := db.MasterEngine()
var court Courttab
@ -165,28 +166,24 @@ func (t *Chargeallocationtab) GetChargeStatisticData(cid int, year int) (result
}
// 获取当年物业费统计
var charge Chargeallocationtab
var currentYearCount float64
currentYearCount, err = engine.Table(charge.TableName()).Where("cid = ? and allocateyear >= ?", cid, year).Sum(charge, "allocateexpense")
if err != nil {
return result, err
var count float64
if selectType == "arrearage" {
count, err = engine.Table(charge.TableName()).Where("cid = ? and allocateyear < ? and createtime >= ? and createtime <= ?", cid, year, start, end).Sum(charge, "allocateexpense")
} else if selectType == "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")
}
currentYearStatistic := &response.StatisticData{
Type: "current",
Count: currentYearCount,
}
// 获取陈欠物业费
var oldCount float64
oldCount, err = engine.Table(charge.TableName()).Where("cid = ? and allocateyear < ?", cid, year).Sum(charge, "allocateexpense")
if err != nil {
fmt.Println("error1:", err)
return result, err
}
oldStatistic := &response.StatisticData{
Type: "old",
Count: oldCount,
if selectType != "current" && selectType != "arrearage" {
selectType = "total"
}
result.Cid = cid
result.Court = court.Descr
result.Items = append(result.Items, currentYearStatistic, oldStatistic)
result.Type = selectType
result.Count = count
return result, nil
}

Loading…
Cancel
Save