首页推荐商家

This commit is contained in:
richboo111
2022-08-24 17:25:02 +08:00
parent 0219a7b02f
commit dd37849bf3
4 changed files with 154 additions and 45 deletions

View File

@@ -121,19 +121,41 @@ 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"` //订单减免金额
}
//首页展示信息
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"` //店铺与定位 直线距离
BrandID int `orm:"column(brand_id)" json:"brandID"` //品牌ID
BrandName string `json:"brandName"` //品牌名字
BrandLogo string `json:"brandLogo"` //品牌logo
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"` //订单减免金额
//Info *Info1 `json:"info"` //拼接数据
//热销商品信息
SkuID int `json:"skuID"` //商品ID
SkuName string `json:"skuName"` //商品名字
@@ -142,9 +164,7 @@ type HomePageInfos struct {
Img string `json:"img"` //商品第一张图片
Price int `json:"price"` // 单位为分,标准价,不为份的就为实际标准价,为份的为每市斤价,实际还要乘质量
Unit string `json:"unit"` //商品售卖单位 份/kg等
//减运策略
DeliveryFeeDeductionSill int `json:"deliveryFeeDeductionSill"` //订单满减金额
DeliveryFeeDeductionFee int `json:"deliveryFeeDeductionFee"` //订单减免金额
}
type JdStoreLevelExt struct {
@@ -545,7 +565,6 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
var storeIDs []int
if err = utils.UnmarshalUseNumber([]byte(params["storeIDs"].(string)), &storeIDs); err == nil {
for _, v := range storeIDs {
globals.SugarLogger.Debug("storeIDs===============", v)
if storeIDsMap[v] != 0 {
storeIDs2 = append(storeIDs2, v)
}
@@ -5707,16 +5726,86 @@ func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*com
}
//首页信息展示
//func GetHomePageByLocation(ctx *jxcontext.Context, params map[string]interface{}) (interface{}, string, error) {
// //获取门店信息
// timeList, err := jxutils.BatchStr2Time("1970-01-01 00:00:00 +0800 CST", "1970-01-01 00:00:00 +0800 CST")
// if err != nil {
// return nil, "", err
// }
// store, err := GetStores(ctx, "", params, 0, 0, timeList[0], timeList[1], 0, 0)
// //获取热销商品
//
// //获取满减策略
//
// return nil, "", nil
//}
func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDistance bool, token string) (interface{}, string, error) {
//获取门店信息
var (
storeID []int
tmp1s []Info1
multipleData []HomePageInfos
)
locationList, err := common.GetStoreListByLocation(ctx, lng, lat, 20000, needWalkDistance, false, 0)
if err != nil {
return nil, "经纬度获取推荐门店失败", err
}
if token != "" {
//权限过滤门店
filterStore, _, err := FilterByB2B(locationList, token)
if err != nil {
return nil, "权限过滤门店失败", err
}
for _, v := range filterStore {
storeID = append(storeID, v.ID)
//获取门店品牌信息
brandInfos, err := dao.GetStoreBrandInfos(v.ID)
if err != nil {
return nil, "获取门店品牌信息失败", err
}
//获取门店减免策略
storePolicy, err := GetStoreVendorMaps(ctx, dao.GetDB(), v.ID, 9)
if err != nil {
return nil, "获取门店减免策略失败", err
}
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,
}
tmp1s = append(tmp1s, tmp1)
}
//获取热销商品
topSkusInfo, err := GetTopSkusByStoreIDs(ctx, storeID)
if err != nil {
return nil, "获取热销商品失败", err
}
for _, i := range tmp1s {
for _, j := range topSkusInfo {
if i.StoreID == j.StoreID {
data := HomePageInfos{
StoreID: i.StoreID,
StoreName: i.StoreName,
OpenTime1: i.OpenTime1,
CloseTime1: i.CloseTime1,
OpenTime2: i.OpenTime2,
CloseTime2: i.CloseTime2,
Status: i.Status,
Distance: i.Distance,
Address: i.Address,
BrandName: i.BrandName,
BrandLogo: i.BrandLogo,
DeliveryFeeDeductionSill: i.DeliveryFeeDeductionSill,
DeliveryFeeDeductionFee: i.DeliveryFeeDeductionFee,
SkuID: j.SkuID,
SkuName: j.Name,
SkuStatus: j.Status,
BestSeller: j.BestSeller,
Img: j.Img,
Price: j.Price,
Unit: j.Unit,
}
multipleData = append(multipleData, data)
}
}
}
}
return multipleData, "", nil
}

View File

@@ -1537,3 +1537,22 @@ func GetBrandBill2(db *DaoDB, brandID int, vendorOrderID string, billType, feeTy
}
return data, err
}
type BrandInfos struct {
Name string
Logo string
}
//获取门店品牌信息
func GetStoreBrandInfos(storeID int) (date *BrandInfos, err error) {
var detail *BrandInfos
sqlParams := []interface{}{}
sql := "SELECT b.`name`,b.logo FROM store s LEFT JOIN brand b ON s.brand_id = b.id WHERE s.id= ? "
if storeID >= 0 {
sqlParams = append(sqlParams, storeID)
}
if err := GetRow(GetDB(), &detail, sql, sqlParams); err != nil {
return nil, err
}
return detail, err
}

View File

@@ -592,28 +592,20 @@ func (c *StoreController) GetStoreListByLocation() {
// @Param token header string false "认证token"
// @Param lng query float64 true "经度"
// @Param lat query float64 true "纬度"
//@Param storeID query string false "门店ID"
// @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)"
// @Param brandID query int false "品牌ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetHomePageByLocation [get]
//func (c *StoreController) GetHomePageByLocation() {
// c.callGetHomePageByLocation(func(params *tStoreGetHomePageByLocationParams) (interface{}, string, error) {
// details, _, err := cms.GetHomePageByLocation(params.Ctx, params.MapData)
// if err != nil {
// return nil, "根据经纬度获取门店详细信息失败", err
// }
// if params.Token != "" {
// utils.Str2Int()
// //获取店铺基本信息
// //storeDetail := cms.GetStores(params.Ctx, params.Keyword, params.MapData, params.Offset, params.PageSize, timeList[0], timeList[1], params.OrderCountFrom, params.OrderCountTo)
// //retVal, err = cms.GetStoreVendorMaps(params.Ctx, nil, utils.Interface2String(), params.VendorID)
// }
// //return locationList, "", err
// return nil, "", err
// })
//}
func (c *StoreController) GetHomePageByLocation() {
c.callGetHomePageByLocation(func(params *tStoreGetHomePageByLocationParams) (interface{}, string, error) {
details, _, err := cms.GetHomePageByLocation(params.Ctx, params.Lng, params.Lat, params.NeedWalkDistance, params.Token)
if err != nil {
return nil, "根据经纬度获取门店详细信息失败", err
}
return details, "", err
})
}
// @Title 老格恢复拓店进度
// @Description 老格恢复拓店进度

View File

@@ -2638,6 +2638,15 @@ func init() {
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
web.ControllerComments{
Method: "GetHomePageByLocation",
Router: `/GetHomePageByLocation`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
web.ControllerComments{
Method: "GetStorePriceScore",