Browse Source

Merge pull request '添加查询车位费返回该业主所有车位id的功能' (#1) from feature_carporttab into master

Reviewed-on: http://101.201.121.115:3000/leo/LAPP_MY_BACKEND/pulls/1
Reviewed-by: weichenglei <chenglei.wei@le-it.com.cn>
master
weichenglei 3 years ago
parent
commit
cf54c046b1
4 changed files with 104 additions and 34 deletions
  1. +3
    -0
      web/controllers/carporttab_controller.go
  2. +16
    -0
      web/controllers/contracttab_controller.go
  3. +1
    -0
      web/models/accesscardtab.go
  4. +84
    -34
      web/models/carporttab.go

+ 3
- 0
web/controllers/carporttab_controller.go View File

@ -194,6 +194,9 @@ func SearchCarporttab(ctx iris.Context) {
buildingid := ctx.URLParam("buildingid") buildingid := ctx.URLParam("buildingid")
unit := ctx.URLParam("unit") unit := ctx.URLParam("unit")
room := ctx.URLParam("room") room := ctx.URLParam("room")
if me.Propertyid == "" {
me.Propertyid = buildingid + "-" + unit + "-" + room
}
data, err := me.Search(buildingid, unit, room) data, err := me.Search(buildingid, unit, room)
if err != nil { if err != nil {
glog.InfoExt("缴费","查询车位费:%v",err) glog.InfoExt("缴费","查询车位费:%v",err)


+ 16
- 0
web/controllers/contracttab_controller.go View File

@ -62,6 +62,7 @@ func InsertContracttab(ctx iris.Context) {
access.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") access.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
access.Lastmodifytime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss") access.Lastmodifytime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
access.Descr = "电梯卡费" access.Descr = "电梯卡费"
access.Lastmodifyby = user.Userid
err := access.Add() err := access.Add()
if err != nil { if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
@ -69,6 +70,21 @@ func InsertContracttab(ctx iris.Context) {
} }
case 3: case 3:
lengthdate = data.Contracttab.Chargedexpense / data.Unitprice lengthdate = data.Contracttab.Chargedexpense / data.Unitprice
carport := new(models.Carporttab)
carport.Cid = user.Pid
carport.Carportid = data.Carportid
carport.Descr = "车位费"
carport.Status = 1
carport.Propertyid = data.Propertyid
carport.Propertytypeid = "车位费"
carport.Createtime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
carport.Lastmodifytime = utils.TimeFormat(time.Now(), "yyyyMMddHHmmss")
carport.Lastmodifyby = user.Userid
err := carport.Add()
if err != nil {
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
return
}
default: default:
lengthdate = data.Contracttab.Chargedexpense / data.Unitprice lengthdate = data.Contracttab.Chargedexpense / data.Unitprice
} }


+ 1
- 0
web/models/accesscardtab.go View File

@ -130,6 +130,7 @@ type ContractInfo struct {
Unitprice float64 `json:"unitprice"` Unitprice float64 `json:"unitprice"`
Chargetime string `json:"chargetime"` Chargetime string `json:"chargetime"`
AccesscardidList []string `json:"accesscardlist"` AccesscardidList []string `json:"accesscardlist"`
CarportidList []string `json:"carportidlist"`
Contracttab Contracttab `json:"contracttab"` Contracttab Contracttab `json:"contracttab"`
} }


+ 84
- 34
web/models/carporttab.go View File

@ -92,7 +92,7 @@ func (t *Carporttab) GetPage(pageSize int, pageIndex int) ([]Carporttab, int, er
table = table.And("descr like ?", descr) table = table.And("descr like ?", descr)
} }
Offset := (pageIndex - 1) * pageSize Offset := (pageIndex - 1) * pageSize
err := query.Limit(pageSize,Offset).Desc("createtime").Find(&data)
err := query.Limit(pageSize, Offset).Desc("createtime").Find(&data)
pcount := new(Carporttab) pcount := new(Carporttab)
count, err := table.Count(pcount) count, err := table.Count(pcount)
@ -108,44 +108,94 @@ type CarporttabContract struct {
Propertytypetab `xorm:"extends"` Propertytypetab `xorm:"extends"`
Contracttab `xorm:"extends"` Contracttab `xorm:"extends"`
} }
type CarporttabInfo struct {
Propertytab `xorm:"extends"`
Propertytypetab `xorm:"extends"`
}
//车位费查询 //车位费查询
func (t *Carporttab) Search(buildingid string, unit string, room string) (ContractInfo, error) {
func (t *Carporttab) Search(buildingid string, unit string, room string) (data ContractInfo, err error) {
//联查 //联查
data := ContractInfo{}
var info CarporttabContract
e := db.MasterEngine() e := db.MasterEngine()
query := e.Table("carporttab").Join("LEFT", "propertytab", "carporttab.propertyid=propertytab.propertyid and carporttab.cid=propertytab.cid").Join("LEFT", "propertytypetab", "carporttab.propertytypeid=propertytypetab.propertytypeid and carporttab.cid=propertytypetab.cid").Join("LEFT", "contracttab", "carporttab.contractid=contracttab.contractid and carporttab.cid=contracttab.cid").Where("carporttab.cid = ?", t.Cid)
if !utils.ValueIsEmpty(buildingid){
query = query.And("propertytab.buildingid = ?",buildingid)
if !utils.ValueIsEmpty(t.Carportid) {
var info CarporttabContract
query := e.Table("carporttab").Join("RIGHT", "propertytab", "carporttab.propertyid=propertytab.propertyid and carporttab.cid=propertytab.cid").Join("LEFT", "propertytypetab", "carporttab.propertytypeid=propertytypetab.propertytypeid and carporttab.cid=propertytypetab.cid").Join("LEFT", "contracttab", "carporttab.contractid=contracttab.contractid and carporttab.cid=contracttab.cid").Where("carporttab.cid = ?", t.Cid)
if !utils.ValueIsEmpty(buildingid) {
query = query.And("propertytab.buildingid = ?", buildingid)
}
if !utils.ValueIsEmpty(unit) {
query = query.And("propertytab.unit = ?", unit)
}
if !utils.ValueIsEmpty(room) {
query = query.And("propertytab.room = ?", room)
}
if !utils.ValueIsEmpty(t.Carportid) {
query = query.And("carporttab.carportid = ?", t.Carportid)
}
if utils.ValueIsEmpty(info.Propertytab.Propertyid) {
data.Propertyid = buildingid + "-" + unit + "-" + room
} else {
data.Propertyid = info.Propertytab.Propertyid
}
_, err = query.Get(&info)
if err != nil {
return data, err
}
data.Propertyid = info.Propertytab.Propertyid
data.Carportid = info.Carporttab.Carportid
data.Cid = info.Propertytab.Cid
data.Room = info.Propertytab.Room
data.Unit = info.Unit
data.Buildingid = info.Propertytab.Buildingid
data.Contractid = info.Propertytab.Contractid
data.Descr = info.Propertytab.Descr
data.Contact = info.Propertytab.Contact
data.Phone1 = info.Propertytab.Phone1
data.Phone2 = info.Propertytab.Phone2
data.Constructionarea = info.Propertytab.Constructionarea
data.Unitprice = info.Propertytypetab.Unitprice
data.Contracttab = info.Contracttab
data.Chargetype = 3
} else {
var info CarporttabInfo
query := e.Table("propertytab").Join("LEFT", "propertytypetab", "propertytab.cid=propertytypetab.cid").Where("propertytab.cid = ? and propertytypetab.propertytypeid = ?", t.Cid, "车位费")
if !utils.ValueIsEmpty(buildingid) {
query = query.And("propertytab.buildingid = ?", buildingid)
}
if !utils.ValueIsEmpty(unit) {
query = query.And("propertytab.unit = ?", unit)
}
if !utils.ValueIsEmpty(room) {
query = query.And("propertytab.room = ?", room)
}
if utils.ValueIsEmpty(info.Propertytab.Propertyid) {
data.Propertyid = buildingid + "-" + unit + "-" + room
} else {
data.Propertyid = info.Propertytab.Propertyid
}
_, err = query.Get(&info)
if err != nil {
return data, err
}
data.Propertyid = info.Propertytab.Propertyid
data.Cid = info.Propertytab.Cid
data.Room = info.Propertytab.Room
data.Unit = info.Unit
data.Buildingid = info.Propertytab.Buildingid
data.Contractid = info.Propertytab.Contractid
data.Descr = info.Propertytab.Descr
data.Contact = info.Propertytab.Contact
data.Phone1 = info.Propertytab.Phone1
data.Phone2 = info.Propertytab.Phone2
data.Constructionarea = info.Propertytab.Constructionarea
data.Unitprice = info.Propertytypetab.Unitprice
data.Chargetype = 3
} }
if !utils.ValueIsEmpty(unit){
query = query.And("propertytab.unit = ?",unit)
}
if !utils.ValueIsEmpty(room){
query = query.And("propertytab.room = ?",room)
}
if !utils.ValueIsEmpty(t.Carportid){
query = query.And("carporttab.carportid = ?",t.Carportid)
}
_, err := query.Get(&info)
carPortIdList := make([]string, 0)
err = e.Table(t.TableName()).Where("cid = ? and propertyid = ?", t.Cid, t.Propertyid).Cols("carportid").Find(&carPortIdList)
if err != nil { if err != nil {
return data, err return data, err
} }
data.Propertyid = info.Propertytab.Propertyid
data.Carportid = info.Carporttab.Carportid
data.Cid = info.Propertytab.Cid
data.Room = info.Propertytab.Room
data.Unit = info.Unit
data.Buildingid = info.Propertytab.Buildingid
data.Contractid = info.Propertytab.Contractid
data.Descr = info.Propertytab.Descr
data.Contact = info.Propertytab.Contact
data.Phone1 = info.Propertytab.Phone1
data.Phone2 = info.Propertytab.Phone2
data.Constructionarea = info.Propertytab.Constructionarea
data.Unitprice = info.Propertytypetab.Unitprice
data.Contracttab = info.Contracttab
data.Chargetype = 3
return data, err
data.CarportidList = carPortIdList
return data, nil
} }

Loading…
Cancel
Save