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

This commit is contained in:
邹宗楠
2022-08-24 13:59:49 +08:00
10 changed files with 164 additions and 73 deletions

View File

@@ -116,6 +116,7 @@ func (c *Auth2Controller) TiktokDecrypt() {
// @router /Login [post]
func (c *Auth2Controller) Login() {
c.callLogin(func(params *tAuth2LoginParams) (retVal interface{}, errCode string, err error) {
globals.SugarLogger.Debug("params.AuthType==============", params.AuthType)
if params.AuthType == auth2.AuthTypeMobile {
params.AuthIDType = auth2.UserIDMobile
} else if params.AuthType == auth2.AuthTypeEmail {
@@ -133,14 +134,18 @@ func (c *Auth2Controller) Login() {
params.AuthSecret = GetComposedCode2(&c.Controller, params.AuthSecret)
}
ctx := auth2.NewContext(c.Ctx.ResponseWriter, c.Ctx.Request)
globals.SugarLogger.Debug("params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret==============", params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret)
authInfo, err := auth2.Login(ctx, params.AuthType, params.AuthID, params.AuthIDType, params.AuthSecret)
globals.SugarLogger.Debug("authInfo==============", authInfo)
// TODO 兼容没有取到authid2的错误
if err == nil && authInfo.AuthBindInfo != nil {
if authInfo.AuthBindInfo.AuthID2 == "" {
globals.SugarLogger.Debug("fgfggggggg")
authInfo.AuthBindInfo.AuthID2 = authInfo.AuthBindInfo.AuthID
}
retVal = authInfo
}
globals.SugarLogger.Debug("retVal==============", retVal)
return retVal, "", err
})
}
@@ -343,6 +348,7 @@ func (c *Auth2Controller) AddAuthBindWithMobile() {
if err != nil {
return retVal, "", err
}
globals.SugarLogger.Debug("打印newAuthInfo==============", newAuthInfo)
err = auth2.AddAuthBindWithMobile(newAuthInfo, params.Mobile)
return retVal, "", err
})

View File

@@ -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"
)
@@ -595,57 +591,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
}
@@ -654,6 +603,34 @@ func (c *StoreController) GetStoreListByLocation() {
})
}
// @Title 根据位置得到首页商店详细信息
// @Description 根据位置得到首页商店详细信息
// @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
// })
//}
// @Title 老格恢复拓店进度
// @Description 老格恢复拓店进度
// @Param token header string true "认证token"

View File

@@ -1,11 +1,10 @@
package controllers
import (
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"git.rosy.net.cn/jx-callback/business/auth2"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/baseapi/platformapi/jdapi"
"errors"
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
"git.rosy.net.cn/jx-callback/business/jxutils"