Commit df42df0a by ivan Lan

Finish Merchant Order Controller

parent 21ab10da
json.current_page @orders.current_page
json.total_pages @orders.total_pages
json.current_page @resources.current_page
json.total_pages @resources.total_pages
json.set! @resources.klass.model_name.collection do
json.array! @resources, partial: 'shotengai/share/order_simple', as: :order
end
\ No newline at end of file
json.partial! "shotengai/share/order_simple", order: @resource
json.partial! "shotengai/share/order", order: @resource
......@@ -3,4 +3,4 @@ json.extract! order, :id, :seq, :status_zh, :address,
:delivery_way, :delivery_cost,
:merchant_remark, :mark, :customer_remark,
:status, :status_zh, :meta
json.snapshots, partial: 'shotengai/share/snapshot_simple', as: :series
\ No newline at end of file
json.snapshots order.snapshots, partial: 'shotengai/share/snapshot_simple', as: :snapshot
\ No newline at end of file
......@@ -59,9 +59,20 @@ module Shotengai
respond_to :json
# TODO: could not catch the exception
# rescue_from Shotengai::WebError do |e|
# render json: { error: e.message }, status: e.status
# end
respond_to :json
rescue_from ::Shotengai::WebError do |e|
render json: { error: e.message }, status: e.status
end
rescue_from ActiveRecord::RecordInvalid do |e|
render json: { error: e.message }, status: 400
end
rescue_from AASM::InvalidTransition do |e|
render json: { error: e.message }, status: 400
end
def index
page = params[:page] || 1
......
......@@ -2,7 +2,26 @@ module Shotengai
module Controller
module Merchant
class OrdersController < Shotengai::Controller::Base
self.resources = Order
self.template_dir = 'shotengai/merchant/orders/'
remove_actions :create, :destroy
index_query do |resource, params|
resource.status_is(params[:status])
end
def send_out
@resource.send_out!
respond_with @resource, template: "#{@@template_dir}/show"
end
private
def resource_params
params.require(resource_key).permit(
:merchant_remark, :mark
)
end
end
end
end
......
......@@ -12,7 +12,6 @@ module Shotengai
end
index_query do |resource, params|
# where(nil) will skip the where
resource.where(
params[:order_id] && { shotengai_order_id: params[:order_id] }
).where(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment