Class: EricWeixin::Xiaodian::SkuName

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/eric_weixin/xiaodian/sku_name.rb

Class Method Summary collapse

Class Method Details

.create_skuname(options) ⇒ Object

创建sku name 接收参数: name weixin_name_id 类别id



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/eric_weixin/xiaodian/sku_name.rb', line 7

def self.create_skuname options
  name = EricWeixin::Xiaodian::SkuName.where(wx_name_id: options[:wx_name_id],
                                             weixin_xiaodian_category_id: options[:weixin_xiaodian_category_id]).first
  name = if name.blank?
           name = EricWeixin::Xiaodian::SkuName.new name: options[:name],
                                                    weixin_xiaodian_category_id: options[:weixin_xiaodian_category_id],
                                                    wx_name_id: options[:wx_name_id]
         else
           name.name = options[:name]
           name
         end
  name.save!
  name
end