-
Notifications
You must be signed in to change notification settings - Fork 19
Store v2 solution #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xdite
wants to merge
11
commits into
store-v2-class
Choose a base branch
from
store-v2-solution
base: store-v2-class
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6f1154b
add v2-#1 TODO
xdite 499a9b1
✔ 清空購物⾞ @done (14-06-20 00:36)
xdite 9cf6e97
✔ 身為消費者,我可以從購物車內刪掉某些物品 @done (14-06-20 00:41)
xdite 1c8272a
add quantity to cart_items
xdite ca8ad31
✔ 身為消費者,我可以從購物車內更新購買數量 @done (14-06-20 00:54)
xdite 6cd3e92
數量為 0 的貨物不能「購買」 @done (14-06-20 00:56)
xdite 98b26a5
✔ 身為消費者,當我在結賬後,購物⾞應自動清空 @done (14-06-20 01:01)
xdite 698f9ef
建立 account/orders 可以看到該使用者過去所有訂單
xdite 8fe15e6
✔ 結賬後跳轉到 account/orders#index @done (14-06-20 01:10)
xdite 95378f4
✔ 身為管理者,可以在後台看訂單,訂單狀態分為未結帳、已結帳、出貨中、已出貨、辦理退貨 @done (14-06-20 01:27)
xdite f9f4c49
✔ 身為管理者,我可以在後台對單張訂單做狀態改變 @done (14-06-20 01:56)
xdite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Place all the behaviors and hooks related to the matching controller here. | ||
| # All this logic will automatically be available in application.js. | ||
| # You can use CoffeeScript in this file: http://coffeescript.org/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the account::orders controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the admin::orders controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Place all the styles related to the cart_items controller here. | ||
| // They will automatically be included in application.css. | ||
| // You can use Sass (SCSS) here: http://sass-lang.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| class Account::OrdersController < ApplicationController | ||
|
|
||
| before_action :authenticate_user! | ||
|
|
||
| def index | ||
| @orders = current_user.orders.recent | ||
| end | ||
|
|
||
|
|
||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| class Admin::OrdersController < AdminController | ||
|
|
||
| before_filter :find_order, :except => [:index] | ||
|
|
||
| def index | ||
| @orders = Order.recent | ||
| end | ||
|
|
||
|
|
||
| def show | ||
|
|
||
| @order_info = @order.info | ||
| @order_items = @order.items | ||
| end | ||
|
|
||
| def ship | ||
| @order.ship! | ||
| redirect_to :back | ||
| end | ||
|
|
||
| def shipped | ||
| @order.deliver! | ||
| redirect_to :back | ||
| end | ||
|
|
||
| def cancel | ||
| @order.cancell_order! | ||
| redirect_to :back | ||
| end | ||
|
|
||
| def return | ||
| @order.return_good! | ||
| redirect_to :back | ||
| end | ||
|
|
||
| protected | ||
|
|
||
|
|
||
| def find_order | ||
| @order = Order.find_by_token(params[:id]) | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| class CartItemsController < ApplicationController | ||
| before_action :authenticate_user! | ||
|
|
||
|
|
||
| def update | ||
| @cart = current_cart | ||
| @item = @cart.cart_items.find(params[:id]) | ||
|
|
||
| @item.update(item_params) | ||
|
|
||
| redirect_to carts_path | ||
| end | ||
|
|
||
|
|
||
| def destroy | ||
| @cart = current_cart | ||
| @item = @cart.cart_items.find(params[:id]) | ||
|
|
||
| @item.destroy | ||
|
|
||
| flash[:warning] = "成功清空物品" | ||
| redirect_to :back | ||
|
|
||
| end | ||
|
|
||
| private | ||
|
|
||
| def item_params | ||
| params.require(:cart_item).permit(:quantity) | ||
| end | ||
|
|
||
| end |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module Account::OrdersHelper | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| module Admin::OrdersHelper | ||
|
|
||
| def render_order_options_for_admin(order) | ||
|
|
||
| render :partial => "admin/orders/state_option", :locals => { :order => order} | ||
|
|
||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module CartItemsHelper | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,23 @@ | ||
| module OrdersHelper | ||
|
|
||
| def render_order_link(order) | ||
| link_to(order.token, order_path(order.token)) | ||
| end | ||
|
|
||
| def render_admin_order_link(order) | ||
| link_to(order.token, admin_order_path(order.token)) | ||
| end | ||
|
|
||
| def render_order_created_time(order) | ||
| order.created_at.to_s(:short) | ||
| end | ||
|
|
||
|
|
||
| def render_order_user_name(user) | ||
| user.email | ||
| end | ||
|
|
||
| def render_order_state(order) | ||
| t("orders.order_state.#{order.aasm_state}") | ||
| end | ||
| end |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
|
|
||
| <h2>訂單列表 </h2> | ||
|
|
||
|
|
||
| <table class="table table-bordered"> | ||
| <thead> | ||
| <tr> | ||
| <th>#</th> | ||
| <th>生成時間</th> | ||
|
|
||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @orders.each do |order| %> | ||
| <tr> | ||
| <td> <%= render_order_link(order) %> </td> | ||
| <td> <%= render_order_created_time(order) %> </td> | ||
| </tr> | ||
| <% end %> | ||
|
|
||
| </tbody> | ||
| </table> | ||
|
|
||
|
|
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
|
|
||
| <div style="padding:10px; float:right;"> | ||
| <% case order.aasm_state %> | ||
| <% when "order_placed" %> | ||
| <%= link_to("取消訂單", cancel_admin_order_path(order.token) , :class => "btn btn-default btn-sm", :method => :post) %> | ||
|
|
||
| <% when "paid" %> | ||
| <%= link_to("取消訂單", cancel_admin_order_path(order.token) , :class => "btn btn-default btn-sm", :method => :post) %> | ||
| <%= link_to("出貨", ship_admin_order_path(order.token) , :class => "btn btn-default btn-sm", :method => :post) %> | ||
| <% when "shipping" %> | ||
| <%= link_to("設為已出貨", shipped_admin_order_path(order.token), :class => "btn btn-default btn-sm", :method => :post) %> | ||
| <% when "shipped" %> | ||
| <%= link_to("退貨", return_admin_order_path(order.token), :class => "btn btn-default btn-sm", :method => :post) %> | ||
|
|
||
| <% when "order_cancelled" %> | ||
| <span class="label label-default">訂單已取消</span> | ||
| <% when "good_returned" %> | ||
| <span class="label label-default">已退貨</span> | ||
|
|
||
| <% end %> | ||
|
|
||
| </div> | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
|
|
||
| <h2>訂單列表 </h2> | ||
|
|
||
|
|
||
| <table class="table table-bordered"> | ||
| <thead> | ||
| <tr> | ||
| <th>#</th> | ||
| <th>生成時間</th> | ||
| <th>訂購者</th> | ||
| <th>訂單狀態</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @orders.each do |order| %> | ||
| <tr> | ||
| <td> <%= render_admin_order_link(order) %> </td> | ||
| <td> <%= render_order_created_time(order) %> </td> | ||
| <td> <%= render_order_user_name(order.user) %></td> | ||
| <td> <%= render_order_state(order) %> </td> | ||
| </tr> | ||
| <% end %> | ||
|
|
||
| </tbody> | ||
| </table> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
請問 看起來在這個地方 是不是應該還會有 後續處理 寄出 EMAIL 通知 信用卡付款成功的信件的相關動作的程式呢?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個在第三周