You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB
Go

package model
import (
"joybuywork/internal/plugins/jsonm"
"joybuywork/internal/repository/mtype"
"joybuywork/internal/utils/verify"
"time"
)
func (s *RedeemMallItem) SetUpShow(val []string) {
s.UpShow, _ = jsonm.ToSliceString(val)
}
func (s *RedeemMallItem) GetUpShow() (val []string) {
_ = jsonm.StrUnmarshal(s.UpShow, &val)
return
}
func (s *RedeemMallItem) SetDownShow(val []string) {
s.DownShow, _ = jsonm.ToSliceString(val)
}
func (s *RedeemMallItem) GetDownShow() (val []string) {
_ = jsonm.StrUnmarshal(s.DownShow, &val)
return
}
func (s *RedeemMallItem) GetStatus() int32 {
if s.IsDel == mtype.Yes {
return mtype.RedeemMallItemStatusDel
}
if s.DownAt > 0 || (s.DownType == mtype.RedeemMallItemDownTypeCustom && s.DownCustom <= time.Now().Unix()) {
return mtype.RedeemMallItemStatusDown
}
if s.UpAt > time.Now().Unix() {
return mtype.RedeemMallItemStatusWait
}
return mtype.RedeemMallItemStatusUp
}
func (s *RedeemMallItem) IsShow() bool {
switch s.GetStatus() {
case mtype.RedeemMallItemStatusWait:
if verify.InArray[string](mtype.RedeemMallItemUpShowClient, s.GetUpShow()...) {
return true
}
return false
case mtype.RedeemMallItemStatusUp:
return true
default:
return false
}
}