ejy
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ejyapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals/api2"
|
||||
@@ -247,5 +250,65 @@ func QueryConfigs(key, configType, keyword string) (configList []*model.NewConfi
|
||||
}
|
||||
|
||||
func InitStation(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
stationMap = make(map[string]*model.StationInfo)
|
||||
stationEjyMap = make(map[string]*ejyapi.GetStationListResult)
|
||||
addList []*model.StationInfo
|
||||
updateList []*model.StationInfo
|
||||
deleteList []*model.StationInfo
|
||||
)
|
||||
if stations, err := dao.GetStationList(db); len(stations) > 0 && err == nil {
|
||||
for _, v := range stations {
|
||||
stationMap[v.StationID] = v
|
||||
}
|
||||
}
|
||||
if getStationListResult, err := api.EjyAPI.GetStationList(); len(getStationListResult) > 0 && err == nil {
|
||||
for _, v := range getStationListResult {
|
||||
stationEjyMap[v.StationID] = v
|
||||
if stationMap[v.StationID] == nil {
|
||||
addList = append(addList, EjyStationToStationInfo(v))
|
||||
} else {
|
||||
updateList = append(updateList, stationMap[v.StationID])
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, v := range stationMap {
|
||||
if stationEjyMap[v.StationID] == nil {
|
||||
deleteList = append(deleteList, v)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func EjyStationToStationInfo(station *ejyapi.GetStationListResult) (stationInfo *model.StationInfo) {
|
||||
stationInfo = &model.StationInfo{
|
||||
StationID: station.StationID,
|
||||
StationName: station.StationName,
|
||||
ProvinceName: station.ProvinceName,
|
||||
ProvinceID: station.ProvinceID,
|
||||
CityName: station.CityName,
|
||||
Latitude: utils.Str2Float64(station.Latitude),
|
||||
Longitude: utils.Str2Float64(station.Longitude),
|
||||
Location: station.Location,
|
||||
StarNum: station.StarNum,
|
||||
Phone: station.Phone,
|
||||
StationPic: station.StationPic,
|
||||
StationBannerPic: station.StationBannerPic,
|
||||
District: station.District,
|
||||
CityID: station.CityID,
|
||||
StationType: station.StationType,
|
||||
}
|
||||
if station.Prices != nil {
|
||||
if data, err := json.Marshal(station.Prices); err == nil {
|
||||
stationInfo.Prices = string(data)
|
||||
}
|
||||
}
|
||||
if station.Adverts != nil {
|
||||
if data, err := json.Marshal(station.Adverts); err == nil {
|
||||
stationInfo.Adverts = string(data)
|
||||
}
|
||||
}
|
||||
return stationInfo
|
||||
}
|
||||
|
||||
@@ -412,3 +412,13 @@ func GetUserSearch(db *DaoDB, userID, keyword string) (userSearchs []*model.User
|
||||
err = GetRows(db, &userSearchs, sql, sqlParams)
|
||||
return userSearchs, err
|
||||
}
|
||||
|
||||
func GetStationList(db *DaoDB) (stations []*model.StationInfo, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM station_info
|
||||
`
|
||||
sqlParams := []interface{}{}
|
||||
err = GetRows(db, &stations, sql, sqlParams)
|
||||
return stations, err
|
||||
}
|
||||
|
||||
@@ -185,23 +185,23 @@ func (v *MtMember) TableIndex() [][]string {
|
||||
type StationInfo struct {
|
||||
ModelIDCUL
|
||||
|
||||
StationID string `orm:"column(station_id)" json:"stationID"`
|
||||
StationName string `json:"stationName"`
|
||||
ProvinceName string `json:"provinceName"`
|
||||
ProvinceID int `orm:"column(province_id)" json:"provinceID"`
|
||||
CityName string `json:"cityName"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
Location string `json:"location"`
|
||||
StarNum string `json:"starNum"`
|
||||
Phone string `json:"phone"`
|
||||
StationPic string `json:"stationPic"`
|
||||
StationBannerPic string `json:"stationBannerPic"`
|
||||
Prices string `orm:"type(text)" json:"prices"`
|
||||
Adverts string `orm:"type(text)" json:"adverts"`
|
||||
District string `json:"district"`
|
||||
CityID int `orm:"column(city_id)" json:"cityID"`
|
||||
StationType int `json:"stationType"`
|
||||
StationID string `orm:"column(station_id)" json:"stationID"`
|
||||
StationName string `json:"stationName"`
|
||||
ProvinceName string `json:"provinceName"`
|
||||
ProvinceID int `orm:"column(province_id)" json:"provinceID"`
|
||||
CityName string `json:"cityName"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Location string `json:"location"`
|
||||
StarNum string `json:"starNum"`
|
||||
Phone string `json:"phone"`
|
||||
StationPic string `json:"stationPic"`
|
||||
StationBannerPic string `json:"stationBannerPic"`
|
||||
Prices string `orm:"type(text)" json:"prices"`
|
||||
Adverts string `orm:"type(text)" json:"adverts"`
|
||||
District string `json:"district"`
|
||||
CityID int `orm:"column(city_id)" json:"cityID"`
|
||||
StationType int `json:"stationType"`
|
||||
}
|
||||
|
||||
func (v *StationInfo) TableUnique() [][]string {
|
||||
|
||||
@@ -192,6 +192,10 @@ tonglianPayKey = "18048531223"
|
||||
tonglianPayCusID = "56065105499TVAH"
|
||||
tonglianPayNotifyURL = "http://callback.rsm.jxc4.com/tonglian/msg/"
|
||||
|
||||
ejyPlatName = "1Zbve"
|
||||
ejyBeforeKey = "ymsrrxlZXlmglK6Q"
|
||||
ejyAfterKey = "MYsFZGgwwprIahzQ"
|
||||
|
||||
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
|
||||
|
||||
yinbaoAppKey = "682628966212343269"
|
||||
@@ -283,4 +287,8 @@ dingdingCallbackURL = "http://callback.jxc4.com/dingding/msg"
|
||||
pushAppID = "5lyyrvHODG6wC8Sdr3a9h"
|
||||
pushAppKey = "iFrkUDmR2g5eqQpfh2kQ57"
|
||||
pushAppSecret = "WTn53qd6WAAdLMXfmXvzb7"
|
||||
pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47"
|
||||
pushMasterSecret= "dGZcR0XGGg7H5Pd7FR3n47"
|
||||
|
||||
ejyPlatName = "1Zbve"
|
||||
ejyBeforeKey = "htvse3XEDhBnCTNo"
|
||||
ejyAfterKey = "QM5RnGl6kNh3ENLT"
|
||||
@@ -4,6 +4,8 @@ import (
|
||||
"io/ioutil"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/ejyapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtmemberapi"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/unipushapi"
|
||||
@@ -86,6 +88,7 @@ var (
|
||||
DingDingAPI *dingdingapi.API
|
||||
DingDingQRCodeAPI *dingdingapi.API
|
||||
AliUpcAPI *aliupcapi.API //阿里商品条码查询api
|
||||
EjyAPI *ejyapi.API //易加油
|
||||
|
||||
FeieAPI *feieapi.API
|
||||
XiaoWMAPI *xiaowmapi.API
|
||||
@@ -245,7 +248,7 @@ func Init() {
|
||||
if alipayAppID := beego.AppConfig.DefaultString("alipayAppID", ""); alipayAppID != "" {
|
||||
AliPayAPI = alipayapi.New(alipayAppID, []byte(beego.AppConfig.String("alipayPrivateKey")))
|
||||
}
|
||||
|
||||
EjyAPI = ejyapi.New(beego.AppConfig.DefaultString("ejyPlatName", ""), beego.AppConfig.DefaultString("ejyBeforeKey", ""), beego.AppConfig.DefaultString("ejyAfterKey", ""))
|
||||
FeieAPI = feieapi.New(beego.AppConfig.DefaultString("feieUser", ""), beego.AppConfig.DefaultString("feieKey", ""))
|
||||
XiaoWMAPI = xiaowmapi.New(beego.AppConfig.DefaultInt("xiaoWMAppID", 0), beego.AppConfig.DefaultString("xiaoWMAppKey", ""))
|
||||
YilianyunAPI = yilianyunapi.New(beego.AppConfig.DefaultString("yilianyunClientID", ""), beego.AppConfig.DefaultString("yilianyunClientSecret", ""))
|
||||
|
||||
Reference in New Issue
Block a user