15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/models/eric_weixin/redpack.rb', line 15
def self.create_redpack options
self.transaction do
packs = EricWeixin::Redpack.where weixin_redpack_order_id: options[:weixin_redpack_order_id],
openid: options[:openid]
return packs[0] unless packs.blank?
redpack = self.new status: options[:status],
openid: options[:openid],
amount: options[:amount],
rcv_time: options[:rcv_time],
weixin_redpack_order_id: options[:weixin_redpack_order_id]
redpack.save!
redpack
end
end
|