package models

import (
	"rdluck_tools/orm"
	"time"
)

type EdbinfoSendMsgRecord struct {
	Id         int `orm:"column(id);pk"`
	UserId     int
	TradeCode  string
	CreateTime time.Time
}

func AddEdbinfoSendMsgRecord(item *EdbinfoSendMsgRecord) (err error) {
	o := orm.NewOrm()
	o.Using("rddp")
	_, err = o.Insert(item)
	return err
}

func GetEdbinfoSendMsgCount(userId int, tradeCode string) (count int, err error) {
	o := orm.NewOrm()
	o.Using("rddp")
	sql := `SELECT COUNT(1) AS count FROM edbinfo_send_msg_record WHERE user_id=? AND trade_code=? AND create_time=DATE(NOW()) `
	err = o.Raw(sql, userId, tradeCode).QueryRow(&count)
	return
}
