eric_weixin 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +17 -8
- data/app/assets/stylesheets/eric_weixin/wz/base.css.scss +72 -0
- data/app/controllers/eric_weixin/cms/weixin/media_news_controller.rb +1 -1
- data/app/controllers/eric_weixin/cms/weixin/weixin_users_controller.rb +24 -0
- data/app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb +37 -4
- data/app/controllers/eric_weixin/wz/xiaodian/orders_controller.rb +8 -0
- data/app/models/eric_weixin/customs_service_record.rb +1 -1
- data/app/models/eric_weixin/media_news.rb +2 -2
- data/app/models/eric_weixin/public_account.rb +46 -2
- data/app/models/eric_weixin/redpack_order.rb +10 -1
- data/app/models/eric_weixin/reply_message_rule.rb +2 -1
- data/app/models/eric_weixin/weixin_user.rb +43 -20
- data/app/models/eric_weixin/xiaodian/order.rb +147 -86
- data/app/views/eric_weixin/cms/weixin/url_encodes/index.html.erb +2 -2
- data/app/views/eric_weixin/cms/weixin/weixin_users/index.html.erb +6 -0
- data/app/views/eric_weixin/cms/weixin/xiaodian/orders/index.html.erb +111 -26
- data/app/views/eric_weixin/wz/xiaodian/orders/index.html.erb +84 -0
- data/config/initializers/assets.rb +1 -0
- data/config/routes.rb +9 -0
- data/lib/eric_weixin/modules/snsapi.rb +1 -1
- data/lib/eric_weixin/version.rb +1 -1
- metadata +33 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
2
2
|
self.table_name = 'weixin_xiaodian_orders'
|
3
|
-
belongs_to :weixin_user, class_name: "::EricWeixin::WeixinUser"
|
3
|
+
# belongs_to :weixin_user, class_name: "::EricWeixin::WeixinUser"
|
4
4
|
belongs_to :product, class_name: "::EricWeixin::Xiaodian::Product", foreign_key: 'weixin_product_id'
|
5
5
|
belongs_to :weixin_public_account, class_name: "::EricWeixin::PublicAccount", foreign_key: 'weixin_public_account_id'
|
6
6
|
# 接收订单
|
@@ -17,12 +17,17 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
17
17
|
"zj001yixun" => "易迅快递"
|
18
18
|
}
|
19
19
|
|
20
|
+
def weixin_user
|
21
|
+
::EricWeixin::WeixinUser.find_by_openid self.openid
|
22
|
+
end
|
23
|
+
|
20
24
|
def product_info
|
21
25
|
return '' if self.sku_info.blank?
|
22
26
|
info = ""
|
23
27
|
list = self.sku_info.split(";")
|
24
28
|
list.each do |sku|
|
25
29
|
str = sku.split(":")[1]
|
30
|
+
return 'error' if str.blank?
|
26
31
|
if str.match /^\$/
|
27
32
|
info += str[1,str.size-1]
|
28
33
|
info += "、"
|
@@ -51,13 +56,11 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
51
56
|
def self.create_order options
|
52
57
|
order = EricWeixin::Xiaodian::Order.where(order_id: options[:OrderId]).first
|
53
58
|
unless order.blank?
|
54
|
-
order.get_info
|
59
|
+
order.delay(:priority => -10).get_info
|
55
60
|
return order
|
56
61
|
end
|
57
|
-
|
58
62
|
openid = options[:FromUserName]
|
59
|
-
user = EricWeixin::WeixinUser.where(openid: openid).first
|
60
|
-
|
63
|
+
# user = EricWeixin::WeixinUser.where(openid: openid).first
|
61
64
|
to_user_name = options[:ToUserName]
|
62
65
|
account = EricWeixin::PublicAccount.where(weixin_number: to_user_name).first
|
63
66
|
|
@@ -68,15 +71,15 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
68
71
|
end
|
69
72
|
|
70
73
|
|
71
|
-
if user.blank?
|
72
|
-
|
73
|
-
|
74
|
-
end
|
74
|
+
# if user.blank?
|
75
|
+
# account.delay.rebuild_users_simple
|
76
|
+
# # user = EricWeixin::WeixinUser.where(openid: openid).first
|
77
|
+
# end
|
75
78
|
|
76
|
-
user_id = user.blank? ? nil : user.id
|
79
|
+
# user_id = user.blank? ? nil : user.id
|
77
80
|
|
78
81
|
order = EricWeixin::Xiaodian::Order.new order_id: options[:OrderId],
|
79
|
-
|
82
|
+
|
80
83
|
order_create_time: options[:CreateTime],
|
81
84
|
order_status: options[:OrderStatus],
|
82
85
|
weixin_product_id: product.id,
|
@@ -85,16 +88,24 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
85
88
|
openid: openid
|
86
89
|
order.save!
|
87
90
|
|
88
|
-
order.get_info
|
91
|
+
order.delay(:priority => -10).get_info
|
89
92
|
|
90
93
|
order
|
91
94
|
end
|
92
95
|
|
93
96
|
|
94
|
-
def buyer_nick
|
95
|
-
|
96
|
-
end
|
97
|
+
# def buyer_nick
|
98
|
+
# CGI::unescape(self.attributes["buyer_nick"]) rescue '无法正常显示'
|
99
|
+
# end
|
97
100
|
|
101
|
+
# 更新指定时间区间的订单信息
|
102
|
+
# EricWeixin::Xiaodian::Order.update_order_infos
|
103
|
+
def self.update_order_infos start_date, end_date
|
104
|
+
self.where("order_create_time between ? and ? ", start_date.to_time.to_i, end_date.to_time.to_i).each do |order|
|
105
|
+
order.get_info
|
106
|
+
end
|
107
|
+
true
|
108
|
+
end
|
98
109
|
|
99
110
|
# 根据订单ID获取订单详情
|
100
111
|
def get_info
|
@@ -107,18 +118,8 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
107
118
|
["receiver_zip", "product_id", "buyer_openid"].each do |a|
|
108
119
|
order_params.delete a
|
109
120
|
end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
# 获取订单详情前,weixin_product_id、sku_info、weixin_user_id应该已经有了值
|
116
|
-
# weixin_product = EricWeixin::Xiaodian::Product.where( product_id: order_params["product_id"], weixin_public_account_id: self.weixin_public_account_id ).first
|
117
|
-
# order_params.merge!("weixin_product_id"=>weixin_product.id) unless weixin_product.blank?
|
118
|
-
# weixin_user = EricWeixin::WeixinUser.where(openid: order_params["buyer_openid"], weixin_public_account_id: self.weixin_public_account_id).first
|
119
|
-
# order_params.merge!("weixin_user_id"=>weixin_user.id) unless weixin_user.blank?
|
120
|
-
|
121
|
-
self.update_attributes order_params
|
121
|
+
self.update_attributes order_params.select{|k,v| ['order_id', 'order_status', 'order_total_price', 'order_create_time', 'order_express_price', 'buyer_nick', 'receiver_name', 'receiver_province', 'receiver_city', 'receiver_zone', 'receiver_address', 'receiver_mobile', 'receiver_phone',
|
122
|
+
'product_name', 'product_name', 'product_sku', 'product_count', 'product_img', 'trans_id'].include? k }
|
122
123
|
else
|
123
124
|
pp response
|
124
125
|
return
|
@@ -143,6 +144,8 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
143
144
|
if response["errcode"] == 0
|
144
145
|
order_list = response["order_list"]
|
145
146
|
order_list.each do |order|
|
147
|
+
orders = EricWeixin::Xiaodian::Order.where order_id: order["order_id"]
|
148
|
+
next unless orders.blank?
|
146
149
|
EricWeixin::Xiaodian::Order.create_order OrderId: order["order_id"],
|
147
150
|
FromUserName: order["buyer_openid"],
|
148
151
|
ToUserName: account.weixin_number,
|
@@ -187,7 +190,7 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
187
190
|
# 是否为6.4.5表之外的其它物流公司(0-否,1-是,无该字段默认为不是其它物流公司)
|
188
191
|
|
189
192
|
def set_delivery options
|
190
|
-
pp options
|
193
|
+
# pp options
|
191
194
|
if options["need_delivery"].to_s == "0"
|
192
195
|
options = {need_delivery: 0}
|
193
196
|
else
|
@@ -202,83 +205,58 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
202
205
|
response = RestClient.post "https://api.weixin.qq.com/merchant/order/setdelivery?access_token=#{token}", options.to_json
|
203
206
|
response = JSON.parse response.body
|
204
207
|
if response["errcode"] == 0
|
205
|
-
true
|
206
208
|
if options["need_delivery"].to_s == "0"
|
207
209
|
self.update_attributes delivery_id: "", delivery_company: ""
|
208
210
|
else
|
209
211
|
self.update_attributes delivery_id: options["delivery_track_no"], delivery_company: options["delivery_company"]
|
210
212
|
end
|
213
|
+
true
|
211
214
|
else
|
212
215
|
false
|
213
216
|
end
|
214
217
|
end
|
215
218
|
|
219
|
+
# need_deliver 1:未发货 0 已发货
|
216
220
|
def self.get_excel_of_orders options
|
217
|
-
orders = self.
|
218
|
-
|
219
|
-
orders = orders.where("
|
221
|
+
orders = self.order_query options
|
222
|
+
# if options[:need_deliver] == '1'
|
223
|
+
# orders = orders.where("delivery_id is null or delivery_id = '' or delivery_company is null or delivery_company = '' ")
|
224
|
+
# else
|
225
|
+
# orders = orders.where("delivery_id is not null and delivery_id <> '' and delivery_company is not null and delivery_company <> '' ")
|
226
|
+
# end
|
220
227
|
orders = orders.order(order_create_time: :desc)
|
221
228
|
|
222
229
|
Spreadsheet.client_encoding = 'UTF-8'
|
223
230
|
book = Spreadsheet::Workbook.new
|
224
231
|
|
225
232
|
sheet1 = book.create_worksheet name: '订单表'
|
226
|
-
sheet1.row(0)
|
227
|
-
|
228
|
-
sheet1.row(0)[2] = "订单ID"
|
229
|
-
sheet1.row(0)[3] = "产品名称"
|
230
|
-
sheet1.row(0)[4] = "sku"
|
231
|
-
sheet1.row(0)[5] = "订单状态"
|
232
|
-
sheet1.row(0)[6] = "总金额"
|
233
|
-
sheet1.row(0)[7] = "订单生成时间"
|
234
|
-
sheet1.row(0)[8] = "快递费"
|
235
|
-
sheet1.row(0)[9] = "昵称"
|
236
|
-
sheet1.row(0)[10] = "收货人"
|
237
|
-
sheet1.row(0)[11] = "省"
|
238
|
-
sheet1.row(0)[12] = "城市"
|
239
|
-
sheet1.row(0)[13] = "区"
|
240
|
-
sheet1.row(0)[14] = "地址"
|
241
|
-
sheet1.row(0)[15] = "移动电话"
|
242
|
-
sheet1.row(0)[16] = "固定电话"
|
243
|
-
sheet1.row(0)[17] = "产品名"
|
244
|
-
sheet1.row(0)[18] = "单价"
|
245
|
-
sheet1.row(0)[19] = "产品sku"
|
246
|
-
sheet1.row(0)[20] = "数量"
|
247
|
-
sheet1.row(0)[21] = "产品图片url"
|
248
|
-
sheet1.row(0)[22] = "运单ID"
|
249
|
-
sheet1.row(0)[23] = "快递公司"
|
250
|
-
sheet1.row(0)[24] = "交易ID"
|
251
|
-
sheet1.row(0)[25] = "openid"
|
252
|
-
sheet1.row(0)[26] = "公众号名称"
|
233
|
+
sheet1.row(0).push '产品名称', '数量', '收货人', '移动电话', '快递公司', '快递单号', '买家昵称', '订单ID', '固定电话', '省', '城市', '区', '地址', '是否是粉丝', '订单时间', '快递费(单位:元)', '总金额(单位:元)'
|
234
|
+
|
253
235
|
current_row = 1
|
254
236
|
orders.each do |order|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
sheet1.row(current_row)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
sheet1.row(current_row)[23] = self::DELIVERY_COMPANY[order.delivery_company]||order.delivery_company rescue ''
|
279
|
-
sheet1.row(current_row)[24] = order.trans_id
|
280
|
-
sheet1.row(current_row)[25] = order.openid
|
281
|
-
sheet1.row(current_row)[26] = order.weixin_public_account.name
|
237
|
+
wx_user = order.weixin_user
|
238
|
+
is_fan = if !wx_user.blank? && wx_user.subscribe == 1
|
239
|
+
'是'
|
240
|
+
else
|
241
|
+
'否'
|
242
|
+
end
|
243
|
+
sheet1.row(current_row).push (begin order.product.name rescue '' end),
|
244
|
+
order.product_count,
|
245
|
+
order.receiver_name,
|
246
|
+
order.receiver_mobile,
|
247
|
+
order.delivery_company,
|
248
|
+
order.delivery_id,
|
249
|
+
order.buyer_nick,
|
250
|
+
order.order_id,
|
251
|
+
order.receiver_phone,
|
252
|
+
order.receiver_province,
|
253
|
+
order.receiver_city,
|
254
|
+
order.receiver_zone,
|
255
|
+
order.receiver_address,
|
256
|
+
is_fan,
|
257
|
+
Time.at(order.order_create_time).strftime("%Y-%m-%d %H:%M:%S"),
|
258
|
+
order.order_express_price.to_f/100,
|
259
|
+
order.order_total_price.to_f/100
|
282
260
|
current_row += 1
|
283
261
|
end
|
284
262
|
dir = Rails.root.join('public', 'downloads')
|
@@ -288,4 +266,87 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
|
|
288
266
|
file_path
|
289
267
|
end
|
290
268
|
|
269
|
+
|
270
|
+
# order查询,支持以下参数:
|
271
|
+
# start_date, end_date 起始日期, 终止日期
|
272
|
+
# buyer_nick 买家昵称
|
273
|
+
# receiver_name 收货人姓名
|
274
|
+
# receiver_mobile 收货人手机
|
275
|
+
# deliver_status 发货状态, (1-未发货, 2-已发货)
|
276
|
+
# delivery_id 快递单号
|
277
|
+
# receiver_address 地址
|
278
|
+
# receiver_city 城市
|
279
|
+
def self.order_query options
|
280
|
+
orders = self.all
|
281
|
+
orders = orders.where("order_create_time >= ?", options[:start_date].to_time.change(hour:0,min:0,sec:0).to_i) unless options[:start_date].blank?
|
282
|
+
orders = orders.where("order_create_time <= ?", options[:end_date].to_time.change(hour:23,min:59,sec:59).to_i) unless options[:end_date].blank?
|
283
|
+
orders = orders.where("buyer_nick LIKE ?", "%#{options[:buyer_nick]}%") unless options[:buyer_nick].blank?
|
284
|
+
orders = orders.where("receiver_name LIKE ?", "%#{options[:receiver_name]}%") unless options[:receiver_name].blank?
|
285
|
+
orders = orders.where("receiver_mobile = ?", options[:receiver_mobile]) unless options[:receiver_mobile].blank?
|
286
|
+
orders = orders.where("delivery_id like ?", "%#{options[:delivery_id]}%") unless options[:delivery_id].blank?
|
287
|
+
orders = orders.where("receiver_address like ?", "%#{options[:receiver_address]}%") unless options[:receiver_address].blank?
|
288
|
+
orders = orders.where("receiver_city like ?", "%#{options[:receiver_city]}%") unless options[:receiver_city].blank?
|
289
|
+
orders = orders.where("delivery_id is null or delivery_id = '' or delivery_company is null or delivery_company = '' ") if options[:deliver_status] == 1.to_s
|
290
|
+
orders = orders.where("delivery_id is not null and delivery_id <> '' and delivery_company is not null and delivery_company <> '' ") if options[:deliver_status] == 2.to_s
|
291
|
+
orders
|
292
|
+
end
|
293
|
+
|
294
|
+
# 通过excel文件更新微信小店订单快递信息,包括快递公司与快递单号
|
295
|
+
def self.update_delivery_info_by_excel file
|
296
|
+
self.transaction do
|
297
|
+
Spreadsheet.client_encoding = 'UTF-8'
|
298
|
+
dir = 'public/temp'
|
299
|
+
Dir.mkdir dir unless Dir.exist? dir
|
300
|
+
path = Rails.root.join(dir, file.original_filename)
|
301
|
+
File.open(path, 'wb') do |f|
|
302
|
+
f.write(file.read)
|
303
|
+
end
|
304
|
+
book = Spreadsheet.open path
|
305
|
+
sheet = book.worksheet 0
|
306
|
+
|
307
|
+
# 遍历到订单ID列
|
308
|
+
order_id_col = -1
|
309
|
+
delivery_company_col = -1
|
310
|
+
delivery_order_id_col = -1
|
311
|
+
100.times do |i|
|
312
|
+
order_id_col = i if sheet.row(0)[i] == '订单ID'
|
313
|
+
delivery_company_col = i if sheet.row(0)[i] == '快递公司'
|
314
|
+
delivery_order_id_col = i if sheet.row(0)[i] == '快递单号'
|
315
|
+
break if order_id_col != -1 && delivery_company_col != -1 && delivery_order_id_col != -1
|
316
|
+
end
|
317
|
+
|
318
|
+
BusinessException.raise '请确保excel文件第一列包含以下列名:订单ID、快递公司、快递单号' if order_id_col == -1 || delivery_company_col == -1 || delivery_order_id_col == -1
|
319
|
+
success_count = 0
|
320
|
+
total_count = 0
|
321
|
+
sheet.each_with_index do |row, index|
|
322
|
+
next if index == 0
|
323
|
+
total_count += 1
|
324
|
+
# 以下几种情况会跳过
|
325
|
+
# * 订单ID不正确
|
326
|
+
# * 没有快递公司
|
327
|
+
# * 没有快递单号
|
328
|
+
# * 数据库中快递小店订单的快递公司已经存在
|
329
|
+
# * 数据库中快递小店订单的快递单号已经存在
|
330
|
+
order_id = row[order_id_col]
|
331
|
+
xiaodian_order = self.find_by_order_id(order_id)
|
332
|
+
next if xiaodian_order.blank?
|
333
|
+
next if row[delivery_company_col].blank? || row[delivery_order_id_col].blank?
|
334
|
+
next if !xiaodian_order.delivery_company.blank? || !xiaodian_order.delivery_id.blank?
|
335
|
+
|
336
|
+
# 过五关、斩六将后,终于可以更新快递信息了
|
337
|
+
delivery_order_id = row[delivery_order_id_col].is_a?(Float) ? row[delivery_order_id_col].to_i.to_s : row[delivery_order_id_col].to_s
|
338
|
+
options = {
|
339
|
+
"delivery_company" => row[delivery_company_col].to_s,
|
340
|
+
"delivery_track_no" => delivery_order_id,
|
341
|
+
"need_delivery" => 1,
|
342
|
+
"is_others" => 1
|
343
|
+
}
|
344
|
+
result = xiaodian_order.set_delivery options
|
345
|
+
success_count += 1 if result
|
346
|
+
end
|
347
|
+
# 删除临时文件
|
348
|
+
File.delete path
|
349
|
+
"共#{total_count}条记录,更新成功#{success_count}条。"
|
350
|
+
end
|
351
|
+
end
|
291
352
|
end
|
@@ -13,10 +13,10 @@
|
|
13
13
|
<% end %>
|
14
14
|
</select>
|
15
15
|
<%= f.check_box :details, checked: "checked" %>
|
16
|
-
<span>以
|
16
|
+
<span>以snsapi_userinfo为scope发起的网页授权</span>
|
17
17
|
<input type="submit" name="commit" class="button right" value="生成微信授权链接"><br>
|
18
18
|
<%= f.check_box :only_id %>
|
19
|
-
<span>以
|
19
|
+
<span>以snsapi_base为scope发起的网页授权</span><hr/>
|
20
20
|
<% end %>
|
21
21
|
<%= form_for(cms_weixin_url_encodes_path, remote: true) do |f|%>
|
22
22
|
<%= f.label :微信公众号 %>
|
@@ -1,3 +1,9 @@
|
|
1
|
+
<% EricWeixin::PublicAccount.all.each do |pa| %>
|
2
|
+
<%= link_to "快速更新#{pa.name}微信用户信息", "/eric_weixin/cms/weixin/weixin_users/quick_get_user_infos?public_account_id=#{pa.id}", class: 'button tiny' %>
|
3
|
+
<% end %><br/>
|
4
|
+
<% EricWeixin::PublicAccount.all.each do |pa| %>
|
5
|
+
<%= link_to "批量更新#{pa.name}微信用户信息", "/eric_weixin/cms/weixin/weixin_users/batch_update_user_infos?public_account_id=#{pa.id}", class: 'button tiny' %>
|
6
|
+
<% end %>
|
1
7
|
<h3>用户表</h3>
|
2
8
|
<%= form_tag '/eric_weixin/cms/weixin/weixin_users', method: :get do %>
|
3
9
|
<div class="row">
|
@@ -1,46 +1,100 @@
|
|
1
|
+
<% EricWeixin::PublicAccount.all.each do |pa| %>
|
2
|
+
<%= link_to "更新#{pa.name}红包信息", "/eric_weixin/cms/weixin/xiaodian/orders/update_hb_infos?public_account_id=#{pa.id}", class: 'button tiny' %>
|
3
|
+
<% end %>
|
4
|
+
<%= link_to "更新本月的订单", "/eric_weixin/cms/weixin/xiaodian/orders/update_order_infos", class: 'button tiny' %>
|
5
|
+
<%= form_tag "/eric_weixin/cms/weixin/xiaodian/orders/", method: :get do %>
|
1
6
|
<div class="row">
|
2
|
-
|
7
|
+
<div class="columns small-2">
|
8
|
+
<label class="inline text-right">时间区间</label>
|
9
|
+
</div>
|
10
|
+
<div class="columns small-2">
|
11
|
+
<%= date_field_tag :start_date, params[:start_date] %>
|
12
|
+
</div>
|
13
|
+
<div class="columns small-2 text-center">
|
14
|
+
<label class="inline center">至</label>
|
15
|
+
</div>
|
16
|
+
<div class="columns small-2 end">
|
17
|
+
<%= date_field_tag :end_date, params[:end_date] %>
|
18
|
+
</div>
|
19
|
+
<div class="columns small-2">
|
20
|
+
<label class="inline text-right">发货状态</label>
|
21
|
+
</div>
|
22
|
+
<div class="columns small-2">
|
23
|
+
<%= select_tag :deliver_status, options_for_select({ '未发货' => 1, '已发货' => 2}, params[:deliver_status]), prompt: '全部' %>
|
24
|
+
<%#= check_box_tag :need_deliver, '1', params[:commit]!='查询'&¶ms[:need_deliver].blank? ? true : params[:need_deliver]=='1' %><!--<label class="inline small-3">需要发货</label>-->
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
<div class="row">
|
28
|
+
<div class="columns small-2">
|
29
|
+
<label class="inline text-right">昵称</label>
|
30
|
+
</div>
|
31
|
+
<div class="columns small-2">
|
32
|
+
<%= text_field_tag :buyer_nick, params[:buyer_nick] %>
|
33
|
+
</div>
|
34
|
+
<div class="columns small-2">
|
35
|
+
<label class="inline text-right">收货人姓名</label>
|
36
|
+
</div>
|
37
|
+
<div class="columns small-2">
|
38
|
+
<%= text_field_tag :receiver_name, params[:receiver_name] %>
|
39
|
+
</div>
|
40
|
+
<div class="columns small-2">
|
41
|
+
<label class="inline text-right">手机号</label>
|
42
|
+
</div>
|
43
|
+
<div class="columns small-2">
|
44
|
+
<%= text_field_tag :receiver_mobile, params[:receiver_mobile] %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
<div class="row">
|
48
|
+
<div class="columns small-2">
|
49
|
+
<label class="inline text-right">快递单号</label>
|
50
|
+
</div>
|
3
51
|
<div class="columns small-2">
|
4
|
-
|
52
|
+
<%= text_field_tag :delivery_id, params[:delivery_id] %>
|
5
53
|
</div>
|
6
|
-
<div class="columns small-
|
7
|
-
|
54
|
+
<div class="columns small-2">
|
55
|
+
<label class="inline text-right">城市</label>
|
8
56
|
</div>
|
9
|
-
<div class="columns small-
|
10
|
-
|
57
|
+
<div class="columns small-2">
|
58
|
+
<%= text_field_tag :receiver_city, params[:receiver_city] %>
|
11
59
|
</div>
|
12
|
-
<div class="columns small-
|
13
|
-
|
60
|
+
<div class="columns small-2">
|
61
|
+
<label class="inline text-right">地址</label>
|
14
62
|
</div>
|
15
|
-
<div class="columns small-
|
16
|
-
<%=
|
63
|
+
<div class="columns small-2">
|
64
|
+
<%= text_field_tag :receiver_address, params[:receiver_address] %>
|
17
65
|
</div>
|
66
|
+
</div>
|
67
|
+
<div class="row">
|
68
|
+
<div class="columns small-12 text-right">
|
69
|
+
<%= submit_tag '查询', class: 'tiny button' %>
|
70
|
+
</div>
|
71
|
+
</div>
|
18
72
|
<% end %>
|
19
|
-
</div>
|
20
|
-
|
21
73
|
<h3>订单列表</h3>
|
22
74
|
微信小店官方物流公司:邮政EMS、申通快递、中通速递、圆通速递、天天快递、顺丰速运、韵达快运、宅急送、汇通快运、易迅快递
|
23
|
-
<table>
|
75
|
+
<table style="width: 113%; table-layout: auto;" >
|
24
76
|
<thead>
|
25
77
|
<th>订单ID</th>
|
26
78
|
|
27
|
-
<th
|
79
|
+
<th>昵称</th><th>购买时间</th><th>宝贝</th><th>宝贝信息</th><th>数量</th><th>收货信息</th>
|
28
80
|
|
29
|
-
<th
|
81
|
+
<th>需物流</th><th>官方物流</th><th>快递公司</th><th>运单号</th><th>操作</th>
|
30
82
|
</thead>
|
31
83
|
<tbody>
|
32
84
|
<% @orders.each do |order| %>
|
33
85
|
<tr>
|
34
86
|
<td style="word-break:break-all"><%= order.order_id %></td>
|
35
|
-
<td style="word-break:break-all"><%= order.
|
36
|
-
<td style="word-break:break-all"><%= Time.at(order.order_create_time).strftime("%Y-%m-%d %H:%M
|
37
|
-
<td style="word-break:break-all"><%= order.product.name %></td>
|
87
|
+
<td style="word-break:break-all"><%= order.buyer_nick rescue '' %></td>
|
88
|
+
<td style="word-break:break-all"><%= Time.at(order.order_create_time).strftime("%Y-%m-%d %H:%M") %></td>
|
89
|
+
<td style="word-break:break-all"><%= order.product.name rescue 'error' %></td>
|
38
90
|
<td style="word-break:break-all"><%= order.product_info %></td>
|
39
91
|
<td style="word-break:break-all"><%= order.product_count %></td>
|
40
|
-
<td style="word-break:break-all"><%= order.receiver_name %></td>
|
41
|
-
<td style="word-break:break-all"><%= order.receiver_province + order.receiver_city + order.receiver_zone + order.receiver_address %></td>
|
42
|
-
<td style="word-break:break-all"><%= order.receiver_mobile %></td>
|
43
92
|
<td style="word-break:break-all">
|
93
|
+
<%= order.receiver_name %>
|
94
|
+
<%= order.receiver_mobile %><br>
|
95
|
+
<%= "#{order.receiver_province}#{order.receiver_city}#{order.receiver_zone}#{order.receiver_address}" %>
|
96
|
+
</td>
|
97
|
+
<td style="word-break:break-all; width:12px">
|
44
98
|
<%= check_box_tag "order_#{order.id}_is_need_delivery", "1", true, onchange: "change_need_delivery(#{order.id})" %>
|
45
99
|
</td>
|
46
100
|
<td id="order_<%= order.id %>_is_xiaodian_delivery_td" style="word-break:break-all">
|
@@ -49,13 +103,25 @@
|
|
49
103
|
</td>
|
50
104
|
<td id="order_<%= order.id %>_delivery_company_td" style="word-break:break-all">
|
51
105
|
<% if is_xiaodian_delivery %>
|
52
|
-
|
106
|
+
<%= select_tag "order_#{order.id}_delivery_company", options_from_collection_for_select(EricWeixin::Xiaodian::Order::DELIVERY_COMPANY, 'first', 'second', order.delivery_company), prompt: '选择快递公司' %>
|
107
|
+
<% elsif order.delivery_company.blank? %>
|
108
|
+
<%= text_field_tag "order_#{order.id}_delivery_company" %>
|
53
109
|
<% else %>
|
110
|
+
<span id="<%= order.id %>_delivery_com_show" onclick="update_delivery('<%=order.id %>');"><%= order.delivery_company %></span>
|
111
|
+
<span id="<%= order.id %>_delivery_com_input_span" style="display: none">
|
54
112
|
<%= text_field_tag "order_#{order.id}_delivery_company", order.delivery_company %>
|
113
|
+
</span>
|
55
114
|
<% end %>
|
56
115
|
</td>
|
57
116
|
<td id="order_<%= order.id %>_deliver_id_td" style="word-break:break-all">
|
58
|
-
|
117
|
+
<% if order.delivery_id.blank? %>
|
118
|
+
<%= text_field_tag "order_#{order.id}_delivery_id" %>
|
119
|
+
<% else %>
|
120
|
+
<span id="<%= order.id %>_delivery_show" onclick="update_delivery('<%=order.id %>');"><%= order.delivery_id %></span>
|
121
|
+
<span id="<%= order.id %>_delivery_input_span" style="display: none">
|
122
|
+
<%= text_field_tag "order_#{order.id}_delivery_id", order.delivery_id %>
|
123
|
+
</span>
|
124
|
+
<% end %>
|
59
125
|
</td>
|
60
126
|
<td id="order_<%= order.id %>_action_td" style="word-break:break-all">
|
61
127
|
<%= link_to '保存', "javascript:save_delivery_info(#{order.id})", id: "order_#{order.id}_action", class: "button tiny" %>
|
@@ -67,10 +133,23 @@
|
|
67
133
|
<%= will_paginate @collection, renderer: FoundationPagination::Rails %>
|
68
134
|
<div class="row">
|
69
135
|
<div class="columns small-12 text-right">
|
70
|
-
<%= link_to '下载订单', "/eric_weixin/cms/weixin/xiaodian/orders/download_orders?start_time=#{params[:start_date]}&end_time=#{params[:end_date]}", class: 'button tiny' %>
|
136
|
+
<%= link_to '下载订单', "/eric_weixin/cms/weixin/xiaodian/orders/download_orders?start_time=#{params[:start_date]}&end_time=#{params[:end_date]}&deliver_status=#{params[:deliver_status]}&buyer_nick=#{params[:buyer_nick]}&receiver_name=#{params[:receiver_name]}&receiver_mobile=#{params[:receiver_mobile]}", class: 'button tiny' %>
|
71
137
|
</div>
|
72
138
|
</div>
|
73
139
|
|
140
|
+
<%= form_tag '/eric_weixin/cms/weixin/xiaodian/orders/update_delivery_info_by_excel', multipart: true, method: 'post' do %>
|
141
|
+
<div class="row">
|
142
|
+
<div class="columns small-5 text-right">
|
143
|
+
<label class="inline">包含快递单信息的excel文件(仅支持xls格式)</label>
|
144
|
+
</div>
|
145
|
+
<div class="columns small-3">
|
146
|
+
<%= file_field_tag 'file' %>
|
147
|
+
</div>
|
148
|
+
<div class="columns small-4 text-left">
|
149
|
+
<%= submit_tag '更新快递单信息', class: 'button tiny' %>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
<% end %>
|
74
153
|
<script language="javascript">
|
75
154
|
function change_need_delivery(order_id){
|
76
155
|
if(!$("#order_"+order_id+"_is_need_delivery")[0].checked){
|
@@ -104,13 +183,13 @@
|
|
104
183
|
}
|
105
184
|
function save_delivery_info(order_id){
|
106
185
|
need_delivery = $("#order_"+order_id+"_is_need_delivery")[0].checked ? 1 : 0;
|
107
|
-
is_others = $("#order_"+order_id+"_is_xiaodian_delivery")[0].checked ? 0 : 1;
|
186
|
+
// is_others = $("#order_"+order_id+"_is_xiaodian_delivery")[0].checked ? 0 : 1;
|
108
187
|
delivery_track_no = $("#order_"+order_id+"_delivery_id")[0].value;
|
109
188
|
delivery_company = $("#order_"+order_id+"_delivery_company")[0].value;
|
110
189
|
$.ajax({
|
111
190
|
url: '/eric_weixin/cms/weixin/xiaodian/orders/save_delivery_info',
|
112
191
|
type: 'post',
|
113
|
-
data: {id: order_id, need_delivery: need_delivery, is_others:
|
192
|
+
data: {id: order_id, need_delivery: need_delivery, is_others: 1, delivery_track_no: delivery_track_no, delivery_company: delivery_company},
|
114
193
|
async: false
|
115
194
|
}).done(
|
116
195
|
function(result){
|
@@ -118,4 +197,10 @@
|
|
118
197
|
}
|
119
198
|
);
|
120
199
|
}
|
200
|
+
function update_delivery(id) {
|
201
|
+
$("#" + id + "_delivery_show").toggle();
|
202
|
+
$("#" + id + "_delivery_input_span").toggle();
|
203
|
+
$("#" + id + "_delivery_com_show").toggle();
|
204
|
+
$("#" + id + "_delivery_com_input_span").toggle();
|
205
|
+
}
|
121
206
|
</script>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>微信小店</title>
|
5
|
+
<%= stylesheet_link_tag "eric_weixin/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "eric_weixin/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
|
9
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
|
10
|
+
<meta content="telephone=no" name="format-detection">
|
11
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
12
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<div class="xiaodian_orders">
|
16
|
+
<% if @orders.blank? %>
|
17
|
+
<div class="no_xiaodian_order">
|
18
|
+
<div class="no_order_suggestion">
|
19
|
+
您还没有订单 _(:з」∠)_
|
20
|
+
|
21
|
+
|
22
|
+
</div>
|
23
|
+
|
24
|
+
</div>
|
25
|
+
<% else %>
|
26
|
+
<% @orders.each do |order| %>
|
27
|
+
<div class="xiaodian_order">
|
28
|
+
|
29
|
+
<div class="product_info-list">
|
30
|
+
<div class="product_info-title">
|
31
|
+
<div class="product_info-name">
|
32
|
+
<%= order.product_name %>
|
33
|
+
</div>
|
34
|
+
<div class="product_info-time">
|
35
|
+
<%= Time.at(order.order_create_time).strftime("%Y-%m-%d %H:%M") %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
<div class="product_info-description">
|
39
|
+
<div class="product_info-part">
|
40
|
+
数量:<%= order.product_count %>
|
41
|
+
</div>
|
42
|
+
<div class="product_info-part">
|
43
|
+
<% sku_info = order.sku_info.gsub(/[$]/, '$' => '') unless order.sku_info.blank? %>
|
44
|
+
<%= "(#{sku_info})" unless order.sku_info.blank? %>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<div class="user_info-list">
|
50
|
+
<div class="user_info-user">
|
51
|
+
<div class="user_info-part">
|
52
|
+
姓名:<%= order.receiver_name %>
|
53
|
+
</div>
|
54
|
+
<div class="user_info-part">
|
55
|
+
手机号:<%= order.receiver_mobile || order.receiver_phone %>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
<div class="user_info-address">
|
59
|
+
收货地址:<%= order.receiver_address %>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
|
64
|
+
<div class="delivery_info-list">
|
65
|
+
<div class="delivery_info-part">
|
66
|
+
快递信息:<%= order.delivery_company %>
|
67
|
+
</div>
|
68
|
+
<div class="delivery_info-part">
|
69
|
+
<%= order.delivery_id %>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
<% end %>
|
74
|
+
|
75
|
+
<%= will_paginate @collections, renderer: FoundationPagination::Rails %>
|
76
|
+
<% end %>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</body>
|
80
|
+
</html>
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
@@ -8,3 +8,4 @@ Rails.application.config.assets.version = '1.0'
|
|
8
8
|
# Rails.application.config.assets.precompile += %w( search.js )
|
9
9
|
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.js )
|
10
10
|
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.css )
|
11
|
+
Rails.application.config.assets.precompile += %w( eric_weixin/wz/base.css )
|