diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 49d07f1af..ced1adeb3 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -121,25 +121,33 @@ type VendorStoreExcel struct { OperatorName3 string `json:"运营负责人3"` } -//门店信息+减免策略 -type Info1 struct { - StoreID int `json:"storeID"` //门店ID - StoreName string `json:"storeName"` //门店名字 - OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 - CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 - OpenTime2 int16 `json:"openTime2"` // 营业时间2 - CloseTime2 int16 `json:"closeTime2"` - Status int `json:"status"` //门店是否营业 - Distance int `json:"distance"` //店铺与定位 直线距离 - Address string `json:"address"` //门店地址 - BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID - BrandName string `json:"brandName"` //品牌名字 - BrandLogo string `json:"brandLogo"` //品牌logo - DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额 - DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额 - WeeklyScore int `json:"weeklyScore"` //店铺每周评分 +//门店信息 +type StoreInfo struct { + StoreID int `json:"storeID"` //门店ID + StoreName string `json:"storeName"` //门店名字 + OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 + CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 + OpenTime2 int16 `json:"openTime2"` // 营业时间2 + CloseTime2 int16 `json:"closeTime2"` + Status int `json:"status"` //门店是否营业 + Distance int `json:"distance"` //店铺与定位 直线距离 + Address string `json:"address"` //门店地址 + BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID + BrandName string `json:"brandName"` //品牌名字 + BrandLogo string `json:"brandLogo"` //品牌logo + //WeeklyScore int `json:"weeklyScore"` //店铺每周评分 } -type Info2 struct { + +//门店减免策略 +type StoreDeductionInfo struct { + StoreID int `json:"storeID"` //门店ID + DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额 + DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额 +} + +//门店热销商品 +type StoreSkuInfo struct { + StoreID int `json:"storeID"` //门店ID SkuID int `json:"skuID"` //商品ID SkuName string `json:"skuName"` //商品名字 SkuStatus int `json:"skuStatus"` //商品是否可售状态 1可售 0不可售 @@ -151,32 +159,9 @@ type Info2 struct { //首页展示信息 type HomePageInfos struct { - //StoreID int `json:"storeID"` //门店ID - //StoreName string `json:"storeName"` //门店名字 - //OpenTime1 int16 `json:"openTime1"` // 930就表示9点半,用两个的原因是为了支持中午休息,1与2的时间段不能交叉,为0表示没有 - //CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 - //OpenTime2 int16 `json:"openTime2"` // 营业时间2 - //CloseTime2 int16 `json:"closeTime2"` - //Status int `json:"status"` //门店是否营业 - //Distance int `json:"distance"` //店铺与定位 直线距离 - //Address string `json:"address"` //门店地址 - //BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID - //BrandName string `json:"brandName"` //品牌名字 - //BrandLogo string `json:"brandLogo"` //品牌logo - //DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额 - //DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额 - //WeeklyScore int `json:"weeklyScore"` //店铺每周评分 - Info Info1 `json:"info1"` //拼接数据 - //热销商品信息 - Info2 []Info2 `json:"info2"` - //SkuID int `json:"skuID"` //商品ID - //SkuName string `json:"skuName"` //商品名字 - //SkuStatus int `json:"skuStatus"` //商品是否可售状态 1可售 0不可售 - //BestSeller int `json:"bestSeller"` //畅销品 0不是 1是 - //Img string `json:"img"` //商品第一张图片 - //Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量 - //Unit string `json:"unit"` //商品售卖单位 份/kg等 - + StoreInfo StoreInfo `json:"storeInfo"` + StoreDeductionInfo []StoreDeductionInfo `json:"StoreDeductionInfo"` + StoreSkuInfo []StoreSkuInfo `json:"StoreSkuInfo"` } type JdStoreLevelExt struct { @@ -5741,12 +5726,14 @@ func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*com func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDistance bool, token string) (interface{}, string, error) { //获取门店信息 var ( - storeID []int - tmp1s []Info1 - multipleData []Info2 - data Info2 - ans HomePageInfos - res []HomePageInfos + storeID []int + storeInfos []StoreInfo + storeDeductionInfo StoreDeductionInfo + storeDeductionInfos []StoreDeductionInfo + storeSkuInfo StoreSkuInfo + StoreSkuInfos []StoreSkuInfo + homePage HomePageInfos + homePages []HomePageInfos ) locationList, err := common.GetStoreListByLocation(ctx, lng, lat, 20000, needWalkDistance, false, 0) if err != nil { @@ -5765,6 +5752,20 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis if err != nil { return nil, "获取门店品牌信息失败", err } + storeInfo := StoreInfo{ + StoreID: v.ID, + StoreName: v.Name, + OpenTime1: v.OpenTime1, + CloseTime1: v.CloseTime1, + OpenTime2: v.OpenTime2, + CloseTime2: v.CloseTime2, + Status: v.Status, + Distance: v.Distance, + Address: v.Address, + BrandName: brandInfos.Name, + BrandLogo: brandInfos.Logo, + } + storeInfos = append(storeInfos, storeInfo) //获取门店减免策略 storePolicy, err := GetStoreVendorMaps(ctx, dao.GetDB(), v.ID, 9) if err != nil { @@ -5777,23 +5778,13 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis //} for _, k := range storePolicy { if k.StoreID == v.ID { - tmp1 := Info1{ - StoreID: v.ID, - StoreName: v.Name, - OpenTime1: v.OpenTime1, - CloseTime1: v.CloseTime1, - OpenTime2: v.OpenTime2, - CloseTime2: v.CloseTime2, - Status: v.Status, - Distance: v.Distance, - Address: v.Address, - BrandName: brandInfos.Name, - BrandLogo: brandInfos.Logo, - DeliveryFeeDeductionSill: storePolicy[0].DeliveryFeeDeductionSill, - DeliveryFeeDeductionFee: storePolicy[0].DeliveryFeeDeductionFee, + storeDeductionInfo = StoreDeductionInfo{ + StoreID: k.StoreID, + DeliveryFeeDeductionSill: k.DeliveryFeeDeductionSill, + DeliveryFeeDeductionFee: k.DeliveryFeeDeductionFee, } - tmp1s = append(tmp1s, tmp1) } + storeDeductionInfos = append(storeDeductionInfos, storeDeductionInfo) } } //获取热销商品 @@ -5801,10 +5792,11 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis if err != nil { return nil, "获取热销商品失败", err } - for _, i := range tmp1s { + for _, i := range storeID { for _, j := range topSkusInfo { - if i.StoreID == j.StoreID { - data = Info2{ + if i == j.StoreID { + storeSkuInfo = StoreSkuInfo{ + StoreID: j.StoreID, SkuID: j.SkuID, SkuName: j.Name, SkuStatus: j.Status, @@ -5815,19 +5807,18 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis } } } - multipleData = append(multipleData, data) - if len(multipleData) > 0 { - ans = HomePageInfos{ - Info: i, - Info2: multipleData, - } - } else { - ans = HomePageInfos{ - Info: i, + StoreSkuInfos = append(StoreSkuInfos, storeSkuInfo) + } + for _, i := range storeInfos { + if i.StoreID == storeDeductionInfos[0].StoreID && i.StoreID == StoreSkuInfos[0].StoreID { + homePage = HomePageInfos{ + StoreInfo: i, + StoreDeductionInfo: storeDeductionInfos, + StoreSkuInfo: StoreSkuInfos, } } - res = append(res, ans) + homePages = append(homePages, homePage) } } - return res, "", nil + return homePages, "", nil }