diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 262efb00..6792babf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -68,7 +68,8 @@ class ApplicationController < ActionController::Base def ecloud_auth ucloud_user_id euser = EcloudUser.where("id =? and opttype not in(3, 5)", ucloud_user_id).first if euser.present? # 开通过业务 - # + # ni + else false end diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index edf568a9..080b2565 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -55,12 +55,12 @@ class EcloudController < ApplicationController begin if params['opttype'] == 0 # 开通企业/个人业务 ecloud = Ecloud.create!(eloud_params) - create_service(params['services'], ecloud.try(:id)) + create_service(params['services'], ecloud.try(:id)) if params['services'].present? create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? # 为管理员添加一条记录 # 开通的时候都是用户的opttype也是0 # 如果管理员已经存在,则不用重复开通 - euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first + euser = EcloudUser.where(userid: params['userid'], custid: params['custid']).first unless euser EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], username: params['username'], useralias: params['useralias'], @@ -88,7 +88,8 @@ class EcloudController < ApplicationController elsif params['opttype'] == 1 # 业务变更 ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first # 套餐变更 - # 新增业务 + # 操作代码 0:新增业务,1:注销业务2:修改业务 + # # 新增服务 add_service = params['services'].select{|s| s['opttype'] == 0} create_service(add_service, ecloud.try(:id)) if add_service.present? @@ -106,8 +107,8 @@ class EcloudController < ApplicationController if edt_services.present? edt_services.each do |es| ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first - ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) - create_serviceparas es['serviceparas'].first, ese.id + ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) if ese.present? + create_serviceparas(es['serviceparas'].first, ese.id) if ese.present? end end @@ -120,6 +121,7 @@ class EcloudController < ApplicationController # ecloud_id = ecloud.try(:id) elsif params['opttype'] == 4 # 再次重复开通 + # 再次申请开通,这种情况就是累加时间 ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first create_service(params['services'], ecloud.try(:id)) create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb index 4a388ed4..dba4a7b2 100644 --- a/app/models/ecloud_service.rb +++ b/app/models/ecloud_service.rb @@ -1,3 +1,4 @@ +# 操作代码 0:新增业务,1:注销业务2:修改业务 class EcloudService < ActiveRecord::Base attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid belongs_to :ecloud