package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type CygxActivityVivoPointsSet struct {
	PointSetId   int       `orm:"column(point_set_id);pk";comment:"主键id"`
	ActivityId   int       `comment:"活动ID"`
	PointsObject string    `comment:"扣点设置方式 1:同报名参会时的扣点数、2：输入其余点数"`
	PointsNum    float64   `comment:"扣点数量"`
	GoodsMoney   float64   `comment:"商品总价"`
	Source       string    `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
	CreateTime   time.Time `comment:"创建时间"`
	ModifyTime   time.Time `comment:"更新时间"`
}

// 根据活动ID判断音视频是否设置了扣点
func GetCygxActivityVivoPointsSetCountByActivityId(activityId int) (count int, err error) {
	o := orm.NewOrm()
	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_vivo_points_set  WHERE activity_id =?  `
	err = o.Raw(sqlCount, activityId).QueryRow(&count)
	return
}

func GetCygxActivityVivoPointsSetByActivityId(activityId int) (item *CygxActivityVivoPointsSet, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM cygx_activity_vivo_points_set WHERE activity_id = ?  `
	err = o.Raw(sql, activityId).QueryRow(&item)
	return
}
