|
|
@@ -294,40 +294,42 @@ func (self *ProductController) GetProductSizesByPid() {
|
|
|
pId, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
|
|
|
type Ret struct {
|
|
|
- Size *product_model.ProductAttrKey `json:"size_list"`
|
|
|
- Color *product_model.ProductAttrKey `json:"color_list"`
|
|
|
+ Product *product_model.Product `json:"product"`
|
|
|
+ Size *product_model.ProductAttrKey `json:"size_list"`
|
|
|
+ Color *product_model.ProductAttrKey `json:"color_list"`
|
|
|
}
|
|
|
product := product_model.GetProductById(pId, false)
|
|
|
- if product == nil {
|
|
|
- self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
- }
|
|
|
+
|
|
|
ret := &Ret{}
|
|
|
- list := product_model.GetProductConfigAttrsByPId(pId)
|
|
|
- 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 {
|
|
|
- if attr.Id == product.SizeId {
|
|
|
- attr.IsSelect = true
|
|
|
- }
|
|
|
+ if product != nil {
|
|
|
+ list := product_model.GetProductConfigAttrsByPId(pId)
|
|
|
+ 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 {
|
|
|
+ if attr.Id == product.SizeId {
|
|
|
+ attr.IsSelect = true
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ productKeyConfig.ProductAttr = attrList
|
|
|
+ ret.Size = productKeyConfig
|
|
|
}
|
|
|
- productKeyConfig.ProductAttr = attrList
|
|
|
- ret.Size = productKeyConfig
|
|
|
- }
|
|
|
- if item.SizeType == product_model.SIZE_TYPE_2 {
|
|
|
- attrList := product_model.GetProductAttrsByKId(productKeyConfig.Id)
|
|
|
- for _, attr := range attrList {
|
|
|
- if attr.Id == product.ColorId {
|
|
|
- attr.IsSelect = true
|
|
|
- }
|
|
|
+ if item.SizeType == product_model.SIZE_TYPE_2 {
|
|
|
+ attrList := product_model.GetProductAttrsByKId(productKeyConfig.Id)
|
|
|
+ /* for _, attr := range attrList {
|
|
|
+ if attr.Id == product.ColorId {
|
|
|
+ attr.IsSelect = true
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ productKeyConfig.ProductAttr = attrList
|
|
|
+ ret.Color = productKeyConfig
|
|
|
}
|
|
|
- productKeyConfig.ProductAttr = attrList
|
|
|
- ret.Color = productKeyConfig
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ ret.Product = product
|
|
|
self.Data["json"] = ret
|
|
|
self.ServeJSON()
|
|
|
}
|