Skip to content

Instantly share code, notes, and snippets.

@rubyonrailsworks
Created November 13, 2012 17:05
Show Gist options
  • Save rubyonrailsworks/4067025 to your computer and use it in GitHub Desktop.
Save rubyonrailsworks/4067025 to your computer and use it in GitHub Desktop.
TAOBAO
def get_promotion
result = TaobaoFu.get(:method => 'taobao.trade.fullinfo.get',
:fields => 'promotion_details',
:tid => '170933582981157'
)
if result["trade_fullinfo_get_response"] && result["trade_fullinfo_get_response"]['trade'] &&
result["trade_fullinfo_get_response"]["trade"]["promotion_details"]
promotion_info = result["trade_fullinfo_get_response"]["trade"]["promotion_details"]["promotion_detail"]
if !promotion_info.to_a.nil? and self.taobao_promotions.blank?
p promotion_info.to_a
promotion_info.to_a.each do |pi|
self.taobao_promotions.create(
:tid => pi["id"].to_s,
:promotion_name => pi["promotion_name"],
:discount_fee => pi["discount_fee"],
:gift_item_name => pi["gift_item_name"]
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment