This commit is contained in:
苏尹岚
2020-12-16 18:24:29 +08:00
parent cf22855307
commit ee27ffdeef

View File

@@ -14,6 +14,7 @@ import (
const (
sortTypeDistance = 1 //距离
sortTypeTime = 2 //发布时间
sortTypeAvgPrice = 4 //奖励高低
)
@@ -122,6 +123,10 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
sql += ` ORDER BY a.avg_price`
} else if sortType == -sortTypeAvgPrice {
sql += ` ORDER BY a.avg_price DESC`
} else if sortType == sortTypeTime {
sql += ` ORDER BY a.created_at`
} else if sortType == -sortTypeTime {
sql += ` ORDER BY a.created_at DESC`
}
}
sql += " LIMIT ? OFFSET ?"
@@ -140,19 +145,19 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
v.JobSteps = jobSteps
}
}
var (
distance float64
)
// var (
// distance float64
// )
if jobImgs, err := GetJobImgs(db, v.ID); err == nil && len(jobImgs) > 0 {
v.JobImgs = jobImgs
v.IndexImg = jobImgs[0].Img
}
if v.Lng != 0 && v.Lat != 0 {
distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat))
} else {
distance = 0
}
v.Distance = distance
// if v.Lng != 0 && v.Lat != 0 {
// distance = jxutils.EarthDistance(lng, lat, jxutils.IntCoordinate2Standard(v.Lng), jxutils.IntCoordinate2Standard(v.Lat))
// } else {
// distance = 0
// }
// v.Distance = distance
}
pagedInfo.Data = jobs
}