沈阳玫苑物业管理后端
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

  1. package models
  2. import (
  3. "lapp_-wy/db"
  4. "lapp_-wy/utils"
  5. )
  6. type RecordLog struct {
  7. Cid int `json:"cid" xorm:"not null pk INT(4)"`
  8. Id string `json:"id" xorm:"VARCHAR(12)"`
  9. Type string `json:"type" xorm:"VARCHAR(12)"`
  10. Content string `json:"content" xorm:"VARCHAR(255)"`
  11. Chargetype int `json:"chargetype" xorm:"INT(4)"`
  12. Propertyid string `json:"propertyid" xorm:"VARCHAR(100)"`
  13. Accesscardid string `json:"accesscardid" xorm:"VARCHAR(100)"`
  14. Carportid string `json:"carportid" xorm:"VARCHAR(100)"`
  15. Chargestartdate string `json:"chargestartdate" xorm:"VARCHAR(20)"`
  16. Chargeenddate string `json:"chargeenddate" xorm:"VARCHAR(20)"`
  17. Chargeway string `json:"chargeway" xorm:"VARCHAR(100)"`
  18. Chargedexpense float64 `json:"chargedexpense" xorm:"DECIMAL(10,2)"`
  19. Chargetime string `json:"chargetime" xorm:"VARCHAR(20)"`
  20. Chargeby string `json:"chargeby" xorm:"VARCHAR(40)"`
  21. Createtime string `json:"createtime" xorm:"VARCHAR(14)"`
  22. Createby string `json:"createby" xorm:"VARCHAR(40)"`
  23. }
  24. func (t *RecordLog) TableName() string {
  25. return "record_log"
  26. }
  27. //分页
  28. func (t *RecordLog) GetPage(pageSize int, pageIndex int, startdate string, enddate string) ([]RecordLog, int, error) {
  29. data := make([]RecordLog, 0)
  30. e := db.MasterEngine()
  31. query := e.Table("record_log").Where("cid = ? ", t.Cid)
  32. table := e.Table("record_log").Where("cid = ? ", t.Cid)
  33. if !utils.ValueIsEmpty(t.Createby) {
  34. query = query.And("createby = ?", t.Createby)
  35. table = table.And("createby = ?", t.Createby)
  36. }
  37. if !utils.ValueIsEmpty(startdate) {
  38. startdate = startdate + "000000"
  39. query = query.And("createtime >= ?", startdate)
  40. table = table.And("createtime >= ?", startdate)
  41. }
  42. if !utils.ValueIsEmpty(enddate) {
  43. enddate = enddate + "235959"
  44. query = query.And("createtime <= ?", enddate)
  45. table = table.And("createtime <= ?", enddate)
  46. }
  47. Offset := (pageIndex - 1) * pageSize
  48. err := query.Limit(pageSize, Offset).Desc("createtime").Find(&data)
  49. pcount := new(RecordLog)
  50. count, err := table.Count(pcount)
  51. if err != nil {
  52. return data, 0, err
  53. }
  54. return data, int(count), nil
  55. }