abiao лет назад: 5
Родитель
Сommit
bf4d612f49
1 измененных файлов с 11 добавлено и 3 удалено
  1. 11 3
      app/models/product.rb

+ 11 - 3
app/models/product.rb

@@ -4,7 +4,7 @@ class Product < ActiveRecord::Base
     belongs_to :product_cat, :foreign_key => :category_id
     belongs_to :merchant, :foreign_key => :merchant_id
     validates :name,:buy_price,:price,:category_id,:count,:robo_balance_price, presence: true
-    attr_accessor :v_share_img
+    attr_accessor :v_share_img,:get_size_enum
 
     TYPE_ENUM = [["直营","direct_sale"]]
     #["代销","user_sale"]
@@ -47,7 +47,15 @@ class Product < ActiveRecord::Base
         clean_share_img
     end
 
-    def gross_interest_rate 
+    def gross_interest_rate
+        @Size = ProductAttrConfig.where("product_id=? and size_type='size'",self.id).first
+        if !@Size.blank?
+            @productAttrs = ProductAttr.where("attr_key_id=?",@Size.id).order("recommend desc")
+            @productAttrs.each do |attr|
+                a=[attr.name,attr.id]
+                SIZE_ENUM.push(a)
+            end
+        end
         rate = 0
         if self.buy_price != 0 && self.price != 0
             rate = (( self.price.to_f - self.buy_price.to_f )/self.buy_price.to_f)*100
@@ -107,7 +115,7 @@ class Product < ActiveRecord::Base
             end
             field :is_only_new
             field :video_state
-            field :get_size_enum
+            # field :get_size_enum
             field :size_id, :enum do
                 enum do
                     SIZE_ENUM