Class: Trade::My::OrdersController
- Inherits:
-
BaseController
- Object
- BaseController
- Trade::My::OrdersController
show all
- Includes:
- ControllerOrderTypes
- Defined in:
- app/controllers/trade/my/orders_controller.rb
Instance Method Summary
collapse
#alipay_pay, #paypal_execute, #paypal_pay, #stripe_pay, #wxpay_pay
Instance Method Details
#create ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/trade/my/orders_controller.rb', line 27
def create
@order = current_cart.orders.build(order_params)
if @order.save
render 'create', locals: { return_to: my_order_url(@order) }
else
render :new, locals: { model: @order }, status: :unprocessable_entity
end
end
|
#destroy ⇒ Object
85
86
87
|
# File 'app/controllers/trade/my/orders_controller.rb', line 85
def destroy
@order.destroy
end
|
#direct ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/trade/my/orders_controller.rb', line 37
def direct
@order = current_buyer.orders.build(order_params)
respond_to do |format|
if @order.save
format.html { redirect_to my_orders_url(id: @order.id) }
format.json { render json: @order, status: :created, location: @order }
else
format.html {
redirect_back fallback_location: my_root_url
}
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end
|
#edit ⇒ Object
65
66
|
# File 'app/controllers/trade/my/orders_controller.rb', line 65
def edit
end
|
#edit_payment_type ⇒ Object
78
79
|
# File 'app/controllers/trade/my/orders_controller.rb', line 78
def edit_payment_type
end
|
#index ⇒ Object
13
14
15
16
|
# File 'app/controllers/trade/my/orders_controller.rb', line 13
def index
query_params = params.permit(:id, :payment_type, :payment_status)
@orders = current_cart.orders.default_where(query_params).order(id: :desc).page(params[:page])
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/trade/my/orders_controller.rb', line 18
def new
@order = current_cart.orders.build
end
|
#refresh ⇒ Object
22
23
24
25
|
# File 'app/controllers/trade/my/orders_controller.rb', line 22
def refresh
@order = current_cart.orders.build(myself: true)
@order.assign_attributes order_params
end
|
#refund ⇒ Object
81
82
83
|
# File 'app/controllers/trade/my/orders_controller.rb', line 81
def refund
@order.apply_for_refund
end
|
#show ⇒ Object
53
54
|
# File 'app/controllers/trade/my/orders_controller.rb', line 53
def show
end
|
#update ⇒ Object
68
69
70
71
72
73
74
75
76
|
# File 'app/controllers/trade/my/orders_controller.rb', line 68
def update
@order.assign_attributes(order_params)
if @order.save
render 'update', locals: { return_to: my_order_url(@order) }
else
render :edit, locals: { model: @order }, status: :unprocessable_entity
end
end
|
#wait ⇒ Object
57
58
59
60
61
62
63
|
# File 'app/controllers/trade/my/orders_controller.rb', line 57
def wait
if @order.all_paid?
render 'show'
else
render 'wait'
end
end
|