This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.all[1] | |
date = '2012-11-11'.to_date | |
range = date.beginning_of_day..date.end_of_day | |
trades = user.trades.where(created: range, status: 'WAIT_SELLER_SEND_GOODS') | |
buyers = {} | |
trades.each do |trade| | |
buyers[trade.buyer_nick] = {} unless buyers.has_key?(trade.buyer_nick) | |
buyer = buyers[trade.buyer_nick] | |
trade.orders.each do |order| | |
buyer[order.num_iid] = {} unless buyer.has_key?(order.num_iid) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.all[1] | |
date = '2012-11-11'.to_date | |
range = date.beginning_of_day..date.end_of_day | |
trades = user.trades.where(created: range, status: 'WAIT_BUYER_PAY') | |
CSV.open("#{date.to_s}-trades.csv", "wb:GB18030", col_sep: ',') do |csv| | |
trades.each do |trade| | |
row = [ | |
trade.tid, | |
trade.payment, | |
trade.buyer_nick, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.all[1] | |
date = '2012-11-11'.to_date | |
range = date.beginning_of_day..Time.parse('2012-11-11 11:00') # date.end_of_day | |
buyers = {} | |
user.trades.where(created: range, :pay_time.ne => nil).each do |trade| | |
buyers[trade.buyer_nick] = { city: trade.receiver_city, payment: 0, items: [] } unless buyers.has_key?(trade.buyer_nick) | |
buyer = buyers[trade.buyer_nick] | |
trade.orders.each do |order| | |
buyer[:payment] += order.payment | |
buyer[:items] << order.num_iid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.all[1] | |
date = '2012-11-11'.to_date | |
range = date.beginning_of_day..date.end_of_day | |
trades = user.trades.where(created: range).sales.sold.norefund | |
trades = trades.only(:payment, :num) | |
payment = 0 | |
num = 0 | |
nulls = [] | |
trades.each do |trade| | |
if trade.payment && trade.num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.all[1] | |
date = '2012-11-11'.to_date | |
user.trades_sync(date) | |
user.orders_sync | |
skus_data = CSV.read('all_items.csv', 'rb:GB18030:UTF-8', headers: true, col_sep: ',') | |
items = {} | |
skus_data.each do |sku| | |
items[sku['SKU']] = 0 unless items.has_key?(sku['SKU']) | |
items[sku['SKU']] += sku['库存'].to_i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.last | |
# 订单列表 | |
trades = CSV.read('trades.csv', 'rb:GB18030:UTF-8', headers: true, col_sep: ';') | |
trade_ids = [] | |
@items = {} | |
trades.each do |trade| | |
trade_ids << trade['TID'] | |
@items[trade['SKU']] = 0 unless @items.has_key?(trade['SKU']) | |
end | |
trade_ids.uniq! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uri = [ | |
# 运动 | |
"http://arcteryxjrh.tmall.com", | |
"http://sanfo.tmall.com", | |
"http://skomart.tmall.com", | |
"http://newbalance.tmall.com", | |
"http://thenorthface.tmall.com", | |
"http://asics.tmall.com", | |
"http://adidas.tmall.com", | |
"http://salomon.tmall.com", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 未知的 | |
unkown_list = [ | |
"219.130.39.9:3128", | |
"122.225.22.22:8080", | |
"202.103.215.199:80", | |
"59.46.173.75:80", | |
"218.23.49.155:80", | |
"218.76.157.98:8001", | |
"218.84.126.82:3128" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $syslog $remote_fs | |
# Required-Stop: $syslog $remote_fs | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: nginx - Persistent key-value db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 获取购买记录 | |
def get_trades(crawler, item_id, seller_id, item_sbn, page=1) | |
start_at = Date.yesterday.beginning_of_day.to_i * 1000 | |
end_at = Date.yesterday.end_of_day.to_i * 1000 | |
# 购买列表 |