示例#1
0
// @router /api/manage/weixin/message/getMessageList [post]
func (this *MessageController) GetMessageList() {
	this.CheckAvaliable("消息查看")
	lastID, _ := this.GetInt("lastID")
	size, _ := this.GetInt("size")
	if size == 0 {
		size = 25
	}
	cond := orm.NewCondition()

	if lastID > 0 {
		cond = cond.And("Id__lt", lastID)
	}

	var messageList []models.Message
	if _, err := models.Orm.QueryTable("message").SetCond(cond).OrderBy("-Id").Limit(size).All(&messageList); err == nil {
		var messageExList []models.MessageEx = make([]models.MessageEx, len(messageList))
		for i, v := range messageList {
			var user models.FollowUser
			user.UserId = v.UserId
			models.Orm.Read(&user, "UserId")
			messageExList[i] = models.MessageEx{Message: v, User: user}
			messageExList[i].CreateOnFmt = v.CreateOn.Format("2006-01-02 15:04:05")
		}
		this.Data["json"] = &messageExList
	} else {
		beego.Error(err.Error())
	}

	this.ServeJson()
}
// @router /weixin/user [get]
func (this *WeixinPageController) UserInfo() {
	this.TplNames = "weixin/userInfo.tpl"
	if userID := this.GetString("userID"); userID != "" {
		var user models.FollowUser
		user.UserId = userID
		if err := models.Orm.Read(&user, "UserId"); err != nil {
			log.Println(err.Error())
		} else {
			this.Data["User"] = &user
		}
	}
}
示例#3
0
// @router /api/manage/weixin/fix/getOrderBindedUser [post]
func (this *FixOrderController) GetOrderBindedUser() {
	this.CheckAvaliable("订单管理")
	var followUser models.FollowUser
	if orderNumber := this.GetString("orderNumber"); orderNumber != "" {
		var pair models.FixOrderPair
		pair.OrderNumber = orderNumber
		if err := models.Orm.Read(&pair, "OrderNumber"); err != nil {
			log.Println(err.Error())
		} else {
			followUser.UserId = pair.UserId
			if err := models.Orm.Read(&followUser, "UserId"); err != nil {
				log.Println(err.Error())
			} else {
				models.Orm.Delete(&pair)
			}
		}
	}
	this.Data["json"] = &followUser

	this.ServeJson()
}