From 5dd82a44dfb378a9dc699fc212afec0e49bb9f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 9 Dec 2020 18:30:39 +0800 Subject: [PATCH] a --- business/jxstore/cms/job.go | 18 ++++++++------ business/model/dao/dao_job.go | 38 +++++++++++++++++++++++++++- business/model/job.go | 47 +++++++++++++++++++++-------------- controllers/job_controller.go | 2 +- 4 files changed, 77 insertions(+), 28 deletions(-) diff --git a/business/jxstore/cms/job.go b/business/jxstore/cms/job.go index d53fe9096..c80e0436a 100644 --- a/business/jxstore/cms/job.go +++ b/business/jxstore/cms/job.go @@ -53,18 +53,20 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e finishedAt time.Time DayTimeBegin, DayTimeEnd = jxutils.GetDayTime() ) - // 需根据任务类型做一些参数判断,比如门店商品链接,地址 - switch job.JobCategoryID { - case model.JobCategoryIDwmtg: - - default: - return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID) - } if data, err := json.Marshal(jobExt); err == nil { json.Unmarshal(data, &job) } finishedAt = utils.Str2Time(jobExt.FinishedAtStr) job.FinishedAt = &finishedAt + // 需根据任务类型做一些参数判断,比如门店商品链接,地址 + switch job.JobCategoryID { + case model.JobCategoryIDwmtg: + if job.StoreURL == "" || job.Address == "" { + return errCode, fmt.Errorf("外卖推广任务请输入门店信息!") + } + default: + return errCode, fmt.Errorf("暂不支持的任务类型! %v", job.JobCategoryID) + } if job.UserID == "" { return errCode, fmt.Errorf("参数有误!") } @@ -646,7 +648,7 @@ func RechargeMtMembers(ctx *jxcontext.Context, phone int) (errCode string, err e return model.ErrCodeAccountBalanceNotEnough, fmt.Errorf("用户余额不足,请充值!") } //账户支出 - if err = financial.AddExpendUpdateAccount(db, userBill, model.BillTypeSpJob, 1000); err != nil { + if err = financial.AddExpendUpdateAccount(db, userBill, model.BillTypeSpJob, 1100); err != nil { dao.Rollback(db) return errCode, err } diff --git a/business/model/dao/dao_job.go b/business/model/dao/dao_job.go index dc726b14c..9cd6467e7 100644 --- a/business/model/dao/dao_job.go +++ b/business/model/dao/dao_job.go @@ -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 diff --git a/business/model/job.go b/business/model/job.go index aeb10b5bd..25b0a95ea 100644 --- a/business/model/job.go +++ b/business/model/job.go @@ -198,24 +198,25 @@ 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 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"` - Distance float64 `json:"distance"` + 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"` + Distance float64 `json:"distance"` + OilInfo []*OilInfo `orm:"-" json:"OilInfo"` } func (v *StationInfo) TableUnique() [][]string { @@ -229,3 +230,13 @@ func (v *StationInfo) TableIndex() [][]string { []string{"CityID", "ProvinceID"}, } } + +type OilInfo struct { + OilID string `json:"oilId"` + StationPrice string `json:"stationPrice"` + OilType string `json:"oilType"` + DiscountPrice string `json:"discountPrice"` + CountryPrice string `json:"countryPrice"` + OilgunCodes []string `json:"oilgunCodes"` + OilCode string `json:"oilCode"` +} diff --git a/controllers/job_controller.go b/controllers/job_controller.go index 62676287d..79617e7be 100644 --- a/controllers/job_controller.go +++ b/controllers/job_controller.go @@ -333,7 +333,7 @@ func (c *JobController) CheckJdDeliveryWeight() { // @Param lat query float64 false "用户坐标" // @Param lng query float64 false "用户坐标" // @Param oilCode query string false "油号" -// @Param sortType query int false "排序, 1为距离,2为评分" +// @Param sortType query int false "排序, 1为距离,2为评分,3为油价" // @Param offset query int false "门店列表起始序号(以0开始,缺省为0)" // @Param pageSize query int false "门店列表页大小(缺省为50,-1表示全部)" // @Success 200 {object} controllers.CallResult