shopqi-app-webhook 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb +2 -0
- data/lib/generators/shopqi_app_webhook/templates/app/controllers/home_controller.rb +11 -0
- data/lib/generators/shopqi_app_webhook/templates/app/controllers/webhook_controller.rb +10 -1
- data/lib/generators/shopqi_app_webhook/templates/app/models/order.rb +5 -1
- data/lib/generators/shopqi_app_webhook/templates/app/views/home/index.html.haml +18 -0
- data/lib/generators/shopqi_app_webhook/templates/db/migrate/create_orders.rb +10 -6
- data/lib/shopqi_app_webhook/version.rb +1 -1
- metadata +6 -5
- data/app/views/layouts/shopqi_app_webhook/application.html.erb +0 -14
@@ -16,6 +16,8 @@ class ShopQiAppWebhookGenerator < Rails::Generators::Base
|
|
16
16
|
def update_files
|
17
17
|
prepend_to_file "app/models/shop.rb", "require \"\#{ShopQiAppWebhook::Engine.models_dir}/shop\"\n"
|
18
18
|
insert_into_file "app/models/shop.rb", "\s\shas_many :orders\n", after: /class Shop( < ActiveRecord::Base){0,1}\n/
|
19
|
+
insert_into_file "config/app_secret_config.yml", "\s\s\s\shost: 'lvh.me:3000'\n", after: /defaults:(.|\n|\s)+?domain:\n/
|
20
|
+
insert_into_file "config/app_secret_config.yml", "\s\s\s\shost: 'example.shopqiapp.com'\n", after: /production:(.|\n|\s)+?domain:\n/
|
19
21
|
end
|
20
22
|
|
21
23
|
def install_migration
|
@@ -2,7 +2,16 @@ class WebhookController < ShopQiAppWebhook::WebhookController
|
|
2
2
|
|
3
3
|
def orders_fulfilled
|
4
4
|
attrs = JSON(request.body.read)['order']
|
5
|
-
shop.orders.where(order_id: order_id).first_or_create!
|
5
|
+
shop.orders.where(order_id: order_id).first_or_create!({
|
6
|
+
name: attrs['name'],
|
7
|
+
financial_status_name: attrs['financial_status_name'],
|
8
|
+
financial_status: attrs['financial_status'],
|
9
|
+
fulfillment_status: attrs['fulfillment_status'],
|
10
|
+
fulfillment_status_name: attrs['fulfillment_status_name'],
|
11
|
+
order_id: attrs['id'],
|
12
|
+
total_price: attrs['total_price'],
|
13
|
+
created_at: attrs['created_at']
|
14
|
+
})
|
6
15
|
render nothing: true
|
7
16
|
end
|
8
17
|
|
@@ -1,4 +1,8 @@
|
|
1
1
|
class Order < ActiveRecord::Base
|
2
2
|
belongs_to :shop
|
3
|
-
attr_accessible :name, :order_id, :total_price, :created_at
|
3
|
+
attr_accessible :name, :financial_status, :financial_status_name, :fulfillment_status, :fulfillment_status_name, :order_id, :total_price, :created_at
|
4
|
+
|
5
|
+
def admin_url
|
6
|
+
"#{SecretSetting.shopqi_domain.protocol}#{shop.shopqi_domain}/admin/orders/#{order_id}"
|
7
|
+
end
|
4
8
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
.content
|
2
|
+
%h2 最近订单
|
3
|
+
%table.table.table-striped
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th 订单号
|
7
|
+
%th 支付状态
|
8
|
+
%th 发货状态
|
9
|
+
%th 总金额
|
10
|
+
%tbody
|
11
|
+
-@orders.each do |order|
|
12
|
+
%tr
|
13
|
+
%td=link_to order.name, order.admin_url, target: :_blank
|
14
|
+
%td
|
15
|
+
%span.label{class: financial_class(order.financial_status)}=order.financial_status_name
|
16
|
+
%td
|
17
|
+
%span.label{class: fulfillment_class(order.fulfillment_status)}=order.fulfillment_status_name
|
18
|
+
%td=order.total_price
|
@@ -1,12 +1,16 @@
|
|
1
1
|
class CreateOrders < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :orders do |t|
|
4
|
-
t.references :shop
|
5
|
-
t.integer :order_id
|
6
|
-
t.string :name
|
7
|
-
t.
|
8
|
-
t.
|
4
|
+
t.references :shop , null: false
|
5
|
+
t.integer :order_id , null: false, unique: true
|
6
|
+
t.string :name , null: false, limit: 32
|
7
|
+
t.string :financial_status , null: false, limit: 16
|
8
|
+
t.string :financial_status_name , null: false, limit: 32
|
9
|
+
t.string :fulfillment_status , null: false, limit: 16
|
10
|
+
t.string :fulfillment_status_name, null: false, limit: 32
|
11
|
+
t.float :total_price , null: false
|
12
|
+
t.datetime :created_at , null: false
|
9
13
|
end
|
10
|
-
add_index :orders, :
|
14
|
+
add_index :orders, :order_id, unique: true
|
11
15
|
end
|
12
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopqi-app-webhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -152,11 +152,12 @@ files:
|
|
152
152
|
- app/models/shop.rb
|
153
153
|
- app/assets/javascripts/shopqi_app_webhook/application.js
|
154
154
|
- app/assets/stylesheets/shopqi_app_webhook/application.css
|
155
|
-
- app/views/layouts/shopqi_app_webhook/application.html.erb
|
156
155
|
- lib/generators/shopqi_app_webhook/templates/db/migrate/create_orders.rb
|
157
156
|
- lib/generators/shopqi_app_webhook/templates/app/jobs/webhook_worker.rb
|
158
157
|
- lib/generators/shopqi_app_webhook/templates/app/controllers/webhook_controller.rb
|
158
|
+
- lib/generators/shopqi_app_webhook/templates/app/controllers/home_controller.rb
|
159
159
|
- lib/generators/shopqi_app_webhook/templates/app/models/order.rb
|
160
|
+
- lib/generators/shopqi_app_webhook/templates/app/views/home/index.html.haml
|
160
161
|
- lib/generators/shopqi_app_webhook/templates/README
|
161
162
|
- lib/generators/shopqi_app_webhook/shopqi_app_webhook_generator.rb
|
162
163
|
- lib/generators/shopqi_app_webhook/USAGE
|
@@ -182,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
segments:
|
184
185
|
- 0
|
185
|
-
hash:
|
186
|
+
hash: 272106625
|
186
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
188
|
none: false
|
188
189
|
requirements:
|
@@ -191,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
192
|
version: '0'
|
192
193
|
segments:
|
193
194
|
- 0
|
194
|
-
hash:
|
195
|
+
hash: 272106625
|
195
196
|
requirements: []
|
196
197
|
rubyforge_project:
|
197
198
|
rubygems_version: 1.8.24
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>ShopQiAppWebhook</title>
|
5
|
-
<%= stylesheet_link_tag "shopqi_app_webhook/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "shopqi_app_webhook/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|