|
|
@@ -5,7 +5,6 @@ class Product < ActiveRecord::Base
|
|
|
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,:get_size_enum
|
|
|
- after_find :gross_interest_rate
|
|
|
|
|
|
TYPE_ENUM = [["直营","direct_sale"]]
|
|
|
#["代销","user_sale"]
|
|
|
@@ -25,6 +24,14 @@ class Product < ActiveRecord::Base
|
|
|
IMG_STORE_PATH = "product"
|
|
|
|
|
|
def v_share_img=file
|
|
|
+ @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
|
|
|
unless file.blank?
|
|
|
file_name = "#{UUID.new.generate[0...8].downcase}.jpg"
|
|
|
file_path = "#{IMG_STORE_PATH}/product/share/#{file_name}"
|
|
|
@@ -210,11 +217,11 @@ class Product < ActiveRecord::Base
|
|
|
field :virtual_sold_count
|
|
|
field :purchase_limit_count
|
|
|
field :share_content
|
|
|
- # field :v_share_img, :file_upload do
|
|
|
- # pretty_value do
|
|
|
- # bindings[:view].tag(:img, {:src => bindings[:object].get_share_img, :class => 'preview'})
|
|
|
- # end
|
|
|
- # end
|
|
|
+ field :v_share_img, :file_upload do
|
|
|
+ pretty_value do
|
|
|
+ bindings[:view].tag(:img, {:src => bindings[:object].get_share_img, :class => 'preview'})
|
|
|
+ end
|
|
|
+ end
|
|
|
field :seckill_start
|
|
|
field :seckill_end
|
|
|
field :seckill_price
|