This commit is contained in:
苏尹岚
2020-12-09 18:30:39 +08:00
parent b4dfec99a2
commit 5dd82a44df
4 changed files with 77 additions and 28 deletions

View File

@@ -476,7 +476,43 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl
if err = GetRows(db, &stations, sql, sqlParams...); err == nil {
pagedInfo = &model.PagedInfo{
TotalCount: GetLastTotalRowCount(db),
Data: stations,
// Data: stations,
}
for _, v := range stations {
utils.Map2StructByJson(v.Prices, &v.OilInfo, false)
}
if oilCode != "" {
for i := 0; i < len(stations); i++ {
for j := 0; j < len(stations)-i-1; j++ {
var (
index int
index2 int
)
for k, v := range stations[j].OilInfo {
if v.OilCode == oilCode {
index = k
}
}
for k, v := range stations[j+1].OilInfo {
if v.OilCode == oilCode {
index2 = k
}
}
if sortType == 3 {
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) < utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
temp := stations[j]
stations[j] = stations[j+1]
stations[j+1] = temp
}
} else if sortType == -3 {
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) > utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
temp := stations[j]
stations[j] = stations[j+1]
stations[j+1] = temp
}
}
}
}
}
}
return pagedInfo, err