瀏覽代碼

order details add commend

abiao 4 年之前
父節點
當前提交
312455020a

+ 11 - 0
go/gopath/src/fohow.com/apps/models/order_model/order_detail.go

@@ -35,6 +35,7 @@ type OrderDetail struct {
 	ColorName            string    `orm:"column(color_name)"                                json:"color_name"`     // varchar(255)
 	Cover                string    `orm:"-"     json:"cover"`                                                      // decimal(10,2)
 	OriginalPrice        float64   `orm:"-"     json:"original_price"`                                             // decimal(10,2)
+	Commend              bool      `orm:"column(commend)"                                json:"commend"`
 	UnitRoboBalancePrice int64     `orm:"column(unit_robo_balance_price)"                     json:"unit_robo_balance_price"`
 	Attrs                string    `orm:"-"     json:"attrs"`      // decimal(10,2)
 	Depart               int64     `orm:"column(depart)" json:"-"` // datetime
@@ -162,3 +163,13 @@ func GetDetailsByOrderIdAndPid(oId string, pId int64) (orderDetail *OrderDetail)
 	}
 	return orderDetail
 }
+
+//根据订单明细ID获取明细
+func GetOrderDetailById(id int64) *OrderDetail {
+	detail := &OrderDetail{Id: id}
+	if err := orm.NewOrm().Read(detail); err != nil {
+		// beego.BeeLogger.Error("get name product cat by id err=[%s][", err)
+		return nil
+	}
+	return detail
+}

+ 55 - 0
go/gopath/src/fohow.com/apps/models/product_model/product_commend.go

@@ -0,0 +1,55 @@
+package product_model
+
+import (
+	// "time"
+
+	"github.com/astaxie/beego"
+	"github.com/astaxie/beego/orm"
+	"time"
+)
+
+const (
+	product_commends_tablename = "product_commends"
+)
+
+type ProductCommend struct {
+	Id        int64     `orm:"column(id);pk"           json:"id"`                            // int(11)
+	NickName  string    `orm:"-"                       json:"nick_name"`                     // varchar(20)
+	Head      string    `orm:"-"                      json:"head"`                           // varchar(20)
+	WxUserId  int64     `orm:"column(wx_user_id);null" json:"-"`                             // int(11)
+	ProductId int64     `orm:"column(product_id);null" json:"-"`                             // int(11)
+	Detail    string    `orm:"column(detail);"         json:"detail"`                        // varchar(20)
+	IsEnable  bool      `orm:"column(is_enable);null"  json:"-"`                             // tinyint(1)
+	IsTop     bool      `orm:"column(is_top);null"     json:"-"`                             // tinyint(1)
+	Score     int64     `orm:"column(score);null"      json:"score"`                         // int(11)
+	Recommend int64     `orm:"column(recommend);null" json:"-"`                              // int(11)
+	CreatedAt time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"` // datetime
+	UpdatedAt time.Time `orm:"column(updated_at);null;auto_now;type(datetime)"     json:"-"` // datetime
+}
+
+func (self *ProductCommend) TableName() string {
+	return product_commends_tablename
+}
+
+func GetProductCommendById(id int64) *ProductCommend {
+	cat := &ProductCommend{Id: id}
+	if err := orm.NewOrm().Read(cat); err != nil {
+		// beego.BeeLogger.Error("get name product cat by id err=[%s][", err)
+		return nil
+	}
+	return cat
+}
+
+//获取商品评论列表
+func GetProductCommends(productId int64, status bool, page, perPage int) (commends []*ProductCommend) {
+	commend := new(ProductCommend)
+	qs := orm.NewOrm().QueryTable(commend)
+	qs = qs.Filter("product_id", productId).Filter("is_enable", status)
+
+	if _, err := qs.OrderBy("-is_top", "-recommend", "-created_at").
+		Limit(perPage, (page-1)*perPage).All(&commends); err != nil {
+		beego.BeeLogger.Debug("get productCommeds[%d] commend list err=[%s]", productId, err)
+		return nil
+	}
+	return commends
+}