Esempio n. 1
0
func (this *AccountController) Cash() {
	data := e.Data{Msg: "申请成功", Status: 1}
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	userId := r.FormValue("user")
	money, _ := strconv.ParseFloat(r.FormValue("cash"), 32)
	user := m.User{Id: userId}
	user = user.GetOneUserById()
	if user.RealName == "" { //无开户人姓名
		data.Status = 0
		data.Msg = "真实姓名为空,请先设置真实姓名"
	}
	if data.Status == 1 && user.ABalance < money {
		data.Status = 0
		data.Msg = "提取金额有误"
	}
	if data.Status == 1 {
		username := user.RealName
		bank := r.FormValue("bank")

		card := r.FormValue("card")
		address := r.FormValue("address")
		cash := m.Cash{Id: this.getCashId(userId), UserId: userId, UserName: username, Bank: bank, Card: card, Address: address, Money: money, BeginTime: time.Now(), Status: "申请"}
		cash.InsertCash()
		user.ABalance = user.ABalance - money
		user.UpdateABalance()
	}
	u.OutputJson(w, &data)
}
Esempio n. 2
0
func (this *UserController) Edit() {
	w := this.ResponseWriter
	r := this.Request
	data := e.TData{}

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("User.edit.introduction.tpl", "User.edit.tpl", "User.edit.avatar.tpl", "User.edit.baseinfo.tpl", "User.edit.skills.tpl", "User.edit.skill.tpl", "User.edit.introduction.tpl")

	r.ParseForm()
	userId := r.FormValue("id")
	user := m.User{Id: userId}

	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()

	flag := true
	if cookie.UserId == nil || userId != cookie.UserId.Value { //无登录cookie
		flag = false
	}
	if flag {
		user = user.GetOneUserById()
		data.CurrentUser = user
		data.Data = user
		data.Flag = flag
		t.Execute(w, &data)
	} else {
		Error{HTTP: this.HTTP}.Get()
	}

}
Esempio n. 3
0
func (this *UserController) Q() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	parId := r.FormValue("id")

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("UserDetail", "T.user.tpl", "Order.add.tpl")

	showuser := m.User{Id: parId}
	data := e.TData{}
	flag := false
	isCurrentUser := false
	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()
	// log.Println("获取cookie中的用户名")
	// username := u.GetCookieUserName(w, r)
	// if username != "" { //如果已经登录了
	// 	user = user.GetOneUserByName(username)
	// } else {

	// }

	log.Println(parId)
	if parId == "" {
		log.Println("url有错误")
	}
	showuser = showuser.GetOneUserById()
	loginuser := m.User{}
	userId := cookie.UserId //登录用户

	log.Println(showuser.RealName)
	if showuser.RealName != "" { //查到用户
		if userId != nil { //查到有登录用户
			loginuser.Id = userId.Value
			flag = true
			if showuser.Id == loginuser.Id { //已登录的用户浏览别人的资料
				isCurrentUser = true
			}
		}
		if !isCurrentUser { //别人浏览
			telph := u.SubString(showuser.UserName, 0, len(showuser.UserName)-4) + "****"
			idCard := u.SubString(showuser.IDCard, 0, len(showuser.IDCard)-4) + "****"
			showuser.UserName = telph
			showuser.IDCard = idCard
		}

		data = e.TData{Data: showuser, CurrentUser: loginuser, Flag: flag}

		t.Execute(w, &data)
	}

}
Esempio n. 4
0
func (this *AccountController) Info() {
	w := this.ResponseWriter
	r := this.Request
	r.ParseForm()
	parId := r.FormValue("id")

	common := CommonController{HTTP: this.HTTP}

	t := common.getTpl("account", "Account.info.tpl")

	showuser := m.User{Id: parId}
	data := e.TData{}
	flag := false

	cookie := u.Cookie{HTTP: this.HTTP}
	cookie = cookie.GetCookie()
	// log.Println("获取cookie中的用户名")
	// username := u.GetCookieUserName(w, r)
	// if username != "" { //如果已经登录了
	// 	user = user.GetOneUserByName(username)
	// } else {

	// }

	log.Println(parId)
	if parId == "" {
		log.Println("url有错误")
	}
	showuser = showuser.GetOneUserById()
	loginuser := m.User{}
	log.Println(showuser.ABalance, showuser.FBalance)
	userId := cookie.UserId //登录用户

	log.Println(showuser.RealName)
	if showuser.RealName != "" { //查到用户
		if userId != nil { //查到有登录用户
			loginuser.Id = userId.Value
			flag = true
			if showuser.Id == loginuser.Id { //自己浏览自己
				data = e.TData{Data: showuser, CurrentUser: loginuser, Flag: flag}
				t.Execute(w, &data)
			}
		}

	}
}