update_intro_user.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #encoding
  2. module RailsAdmin
  3. module Config
  4. module Actions
  5. class UpdateIntroUser < RailsAdmin::Config::Actions::Base
  6. register_instance_option :visible? do
  7. authorized?
  8. end
  9. register_instance_option :member do
  10. true
  11. end
  12. register_instance_option :link_icon do
  13. 'icon-share'
  14. end
  15. register_instance_option :pjax? do
  16. false
  17. end
  18. register_instance_option :controller do
  19. Proc.new do
  20. require 'rest-client'
  21. wx_user = WxUser.where("id = ? and show_invite_mode = ?",@object.id, 0).first
  22. n = "此状态不支持操作"
  23. if not wx_user.blank?
  24. n = "已成功升级"
  25. url = "#{CONFIG_FILE["api_host"]}/railsadmin/update/intro/#{@object.id}"
  26. begin
  27. ret = RestClient.get url, {} #per_page: 5
  28. rescue Exception => e
  29. n = "升级失败!"
  30. end
  31. end
  32. new_wx_user = WxUser.where("id = ? ",@object.id).first
  33. if new_wx_user.id==1
  34. n = "已成功整理关系!"
  35. url = "#{CONFIG_FILE["api_host"]}/v1/cron/comb_three_user"
  36. begin
  37. ret = RestClient.get url, {} #per_page: 5
  38. rescue Exception => e
  39. n = "升级失败!"
  40. end
  41. end
  42. redirect_to :back, notice: "#{n}"
  43. end
  44. end
  45. end
  46. end
  47. end
  48. end