You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package models
import ( "github.com/ouxuanserver/osmanthuswine/src/core" "hudongzhuanjia/utils/define" "time" )
const ShakeRedEnvelopeRuleTableName = TableNamePrefix + "shake_red_envelope_rule"
//摇红包活动规则
type ShakeRedEnvelopeRule struct { Id int64 `json:"id" xorm:"not null pk autoincr INT(11)"` IsDelete bool `json:"-" xorm:"not null default(0) comment('是否删除')"` CreatedAt time.Time `json:"-" xorm:"not null created comment('创建时间')"` UpdatedAt time.Time `json:"-" xorm:"not null default 'CURRENT_TIMESTAMP' updated comment('更新时间')"`
ShakeRedEnvelopeActivityId int64 `json:"shake_red_envelope_activity_id" xorm:"not null comment('主活动id')" description:"主活动的id"` AreaId int64 `json:"area_id" xorm:"not null comment('地区id')" description:"地区id"` Model string `json:"model" description:"[普通红包,随机红包,阶梯红包]"` RedEnvelopeNum int `json:"red_envelope_num" xorm:"not null comment('红包个数')" description:"红包个数"` RandSum float64 `json:"rand_sum" xorm:"decimal not null comment('红包总金额')"` Single float64 `json:"single" description:"单个金额" xorm:"not null comment('单个金额')"` Probability float64 `json:"probability" description:"概率[0-100)" xorm:"not null comment('概率')"` Des string `json:"des" xorm:"not null default('根据对应得概率获得红包') comment('规则描述')"` ShakeRedEnvelopeStatus string `json:"shake_red_envelope_status" xorm:"not null default('未开始') comment('未开始|进行中|已结束')"` ShakeRedEnvelopeRuleLadders []*ShakeRedEnvelopeRuleLadder `json:"shake_red_envelope_rule_ladders" xorm:"-" description:"阶梯红包"` }
func (t *ShakeRedEnvelopeRule) TableName() string { return ShakeRedEnvelopeRuleTableName }
func (t *ShakeRedEnvelopeRule) UpdateStatus(id int64, status string) (int64, error) { t.ShakeRedEnvelopeStatus = status t.UpdatedAt = time.Now() return core.GetXormAuto().Where("is_delete=0 and id=?", id). Cols("shake_red_envelope_status", "updated_at").Update(t) }
func (t *ShakeRedEnvelopeRule) UpdateToStatusBySids(sids []int64, before, after string) (int64, error) { t.ShakeRedEnvelopeStatus = after t.UpdatedAt = time.Now() return core.GetXormAuto().Where("is_delete=0 and shake_red_envelope_status=? ", before). In("shake_red_envelope_activity_id", sids).Cols("shake_red_envelope_status", "updated_at"). Update(t) }
func (t *ShakeRedEnvelopeRule) GetCurrent(aid int64) (bool, error) { return core.GetXormAuto().Table(t).Alias("r"). Join("LEFT", new(ShakeRedEnvelopeActivity).Alias("a"), "a.id=r.shake_red_envelope_activity_id and a.is_delete=0"). Where("r.is_delete=0 and (r.shake_red_envelope_status=? or r.shake_red_envelope_status=?) and a.activity_id=?", define.StatusReady, define.StatusRunning, aid).Get(t) }
func UpdateSRERuleStatusBySREActivityIds(ids []int64) (int64, error) { return core.GetXormAuto().Where("is_delete=0").In("shake_red_envelope_activity_id", ids). Update(&ShakeRedEnvelopeRule{ShakeRedEnvelopeStatus: define.StatusNotBegin}) }
|