瀏覽代碼

add balance ,shop promotion

abiao 4 年之前
父節點
當前提交
46bf9fccad

+ 3 - 3
go/gopath/src/fohow.com/apps/models/promotion_model/order_promotion.go

@@ -63,9 +63,9 @@ func GetEffetivePromotions(queryDate time.Time, orderType, depart int64, useCach
 	}
 
 	sql := `
-		select * from
-		promotions
-		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 ;
+		select a.* from
+		promotions a left join depart_records_promotions b on a.id=b.promotion_id
+		where DATE_ADD(a.begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(a.end_time,INTERVAL 8 HOUR) >= ? and a.order_type = ? and b.depart_record_id=?  and a.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, depart).QueryRows(&list)

+ 6 - 6
go/gopath/src/fohow.com/apps/models/promotion_model/promotion_model.go

@@ -78,9 +78,9 @@ func GetBalanceEffetivePromotions(queryDate time.Time, depart int64, useCache bo
 	}
 
 	sql := `
-		select * from
-		balance_promotions
-		where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? and (depart = ? || depart=0) and is_enable = 1 ;
+		select a.* from
+		balance_promotions  a left join depart_records_balance_promotions b on a.id=b.balance_promotion_id
+		where DATE_ADD(a.begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(a.end_time,INTERVAL 8 HOUR) >= ? and b.depart_record_id = ? and a.is_enable = 1 ;
 		`
 
 	_, err := orm.NewOrm().Raw(sql, queryDate.Format("2006-01-02 15:04:05"), queryDate.Format("2006-01-02 15:04:05"), depart).QueryRows(&list)
@@ -102,9 +102,9 @@ func GetShopEffetivePromotions(queryDate time.Time, depart int64, useCache bool)
 	}
 
 	sql := `
-		select * from
-		shop_promotions
-		where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? and  (depart = ? || depart=0) and is_enable = 1 ;
+		select a.* from
+		shop_promotions a left join depart_records_shop_promotions b on a.id=b.shop_promotion_id
+		where DATE_ADD(a.begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(a.end_time,INTERVAL 8 HOUR) >= ? and b.depart_record_id = ?  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"), depart).QueryRows(&list)