1
This commit is contained in:
@@ -5844,15 +5844,15 @@ func UpdateStoreTemplate(ctx *jxcontext.Context, storeID int, content, sound str
|
|||||||
}
|
}
|
||||||
|
|
||||||
//条件过滤 B2B、物料店
|
//条件过滤 B2B、物料店
|
||||||
func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*common.Store4User, errCode string, err error) {
|
func FilterByB2B(locationList []*common.Store4User) (retVal []*common.Store4User, errCode string, err error) {
|
||||||
userAuth, err := auth2.GetTokenInfo(token)
|
//userAuth, err := auth2.GetTokenInfo(token)
|
||||||
if err != nil {
|
// //if err != nil {
|
||||||
return nil, "", err
|
// // return nil, "", err
|
||||||
}
|
// //}
|
||||||
user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1)
|
// //user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1)
|
||||||
if err != nil {
|
// //if err != nil {
|
||||||
return nil, "", err
|
// // return nil, "", err
|
||||||
}
|
// //}
|
||||||
// 获取位置附近门店列表
|
// 获取位置附近门店列表
|
||||||
storeIDs := make([]int, 0, len(locationList))
|
storeIDs := make([]int, 0, len(locationList))
|
||||||
for _, v := range locationList {
|
for _, v := range locationList {
|
||||||
@@ -5875,7 +5875,8 @@ func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*com
|
|||||||
for _, v := range store {
|
for _, v := range store {
|
||||||
for _, s := range locationList {
|
for _, s := range locationList {
|
||||||
if v.ID == s.ID {
|
if v.ID == s.ID {
|
||||||
if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店
|
//if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店
|
||||||
|
if v.BrandID == model.B2BNumberId || isMatterStore { // 普通用户进入物料店和b2b店
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
result = append(result, s)
|
result = append(result, s)
|
||||||
@@ -5884,18 +5885,18 @@ func FilterByB2B(locationList []*common.Store4User, token string) (retVal []*com
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if total != model.YES {
|
//if total != model.YES {
|
||||||
return result, "", errors.New("")
|
// return result, "", errors.New("")
|
||||||
}
|
//}
|
||||||
if user[0].Type != model.YES {
|
//if user[0].Type != model.YES {
|
||||||
return locationList, "", nil
|
// return locationList, "", nil
|
||||||
} else {
|
//} else {
|
||||||
return result, "", err
|
return result, "", err
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
//首页信息展示
|
//首页信息展示
|
||||||
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) (interface{}, string, error) {
|
||||||
//获取门店信息
|
//获取门店信息
|
||||||
var (
|
var (
|
||||||
storeID []int
|
storeID []int
|
||||||
@@ -5910,49 +5911,50 @@ func GetHomePageByLocation(ctx *jxcontext.Context, lng, lat float64, needWalkDis
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "经纬度获取推荐门店失败", err
|
return nil, "经纬度获取推荐门店失败", err
|
||||||
}
|
}
|
||||||
if token != "" {
|
//if token != "" {
|
||||||
//权限过滤门店
|
//权限过滤门店
|
||||||
filterStore, _, err := FilterByB2B(locationList, token)
|
//filterStore, _, err := FilterByB2B(locationList, token)
|
||||||
|
filterStore, _, err := FilterByB2B(locationList)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "权限过滤门店失败", err
|
||||||
|
}
|
||||||
|
for _, v := range filterStore {
|
||||||
|
storeID = append(storeID, v.ID)
|
||||||
|
//获取门店品牌信息
|
||||||
|
brandInfos, err := dao.GetStoreBrandInfos(v.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "权限过滤门店失败", err
|
return nil, "获取门店品牌信息失败", err
|
||||||
}
|
}
|
||||||
for _, v := range filterStore {
|
storeInfo := StoreInfo{
|
||||||
storeID = append(storeID, v.ID)
|
StoreID: v.ID,
|
||||||
//获取门店品牌信息
|
StoreName: v.Name,
|
||||||
brandInfos, err := dao.GetStoreBrandInfos(v.ID)
|
OpenTime1: v.OpenTime1,
|
||||||
if err != nil {
|
CloseTime1: v.CloseTime1,
|
||||||
return nil, "获取门店品牌信息失败", err
|
OpenTime2: v.OpenTime2,
|
||||||
}
|
CloseTime2: v.CloseTime2,
|
||||||
storeInfo := StoreInfo{
|
Status: v.Status,
|
||||||
StoreID: v.ID,
|
Distance: v.Distance,
|
||||||
StoreName: v.Name,
|
Address: v.Address,
|
||||||
OpenTime1: v.OpenTime1,
|
BrandName: brandInfos.Name,
|
||||||
CloseTime1: v.CloseTime1,
|
BrandLogo: brandInfos.Logo,
|
||||||
OpenTime2: v.OpenTime2,
|
}
|
||||||
CloseTime2: v.CloseTime2,
|
storeInfos = append(storeInfos, storeInfo)
|
||||||
Status: v.Status,
|
//获取门店减免策略
|
||||||
Distance: v.Distance,
|
storePolicy, err := GetStoreVendorMaps(ctx, dao.GetDB(), v.ID, 9)
|
||||||
Address: v.Address,
|
if err != nil {
|
||||||
BrandName: brandInfos.Name,
|
return nil, "获取门店减免策略失败", err
|
||||||
BrandLogo: brandInfos.Logo,
|
}
|
||||||
}
|
for _, k := range storePolicy {
|
||||||
storeInfos = append(storeInfos, storeInfo)
|
if k.StoreID == v.ID {
|
||||||
//获取门店减免策略
|
storeDeductionInfo = StoreDeductionInfo{
|
||||||
storePolicy, err := GetStoreVendorMaps(ctx, dao.GetDB(), v.ID, 9)
|
StoreID: k.StoreID,
|
||||||
if err != nil {
|
DeliveryFeeDeductionSill: k.DeliveryFeeDeductionSill,
|
||||||
return nil, "获取门店减免策略失败", err
|
DeliveryFeeDeductionFee: k.DeliveryFeeDeductionFee,
|
||||||
}
|
|
||||||
for _, k := range storePolicy {
|
|
||||||
if k.StoreID == v.ID {
|
|
||||||
storeDeductionInfo = StoreDeductionInfo{
|
|
||||||
StoreID: k.StoreID,
|
|
||||||
DeliveryFeeDeductionSill: k.DeliveryFeeDeductionSill,
|
|
||||||
DeliveryFeeDeductionFee: k.DeliveryFeeDeductionFee,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
storeDeductionInfos = append(storeDeductionInfos, storeDeductionInfo)
|
|
||||||
}
|
}
|
||||||
|
storeDeductionInfos = append(storeDeductionInfos, storeDeductionInfo)
|
||||||
}
|
}
|
||||||
|
//}
|
||||||
//获取热销商品
|
//获取热销商品
|
||||||
topSkusInfo, err := GetTopSkusByStoreIDs(ctx, storeID)
|
topSkusInfo, err := GetTopSkusByStoreIDs(ctx, storeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -588,7 +588,6 @@ func (c *StoreController) SyncStoresCourierInfo() {
|
|||||||
|
|
||||||
// @Title 根据位置得到推荐门店列表
|
// @Title 根据位置得到推荐门店列表
|
||||||
// @Description 根据位置得到推荐门店列表
|
// @Description 根据位置得到推荐门店列表
|
||||||
// @Param token header string false "认证token"
|
|
||||||
// @Param lng query float64 true "经度"
|
// @Param lng query float64 true "经度"
|
||||||
// @Param lat query float64 true "纬度"
|
// @Param lat query float64 true "纬度"
|
||||||
// @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)"
|
// @Param needWalkDistance query bool false "是否需要返回步行距离(且以步行距离排序)"
|
||||||
@@ -600,7 +599,7 @@ func (c *StoreController) GetStoreListByLocation() {
|
|||||||
c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) {
|
c.callGetStoreListByLocation(func(params *tStoreGetStoreListByLocationParams) (retVal interface{}, errCode string, err error) {
|
||||||
locationList, err := common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID)
|
locationList, err := common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID)
|
||||||
if params.Token != "" {
|
if params.Token != "" {
|
||||||
result, _, err := cms.FilterByB2B(locationList, params.Token)
|
result, _, err := cms.FilterByB2B(locationList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
} else {
|
} else {
|
||||||
@@ -622,7 +621,7 @@ func (c *StoreController) GetStoreListByLocation() {
|
|||||||
// @router /GetHomePageByLocation [get]
|
// @router /GetHomePageByLocation [get]
|
||||||
func (c *StoreController) GetHomePageByLocation() {
|
func (c *StoreController) GetHomePageByLocation() {
|
||||||
c.callGetHomePageByLocation(func(params *tStoreGetHomePageByLocationParams) (interface{}, string, error) {
|
c.callGetHomePageByLocation(func(params *tStoreGetHomePageByLocationParams) (interface{}, string, error) {
|
||||||
details, _, err := cms.GetHomePageByLocation(params.Ctx, params.Lng, params.Lat, params.NeedWalkDistance, params.Token)
|
details, _, err := cms.GetHomePageByLocation(params.Ctx, params.Lng, params.Lat, params.NeedWalkDistance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "根据经纬度获取门店详细信息失败", err
|
return nil, "根据经纬度获取门店详细信息失败", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user