package wx_user

//权益正式客户到期前30天弹窗消息提醒
import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type WxUserEndDateLog struct {
	EndDateId   int `orm:"column(end_date_id);pk"`
	UserId      int
	Mobile      string    `description:"手机号"`
	Email       string    `description:"邮箱"`
	CompanyId   int       `description:"公司id"`
	CompanyName string    `description:"公司名称"`
	ModifyTime  time.Time `description:"修改时间"`
	CreateTime  time.Time `description:"创建时间"`
	RealName    string    `description:"用户实际名称"`
	EndDate     string    `description:"结束时间"`
}

// 添加历史信息
func AddWxUserEndDateLog(item *WxUserEndDateLog) (lastId int64, err error) {
	o := orm.NewOrm()
	lastId, err = o.Insert(item)
	return
}

func GeWxUserEndDateLogCount(userId int, endDate string) (count int, err error) {
	o := orm.NewOrm()
	sql := ` SELECT COUNT(1) AS count FROM  wx_user_end_date_log WHERE user_id = ? AND end_date = ? `
	err = o.Raw(sql, userId, endDate).QueryRow(&count)
	return
}
