@ -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,55 +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 { }
carPortIdList := make ( [ ] string , 0 )
var info CarporttabContract
e := db . MasterEngine ( )
e := db . MasterEngine ( )
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 ( "propertytab.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
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 {
} 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 . 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
}
}
_ , err := query . Get ( & info )
if err != nil {
return data , err
}
carPortIdList := make ( [ ] string , 0 )
err = e . Table ( t . TableName ( ) ) . Where ( "cid = ? and propertyid = ?" , t . Cid , t . Propertyid ) . Cols ( "carportid" ) . Find ( & carPortIdList )
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
data . CarportidList = carPortIdList
data . CarportidList = carPortIdList
return data , err
return data , nil
}
}