Browse Source

cancel take cash auto

abiao 5 years ago
parent
commit
529eec6a5b

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

@@ -160,13 +160,14 @@ func (self *PermitController) XcxAuthorize() {
 	// beego.BeeLogger.Warn("XcxAuthorize wxUser before save() Nickname:%s, Sex:%s, City:%s, Province:%s, Country:%s ", wxUser.Nickname, wxUser.Sex, wxUser.City, wxUser.Province, wxUser.Country)
 	wxUser.Save()
 	beego.BeeLogger.Warn("XcxAuthorize wxUser after save() Nickname:%s, Sex:%s, City:%s, Province:%s, Country:%s ", wxUser.Nickname, wxUser.Sex, wxUser.City, wxUser.Province, wxUser.Country)
-	wxUser.UploadHead(info.UserInfo.AvatarUrl)
 
 	if wxUser != nil {
 		self.SetSession(apps.SessionWxUserKey, wxUser.Id)
 	}
 	//赠送积分
 	if first {
+		go wxUser.UploadHead(info.UserInfo.AvatarUrl)
+		go user.XcxPermitUploadHead(info.UserInfo.AvatarUrl)
 		go helpers.SendCent(wxUser.Id, inviteId)
 	}
 	// 如果微信用户已绑定手机,则找出userId,并且赋值给session[userId]

+ 20 - 0
go/gopath/src/fohow.com/apps/models/user_model/user.go

@@ -233,6 +233,26 @@ func (self *User) CopyWxUserHead(imgName string) string {
 	}
 }
 
+func (self *User) XcxPermitUploadHead(httpPath string) string {
+	if httpPath == "" {
+		return ""
+	}
+	imgName := fmt.Sprintf("%s.jpg", tool.Get8Uuid())
+	imgPath := fmt.Sprintf("%s/%s", UserHeadOssStorePath, imgName)
+	err := ali_oss.PutObjectWithHttpPath(beego.AppConfig.String("AliOssEndPoint"),
+		beego.AppConfig.String("AliOssAccessId"),
+		beego.AppConfig.String("AliOssAccessSecret"),
+		beego.AppConfig.String("AliOssBucket"), imgPath, httpPath)
+	if err == nil {
+		self.Head = imgPath
+		self.UpdateField("Head")
+		return imgPath
+	} else {
+		beego.BeeLogger.Error("Upload user head error: %s, httpPath: %s, imgPath: %s", err, httpPath, imgPath)
+		return ""
+	}
+}
+
 //名称隐藏第二个字,用*代替(仅试用中文)
 func (self *User) GetNickNameWithStar() string {
 	return tool.ReplaceNameWithStar(self.Nickname)