|
@@ -10,10 +10,10 @@ import (
|
|
|
//申请代理
|
|
//申请代理
|
|
|
func (self *UserController) AgentApplication() {
|
|
func (self *UserController) AgentApplication() {
|
|
|
mobile := self.GetString("mobile")
|
|
mobile := self.GetString("mobile")
|
|
|
- _id := self.Ctx.Input.Param(":wx_uid")
|
|
|
|
|
- wxId, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
|
|
- introUserId := self.GetCurrentWxUserId()
|
|
|
|
|
|
|
+ wxId, _ := self.GetInt64("wx_uid", 0)
|
|
|
|
|
|
|
|
|
|
+ introUserId := self.GetCurrentWxUserId()
|
|
|
|
|
+ //introUserId := int64(30608)
|
|
|
/* if len(mobile) != 11 {
|
|
/* if len(mobile) != 11 {
|
|
|
self.ReturnError(404, apps.ParamsError, "", nil)
|
|
self.ReturnError(404, apps.ParamsError, "", nil)
|
|
|
}*/
|
|
}*/
|
|
@@ -30,7 +30,9 @@ func (self *UserController) AgentApplication() {
|
|
|
if curWxUser == nil {
|
|
if curWxUser == nil {
|
|
|
self.ReturnError(403, apps.UserNeedLogin, "", nil)
|
|
self.ReturnError(403, apps.UserNeedLogin, "", nil)
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if curWxUser.Rank < user_model.WX_USER_RANK_ONE {
|
|
|
|
|
+ self.ReturnError(403, apps.ComNotAllow, "", nil)
|
|
|
|
|
+ }
|
|
|
record := user_model.GetAgentApplyByWxUId(wxUser.Id)
|
|
record := user_model.GetAgentApplyByWxUId(wxUser.Id)
|
|
|
if record != nil {
|
|
if record != nil {
|
|
|
self.ReturnError(403, apps.ShopNoRepit, "", nil)
|
|
self.ReturnError(403, apps.ShopNoRepit, "", nil)
|
|
@@ -51,10 +53,10 @@ func (self *UserController) AgentApplication() {
|
|
|
|
|
|
|
|
//审核申请代理
|
|
//审核申请代理
|
|
|
func (self *UserController) ComAgentApplication() {
|
|
func (self *UserController) ComAgentApplication() {
|
|
|
- _id := self.Ctx.Input.Param(":apply_id")
|
|
|
|
|
|
|
+ _id := self.Ctx.Input.Param(":id")
|
|
|
applyId, _ := strconv.ParseInt(_id, 10, 64)
|
|
applyId, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
introUserId := self.GetCurrentWxUserId()
|
|
introUserId := self.GetCurrentWxUserId()
|
|
|
-
|
|
|
|
|
|
|
+ //introUserId := int64(30608)
|
|
|
record := user_model.GetAgentApplyById(applyId)
|
|
record := user_model.GetAgentApplyById(applyId)
|
|
|
if record == nil {
|
|
if record == nil {
|
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
self.ReturnError(403, apps.NoExist, "", nil)
|
|
@@ -81,3 +83,109 @@ func (self *UserController) ComAgentApplication() {
|
|
|
self.Data["json"] = ret
|
|
self.Data["json"] = ret
|
|
|
self.ServeJSON()
|
|
self.ServeJSON()
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+//获取我的代理列表
|
|
|
|
|
+func (self *UserController) GetMyAgentList() {
|
|
|
|
|
+ page, _ := self.GetInt64("page", 1)
|
|
|
|
|
+ perPage, _ := self.GetInt64("per_page", 20)
|
|
|
|
|
+ if perPage <= 0 || perPage > 100 {
|
|
|
|
|
+ perPage = 20
|
|
|
|
|
+ }
|
|
|
|
|
+ cache, _ := self.GetBool("cache", false)
|
|
|
|
|
+
|
|
|
|
|
+ //user := self.GetCurrentUser(cache)
|
|
|
|
|
+ wxUId := self.GetCurrentWxUserId()
|
|
|
|
|
+ //wxUId := int64(30608)
|
|
|
|
|
+ curWxUser := user_model.GetWxUserById(wxUId, true)
|
|
|
|
|
+ if curWxUser == nil {
|
|
|
|
|
+ self.ReturnError(403, apps.UserNeedLogin, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ if curWxUser.Rank < user_model.WX_USER_RANK_THERE {
|
|
|
|
|
+ self.ReturnError(403, apps.AccountError, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ list := user_model.GetAllApplys(curWxUser.Depart, page, perPage, cache)
|
|
|
|
|
+ count := user_model.GetAllApplyCount(curWxUser.Depart, false)
|
|
|
|
|
+ type AgentInfo struct {
|
|
|
|
|
+ AgentList []*user_model.AgentApply `orm:"-" json:"agent_list"`
|
|
|
|
|
+ AgentCount int64 `orm:"-" json:"count"`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.Data["json"] = &AgentInfo{AgentList: list, AgentCount: count}
|
|
|
|
|
+ self.ServeJSON()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//获取代理申请详细
|
|
|
|
|
+func (self *UserController) GetAgentDetail() {
|
|
|
|
|
+ _id := self.Ctx.Input.Param(":id")
|
|
|
|
|
+ id, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
|
|
+ //uId := self.GetCurrentUserId()
|
|
|
|
|
+ wxUId := self.GetCurrentWxUserId()
|
|
|
|
|
+ //wxUId := int64(30608)
|
|
|
|
|
+ curWxUser := user_model.GetWxUserById(wxUId, true)
|
|
|
|
|
+ if curWxUser == nil {
|
|
|
|
|
+ self.ReturnError(403, apps.UserNeedLogin, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //wxUId := int64(1781)
|
|
|
|
|
+ item := user_model.GetAgentApplyById(id)
|
|
|
|
|
+ if item == nil {
|
|
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ introUser := user_model.GetWxUserById(item.IntroUserId, true)
|
|
|
|
|
+
|
|
|
|
|
+ if item.Depart != curWxUser.Depart {
|
|
|
|
|
+ self.ReturnError(403, apps.ComNotAllow, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ item.Head = user_model.GetFullImgUrl(curWxUser.Head)
|
|
|
|
|
+ item.IntroNickName = introUser.Nickname
|
|
|
|
|
+ item.SaleGroupSum = curWxUser.SaleGroupSum
|
|
|
|
|
+ self.Data["json"] = item
|
|
|
|
|
+ self.ServeJSON()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 获取某用户信息
|
|
|
|
|
+func (self *UserController) GetUserInfo() {
|
|
|
|
|
+ useCache, err := self.GetBool("cache", true)
|
|
|
|
|
+ _id := self.Ctx.Input.Param(":id")
|
|
|
|
|
+ id, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ useCache = false
|
|
|
|
|
+ }
|
|
|
|
|
+ wxUser := user_model.GetWxUserById(id, useCache)
|
|
|
|
|
+ if wxUser != nil {
|
|
|
|
|
+ wxUser.Head = self.GetFullImgUrl(wxUser.Head)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ type Ret struct {
|
|
|
|
|
+ WxUser *user_model.WxUser `json:"wx_user"`
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ user := &Ret{WxUser: wxUser}
|
|
|
|
|
+ self.Data["json"] = user
|
|
|
|
|
+ self.ServeJSON()
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//获取代理申请详细
|
|
|
|
|
+func (self *UserController) GetAgentDetailByWxUid() {
|
|
|
|
|
+ _id := self.Ctx.Input.Param(":wx_uid")
|
|
|
|
|
+ id, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
|
|
+ //uId := self.GetCurrentUserId()
|
|
|
|
|
+ curId := self.GetCurrentWxUserId()
|
|
|
|
|
+ //curId := int64(30608)
|
|
|
|
|
+ curWxUser := user_model.GetWxUserById(curId, true)
|
|
|
|
|
+ if curWxUser == nil {
|
|
|
|
|
+ self.ReturnError(403, apps.UserNeedLogin, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ //wxUId := int64(1781)
|
|
|
|
|
+ item := user_model.GetAgentApplyByWxUId(id)
|
|
|
|
|
+ if item == nil {
|
|
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ if item.WxUId != id {
|
|
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
|
|
+ }
|
|
|
|
|
+ item.SaleGroup = curWxUser.SaleGroup
|
|
|
|
|
+ item.SaleGroupSum = curWxUser.SaleGroupSum
|
|
|
|
|
+ self.Data["json"] = item
|
|
|
|
|
+ self.ServeJSON()
|
|
|
|
|
+}
|