沈阳玫苑物业管理后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

package models
import (
"lapp_-wy/db"
"lapp_-wy/utils"
)
type RecordLog struct {
Cid int `json:"cid" xorm:"not null pk INT(4)"`
Id string `json:"id" xorm:"VARCHAR(12)"`
Type string `json:"type" xorm:"VARCHAR(12)"`
Content string `json:"content" xorm:"VARCHAR(255)"`
Chargetype int `json:"chargetype" xorm:"INT(4)"`
Propertyid string `json:"propertyid" xorm:"VARCHAR(100)"`
Accesscardid string `json:"accesscardid" xorm:"VARCHAR(100)"`
Carportid string `json:"carportid" xorm:"VARCHAR(100)"`
Chargestartdate string `json:"chargestartdate" xorm:"VARCHAR(20)"`
Chargeenddate string `json:"chargeenddate" xorm:"VARCHAR(20)"`
Chargeway string `json:"chargeway" xorm:"VARCHAR(100)"`
Chargedexpense float64 `json:"chargedexpense" xorm:"DECIMAL(10,2)"`
Chargetime string `json:"chargetime" xorm:"VARCHAR(20)"`
Chargeby string `json:"chargeby" xorm:"VARCHAR(40)"`
Createtime string `json:"createtime" xorm:"VARCHAR(14)"`
Createby string `json:"createby" xorm:"VARCHAR(40)"`
}
func (t *RecordLog) TableName() string {
return "record_log"
}
//分页
func (t *RecordLog) GetPage(pageSize int, pageIndex int, startdate string, enddate string) ([]RecordLog, int, error) {
data := make([]RecordLog, 0)
e := db.MasterEngine()
query := e.Table("record_log").Where("cid = ? ", t.Cid)
table := e.Table("record_log").Where("cid = ? ", t.Cid)
if !utils.ValueIsEmpty(t.Createby) {
query = query.And("createby = ?", t.Createby)
table = table.And("createby = ?", t.Createby)
}
if !utils.ValueIsEmpty(startdate) {
startdate = startdate + "000000"
query = query.And("createtime >= ?", startdate)
table = table.And("createtime >= ?", startdate)
}
if !utils.ValueIsEmpty(enddate) {
enddate = enddate + "235959"
query = query.And("createtime <= ?", enddate)
table = table.And("createtime <= ?", enddate)
}
Offset := (pageIndex - 1) * pageSize
err := query.Limit(pageSize, Offset).Desc("createtime").Find(&data)
pcount := new(RecordLog)
count, err := table.Count(pcount)
if err != nil {
return data, 0, err
}
return data, int(count), nil
}