+ TmpGetMyStoreList
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/mobile"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth/weixin"
|
||||||
@@ -65,6 +66,33 @@ func GetSelfInfo(ctx *jxcontext.Context) (storeUserInfo *dao.StoreUserInfo, err
|
|||||||
return storeUserInfo, err
|
return storeUserInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getMobileFromCtx(ctx *jxcontext.Context) (mobile string) {
|
||||||
|
token := ctx.GetToken()
|
||||||
|
if auth2.IsV2Token(token) {
|
||||||
|
authInfo, err2 := auth2.GetTokenInfo(token)
|
||||||
|
if err2 == nil {
|
||||||
|
if authInfo.TokenType == auth2.TokenTypeNormal {
|
||||||
|
mobile = authInfo.GetMobile()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
userInfo, err2 := auth.GetUserInfo(token)
|
||||||
|
if err2 == nil {
|
||||||
|
mobile = userInfo.GetAuthID()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mobile
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMyStoreList(ctx *jxcontext.Context) (storeList []*model.Store, err error) {
|
||||||
|
mobileNum := getMobileFromCtx(ctx)
|
||||||
|
if mobileNum == "" {
|
||||||
|
return nil, fmt.Errorf("不能得到用户手机号")
|
||||||
|
}
|
||||||
|
storeList, err = dao.GetStoreListByMobile(dao.GetDB(), mobileNum)
|
||||||
|
return storeList, err
|
||||||
|
}
|
||||||
|
|
||||||
func UnbindMobile(ctx *jxcontext.Context, mobile string) (num int64, err error) {
|
func UnbindMobile(ctx *jxcontext.Context, mobile string) (num int64, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
num, err = dao.UpdateEntityByKV(db, &legacymodel.WeiXins{}, map[string]interface{}{
|
num, err = dao.UpdateEntityByKV(db, &legacymodel.WeiXins{}, map[string]interface{}{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
@@ -57,7 +56,7 @@ func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Reque
|
|||||||
authInfo, err2 := auth2.GetTokenInfo(token)
|
authInfo, err2 := auth2.GetTokenInfo(token)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
ctx.userInfo = authInfo
|
ctx.userInfo = authInfo
|
||||||
// globals.SugarLogger.Debugf("jxcontext New, V2 authInfo:%s", utils.Format4Output(authInfo, false))
|
// globals.SugarLogger.Debugf("jxcontext New, V2 authInfo:%s", utils.Format4Output(authInfo, true))
|
||||||
if authInfo.TokenType != auth2.TokenTypeNormal {
|
if authInfo.TokenType != auth2.TokenTypeNormal {
|
||||||
err = errors.New("需要正式TOKEN")
|
err = errors.New("需要正式TOKEN")
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,7 @@ func New(notUsed interface{}, token string, w http.ResponseWriter, r *http.Reque
|
|||||||
} else {
|
} else {
|
||||||
userInfo, err2 := auth.GetUserInfo(token)
|
userInfo, err2 := auth.GetUserInfo(token)
|
||||||
if err = err2; err == nil {
|
if err = err2; err == nil {
|
||||||
globals.SugarLogger.Debugf("jxcontext New, V1 authInfo:%s", utils.Format4Output(userInfo, false))
|
// globals.SugarLogger.Debugf("jxcontext New, V1 authInfo:%s", utils.Format4Output(userInfo, true))
|
||||||
ctx.userInfo = userInfo
|
ctx.userInfo = userInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
"git.rosy.net.cn/jx-callback/business/model/legacymodel"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -116,3 +117,30 @@ func GetUserStoreInfo(db *DaoDB, fieldName, fieldValue string) (storeUserInfo *S
|
|||||||
}
|
}
|
||||||
return storeUserInfo, err
|
return storeUserInfo, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStoreListByMobile(db *DaoDB, mobile string) (storeList []*model.Store, err error) {
|
||||||
|
if mobile != "" {
|
||||||
|
sql := `
|
||||||
|
SELECT DISTINCT *
|
||||||
|
FROM (
|
||||||
|
SELECT *
|
||||||
|
FROM store t1
|
||||||
|
WHERE (t1.market_man_phone = ? OR t1.operator_phone = ?)
|
||||||
|
UNION DISTINCT
|
||||||
|
SELECT t1.*
|
||||||
|
FROM store t1
|
||||||
|
JOIN weixins t2 ON t2.jxstoreid = t1.id AND t2.parentid = -1
|
||||||
|
LEFT JOIN weixins t3 ON t3.parentid = t2.id
|
||||||
|
WHERE (t2.tel = ? OR t3.tel = ?)
|
||||||
|
) t1
|
||||||
|
ORDER BY t1.name`
|
||||||
|
sqlParams := []interface{}{
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
mobile,
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeList, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
return storeList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -50,6 +50,19 @@ func (c *UserController) TmpGetSelfInfo() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 得到用户自己的门店列表
|
||||||
|
// @Description 得到用户自己的门店列表
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /TmpGetMyStoreList [get]
|
||||||
|
func (c *UserController) TmpGetMyStoreList() {
|
||||||
|
c.callTmpGetSelfInfo(func(params *tUserTmpGetSelfInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = cms.GetMyStoreList(params.Ctx)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// @Title 取消手机门店绑定
|
// @Title 取消手机门店绑定
|
||||||
// @Description 此操作会将此手机关联的所有门店信息清除(取消组长,取消自己为他组组员),如果此人为组长,取消后组员也相应会取消门店绑定(但组员的成员关系还在)
|
// @Description 此操作会将此手机关联的所有门店信息清除(取消组长,取消自己为他组组员),如果此人为组长,取消后组员也相应会取消门店绑定(但组员的成员关系还在)
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
|
|||||||
@@ -1744,6 +1744,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "TmpGetMyStoreList",
|
||||||
|
Router: `/TmpGetMyStoreList`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:UserController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "TmpGetSelfInfo",
|
Method: "TmpGetSelfInfo",
|
||||||
|
|||||||
Reference in New Issue
Block a user