|
@@ -69,7 +69,7 @@ func (this *WechatController) Notify() {
|
|
go subscribe(openId)
|
|
go subscribe(openId)
|
|
case "unsubscribe":
|
|
case "unsubscribe":
|
|
fmt.Println("取消关注")
|
|
fmt.Println("取消关注")
|
|
- go models.UserSubscribe(0, openId)
|
|
|
|
|
|
+ go unsubscribe(openId)
|
|
case "CLICK":
|
|
case "CLICK":
|
|
returnResult = xmlTpl
|
|
returnResult = xmlTpl
|
|
default:
|
|
default:
|
|
@@ -148,6 +148,49 @@ func subscribe(openId string) {
|
|
fmt.Println("关注后,添加user_record信息失败,err:" + err.Error())
|
|
fmt.Println("关注后,添加user_record信息失败,err:" + err.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 检测用户是否绑定小程序,如果绑定修改用户状态
|
|
|
|
+ user, err := models.GetUserByUnionId(newUserRecord.UnionId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("修改绑定用户状态异常,ERR:", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if user != nil {
|
|
|
|
+ user.IsRegistered = true
|
|
|
|
+ user.ModifyTime = time.Now()
|
|
|
|
+ err = user.Update([]string{"is_registered", "modify_time"})
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("关注后,修改绑定用户状态异常,ERR:", err)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// unsubscribe 取消关注后的处理逻辑
|
|
|
|
+func unsubscribe(openId string) {
|
|
|
|
+ userRecord, err := models.GetUserRecordByOpenId(openId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ userRecord.Subscribe = 0
|
|
|
|
+ err = userRecord.Update([]string{"subscribe"})
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if userRecord.UnionId != "" {
|
|
|
|
+ user, err := models.GetUserByUnionId(userRecord.UnionId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if user != nil {
|
|
|
|
+ user.IsSubscribed = false
|
|
|
|
+ user.ModifyTime = time.Now()
|
|
|
|
+ err = user.Update([]string{"is_subscribed", "modify_time"})
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// @Title 微信登录
|
|
// @Title 微信登录
|