diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 9af476cf..096275bb 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -81,15 +81,13 @@ class EcloudController < ApplicationController # 用户业务开通与变更接口 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 - 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, status: 1) + user_params = params['users'] + user_params.each do |user_param| + 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, status: 1) + end render :json => {success: true, errmsg: ""} # end rescue Exception => e @@ -99,13 +97,15 @@ class EcloudController < ApplicationController end # 用户业务状态变更 + # 授权statu为1,取消授权status为0 def ps_update begin - ecloud = Ecloud.where(applyno: params['applyno']).first - user_param = params['users'].first - ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first + user_params = params['users'] + user_params.each do |user_param| + ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first + ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0) + end - ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0) render :json => {success: true, errmsg: ""} # else # render :json => {code: 404, msg: "企业ID不存在"}