Преглед на файлове

add balance ,shop promotion

abiao преди 4 години
родител
ревизия
ecd121d4e3

+ 1 - 1
go/gopath/src/fohow.com/apps/helpers/promotion_helper.go

@@ -33,7 +33,7 @@ func SetOrderPromotion(orderId string, wxUid int64) {
 
 	queryDate := time.Now()
 	// 获取所有有效促销记录
-	effectivePromotions := promotion_model.GetEffetivePromotions(queryDate, order.OrderType, false)
+	effectivePromotions := promotion_model.GetEffetivePromotions(queryDate, order.OrderType, order.Depart, false)
 	for _, item := range effectivePromotions {
 		//beego.Warn("item_name%d", item.Name)
 

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

@@ -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

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

@@ -80,7 +80,7 @@ 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 = ? and is_enable = 1 ;
+		where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? 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"), depart).QueryRows(&list)
@@ -104,7 +104,7 @@ 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 = ? and is_enable = 1 ;
+		where DATE_ADD(begin_time,INTERVAL 8 HOUR) <= ? and DATE_ADD(end_time,INTERVAL 8 HOUR) >= ? 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"), depart).QueryRows(&list)