Class: EricWeixin::Cms::Weixin::Xiaodian::OrdersController
- Inherits:
-
BaseController
- Object
- BaseController
- EricWeixin::Cms::Weixin::Xiaodian::OrdersController
- Defined in:
- app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb
Instance Method Summary collapse
- #download_orders ⇒ Object
- #index ⇒ Object
- #save_delivery_info ⇒ Object
- #update_delivery_info_by_excel ⇒ Object
- #update_hb_infos ⇒ Object
- #update_order_infos ⇒ Object
Instance Method Details
#download_orders ⇒ Object
27 28 29 30 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 27 def download_orders file_name = EricWeixin::Xiaodian::Order.get_excel_of_orders params.permit(:start_date, :end_date, :deliver_status, :buyer_nick, :receiver_name, :receiver_mobile) send_file file_name end |
#index ⇒ Object
2 3 4 5 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 2 def index @orders = EricWeixin::Xiaodian::Order.order_query params @orders = @orders.order(order_create_time: :desc).paginate(per_page: params[:per_page]||6, page: params[:page]||1) end |
#save_delivery_info ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 7 def save_delivery_info begin order = EricWeixin::Xiaodian::Order.find_by_id(params[:id]) if order.blank? render text: 'order的ID不正确。' return end = {} ["delivery_company"] = params[:delivery_company] ["delivery_track_no"] = params[:delivery_track_no] ["need_delivery"] = params[:need_delivery].to_i ["is_others"] = params[:is_others].to_i result = order.set_delivery render text: result ? '成功' : '失败' rescue Exception=>e dispose_exception e render text: "保存失败: #{get_notice_str}" end end |
#update_delivery_info_by_excel ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 50 def update_delivery_info_by_excel begin if params[:file].blank? flash[:alert] = '请先选择文件,再更新快递单信息' redirect_to action: :index return end flash[:success] = EricWeixin::Xiaodian::Order.update_delivery_info_by_excel params[:file] redirect_to action: :index rescue Exception=> e dispose_exception e flash[:alert] = get_notice_str redirect_to action: :index end end |
#update_hb_infos ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 32 def update_hb_infos EricWeixin::RedpackOrder.delay(priority: 10).update_info_from_wx params[:public_account_id] flash[:success] = '已经将更新红包任务放到队列' redirect_to action: :index end |
#update_order_infos ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb', line 38 def update_order_infos # 默认更新本月订单 params[:start_date] ||= Time.now.beginning_of_month params[:end_date] ||= Time.now.end_of_month params[:start_date] = params[:start_date].to_date.change(hour:0,min:0,sec:0) params[:end_date] = params[:end_date].to_date.change(hour:23,min:59,sec:59) EricWeixin::Xiaodian::Order.delay(priority: 10).update_order_infos params[:start_date], params[:end_date] flash[:success] = '已经将更新订单信息的任务放到队列' redirect_to action: :index end |