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.
37 lines
868 B
37 lines
868 B
package dao |
|
|
|
import ( |
|
"go-common/app/service/openplatform/ticket-item/model" |
|
"time" |
|
) |
|
|
|
const ( |
|
// StatusWaitShelf 待上架 |
|
StatusWaitShelf = 1 |
|
// StatusUpShelf 已上架 |
|
StatusUpShelf = 2 |
|
) |
|
|
|
// HasPromotion 检查场次id或者票价id下是否有未开售,售卖中的待上架和已上架拼团 checkType 1-场次id 2-票价id |
|
func (d *Dao) HasPromotion(ids []int64, checkType int32) bool { |
|
if ids == nil { |
|
return false |
|
} |
|
|
|
status := []int{StatusWaitShelf, StatusUpShelf} |
|
whereStr := "(begin_time > ? OR (begin_time <= ? AND end_time > ?)) AND status IN (?) AND " |
|
|
|
if checkType == 1 { |
|
// screen |
|
whereStr += "extra IN (?)" |
|
} else { |
|
// sku |
|
whereStr += "sku_id IN (?)" |
|
} |
|
|
|
var count int64 |
|
currTime := time.Now().Unix() |
|
d.db.Model(&model.Promotion{}).Where(whereStr, currTime, currTime, currTime, status, ids).Count(&count) |
|
|
|
return count > 0 |
|
}
|
|
|