|
|
@@ -17,9 +17,10 @@ type Promotion struct {
|
|
|
Name string `orm:"column(name)" json:"name"` // varchar(64)
|
|
|
BeginTime time.Time `orm:"column(begin_time)" json:"-"`
|
|
|
EndTime time.Time `orm:"column(end_time)" json:"-"`
|
|
|
- IsEnable bool `orm:"column(is_enable)" json:"is_enable"` // int(11)
|
|
|
- IsFirst bool `orm:"column(is_first)" json:"is_first"` // int(11)
|
|
|
+ IsEnable bool `orm:"column(is_enable)" json:"-"` // int(11)
|
|
|
+ IsFirst bool `orm:"column(is_first)" json:"-"` // int(11)
|
|
|
IsMore bool `orm:"column(is_more)" json:"-"` // int(11)
|
|
|
+ Depart int64 `orm:"column(depart)" json:"-"` // int(11)
|
|
|
OrderType int64 `orm:"column(order_type)" json:"order_type"` // varchar(64)
|
|
|
MinTotal int64 `orm:"column(min_total)" json:"min_total"` // int(11)
|
|
|
MaxTotal int64 `orm:"column(max_total)" json:"-"` // datetime
|
|
|
@@ -53,7 +54,7 @@ func (self *Promotion) TableName() string {
|
|
|
return promotions_tablename
|
|
|
}
|
|
|
|
|
|
-func GetEffetivePromotions(queryDate time.Time, orderType int64, useCache bool) (list []*Promotion) {
|
|
|
+func GetEffetivePromotions(queryDate time.Time, orderType, depart int64, useCache bool) (list []*Promotion) {
|
|
|
k := fmt.Sprintf("promotion_model.GetEffetivePromotions(%s)", queryDate.Format("2006-01-02"))
|
|
|
if useCache {
|
|
|
if ret, ok := cache.Cache.Get(k).([]*Promotion); ok {
|
|
|
@@ -64,10 +65,10 @@ func GetEffetivePromotions(queryDate time.Time, orderType int64, useCache bool)
|
|
|
sql := `
|
|
|
select * from
|
|
|
promotions
|
|
|
- where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? and order_type = ? and is_enable = 1 ;
|
|
|
+ where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? and order_type = ? and ( depart = ? || depart=0 ) and is_enable = 1 ;
|
|
|
`
|
|
|
|
|
|
- _, err := orm.NewOrm().Raw(sql, queryDate.Format("2006-01-02 15:04:05"), queryDate.Format("2006-01-02 15:04:05"), orderType).QueryRows(&list)
|
|
|
+ _, err := orm.NewOrm().Raw(sql, queryDate.Format("2006-01-02 15:04:05"), queryDate.Format("2006-01-02 15:04:05"), orderType, depart).QueryRows(&list)
|
|
|
if err != nil {
|
|
|
beego.BeeLogger.Warn("promotion_model.GetEffetivePromotions(%s) err=%s", queryDate.Format("2006-01-02"), err)
|
|
|
return nil
|