abiao пре 4 година
родитељ
комит
5f233eb9e5

+ 8 - 1
go/gopath/src/fohow.com/apps/controllers/user_controller/agent_apply_controller.go

@@ -74,7 +74,14 @@ func (self *UserController) ComAgentApplication() {
 	record.Status = true
 	record.ComTime = time.Now().Unix()
 	record.ComUser = introUserId
-	record.Save()
+	err := record.Save()
+	if err == nil {
+		//申请会员升级代理
+		applyuser := user_model.GetWxUserById(record.WxUId, false)
+		applyuser.Rank = user_model.COPARTNER_STATE_YES
+		applyuser.ShowInviteMode = 1
+		applyuser.Save()
+	}
 
 	type Ret struct {
 		Result bool `json:"result"`

+ 14 - 4
go/gopath/src/fohow.com/apps/models/user_model/invite.go

@@ -214,7 +214,7 @@ func GetMyIntroListByInviteId(inviteId, page, perPage int64, useCache bool) (lis
 			wx_users a
 			LEFT JOIN ( SELECT sum( count ) AS total, sum( amount ) AS amount, benefit_wx_uid AS wx_uid from invite_benefit_orders WHERE 1 group  by benefit_wx_uid ) b ON a.id = b.wx_uid 
 		WHERE
-			a.invite_id=%d
+			a.intro_user_id=%d
 		ORDER BY
 			a.sale_group DESC
 			LIMIT %d,%d;
@@ -251,7 +251,7 @@ func GetMyIntroCountByInviteId(inviteId int64) int64 {
 	}
 	ret := &Ret{}
 	o := orm.NewOrm()
-	sql := fmt.Sprintf("select count(DISTINCT id) as count from wx_users where invite_id=%d;", inviteId)
+	sql := fmt.Sprintf("select count(DISTINCT id) as count from wx_users where intro_user_id=%d;", inviteId)
 	err := o.Raw(sql).QueryRow(ret)
 	if err != nil {
 		beego.BeeLogger.Error("GetMyIntroCountByInviteId, inviteId:%d, err=[%s]", inviteId, err)
@@ -395,7 +395,7 @@ func GetMyMonthIntroListByInviteId(inviteId int64, page, perPage int64, createTi
 			wx_users a
 			LEFT JOIN ( SELECT sum( count ) AS total, sum( amount ) AS amount, benefit_wx_uid AS wx_uid FROM invite_benefit_orders WHERE date_format(date_add(created_at, interval 8 HOUR), '%s')= ? GROUP BY benefit_wx_uid ) b ON a.id = b.wx_uid 
 		WHERE
-			 a.invite_id=%d 
+			 a.intro_user_id=%d 
 		ORDER BY
 			a.sale_group DESC
 			LIMIT %d,%d;
@@ -408,6 +408,16 @@ func GetMyMonthIntroListByInviteId(inviteId int64, page, perPage int64, createTi
 	}
 	for _, item := range list {
 		item.Head = GetFullImgUrl(item.Head)
+		//代理状态判断---普通会员(status=0),则显示 申请代理
+		if item.ShowInviteMode == 0 {
+			item.Status = 0
+			record := GetAgentApplyByWxUId(item.WxUId)
+			if record != nil {
+				item.Status = 1
+			}
+		} else {
+			item.Status = 2
+		}
 	}
 
 	cache.Cache.Put(k, list, 1*time.Minute)
@@ -421,7 +431,7 @@ func GetMyMonthIntroListCount(inviteId int64) int64 {
 	}
 	ret := &Ret{}
 	o := orm.NewOrm()
-	sql := fmt.Sprintf("select count(DISTINCT id) as count from wx_users where invite_id=%d  ;", inviteId)
+	sql := fmt.Sprintf("select count(DISTINCT id) as count from wx_users where intro_user_id=%d  ;", inviteId)
 	err := o.Raw(sql).QueryRow(ret)
 	if err != nil {
 		beego.BeeLogger.Error("GetMyMonthIntroListCount, inviteId:%d, err=[%s]", inviteId, err)