Преглед на файлове

add agent apply function

abiao преди 4 години
родител
ревизия
76e49cb2ab

+ 114 - 6
go/gopath/src/fohow.com/apps/controllers/user_controller/agent_apply_controller.go

@@ -10,10 +10,10 @@ import (
 //申请代理
 func (self *UserController) AgentApplication() {
 	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 {
 		self.ReturnError(404, apps.ParamsError, "", nil)
 	}*/
@@ -30,7 +30,9 @@ func (self *UserController) AgentApplication() {
 	if curWxUser == 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)
 	if record != nil {
 		self.ReturnError(403, apps.ShopNoRepit, "", nil)
@@ -51,10 +53,10 @@ func (self *UserController) AgentApplication() {
 
 //审核申请代理
 func (self *UserController) ComAgentApplication() {
-	_id := self.Ctx.Input.Param(":apply_id")
+	_id := self.Ctx.Input.Param(":id")
 	applyId, _ := strconv.ParseInt(_id, 10, 64)
 	introUserId := self.GetCurrentWxUserId()
-
+	//introUserId := int64(30608)
 	record := user_model.GetAgentApplyById(applyId)
 	if record == nil {
 		self.ReturnError(403, apps.NoExist, "", nil)
@@ -81,3 +83,109 @@ func (self *UserController) ComAgentApplication() {
 	self.Data["json"] = ret
 	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()
+}

+ 2 - 1
go/gopath/src/fohow.com/apps/controllers/user_controller/init.go

@@ -22,8 +22,9 @@ import (
 var (
 	exceptCheckUserLoginAction = []string{"BindingTel", "UpdateWxUserInfo",
 		"CheckLogin", "GenerateQrcode",
+		"AgentApplication", "ComAgentApplication", "GetMyAgentList", "GetAgentDetail", "GetUserInfo", "GetAgentDetailByWxUid",
 		"GetInviteList", "GetMonthlyInviteList", "OneClickBindingTel", "BindingWxPhone", "SetWxUserInviter", "Get"}
-	exceptCheckWxUserLoginAction = []string{"CheckLogin"}
+	exceptCheckWxUserLoginAction = []string{"AgentApplication", "ComAgentApplication", "GetMyAgentList", "GetAgentDetail", "GetUserInfo", "GetAgentDetailByWxUid", "CheckLogin"}
 )
 
 type UserController struct {

+ 12 - 0
go/gopath/src/fohow.com/apps/controllers/user_controller/invite_controller.go

@@ -98,6 +98,18 @@ func (self *UserController) GetInviteList() {
 	if list == nil {
 		list = make([]*user_model.Invitee, 0, 0)
 	}
+	//代理状态判断---普通会员(status=0),则显示 申请代理
+	for _, item := range list {
+		if item.ShowInviteMode == 0 {
+			item.Status = 0
+			record := user_model.GetAgentApplyByWxUId(item.WxUId)
+			if record != nil {
+				item.Status = 1
+			}
+		} else {
+			item.Status = 2
+		}
+	}
 
 	type Ret struct {
 		Inviter   *user_model.WxUser    `json:"wx_inviter"`

+ 1 - 1
go/gopath/src/fohow.com/apps/init.go

@@ -27,7 +27,7 @@ const (
 
 var (
 	// 共用
-	ComNotAllow = []string{"notAllow", "审核人权限不够,请联系管理员"}
+	ComNotAllow = []string{"notAllow", "权限不够,请联系管理员"}
 
 	BindFail         = []string{"bindFail", "迁移失败,请联系管理员"}
 	HasBind          = []string{"hasBind", "该会员编号已绑定会员"}

+ 18 - 16
go/gopath/src/fohow.com/apps/models/user_model/agent_application.go

@@ -1,7 +1,6 @@
 package user_model
 
 import (
-	"api.com/apps/models/user_model"
 	"fohow.com/cache"
 
 	"fmt"
@@ -16,19 +15,22 @@ const (
 )
 
 type AgentApply struct {
-	Id          int64     `orm:"column(id);pk"                                       json:"id"`          // int(11)
-	HTime       int64     `orm:"column(happen_time)"                                 json:"happen_time"` // int(11)
-	IntroUserId int64     `orm:"column(intro_user_id)"                          json:"intro_user_id"`
-	WxUId       int64     `orm:"column(wx_user_id)"                                  json:"wx_uid"`   // int(11)
-	NickName    string    `orm:"column(nickname)"                                    json:"nickname"` // varchar(64)
-	Mobile      string    `orm:"column(mobile)"                                      json:"mobile"`   // int(11)
-	Depart      int64     `orm:"column(depart)" json:"-"`                                             // datetime
-	Status      bool      `orm:"column(status)"                                      json:"status"`
-	ComUser     int64     `orm:"column(com_user_id)"                                 json:"com_user_id"` // int(11)
-	ComTime     int64     `orm:"column(com_time)"                                    json:"com_time"`    // int(11)
-	Head        string    `orm:"-"                                                   json:"head"`        // varchar(255)
-	CreatedAt   time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"`           // datetime
-	UpdatedAt   time.Time `orm:"column(updated_at);null;auto_now;type(datetime)"     json:"-"`           // datetime
+	Id            int64     `orm:"column(id);pk"                                       json:"id"`          // int(11)
+	HTime         int64     `orm:"column(happen_time)"                                 json:"happen_time"` // int(11)
+	IntroUserId   int64     `orm:"column(intro_user_id)"                          json:"intro_user_id"`
+	WxUId         int64     `orm:"column(wx_user_id)"                                  json:"wx_uid"`   // int(11)
+	NickName      string    `orm:"column(nickname)"                                    json:"nickname"` // varchar(64)
+	Mobile        string    `orm:"column(mobile)"                                      json:"mobile"`   // int(11)
+	Depart        int64     `orm:"column(depart)" json:"-"`                                             // datetime
+	Status        bool      `orm:"column(status)"                                      json:"status"`
+	ComUser       int64     `orm:"column(com_user_id)"                                 json:"com_user_id"`    // int(11)
+	ComTime       int64     `orm:"column(com_time)"                                    json:"com_time"`       // int(11)
+	Head          string    `orm:"-"                                                   json:"head"`           // varchar(255)
+	IntroNickName string    `orm:"-"                                          json:"intro_nick_name"`         // varchar(255)
+	SaleGroupSum  float64   `orm:"-"                                                   json:"sale_group_sum"` // varchar(255)
+	SaleGroup     float64   `orm:"-"                                                   json:"sale_group"`     // varchar(255)
+	CreatedAt     time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"`              // datetime
+	UpdatedAt     time.Time `orm:"column(updated_at);null;auto_now;type(datetime)"     json:"-"`              // datetime
 }
 
 func (self *AgentApply) TableName() string {
@@ -87,7 +89,7 @@ func GetAgentApplyById(id int64) *AgentApply {
 }
 
 //获取区代所有代理申请记录
-func GetAllApplys(page, perPage, depart int64, useCache bool) (agent_apply []*AgentApply) {
+func GetAllApplys(depart, page, perPage int64, useCache bool) (agent_apply []*AgentApply) {
 	k := fmt.Sprintf("user_model.GetAllApplys.page(%d).perPage(%d).depart(%d)", page, perPage, depart)
 	if useCache {
 		if ret, ok := cache.Cache.Get(k).([]*AgentApply); ok {
@@ -101,7 +103,7 @@ func GetAllApplys(page, perPage, depart int64, useCache bool) (agent_apply []*Ag
 		beego.BeeLogger.Debug("GetLatest err=%s", err)
 	}
 	for _, ap := range agent_apply {
-		wxUser := user_model.GetWxUserById(ap.WxUId, true)
+		wxUser := GetWxUserById(ap.WxUId, true)
 		if wxUser != nil {
 			ap.Head = GetFullImgUrl(wxUser.Head)
 		}

+ 1 - 1
go/gopath/src/fohow.com/apps/models/user_model/init.go

@@ -6,5 +6,5 @@ import (
 
 func init() {
 	orm.RegisterModel(new(Session), new(User), new(WxUser), new(InviteOrder), new(WxUserGongzhonghao),
-		new(ThreeWxUser), new(ShopApplication), new(BindUser), new(SysCent))
+		new(ThreeWxUser), new(ShopApplication), new(BindUser), new(SysCent), new(AgentApply))
 }

+ 2 - 0
go/gopath/src/fohow.com/apps/models/user_model/invite.go

@@ -123,6 +123,8 @@ type Invitee struct {
 	SaleGroupSum   float64     `orm:"column(sale_group_sum)" json:"sale_group_sum"`           // datetime
 	NeInvitee      interface{} `orm:"-"         json:"ne_invitee"`                            //WxUId下一级邀请关系
 	NeInviteeCount int64       `orm:"-"         json:"ne_invitee_count"`                      //WxUId下一级邀请总数
+	Status         int64       `orm:"-"        json:"status"`                                 //代理状态
+
 }
 
 //邀请的一级关系- 总佣金

BIN
go/gopath/src/fohow.com/fohowmall.com


+ 18 - 0
go/gopath/src/fohow.com/routers/routes.go

@@ -326,4 +326,22 @@ func init() {
 	beego.Router("/v1/live_broad/current", &live_controller.LiveController{}, "get:GetCurrentLiveShow")
 	//获取直播列表
 	beego.Router("/v1/live_broad/list", &live_controller.LiveController{}, "get:Latest")
+
+	//----------------代理申请管理-------------------
+	//获取某用户信息
+	beego.Router("/v1/user/others_info/:id([0-9]+)", &user_controller.UserController{}, "get:GetUserInfo")
+
+	//获取某用户申请历史记录
+	beego.Router("/v1/user/history_apply/:wx_uid([0-9]+)", &user_controller.UserController{}, "get:GetAgentDetailByWxUid")
+
+	//申请代理
+	beego.Router("/v1/user/agent_apply", &user_controller.UserController{}, "post:AgentApplication")
+	//获取我的代理
+	beego.Router("/v1/user/my_agent", &user_controller.UserController{}, "get:GetMyAgentList")
+	//获取代理申请详细信息
+	beego.Router("/v1/user/my_agent/:id", &user_controller.UserController{}, "get:GetAgentDetail")
+
+	//审核代理申请记录
+	beego.Router("/v1/user/com_agent/:id", &user_controller.UserController{}, "get:ComAgentApplication")
+
 }