func (c *WxUserListController) Post() {
	op := c.Input().Get("op")
	if op == "del" {
		openid := c.Input().Get("openid")
		if len(openid) != 0 {
			user, err := models.GetOneWxUserInfo(openid)
			if err == nil {
				err = models.DeleteWxUser(user.Id)
				if err != nil {
					beego.Error(err)
				} else {
					err = models.DeleteUserMoneyRecord(user.OpenId)
					if err != nil {
						beego.Error(err)
					}
				}
			} else {
				beego.Error(err)
			}

		}
		url := "/admin/wxuserlist"
		c.Redirect(url, 302)
		return
	}
	c.TplName = "adminwxuserlist.html"
}
func (c *AdminUpWxuserInfoController) Post() {
	openid := c.Input().Get("openid")
	op := c.Input().Get("op")
	if op == "up" {
		subscribe := c.Input().Get("subscribe")
		if len(subscribe) != 0 {
			err := models.UpWxUserSubscribe(openid, subscribe)
			if err != nil {
				beego.Error(err)
			}
		}
		url := "/admin/wxuserlist"
		c.Redirect(url, 302)
		return
	}
	c.Data["IsOpenid"] = false
	if len(openid) != 0 {
		user, err := models.GetOneWxUserInfo(openid)
		if err == nil {
			c.Data["IsOpenid"] = true
			c.Data["User"] = user
		}

	}
	c.TplName = "adminupwxuserinfo.html"
}
Esempio n. 3
0
func (c *UplodeController) Post() {
	image_name := ""
	title := c.Input().Get("title")
	info := c.Input().Get("info")
	city := c.Input().Get("city")
	beego.Debug("city", city)
	if len(title) != 0 && len(info) != 0 {
		// 获取附件
		_, fh, err := c.GetFile("image")
		if err != nil {
			beego.Error(err)
		}
		var attachment string
		if fh != nil {
			// 保存附件
			attachment = fh.Filename
			t := time.Now().Unix()
			str2 := fmt.Sprintf("%d", t)
			s := []string{attachment, str2}
			h := md5.New()
			h.Write([]byte(strings.Join(s, ""))) // 需要加密的字符串
			image_name = hex.EncodeToString(h.Sum(nil))
			beego.Info(image_name) // 输出加密结果
			err = c.SaveToFile("image", path.Join("imagehosting", image_name))
			if err != nil {
				beego.Error(err)
				image_name = ""
			}
		}
		if err != nil {
			beego.Error(err)
		}
	} else {
		c.Redirect("/uplode", 302)
	}
	if len(title) != 0 && len(info) != 0 {
		openid := getUplodeCookie(c)
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		}
		beego.Debug("----------AddPostLabelWx--------")
		beego.Debug(openid)
		beego.Debug(wxuser)
		err = models.AddPostLabelWx(title, info, 1, image_name, openid, wxuser.NickeName, wxuser.Sex, wxuser.HeadImgurl, city)
		if err != nil {
			beego.Error(err)
		}
		beego.Debug("inset ok")
		c.Redirect("/mymessage", 302)
	}
}
Esempio n. 4
0
func getWXListUser(c *WcListController) {
	isUser := false
	openid := c.Ctx.GetCookie(COOKIE_WX_OPENID)
	beego.Debug(openid)
	if len(openid) != 0 {
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		} else {
			isUser = true
			c.Data["WxUser"] = wxuser
		}
	}
	c.Data["isUser"] = isUser
}
Esempio n. 5
0
func getWaimaiListCookie(c *WaimaiListController) string {
	isUser := false
	openid := c.Ctx.GetCookie(COOKIE_WX_OPENID)
	if len(openid) != 0 {
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		} else {
			isUser = true
			c.Data["WxUser"] = wxuser
		}
	}
	c.Data["isUser"] = isUser
	return openid
}
Esempio n. 6
0
func getULCookie(c *UpdateLogController) string {
	isUser := false
	openid := c.Ctx.GetCookie(COOKIE_WX_OPENID)
	beego.Debug(openid)
	if len(openid) != 0 {
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		} else {
			isUser = true
			beego.Debug(wxuser)
			c.Data["WxUser"] = wxuser
		}
	}
	c.Data["isUser"] = isUser
	return openid
}
Esempio n. 7
0
func getFeedbackCookie(c *FeedbackController) string {
	isUser := false
	openid := c.Ctx.GetCookie("wx_openid")
	beego.Debug("------------openid--------")
	beego.Debug(openid)
	if len(openid) != 0 {
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		} else {
			isUser = true
			beego.Debug("--------------wxuser----------")
			beego.Debug(wxuser)
			c.Data["WxUser"] = wxuser
		}
	}
	c.Data["isUser"] = isUser
	return openid
}
Esempio n. 8
0
func (c *FeedbackController) Get() {
	openid := getFeedbackCookie(c)
	c.TplName = "feedback.html"

	info := c.Input().Get("info")
	if len(info) != 0 {
		beego.Debug("------------AddFeedback--------")
		beego.Debug(openid)
		wxuser, err := models.GetOneWxUserInfo(openid)
		if err != nil {
			beego.Error(err)
		}
		err = models.AddFeedback(info, openid, wxuser.NickeName, wxuser.Sex, wxuser.HeadImgurl)
		if err != nil {
			beego.Error(err)
		}
		c.Redirect("/", 302)
	}
}
Esempio n. 9
0
func (c *AdminExchangeController) Get() {
	bool, username := chackAccount(c.Ctx)
	if bool {
		c.Data["isUser"] = bool
		c.Data["User"] = username
	} else {
		c.Redirect("/admin", 302)
		return
	}
	op := c.Input().Get("op")
	switch op {
	case "state":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.UpdateUorderState(id, 1)
		if err != nil {
			beego.Debug(err)
		} else {
			uoder, err := models.GetOneUorder(id)

			if err != nil {
				beego.Error(err)
			} else {
				com, err := models.GetOneCommodity1(uoder.CommodityId)
				if err != nil {
					beego.Error(err)
				} else {
					err = models.ConsumeWxUserMoney(uoder.OpenId, com.Money)
					if err != nil {
						beego.Error(err)
					} else {
						models.AddUserMoneyRecord(uoder.OpenId, com.Money, MONEY_EXCHANGE)
						if err != nil {
							beego.Error(err)
						} else {
						}
					}
				}
			}
		}
		c.Redirect("/admin/exchange", 302)
		return
	case "state1":
		id := c.Input().Get("id")
		if len(id) == 0 {
			break
		}
		err := models.UpdateUorderState(id, 0)
		if err != nil {
			beego.Debug(err)
		} else {

		}
		c.Redirect("/admin/exchange", 302)
		return
	}

	uorders, err := models.GetAllUorders()
	if err != nil {
		beego.Error(err)
	}
	var showOrders []models.ShowOrder
	for i := 0; i < len(uorders); i++ {
		com, err := models.GetOneCommodity1(uorders[i].CommodityId)
		if err != nil {
			beego.Error(err)
		} else {
			obj := models.ShowOrder{Id: uorders[i].Id, OpenId: uorders[i].OpenId, CommodityId: uorders[i].CommodityId,
				State: uorders[i].State, CreateTime: uorders[i].CreateTime, Time: uorders[i].Time,
				ExchangeTime: uorders[i].ExchangeTime, Time1: uorders[i].Time1, Commodity: com}
			user, err := models.GetOneWxUserInfo(uorders[i].OpenId)
			if err != nil {
				beego.Debug(err)
			} else {
				obj.NickeName = user.NickeName
				obj.HeadImgurl = user.HeadImgurl
			}
			showOrders = append(showOrders, obj)
		}

	}
	// beego.Debug("ShowOrders :", showOrders)
	c.Data["ShowOrders"] = showOrders
	c.TplName = "adminexchange.html"
}