未完待续

dev_SaaS
huang 6 years ago
parent 03b67d1b4d
commit 4c58e97d94

@ -53,41 +53,56 @@ class EcloudController < ApplicationController
def bs_new def bs_new
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
ecloud_id = 0
if params['opttype'] == 0 # 开通企业/个人业务 if params['opttype'] == 0 # 开通企业/个人业务
ecloud = Ecloud.create!(eloud_params) ecloud = Ecloud.create!(eloud_params)
# 业务列表 ecloud_id = ecloud.try(:id)
services = params['services'] elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
if services.present? ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
services.each do |service| ecloud.update_attributes!(eloud_params)
es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'], ecloud.ecloud_productparas.destroy
endtime: service['endtime'], ecloud_id: ecloud.try(:id)) ecloud.ecloud_services.destroy
if service['serviceparas'].present? ecloud_id = ecloud.try(:id)
service['serviceparas'].each do |servicepara| elsif params['opttype'] == 1 # 业务变更
EcloudServieceServicepara.create!(ecloud_service_id: es.id, key: servicepara['key'], value: servicepara['value']) ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
end ecloud.update_attributes!(eloud_params)
ecloud.ecloud_productparas.destroy
ecloud.ecloud_services.destroy
ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 4 # 再次重复开通
REDO
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
end
# 业务列表
services = params['services']
if services.present?
services.each do |service|
es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
endtime: service['endtime'], ecloud_id: ecloud_id)
if service['serviceparas'].present?
service['serviceparas'].each do |servicepara|
EcloudServieceServicepara.create!(ecloud_service_id: es.id, key: servicepara['key'], value: servicepara['value'])
end end
end end
end end
end
# 应用开通参数 # 应用开通参数
productparas = params['productparas'] productparas = params['productparas']
if productparas.present? if productparas.present?
productparas.each do |productpara| productparas.each do |productpara|
EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud.try(:id)) EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud_id)
end
end end
end
# 为管理员单独创建一条账号,企业账号 # 非试用情况下,为管理员单独创建一条账号,企业账号
unless params['trial']
EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'], EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'],
username: params['username'], useralias: params['useralias'], username: params['username'], useralias: params['useralias'],
mobile: params['mobile'], email: params['email']) mobile: params['mobile'], email: params['email'])
elsif params['opttype'] == 1 # 变更企业/个人业务
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
ecloud.update_attributes!(eloud_params)
ecloud.ecloud_productparas.destroy
ecloud.ecloud_service.destroy
end end
render :json => {result: true, errmsg: ""} render :json => {result: true, errmsg: ""}
@ -103,7 +118,7 @@ class EcloudController < ApplicationController
def bs_update def bs_update
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
ecloud = Ecloud.where(custid: params['custid']).first ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
ecloud.update_attributes!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], ecloud.update_attributes!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'],
custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'],
operatime: params['operatime'], effecttime: params['effecttime']) operatime: params['operatime'], effecttime: params['effecttime'])

@ -4,8 +4,8 @@ class Ecloud < ActiveRecord::Base
:mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email, :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email,
:effecttime, :operatime :effecttime, :operatime
has_many :ecloud_service # 业务列表 has_many :ecloud_services, :dependent => :destroy # 业务列表
has_many :ecloud_productparas # 开通参数列表 has_many :ecloud_productparas, :dependent => :destroy # 开通参数列表
has_one :ecloud_user has_one :ecloud_user
end end

Loading…
Cancel
Save