Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop

This commit is contained in:
邹宗楠
2022-08-25 15:02:20 +08:00

View File

@@ -121,42 +121,33 @@ type VendorStoreExcel struct {
OperatorName3 string `json:"运营负责人3"` OperatorName3 string `json:"运营负责人3"`
} }
//门店信息+减免策略 //门店信息
type Info1 struct { type StoreInfo struct {
StoreID int `json:"storeID"` //门店ID StoreID int `json:"storeID"` //门店ID
StoreName string `json:"storeName"` //门店名字 StoreName string `json:"storeName"` //门店名字
OpenTime1 int16 `json:"openTime1"` // 930就表示9点半用两个的原因是为了支持中午休息1与2的时间段不能交叉为0表示没有 OpenTime1 int16 `json:"openTime1"` // 930就表示9点半用两个的原因是为了支持中午休息1与2的时间段不能交叉为0表示没有
CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 CloseTime1 int16 `json:"closeTime1"` // 营业时间 1
OpenTime2 int16 `json:"openTime2"` // 营业时间2 OpenTime2 int16 `json:"openTime2"` // 营业时间2
CloseTime2 int16 `json:"closeTime2"` CloseTime2 int16 `json:"closeTime2"`
Status int `json:"status"` //门店是否营业 Status int `json:"status"` //门店是否营业
Distance int `json:"distance"` //店铺与定位 直线距离 Distance int `json:"distance"` //店铺与定位 直线距离
Address string `json:"address"` //门店地址 Address string `json:"address"` //门店地址
BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID
BrandName string `json:"brandName"` //品牌名字 BrandName string `json:"brandName"` //品牌名字
BrandLogo string `json:"brandLogo"` //品牌logo BrandLogo string `json:"brandLogo"` //品牌logo
DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额 //WeeklyScore int `json:"weeklyScore"` //店铺每周评分
DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额
} }
//首页展示信息 //门店减免策略
type HomePageInfos struct { type StoreDeductionInfo struct {
StoreID int `json:"storeID"` //门店ID StoreID int `json:"storeID"` //门店ID
StoreName string `json:"storeName"` //门店名字 DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额
OpenTime1 int16 `json:"openTime1"` // 930就表示9点半用两个的原因是为了支持中午休息1与2的时间段不能交叉为0表示没有 DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额
CloseTime1 int16 `json:"closeTime1"` // 营业时间 1 }
OpenTime2 int16 `json:"openTime2"` // 营业时间2
CloseTime2 int16 `json:"closeTime2"` //门店热销商品
Status int `json:"status"` //门店是否营业 type StoreSkuInfo struct {
Distance int `json:"distance"` //店铺与定位 直线距离 StoreID int `json:"storeID"` //门店ID
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"` //订单减免金额
//Info *Info1 `json:"info"` //拼接数据
//热销商品信息
SkuID int `json:"skuID"` //商品ID SkuID int `json:"skuID"` //商品ID
SkuName string `json:"skuName"` //商品名字 SkuName string `json:"skuName"` //商品名字
SkuStatus int `json:"skuStatus"` //商品是否可售状态 1可售 0不可售 SkuStatus int `json:"skuStatus"` //商品是否可售状态 1可售 0不可售
@@ -164,7 +155,13 @@ type HomePageInfos struct {
Img string `json:"img"` //商品第一张图片 Img string `json:"img"` //商品第一张图片
Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量 Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量
Unit string `json:"unit"` //商品售卖单位 份/kg等 Unit string `json:"unit"` //商品售卖单位 份/kg等
}
//首页展示信息
type HomePageInfos struct {
StoreInfo StoreInfo `json:"storeInfo"`
StoreDeductionInfo []StoreDeductionInfo `json:"StoreDeductionInfo"`
StoreSkuInfo []StoreSkuInfo `json:"StoreSkuInfo"`
} }
type JdStoreLevelExt struct { type JdStoreLevelExt struct {
@@ -5729,9 +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) { func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDistance bool, token string) (interface{}, string, error) {
//获取门店信息 //获取门店信息
var ( var (
storeID []int storeID []int
tmp1s []Info1 storeInfos []StoreInfo
multipleData []HomePageInfos storeDeductionInfo StoreDeductionInfo
storeDeductionInfos []StoreDeductionInfo
storeSkuInfo StoreSkuInfo
StoreSkuInfos []StoreSkuInfo
homePage HomePageInfos
homePages []HomePageInfos
) )
locationList, err := common.GetStoreListByLocation(ctx, lng, lat, 20000, needWalkDistance, false, 0) locationList, err := common.GetStoreListByLocation(ctx, lng, lat, 20000, needWalkDistance, false, 0)
if err != nil { if err != nil {
@@ -5750,62 +5752,76 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis
if err != nil { if err != nil {
return nil, "获取门店品牌信息失败", err 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) storePolicy, err := GetStoreVendorMaps(ctx, dao.GetDB(), v.ID, 9)
if err != nil { if err != nil {
return nil, "获取门店减免策略失败", err return nil, "获取门店减免策略失败", err
} }
tmp1 := Info1{ for _, k := range storePolicy {
StoreID: v.ID, if k.StoreID == v.ID {
StoreName: v.Name, storeDeductionInfo = StoreDeductionInfo{
OpenTime1: v.OpenTime1, StoreID: k.StoreID,
CloseTime1: v.CloseTime1, DeliveryFeeDeductionSill: k.DeliveryFeeDeductionSill,
OpenTime2: v.OpenTime2, DeliveryFeeDeductionFee: k.DeliveryFeeDeductionFee,
CloseTime2: v.CloseTime2, }
Status: v.Status, }
Distance: v.Distance, storeDeductionInfos = append(storeDeductionInfos, storeDeductionInfo)
Address: v.Address,
BrandName: brandInfos.Name,
BrandLogo: brandInfos.Logo,
DeliveryFeeDeductionSill: storePolicy[0].DeliveryFeeDeductionSill,
DeliveryFeeDeductionFee: storePolicy[0].DeliveryFeeDeductionFee,
} }
tmp1s = append(tmp1s, tmp1)
} }
globals.SugarLogger.Debug("storeInfos============", storeInfos)
globals.SugarLogger.Debug("storeDeductionInfos=================", storeDeductionInfos)
//获取热销商品 //获取热销商品
topSkusInfo, err := GetTopSkusByStoreIDs(ctx, storeID) topSkusInfo, err := GetTopSkusByStoreIDs(ctx, storeID)
globals.SugarLogger.Debug("topSkusInfo==============", topSkusInfo)
if err != nil { if err != nil {
return nil, "获取热销商品失败", err return nil, "获取热销商品失败", err
} }
for _, i := range tmp1s { for _, j := range topSkusInfo {
for _, j := range topSkusInfo { //for _, i := range storeID {
if i.StoreID == j.StoreID { //if i == j.StoreID {
data := HomePageInfos{ storeSkuInfo = StoreSkuInfo{
StoreID: i.StoreID, StoreID: j.StoreID,
StoreName: i.StoreName, SkuID: j.SkuID,
OpenTime1: i.OpenTime1, SkuName: j.Name,
CloseTime1: i.CloseTime1, SkuStatus: j.Status,
OpenTime2: i.OpenTime2, BestSeller: j.BestSeller,
CloseTime2: i.CloseTime2, Img: j.Img,
Status: i.Status, Price: j.Price,
Distance: i.Distance, Unit: j.Unit,
Address: i.Address, }
BrandName: i.BrandName, //}
BrandLogo: i.BrandLogo, //}
DeliveryFeeDeductionSill: i.DeliveryFeeDeductionSill, StoreSkuInfos = append(StoreSkuInfos, storeSkuInfo)
DeliveryFeeDeductionFee: i.DeliveryFeeDeductionFee, }
SkuID: j.SkuID, globals.SugarLogger.Debug("StoreSkuInfos=================", StoreSkuInfos)
SkuName: j.Name, for _, i := range storeInfos {
SkuStatus: j.Status, for _, j := range storeDeductionInfos {
BestSeller: j.BestSeller, for _, k := range StoreSkuInfos {
Img: j.Img, if i.StoreID == j.StoreID && i.StoreID == k.StoreID {
Price: j.Price, homePage = HomePageInfos{
Unit: j.Unit, StoreInfo: i,
StoreDeductionInfo: j,
StoreSkuInfo: k,
}
} }
multipleData = append(multipleData, data)
} }
} }
homePages = append(homePages, homePage)
} }
} }
return multipleData, "", nil return homePages, "", nil
} }