Browse Source

Merge branch 'master' of 101.201.121.115:leo/LAPP_MY_BACKEND

pull/2/head
娄文智 4 years ago
parent
commit
5c481b4813
6 changed files with 399 additions and 26 deletions
  1. +1
    -0
      main.go
  2. +181
    -18
      web/controllers/chargetab_controller.go
  3. +39
    -0
      web/models/chargeallocationtab.go
  4. +156
    -6
      web/models/chargetab.go
  5. +17
    -0
      web/models/response/chargeallocationtab.go
  6. +5
    -2
      web/routes/routes.go

+ 1
- 0
main.go View File

@ -18,6 +18,7 @@ import (
//基于windows系统服务器,安装成服务
type program struct{}
func (p *program) Start(s service.Service) error {


+ 181
- 18
web/controllers/chargetab_controller.go View File

@ -93,8 +93,8 @@ func GetChargetabByYear(ctx iris.Context) {
beginyear := ctx.URLParam("startYear")
endyear := ctx.URLParam("endYear")
accountMonth := ctx.URLParam("accountMonth")
settledate := utils.ValueToInt(accountMonth,0)
result, count, err := me.ChargeTotalByYear(beginyear, endyear,settledate)
settledate := utils.ValueToInt(accountMonth, 0)
result, count, err := me.ChargeTotalByYear(beginyear, endyear, settledate)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
return
@ -119,9 +119,9 @@ func GetChargetabByBuilding(ctx iris.Context) {
buildingid := ctx.URLParam("building")
beginyear := ctx.URLParam("startYear")
accountMonth := ctx.URLParam("accountMonth")
settledate := utils.ValueToInt(accountMonth,0)
endyear := utils.ValueToInt(beginyear,0) +1
result, count,rate, err := me.ChargeTotalByBuilding(buildingid, beginyear,utils.ValueToString(endyear,""),settledate)
settledate := utils.ValueToInt(accountMonth, 0)
endyear := utils.ValueToInt(beginyear, 0) + 1
result, count, rate, err := me.ChargeTotalByBuilding(buildingid, beginyear, utils.ValueToString(endyear, ""), settledate)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
return
@ -174,7 +174,7 @@ func GetChargetabListPage(ctx iris.Context) {
}
searchtime := ctx.URLParam("expireDate")
startDate := ctx.URLParam("startDate")
result, count,total, err := data.ListPage(pageSize, pageIndex, startDate,searchtime)
result, count, total, err := data.ListPage(pageSize, pageIndex, startDate, searchtime)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
return
@ -211,7 +211,7 @@ func GetChargetabReadExcel(ctx iris.Context) {
data.Chargetype = chargetype
searchtime := ctx.URLParam("expireDate")
startDate := ctx.URLParam("startDate")
_, filename, err := data.ReadExcel(startDate,searchtime)
_, filename, err := data.ReadExcel(startDate, searchtime)
if err != nil {
fmt.Printf("错误err : %v", err)
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
@ -234,9 +234,9 @@ func GetChargetabReadBuildingExcel(ctx iris.Context) {
buildingid := ctx.URLParam("building")
beginyear := ctx.URLParam("startYear")
accountMonth := ctx.URLParam("accountMonth")
settledate := utils.ValueToInt(accountMonth,0)
endyear := utils.ValueToInt(beginyear,0) +1
_, filename, err := data.ReadBuildExcel(buildingid, beginyear,utils.ValueToString(endyear,""),settledate)
settledate := utils.ValueToInt(accountMonth, 0)
endyear := utils.ValueToInt(beginyear, 0) + 1
_, filename, err := data.ReadBuildExcel(buildingid, beginyear, utils.ValueToString(endyear, ""), settledate)
if err != nil {
fmt.Printf("错误err : %v", err)
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
@ -259,8 +259,8 @@ func GetChargetabReadYearExcel(ctx iris.Context) {
beginyear := ctx.URLParam("startYear")
endyear := ctx.URLParam("endYear")
accountMonth := ctx.URLParam("accountMonth")
settledate := utils.ValueToInt(accountMonth,0)
_, filename, err := me.ReadYearExcel(beginyear, endyear,settledate)
settledate := utils.ValueToInt(accountMonth, 0)
_, filename, err := me.ReadYearExcel(beginyear, endyear, settledate)
if err != nil {
fmt.Printf("错误err : %v", err)
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
@ -313,12 +313,12 @@ func DelChargetab(ctx iris.Context) {
logs.InsertRecord()
data := new(models.Chargetab)
data.Cid = user.Pid
data.Chargenr,_ = ctx.URLParamInt("chargenr")
data.Chargenr, _ = ctx.URLParamInt("chargenr")
data.Lastmodifyby = user.Userid
data.Serialnumber = ctx.URLParam("serialnumber")
err := data.Del()
if err != nil {
glog.InfoExt("删除缴费记录","错误原因:",err)
glog.InfoExt("删除缴费记录", "错误原因:", err)
supports.Error(ctx, iris.StatusBadRequest, "删除失败", nil)
return
}
@ -328,7 +328,7 @@ func DelChargetab(ctx iris.Context) {
func GetRecordLogList(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
utils.TrimStruct(user,*user)
utils.TrimStruct(user, *user)
if !ok {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
@ -340,7 +340,7 @@ func GetRecordLogList(ctx iris.Context) {
logs.Function = "GetRecordLogList"
logs.Message = "删除记录列表查看"
logs.Operator = user.Userid
logs.TimeStamp = utils.TimeFormat(time.Now(),"yyyyMMddHHmmss")
logs.TimeStamp = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
logs.InsertRecord()
var data models.RecordLog
var err error
@ -359,7 +359,7 @@ func GetRecordLogList(ctx iris.Context) {
startdate := ctx.URLParam("startdate")
enddate := ctx.URLParam("enddate")
result, count, err := data.GetPage(pageSize, pageIndex,startdate,enddate)
result, count, err := data.GetPage(pageSize, pageIndex, startdate, enddate)
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, "抱歉未找到相关信息", nil)
return
@ -370,4 +370,167 @@ func GetRecordLogList(ctx iris.Context) {
res["pageIndex"] = pageIndex
res["pageSize"] = pageSize
supports.Ok(ctx, supports.OptionSuccess, res)
}
}
// 获取当前和陈欠的缴费统计数据
func GetChargeStatisticData(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
utils.TrimStruct(user, *user)
if !ok {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
logs := new(models.LeitServerLog)
logs.File = "/controllers/Chargetab_controller.go"
logs.Level = "info"
logs.Function = "GetChargeStatisticData"
logs.Message = "当年及陈欠缴费统计查看"
logs.Operator = user.Userid
logs.TimeStamp = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
logs.InsertRecord()
var cid int
// 如果公司机关部门可以搜索cid
if user.Pid == 110 {
cidStr := ctx.URLParam("cid")
cid = utils.ValueToInt(cidStr, 0)
} else {
cid = user.Pid
}
if cid == 0 {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
var chargeTab models.Chargeallocationtab
//chargeTab.Cid = user.Pid
year := time.Now().Year()
start := fmt.Sprintf("%d0101", year)
end := fmt.Sprintf("%d1231", year)
selectType := ctx.URLParam("type")
result, err := chargeTab.GetChargeStatisticData(cid, year, start, end, selectType)
if err != nil {
supports.Error(ctx, iris.StatusInternalServerError, "抱歉未找到相关信息", nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
}
// 按日期和缴费类型获取缴费数据
func GetChargeTypeData(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
utils.TrimStruct(user, *user)
if !ok {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
logs := new(models.LeitServerLog)
logs.File = "/controllers/Chargetab_controller.go"
logs.Level = "info"
logs.Function = "GetChargeTypeData"
logs.Message = "按日期和收款类型查看缴费数据"
logs.Operator = user.Userid
logs.TimeStamp = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
logs.InsertRecord()
var pageSize = 10
var pageIndex = 1
if size := ctx.URLParam("size"); size != "" {
pageSize = utils.ValueToInt(size, 0)
}
if index := ctx.URLParam("index"); index != "" {
pageIndex = utils.ValueToInt(index, 0)
}
var cid int
// 如果公司机关部门可以搜索cid
if user.Pid == 110 {
cidStr := ctx.URLParam("cid")
cid = utils.ValueToInt(cidStr, 0)
} else {
cid = user.Pid
}
if cid == 0 {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
date := ctx.URLParam("date")
tDate, err1 := utils.TimeParseyyyyMMdd(date)
if err1 != nil {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
// 如为传入或传入的chargeType 不合规则使用-1 进行所有chargeType的分类统计
date = utils.TimeFormat(tDate, "yyyy-MM-dd")
chargeWay := ctx.URLParam("charge_way")
if chargeWay == "" {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
var charge models.Chargetab
result, err := charge.GetChargeTypeData(cid, chargeWay, date, pageIndex, pageSize)
if err != nil {
supports.Error(ctx, iris.StatusInternalServerError, "抱歉未找到相关信息", nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
}
// 按日期和缴费类型获取缴费统计数据
func GetChargeArrearageData(ctx iris.Context) {
user, ok := jwts.ParseToken(ctx)
utils.TrimStruct(user, *user)
if !ok {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
logs := new(models.LeitServerLog)
logs.File = "/controllers/Chargetab_controller.go"
logs.Level = "info"
logs.Function = "GetChargeArrearageData"
logs.Message = "按日期查看缴费陈欠数据"
logs.Operator = user.Userid
logs.TimeStamp = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
logs.InsertRecord()
var pageSize = 10
var pageIndex = 1
if size := ctx.URLParam("size"); size != "" {
pageSize = utils.ValueToInt(size, 0)
}
if index := ctx.URLParam("index"); index != "" {
pageIndex = utils.ValueToInt(index, 0)
}
var cid int
// 如果公司机关部门可以搜索cid
if user.Pid == 110 {
cidStr := ctx.URLParam("cid")
cid = utils.ValueToInt(cidStr, 0)
} else {
cid = user.Pid
}
if cid == 0 {
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
return
}
chargeType, err := ctx.URLParamInt("chargetype")
if err != nil {
chargeType = 0
}
buildingId := ctx.URLParam("buildingid")
propertyId := ctx.URLParam("propertyid")
year := time.Now().Year()
selectType := ctx.URLParam("type")
arrearageDate := fmt.Sprintf("%d-12-31", year-1)
var charge models.Chargetab
result, err := charge.GetChargeArrearageData(cid, pageIndex, pageSize, year, arrearageDate, selectType, chargeType, buildingId, propertyId)
if err != nil {
fmt.Println("outer error:", err)
supports.Error(ctx, iris.StatusInternalServerError, "抱歉未找到相关信息", nil)
return
}
supports.Ok(ctx, supports.OptionSuccess, result)
}

+ 39
- 0
web/models/chargeallocationtab.go View File

@ -1,9 +1,12 @@
package models
import (
"errors"
"fmt"
"github.com/go-xorm/xorm"
"lapp_-wy/db"
"lapp_-wy/utils"
"lapp_-wy/web/models/response"
"strings"
"time"
)
@ -148,3 +151,39 @@ func ChargeShareTheMonth(session *xorm.Session, cid int, chargenr int, begdate s
}
return true
}
// 获取当年物业费和陈欠物业费统计数据
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
exist, err := engine.Table(court.TableName()).ID(cid).Get(&court)
if err != nil {
return result, err
}
if !exist {
return result, errors.New("data not exist")
}
// 获取当年物业费统计
var charge Chargeallocationtab
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")
}
if err != nil {
fmt.Println("error1:", err)
return result, err
}
if selectType != "current" && selectType != "arrearage" {
selectType = "total"
}
result.Cid = cid
result.Court = court.Descr
result.Type = selectType
result.Count = count
return result, nil
}

+ 156
- 6
web/models/chargetab.go View File

@ -9,6 +9,7 @@ import (
"lapp_-wy/db"
"lapp_-wy/utils"
"lapp_-wy/web/middleware/glog"
"math"
"strings"
"time"
"xorm.io/core"
@ -36,6 +37,32 @@ type Chargetab struct {
Lastmodifyby string `json:"lastmodifyby" xorm:"VARCHAR(20)"`
}
type ChargeArrearage struct {
*Chargetab
Arrearage float64 `json:"arrearage"`
ArrearageDate string `json:"arrearage_date"`
}
type ChargeTypeResponse struct {
Cid int `json:"cid"`
Court string `json:"court"`
ChargeWay string `json:"charge_way"`
ChargeCount float64 `json:"charge_count"`
Items []*Chargetab `json:"items"`
Total int64 `json:"total"`
TotalPage int `json:"total_page"`
CurrentPage int `json:"current_page"`
}
type ChargeArrearageResponse struct {
Cid int `json:"cid"`
Court string `json:"court"`
Items []*ChargeArrearage `json:"items"`
Total int64 `json:"total"`
TotalPage int `json:"total_page"`
CurrentPage int `json:"current_page"`
}
func (t *Chargetab) TableName() string {
return "chargetab"
}
@ -179,10 +206,10 @@ func (t *Chargetab) ChargeTotalByBuilding(buildingid string, beginyear string, e
query = query.And("propertytab.buildingid = ?", buildingid)
}
if !utils.ValueIsEmpty(beginyear) {
query = query.And("chargeallocationtab.allocateyear = ? and chargeallocationtab.allocatemonth >= ? and chargeallocationtab.cid = ?", beginyear, settledate,t.Cid)
query = query.And("chargeallocationtab.allocateyear = ? and chargeallocationtab.allocatemonth >= ? and chargeallocationtab.cid = ?", beginyear, settledate, t.Cid)
}
if !utils.ValueIsEmpty(endyear) {
query = query.Or("chargeallocationtab.allocateyear = ? and chargeallocationtab.allocatemonth <= ? and chargeallocationtab.cid = ?", endyear, settledate,t.Cid)
query = query.Or("chargeallocationtab.allocateyear = ? and chargeallocationtab.allocatemonth <= ? and chargeallocationtab.cid = ?", endyear, settledate, t.Cid)
}
if t.Chargetype > 0 {
query = query.And("chargetab.chargetype = ?", t.Chargetype)
@ -199,9 +226,9 @@ func (t *Chargetab) ChargeTotalByBuilding(buildingid string, beginyear string, e
sumMoney += v.Money
//计算每栋楼的缴费数
p := new(Propertytab)
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)
rate := utils.ValueToFloat(total, 0.0) / utils.ValueToFloat(alltotal, 0.0) * 100
rateMoney += rate
data[k].Rate = fmt.Sprintf("%0.0f", rate) + "%"
@ -253,7 +280,7 @@ func (t *Chargetab) ChargeTotalByYear(beginyear string, endyear string, settleda
}
//计算实收金额
ss := new(SumStruct)
_, 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)
//计算实收缴费面积
one := SumStruct{}
one.Cid = t.Cid
@ -270,7 +297,7 @@ func (t *Chargetab) ChargeTotalByYear(beginyear string, endyear string, settleda
one.PaidInArea = utils.ValueToFloat(area, 0.0)
//计算应收金额和面积
buildInfo := new(BuildingInfo)
_, 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)
if err != nil {
glog.InfoExtln("年缴费测试", "err2 := ", err)
continue
@ -1574,3 +1601,126 @@ func (t *Chargetab) Del() error {
}
return nil
}
// 按日期获取指定缴费类型的缴费额
func (t *Chargetab) GetChargeTypeData(cid int, chargeWay string, date string, pageIndex, pageSize int) (result *ChargeTypeResponse, err error) {
result = new(ChargeTypeResponse)
engine := db.MasterEngine()
var court Courttab
exist, err := engine.Table(court.TableName()).ID(cid).Get(&court)
if err != nil {
return result, err
}
if !exist {
return result, errors.New("data not exist")
}
var totalMoney float64
// 扫码包含 微信 支付宝 和 扫码
if chargeWay == "扫码" {
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")
}
if err != nil {
fmt.Println("error here1:", err)
return nil, err
}
offset := (pageIndex - 1) * pageSize
var count int64
var chargeLi []*Chargetab
if chargeWay == "扫码" {
err = engine.Table(t.TableName()).Where("cid = ? and (chargeway = \"扫码\" or chargeway = \"微信\" or chargeway = \"支付宝\") and chargetime = ?", cid, date).Limit(pageSize, offset).Find(&chargeLi)
if err != nil {
return nil, err
}
count, err = engine.Table(t.TableName()).Where("cid = ? and (chargeway = \"扫码\" or chargeway = \"微信\" or chargeway = \"支付宝\") and chargetime = ?", cid, date).Count()
if err != nil {
fmt.Println("error:", err)
return nil, 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()
}
if err != nil {
return nil, err
}
result.Cid = cid
result.Court = court.Descr
result.ChargeCount = totalMoney
result.ChargeWay = chargeWay
result.Items = chargeLi
result.Total = count
result.TotalPage = int(math.Ceil(float64(result.Total) / float64(pageSize)))
result.CurrentPage = pageIndex
return result, err
}
// 缴费台账接口
func (t *Chargetab) GetChargeArrearageData(cid int, pageIndex, pageSize int, year int, arrearageDate string, selectType string, chargeType int, buildingId string, propertyId string) (result *ChargeArrearageResponse, err error) {
result = new(ChargeArrearageResponse)
engine := db.MasterEngine()
var court Courttab
exist, err := engine.Table(court.TableName()).ID(cid).Get(&court)
if err != nil {
return result, err
}
if !exist {
return result, errors.New("data not exist")
}
var chargeLi []*Chargetab
query := engine.Table(t.TableName())
table := engine.Table(t.TableName())
// 若搜索楼栋id则与物业表连表
if !utils.ValueIsEmpty(buildingId) {
query = query.Join("LEFT", "propertytab", "propertytab.propertyid = chargetab.propertyid and propertytab.cid = chargetab.cid").Where("chargetab.cid = ?", cid).And("propertytab.buildingid = ?", buildingId)
table = table.Join("LEFT", "propertytab", "propertytab.propertyid = chargetab.propertyid and propertytab.cid = chargetab.cid").Where("chargetab.cid = ?", cid).And("propertytab.buildingid = ?", buildingId)
}
// arrearage 陈欠 current 当年
if selectType == "arrearage" {
query = query.Where("chargetab.chargetime <= ?", arrearageDate)
table = table.Where("chargetab.chargetime <= ?", arrearageDate)
} else if selectType == "current" {
query = query.Where("chargetab.chargetime > ?", arrearageDate)
table = table.Where("chargetab.chargetime > ?", arrearageDate)
}
if chargeType != 0 {
query = query.And("chargetab.chargetype = ?", chargeType)
table = table.And("chargetab.chargetype = ?", chargeType)
}
if !utils.ValueIsEmpty(propertyId) {
query = query.And("chargetab.propertyid = ?", propertyId)
table = table.And("chargetab.propertyid = ?", propertyId)
}
offset := pageSize * (pageIndex - 1)
err = query.Limit(pageSize, offset).Find(&chargeLi)
if err != nil {
return nil, err
}
count, err := table.Count()
if err != nil {
return nil, err
}
// 在chargetab上拼接两个字段 一个陈欠日期 一个陈欠金额
var chargeArrearageLi []*ChargeArrearage
for _, charge := range chargeLi {
var chargeallocation Chargeallocationtab
var chargeArrearage ChargeArrearage
chargeArrearage.Chargetab = charge
chargeCount, err := engine.Table(chargeallocation.TableName()).Where("chargenr = ? and allocateyear < ?", charge.Chargenr, year).Sum(chargeallocation, "allocateexpense")
if err != nil {
return nil, err
}
chargeArrearage.Arrearage = chargeCount
chargeArrearage.ArrearageDate = arrearageDate
chargeArrearageLi = append(chargeArrearageLi, &chargeArrearage)
}
result.Court = court.Descr
result.Items = chargeArrearageLi
result.CurrentPage = pageIndex
result.Total = count
result.TotalPage = int(math.Ceil(float64(count) / float64(pageSize)))
return result, nil
}

+ 17
- 0
web/models/response/chargeallocationtab.go View File

@ -0,0 +1,17 @@
/******************************************************************************
* @Function Name :
*-----------------------------------------------------------------------------
* @Description :
* @Function Parameters:
* @Return Value :
* @Author : Zhang Xin
* @Date : 2021/3/3 11:02
******************************************************************************/
package response
type ChargeStatisticResponse struct {
Cid int `json:"cid"`
Court string `json:"court"`
Type string `json:"type"`
Count float64 `json:"count"`
}

+ 5
- 2
web/routes/routes.go View File

@ -1,10 +1,10 @@
package routes
import (
"github.com/kataras/iris"
"lapp_-wy/web/controllers"
"lapp_-wy/web/middleware"
"lapp_-wy/web/middleware/cors"
"github.com/kataras/iris"
)
// 所有的路由
@ -157,7 +157,7 @@ func Hub(app *iris.Application) {
//收费记录表
chargetab := admin.Party("/chargetab")
chargetab.Get("/listpage", controllers.GetChargetabList)
chargetab.Get("/listpage", controllers.GetChargeArrearageData)
chargetab.Get("/datapage", controllers.GetChargetabListPage)
chargetab.Get("/selectinfo", controllers.GetChargetab)
chargetab.Get("/totalyear", controllers.GetChargetabByYear)
@ -168,6 +168,9 @@ func Hub(app *iris.Application) {
chargetab.Get("/readdataexcel", controllers.GetChargetabReadDataExcel)
chargetab.Delete("/del", controllers.DelChargetab)
chargetab.Get("/recordlist", controllers.GetRecordLogList)
chargetab.Get("/statistic", controllers.GetChargeStatisticData)
chargetab.Get("/type/list", controllers.GetChargeTypeData)
//chargetab.Get("/arrearage/list", controllers.GetChargeArrearageData)
// 固定资产
assettab := admin.Party("/assettab")


Loading…
Cancel
Save