takecash_at_once.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # encoding:utf-8
  2. # 立即提现
  3. module RailsAdmin
  4. module Config
  5. module Actions
  6. class TakecashAtOnce < RailsAdmin::Config::Actions::Base
  7. register_instance_option :visible? do
  8. if not bindings[:object].blank?
  9. authorized? && bindings[:object].audit_state == 1 && bindings[:object].pay_state ==0 && [nil,0].include?(bindings[:object].paied_at)
  10. else
  11. authorized?
  12. end
  13. end
  14. # We want the action on members, not the Users collection
  15. register_instance_option :member do
  16. true
  17. end
  18. register_instance_option :link_icon do
  19. 'icon-plane'
  20. end
  21. # You may or may not want pjax for your action
  22. register_instance_option :pjax? do
  23. false
  24. end
  25. register_instance_option :controller do
  26. Proc.new do
  27. if @object.audit_state == 1 && @object.pay_state ==0 && [nil,0].include?(@object.paied_at)
  28. @object.update_attribute(:expc_pay_at, Time.now)
  29. end
  30. # redirect_to back_or_index, notice: "已提现"
  31. redirect_to :back,notice: "已提现"
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end