func (c *ContentController) Post() { openid := getContentCookie(c) op := c.Input().Get("op") beego.Debug("post op :---------------", op) switch op { case "help": id_s := c.Input().Get("id") if len(openid) != 0 && len(id_s) != 0 { post, err := models.GetOnePost(id_s) if err != nil { beego.Error(err) } _, err = models.AddPosthelp(post.Id, openid, 1) if err != nil { beego.Error(err) } else { if post.Label == 1 { err = models.AddWxUserMoney(post.OpenId, 1) if err != nil { beego.Error(err) } else { _, err = models.AddUserMoneyRecord(post.OpenId, MONEY_BELIKE_SUM, MONEY_BELIKE) } } url := "/content?op=con&id=" + id_s c.Redirect(url, 302) return } } c.TplName = "content.html" break } c.TplName = "content.html" }
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 *AdminUpUserMoneyController) Post() { id := c.Input().Get("id") op := c.Input().Get("op") beego.Debug("op :", op) switch op { case "up": beego.Debug("op ok") if len(id) != 0 { user, err := models.GetOneWxUserInfoId(id) if err != nil { beego.Error(err) } else { moneytype := c.Input().Get("moneytype") if len(moneytype) != 0 { addmoney := int64(0) if moneytype == "1" { addmoney = MONEY_SUBSCRIBE_SUM } else if moneytype == "2" { addmoney = MONEY_EXAMINE_SUM } else if moneytype == "3" { addmoney = MONEY_BELIKE_SUM } err = models.AddWxUserMoney(user.OpenId, addmoney) moneytype_i, err := strconv.ParseInt(moneytype, 10, 64) if err != nil { beego.Debug("err :", err) } _, err = models.AddUserMoneyRecord(user.OpenId, addmoney, moneytype_i) if err != nil { beego.Error(err) } } } } c.Redirect("/admin/wxuserlist", 302) return } c.TplName = "adminupusermoney.html" }