func (c *AdminImportUserController) Get() { op := c.Input().Get("op") if op == "import" { beego.Debug("AdminImportUserController get import") openid := c.Input().Get("openid") errcode, token := getToken() if errcode == 0 && len(openid) != 0 { user, err := getWxUser(openid, token) if err == nil { if user.ErrCode == 0 { err = models.AddWxUserInfo(user) if err != nil { beego.Error(err) } else { err = models.AddWxUserMoney(user.OpenId, 4) if err != nil { beego.Error(err) } else { _, err = models.AddUserMoneyRecord(user.OpenId, MONEY_SUBSCRIBE_SUM, MONEY_SUBSCRIBE) } } } } } url := "/admin/importuser" c.Redirect(url, 302) return } wxusers, err := models.GetAllWxUsers() if err != nil { beego.Error("err :", err) } // var wxusermap map[string]int64 wxusermap := make(map[string]int64) for i := 0; i < len(wxusers); i++ { wxusermap[wxusers[i].OpenId] = wxusers[i].Id } errcode, token := getToken() beego.Debug("errcode :", errcode, "token :", token) if errcode == 0 { openids := getWxUserList(token, c) importUsers := make([]*ImportUser, len(openids)) for i := 0; i < len(openids); i++ { importUser := &ImportUser{OpenId: openids[i]} if _, ok := wxusermap[openids[i]]; ok { //存在 importUser.IsImport = true } // beego.Debug(" openids ", i, importUser) importUsers[i] = importUser } c.Data["ImportUsers"] = importUsers } c.TplName = "adminimportuser.html" }
func (c *WxUserListController) Get() { bool, username := chackAccount(c.Ctx) if bool { } else { c.Redirect("/admin", 302) return } c.Data["isUser"] = bool c.Data["User"] = username c.TplName = "adminwxuserlist.html" admins, err := models.GetAllWxUsers() if err != nil { beego.Error(err) } beego.Debug(admins) c.Data["WxUsers"] = admins }