From b72c93074a68b23d3776e7ab256ba5e936c3cc90 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Mar 2019 21:49:10 +0800 Subject: [PATCH] =?UTF-8?q?ecloud=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 36 ++++++++++--------- app/models/ecloud.rb | 7 ++-- .../20190312133606_add_operatime_to_ecloud.rb | 6 ++++ 3 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20190312133606_add_operatime_to_ecloud.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 077b463e..36ee0bd1 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -7,10 +7,10 @@ class EcloudController < ApplicationController # before_filter :check_sign before_filter :user_setup - before_filter :require_login, only: [:authorize] + # before_filter :require_login, only: [:authorize] - skip_before_filter :verify_authenticity_token, only: [:ps_new, :ps_edit, :ecloud_login_callback] + skip_before_filter :verify_authenticity_token, only: [:ps_new, :ps_update, :bs_new, :bs_update, :ecloud_login_callback] def index @@ -63,10 +63,11 @@ class EcloudController < ApplicationController begin ecloud = Ecloud.where(custid: params['custid']).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']) - services = params['ervices'].first - ecloud.ecloud_services.update_attributes!(packagecode: services['packagecode'], bossorderid: services['bossorderid']) + custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], + operatime: params['operatime'], effecttime: params['effecttime']) + services = params['services'].first + ecloud.ecloud_service.update_attributes!(packagecode: services['packagecode'], bossorderid: services['bossorderid']) + render :json => {result: true, errmsg: ""} rescue Exception => e logger.error(e.message) @@ -79,15 +80,15 @@ class EcloudController < ApplicationController # 用户业务开通接口 def ps_new begin - logger.info("11111######params") - ecloud_user = EcloudUser.where(:custid => params['custid'], :user_id => params['users']['userid']).first + user_param = params['users'].first + ecloud_user = EcloudUser.where(:custid => params['custid'], :userid => user_param['userid']).first if ecloud_user.present? - render :json => {code: 501, msg: "你已开通过该业务"} + render :json => {code: 500, msg: "你已开通过该业务"} else - EcloudUser.create!(custid: params['custid'], opttype: params['users']['opttype'], userid: params['users']['userid'], - username: params['users']['username'], useralias: params['users']['useralias'], - mobile: params['users']['mobile'], email: params['users']['email'], begintime: params['users']['begintime'].to_s, - endtime: params['users']['endtime'].to_s) + 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 rescue Exception => e @@ -99,12 +100,13 @@ class EcloudController < ApplicationController # 用户业务变更、销毁接口 def ps_update begin - ecloud_user = EcloudUser.where(:custid => params['custid'], :user_id => params['users']['userid']).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: params['users']['opttype']) - render :json => {code: 501, msg: "你已开通过该业务"} + ecloud_user.update_attributes(opttype: user_param['opttype']) + render :json => {success: true, errmsg: ""} else - render :json => {code: 404, errmsg: ""} + render :json => {code: 404, msg: "企业ID不存在"} end rescue Exception => e logger.error(e.message) diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index ffd2ebd6..fc23d00a 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -1,6 +1,7 @@ class Ecloud < ActiveRecord::Base attr_accessible :applyno, :begintime, :bossorderid, :custcode, :custid, :custname, :custtype, :ecordercode, :endtime, - :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email - has_one :ecloud_users - has_one :ecloud_services + :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email, + :effecttime, :operatime + has_one :ecloud_user + has_one :ecloud_service end diff --git a/db/migrate/20190312133606_add_operatime_to_ecloud.rb b/db/migrate/20190312133606_add_operatime_to_ecloud.rb new file mode 100644 index 00000000..03165771 --- /dev/null +++ b/db/migrate/20190312133606_add_operatime_to_ecloud.rb @@ -0,0 +1,6 @@ +class AddOperatimeToEcloud < ActiveRecord::Migration + def change + add_column :eclouds, :operatime, :string + add_column :eclouds, :effecttime, :string + end +end