Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

abiao лет назад: 4
Родитель
Сommit
253bcae9fd

+ 2 - 1
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/generate_controller.go

@@ -173,7 +173,8 @@ func (self *RailsadminController) GenerateXcxQrcode() {
 		wxUser.Save()
 		qrcodeUrl = self.GetFullImgUrl(uploadPath)
 	}
-
+	//消除user,wxuser缓存
+	go wxUser.CleanCache()
 	self.Data["json"] = &Ret{QrcodeUrl: qrcodeUrl}
 	self.ServeJSON()
 }

+ 1 - 6
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/intro_user_controller.go

@@ -1,10 +1,8 @@
 package railsadmin_controller
 
 import (
-	"fmt"
 	"fohow.com/apps"
 	"fohow.com/apps/models/user_model"
-	"fohow.com/cache"
 	"github.com/astaxie/beego"
 	"strconv"
 	"time"
@@ -33,9 +31,6 @@ func (self *RailsadminController) UpdateIntroUser() {
 	inviteList := user_model.GetWxUsersByInviteIdAll(wxUser.Id, false)
 	go user_model.UpdateClass(inviteList, wxUser.Id, wxUser.IntroUserId)
 	//消除user,wxuser缓存
-	userKey := fmt.Sprintf("user.GetByUid[%d]", wxUser.UserId)
-	wxUserKey := cache.GetKey(cache.GetWxUserById, wxUser.Id)
-	cache.Cache.Delete(userKey)
-	cache.Cache.Delete(wxUserKey)
+	go wxUser.CleanCache()
 	self.ServeJSON()
 }

+ 1 - 5
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/update_shop_application.go

@@ -7,7 +7,6 @@ import (
 	"fohow.com/apps/models/balance_model"
 	"fohow.com/apps/models/sys_config"
 	"fohow.com/apps/models/user_model"
-	"fohow.com/cache"
 	"github.com/astaxie/beego"
 	"strconv"
 	"time"
@@ -49,10 +48,7 @@ func (self *RailsadminController) UpdateShopApplication() {
 	//helpers.ShopOrderPromotion(shopApplication.Id, wxUser.Id, wxUser.Depart)
 	helpers.CreateShopApplyOrder(shopApplication.Id)
 	//消除user,wxuser缓存
-	userKey := fmt.Sprintf("user.GetByUid[%d]", wxUser.UserId)
-	wxUserKey := cache.GetKey(cache.GetWxUserById, wxUser.Id)
-	cache.Cache.Delete(userKey)
-	cache.Cache.Delete(wxUserKey)
+	go wxUser.CleanCache()
 	self.ServeJSON()
 }
 

+ 1 - 4
go/gopath/src/fohow.com/apps/controllers/user_controller/binding_controller.go

@@ -135,10 +135,7 @@ func (self *UserController) BindingTelNew() {
 			self.SetSession(apps.SessionUserKey, user.Id)
 		}
 		//消除user,wxuser缓存
-		userKey := fmt.Sprintf("user.GetByUid[%d]", wxUser.UserId)
-		wxUserKey := cache.GetKey(cache.GetWxUserById, wxUser.Id)
-		cache.Cache.Delete(userKey)
-		cache.Cache.Delete(wxUserKey)
+		go wxUser.CleanCache()
 	}
 	self.Data["json"] = user
 	self.ServeJSON()

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

@@ -540,10 +540,7 @@ func (self *UserController) SysUserBind() {
 	}
 
 	//清掉wxuser缓存
-	userKey := fmt.Sprintf("user.GetByUid[%d]", wxUser.UserId)
-	wxUserKey := cache.GetKey(cache.GetWxUserById, wxUser.Id)
-	cache.Cache.Delete(userKey)
-	cache.Cache.Delete(wxUserKey)
+	go wxUser.CleanCache()
 	type Ret struct {
 		Result bool `json:"result"`
 	}

+ 1 - 6
go/gopath/src/fohow.com/apps/helpers/intro_helper.go

@@ -1,9 +1,7 @@
 package helpers
 
 import (
-	"fmt"
 	"fohow.com/apps/models/user_model"
-	"fohow.com/cache"
 	"time"
 )
 
@@ -22,8 +20,5 @@ func UpdateIntroUser(wxUser *user_model.WxUser) {
 	inviteList := user_model.GetWxUsersByInviteIdAll(wxUser.Id, false)
 	go user_model.UpdateClass(inviteList, wxUser.Id, wxUser.IntroUserId)
 	//消除user,wxuser缓存
-	userKey := fmt.Sprintf("user.GetByUid[%d]", wxUser.UserId)
-	wxUserKey := cache.GetKey(cache.GetWxUserById, wxUser.Id)
-	cache.Cache.Delete(userKey)
-	cache.Cache.Delete(wxUserKey)
+	go wxUser.CleanCache()
 }

+ 10 - 0
go/gopath/src/fohow.com/apps/models/user_model/wx_user.go

@@ -387,6 +387,16 @@ func (self *WxUser) SetInviter(ivId int64) {
 	}
 }
 
+// 清空微信会员缓存
+func (self *WxUser) CleanCache() {
+	//消除user,wxuser缓存
+	userKey := fmt.Sprintf("user.GetByUid[%d]", self.UserId)
+	wxUserKey := cache.GetKey(cache.GetWxUserById, self.Id)
+	beego.BeeLogger.Warn("CleanCache--wxuserkey(%s)", wxUserKey)
+	cache.Cache.Delete(userKey)
+	cache.Cache.Delete(wxUserKey)
+}
+
 func GetCountByWxUserInviter(id int64) int64 {
 	o := orm.NewOrm()
 	i, err := o.QueryTable(new(WxUser)).Filter("invite_id", id).Count()