diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index eb81603b..650bbf58 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -5,7 +5,8 @@ require 'digest' class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token - before_filter :check_sign + before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] + before_filter :user_setup # before_filter :require_login, only: [:authorize] @@ -13,7 +14,6 @@ class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token, only: [:ps_new, :ps_update, :bs_new, :bs_update, :ecloud_login_callback] def index - render file: 'public/react-oschina/build/index.html', :layout => false end @@ -34,6 +34,7 @@ class EcloudController < ApplicationController # 企业开通 + # applyno 申请单号,唯一 # ecordercode 唯一标志一个企业的订购关系 def bs_new ActiveRecord::Base.transaction do @@ -61,7 +62,7 @@ class EcloudController < ApplicationController def bs_update ActiveRecord::Base.transaction do begin - ecloud = Ecloud.where(custid: params['custid']).first + ecloud = Ecloud.where(applyno: params['applyno']).first ecloud.update_attributes!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], operatime: params['operatime'], effecttime: params['effecttime']) @@ -77,37 +78,38 @@ class EcloudController < ApplicationController end end - # 用户业务开通接口 + # 用户业务开通与变更接口 def ps_new begin user_param = params['users'].first - ecloud_user = EcloudUser.where(:custid => params['custid'], :userid => user_param['userid']).first - if ecloud_user.present? - render :json => {code: 500, msg: "你已开通过该业务"} - else + # ecloud_user = EcloudUser.where(:custid => params['custid'], :userid => user_param['userid']).first + # if ecloud_user.present? + # render :json => {code: 500, msg: "你已开通过该业务"} + # else EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], username: user_param['username'], useralias: user_param['useralias'], mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, endtime: user_param['endtime'].to_s) render :json => {success: true, errmsg: ""} - end + # end rescue Exception => e logger.error(e.message) render :json => {code: 500, msg: "#{e.message}"} end end - # 用户业务变更、销毁接口 + # 用户业务状态变更 def ps_update begin + ecloud = Ecloud.where(applyno: params['applyno']).first user_param = params['users'].first - ecloud_user = EcloudUser.where(:custid => params['custid'], :userid => user_param['userid']).first - if ecloud_user.present? - ecloud_user.update_attributes(opttype: user_param['opttype']) + ecloud_user = ecloud.ecloud_user + + ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid']) render :json => {success: true, errmsg: ""} - else - render :json => {code: 404, msg: "企业ID不存在"} - end + # else + # render :json => {code: 404, msg: "企业ID不存在"} + # end rescue Exception => e logger.error(e.message) render :json => {code: 500, msg: "#{e.message}"} @@ -193,6 +195,6 @@ class EcloudController < ApplicationController render :json => {code: 501, msg: "sign的值错误"} return end - end + end