Class: Trade::My::OrdersController

Inherits:
BaseController
  • Object
show all
Includes:
ControllerOrderTypes
Defined in:
app/controllers/trade/my/orders_controller.rb

Instance Method Summary collapse

Methods included from ControllerOrderTypes

#alipay_pay, #paypal_execute, #paypal_pay, #stripe_pay, #wxpay_pay

Instance Method Details

#createObject



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

#destroyObject



85
86
87
# File 'app/controllers/trade/my/orders_controller.rb', line 85

def destroy
  @order.destroy
end

#directObject



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

#editObject



65
66
# File 'app/controllers/trade/my/orders_controller.rb', line 65

def edit
end

#edit_payment_typeObject



78
79
# File 'app/controllers/trade/my/orders_controller.rb', line 78

def edit_payment_type
end

#indexObject



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

#newObject



18
19
20
# File 'app/controllers/trade/my/orders_controller.rb', line 18

def new
  @order = current_cart.orders.build
end

#refreshObject



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

#refundObject



81
82
83
# File 'app/controllers/trade/my/orders_controller.rb', line 81

def refund
  @order.apply_for_refund
end

#showObject



53
54
# File 'app/controllers/trade/my/orders_controller.rb', line 53

def show
end

#updateObject



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

#waitObject

todo part paid case



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