diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index f280616d9..b78a80e4e 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "git.rosy.net.cn/jx-callback/business/jxstore/common" "git.rosy.net.cn/jx-callback/business/jxstore/event" "io" "math" @@ -5626,3 +5627,56 @@ func UpdateStoreTemplate(ctx *jxcontext.Context, storeID int, content, sound str _, err = dao.UpdateEntity(db, store, "PrinterTemplate", "PrinterSound") return err } + +//条件过滤 B2B、物料店 +func FilterByB2B(locationList []*common.Store4User, token string) (retVal interface{}, errCode string, err error) { + userAuth, err := auth2.GetTokenInfo(token) + if err != nil { + return nil, "", err + } + user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1) + if err != nil { + return nil, "", err + } + globals.SugarLogger.Debug("检测数据userAuth,user,total==============", userAuth, user, total) + // 获取位置附近门店列表 + storeIDs := make([]int, 0, len(locationList)) + for _, v := range locationList { + storeIDs = append(storeIDs, v.ID) + } + globals.SugarLogger.Debug("检测数据locationList,storeIDs==============", locationList, storeIDs) + // 判断门店是不是b2b门店,如果是,用户必须为系统管理员(门店老板和运营人员) + store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "") + if err != nil { + return nil, "", err + } + + isMatterStore := false + for _, v := range storeIDs { + if v == model.MatterStoreID { + isMatterStore = true + } + } + + result := make([]*common.Store4User, 0, 0) + for _, v := range store { + for _, s := range locationList { + if v.ID == s.ID { + if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店 + continue + } else { + result = append(result, s) + } + } + } + } + + if total != model.YES { + return result, "", errors.New("") + } + if user[0].Type != model.YES { + return locationList, "", nil + } else { + return result, "", err + } +} diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index c4768d014..d7bf60768 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -3,7 +3,6 @@ package localjx import ( "errors" "fmt" - "git.rosy.net.cn/baseapi/platformapi/tiktok" "math" "regexp" "strings" @@ -326,9 +325,9 @@ func Pay4Order(ctx *jxcontext.Context, orderID int64, payType int, vendorPayType err = dao.CreateEntity(dao.GetDB(), orderPay) } case model.PayTypeTL: - if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID { - subAppID = model.JXC4AppId // 京西商城 - } + //if subAppID == tiktok.TiktokAppId || subAppID == tiktok.TiktokJXDJAppID { + // subAppID = model.JXC4AppId // 京西商城 + //} if orderPay, err = pay4OrderByTL(ctx, order, payType, vendorPayType, subAppID); err == nil && orderPay != nil { dao.WrapAddIDCULDEntity(orderPay, ctx.GetUserName()) err = dao.CreateEntity(dao.GetDB(), orderPay) diff --git a/controllers/cms_store.go b/controllers/cms_store.go index dda4317b9..823dafb1f 100644 --- a/controllers/cms_store.go +++ b/controllers/cms_store.go @@ -1,9 +1,7 @@ package controllers import ( - "errors" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/business/auth2" "git.rosy.net.cn/jx-callback/business/jxstore/cms" "git.rosy.net.cn/jx-callback/business/jxstore/common" "git.rosy.net.cn/jx-callback/business/jxstore/misc" @@ -11,8 +9,6 @@ import ( "git.rosy.net.cn/jx-callback/business/jxutils" "git.rosy.net.cn/jx-callback/business/jxutils/netprinter" "git.rosy.net.cn/jx-callback/business/model" - "git.rosy.net.cn/jx-callback/business/model/dao" - "git.rosy.net.cn/jx-callback/globals" "git.rosy.net.cn/jx-callback/globals/api" "github.com/astaxie/beego/server/web" ) @@ -579,57 +575,10 @@ func (c *StoreController) SyncStoresCourierInfo() { func (c *StoreController) GetStoreListByLocation() { 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) - //if params.Token == "tempToken" { - // return locationList, "", nil - //} if params.Token != "" { - // 获取用户权限,如果是普通用户不展示b2b相关目录,如果是门店老板或者管理则展示全部 - userAuth, err := auth2.GetTokenInfo(params.Token) + result, _, err := cms.FilterByB2B(locationList, params.Token) if err != nil { return nil, "", err - } - user, total, err := dao.GetUsers(dao.GetDB(), 1, "", []string{userAuth.UserID}, nil, nil, 0, 1) - if err != nil { - return nil, "", err - } - globals.SugarLogger.Debug("检测数据userAuth,user,total==============", userAuth, user, total) - // 获取位置附近门店列表 - storeIDs := make([]int, 0, len(locationList)) - for _, v := range locationList { - storeIDs = append(storeIDs, v.ID) - } - globals.SugarLogger.Debug("检测数据locationList,storeIDs==============", locationList, storeIDs) - // 判断门店是不是b2b门店,如果是,用户必须为系统管理员(门店老板和运营人员) - store, err := dao.GetStoreList(dao.GetDB(), storeIDs, nil, nil, nil, nil, "") - if err != nil { - return nil, "", err - } - - isMatterStore := false - for _, v := range storeIDs { - if v == model.MatterStoreID { - isMatterStore = true - } - } - - result := make([]*common.Store4User, 0, 0) - for _, v := range store { - for _, s := range locationList { - if v.ID == s.ID { - if (v.BrandID == model.B2BNumberId || isMatterStore) && user[0].Type == model.YES { // 普通用户进入物料店和b2b店 - continue - } else { - result = append(result, s) - } - } - } - } - - if total != model.YES { - return result, "", errors.New("") - } - if user[0].Type != model.YES { - return locationList, "", nil } else { return result, "", err } @@ -638,6 +587,36 @@ func (c *StoreController) GetStoreListByLocation() { }) } +// @Title 根据位置得到首页商店详细信息 +// @Description 根据位置得到首页商店详细信息 +// @Param token header string false "认证token" +// @Param lng query float64 true "经度" +// @Param lat query float64 true "纬度" +// @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) { + locationList, err := common.GetStoreListByLocation(params.Ctx, params.Lng, params.Lat, 20000, params.NeedWalkDistance, false, params.BrandID) + if err != nil { + return nil, "根据经纬度获取商店失败", err + } + if params.Token != "" { + // 获取用户权限,如普通用户不展示b2b相关目录,门店老板或者管理则展示全部 + result, _, err := cms.FilterByB2B(locationList, params.Token) + if err != nil { + return nil, "根据用户权限过滤商店失败", err + } + //获取店铺基本信息 + //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 + }) +} + // @Title 老格恢复拓店进度 // @Description 老格恢复拓店进度 // @Param token header string true "认证token"