瀏覽代碼

edit base details function

abiao 4 年之前
父節點
當前提交
e33e8686ae

+ 39 - 0
go/gopath/src/fohow.com/apps/controllers/product_controller/product_controller.go

@@ -72,6 +72,45 @@ func (self *ProductController) Latest() {
 		}
 		pd.DeliverStartTime = pd.DeliverStartAt.Unix()
 		pd.DeliverStopTime = pd.DeliverStopAt.Unix()
+		//店铺列表专区商品增加规格显示
+		if ptype == product_model.SHOP_SALE && product_model.GetProductAttrConfig(pd.RelateProductId) != nil {
+
+			list := product_model.GetProductConfigAttrsByPId(pd.RelateProductId)
+			for _, item := range list {
+
+				productKeyConfig := product_model.GetProductAttrKey(item.AttrKeyId)
+				if productKeyConfig != nil {
+					if item.SizeType == product_model.SIZE_TYPE_1 {
+						attrList := product_model.GetProductAttrsByKId(productKeyConfig.Id)
+						for _, attr := range attrList {
+							prodSize := product_model.GetProductByIdAndSizeId(pd.RelateProductId, attr.Id, true)
+							if prodSize != nil {
+								size := &product_model.ProductAttr{}
+								size.Id = attr.Id
+								//beego.BeeLogger.Warn("size_id --- %d", size.Id)
+								size.Name = attr.Name
+								productKeyConfig.ProductAttr = append(productKeyConfig.ProductAttr, size)
+							}
+						}
+						pd.Size = productKeyConfig
+					}
+					if item.SizeType == product_model.SIZE_TYPE_2 {
+						attrList := product_model.GetProductAttrsByKId(productKeyConfig.Id)
+						for _, attr := range attrList {
+							prodColor := product_model.GetProductByIdAndColorId(pd.RelateProductId, attr.Id, true)
+							if prodColor != nil {
+								size := &product_model.ProductAttr{}
+								size.Id = attr.Id
+								//beego.BeeLogger.Warn("color_id --- %d", size.Id)
+								size.Name = attr.Name
+								productKeyConfig.ProductAttr = append(productKeyConfig.ProductAttr, size)
+							}
+						}
+						pd.Color = productKeyConfig
+					}
+				}
+			}
+		}
 	}
 
 	self.Data["json"] = &Ret{List: pds, ListCount: count}

+ 4 - 3
go/gopath/src/fohow.com/apps/models/product_model/product.go

@@ -105,9 +105,10 @@ type Product struct {
 	ColorName        string `orm:"-"                                     json:"-"`         // varchar(255)
 	SinglePurchLimit int64  `orm:"column(single_purch_limit)"            json:"-"`         // varchar(255)
 
-	Package     bool           `orm:"column(package)"                          json:"package"` // varchar(255)
-	PackageList []*ProductItem `orm:"-"                           json:"package_list"`         // varchar(255)
-
+	Package     bool            `orm:"column(package)"                          json:"package"` // varchar(255)
+	PackageList []*ProductItem  `orm:"-"                           json:"package_list"`         // varchar(255)
+	Size        *ProductAttrKey `json:"size_list"`
+	Color       *ProductAttrKey `json:"color_list"`
 }
 
 //获取最新推荐商品