aa
This commit is contained in:
@@ -3,6 +3,7 @@ package dao
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
@@ -481,39 +482,42 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl
|
|||||||
for _, v := range stations {
|
for _, v := range stations {
|
||||||
utils.Map2StructByJson(v.Prices, &v.OilInfo, false)
|
utils.Map2StructByJson(v.Prices, &v.OilInfo, false)
|
||||||
}
|
}
|
||||||
if oilCode != "" {
|
if math.Abs(utils.Int2Float64(sortType)) == 3 {
|
||||||
for i := 0; i < len(stations); i++ {
|
if oilCode != "" {
|
||||||
for j := 0; j < len(stations)-i-1; j++ {
|
for i := 0; i < len(stations); i++ {
|
||||||
var (
|
for j := 0; j < len(stations)-i-1; j++ {
|
||||||
index int
|
var (
|
||||||
index2 int
|
index int
|
||||||
)
|
index2 int
|
||||||
for k, v := range stations[j].OilInfo {
|
)
|
||||||
if v.OilCode == oilCode {
|
for k, v := range stations[j].OilInfo {
|
||||||
index = k
|
if v.OilCode == oilCode {
|
||||||
|
index = k
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
for k, v := range stations[j+1].OilInfo {
|
||||||
for k, v := range stations[j+1].OilInfo {
|
if v.OilCode == oilCode {
|
||||||
if v.OilCode == oilCode {
|
index2 = k
|
||||||
index2 = k
|
}
|
||||||
}
|
}
|
||||||
}
|
if sortType == 3 {
|
||||||
if sortType == 3 {
|
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) < utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
|
||||||
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) < utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
|
temp := stations[j]
|
||||||
temp := stations[j]
|
stations[j] = stations[j+1]
|
||||||
stations[j] = stations[j+1]
|
stations[j+1] = temp
|
||||||
stations[j+1] = temp
|
}
|
||||||
}
|
} else if sortType == -3 {
|
||||||
} else if sortType == -3 {
|
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) > utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
|
||||||
if utils.Str2Float64(stations[j].OilInfo[index].StationPrice) > utils.Str2Float64(stations[j+1].OilInfo[index2].StationPrice) {
|
temp := stations[j]
|
||||||
temp := stations[j]
|
stations[j] = stations[j+1]
|
||||||
stations[j] = stations[j+1]
|
stations[j+1] = temp
|
||||||
stations[j+1] = temp
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pagedInfo.Data = stations
|
||||||
}
|
}
|
||||||
return pagedInfo, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user