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
# 同步现有数据 | |
require 'csv' | |
user = User.all[0] | |
user.items_sync | |
user.skus_sync | |
# 导入数据 | |
file_csv = File.join(PADRINO_ROOT, "items.csv") | |
items = CSV.read(file_csv, "rb:GB18030:UTF-8", headers: true, col_sep: ',') | |
skus_data = {} | |
items.each do |item| |
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
# SKU转码 | |
user = User.all[0] | |
user.items_sync | |
user.skus_sync | |
skus_data = { | |
'AWLT932900100L' => 6946401914277, | |
} | |
counter = 0 | |
puts skus_data.count | |
user.items.each do |item| |
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[2] | |
# 同步最新的店铺会员 | |
user.members_sync | |
# 设定时间区间 | |
start_at='2012-04-01'.to_date | |
end_at='2012-05-09'.to_date | |
range = start_at.beginning_of_day..end_at.end_of_day | |
members = user.members.where(last_trade_time: range) | |
# 获得交易集合 | |
trade_ids = members.distinct(:biz_order_id) |
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[2] | |
# 同步最新的店铺会员 | |
user.members_sync | |
# 设定时间区间 | |
start_at='2012-04-01'.to_date | |
end_at='2012-05-09'.to_date | |
range = start_at.beginning_of_day..end_at.end_of_day | |
members = user.members.where(last_trade_time: range) | |
# 获得交易集合 | |
trade_ids = members.distinct(:biz_order_id) |
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[2] | |
# 同步最新的店铺会员 | |
user.members_sync | |
# 设定时间区间 | |
start_at='2012-04-01'.to_date | |
end_at='2012-05-09'.to_date | |
range = start_at.beginning_of_day..end_at.end_of_day | |
members = user.members.where(last_trade_time: range) | |
# 获得交易集合 | |
trade_ids = members.distinct(:biz_order_id) |
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[5] | |
reply_nicks=[] | |
non_reply_nicks=[] | |
date='2012-07-10'.to_date | |
user.subusers.all[1].chatpeers.where(date: date).each do |chatpeer| | |
# 定义基础变量 | |
questions = 0 # 提问数 | |
answers = 0 # 答复数 | |
qna_rate = 0 # 问答率 | |
avg_waiting_times = 0 # 平均等待时间 |
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 filter_meta(filter) | |
{ name: filter.name, num: 0, children: {}, item_ids: filter.item_ids} | |
end | |
def filter_tree(filter, node, filters) # 构建层级 | |
key = filter._id.to_s | |
unless node.has_key?(key) | |
node[key] = filter_meta(filter) | |
if filter.child_ids.count > 0 | |
children = node[key][:children] = {} | |
filters.also_in(_id: filter.child_ids).each do |child| |
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 mobile_specs(mobile) | |
mobile = mobile.to_s[0..2].to_i # 号段 | |
china_mobile = { | |
'2G' => [134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 182], | |
'3G' => [187, 188] | |
} | |
china_unicom = { | |
'2G' => [130, 131, 132, 155, 156], | |
'3G' => [185, 186] | |
} |
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
# -*- encoding: utf-8 -*- | |
require 'savon' | |
client = Savon.client('http://interface.youruijin.com/RaybanCodeServer.php?wsdl') | |
code = "TES#{Time.now.to_i}" | |
response = client.request :rsync_code, body: { | |
code: code, | |
buydate: '2012-08-09 16:56:35', | |
channel: 1, | |
trade_id: '测试', | |
sku_id: '测试', |
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
class Issue | |
# Referenced | |
belongs_to :user, foreign_key: 'seller_nick' # 店铺 | |
belongs_to :eventable, polymorphic: true # | |
has_many :changesets | |
field :seller_nick, type: String | |
field :memo, type: String | |
field :status, type: String |