重构业务新增

dev_shixuns
huang 6 years ago
parent 8b62caf8a6
commit 2e0c9faf47

@ -57,13 +57,12 @@ class EcloudController < ApplicationController
ecloud_id = 0
if params['opttype'] == 0 # 开通企业/个人业务
ecloud = Ecloud.create!(eloud_params)
ecloud_id = ecloud.try(:id)
create_service(params['services'], ecloud_id, params['productcode'])
elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
# 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐)
# 需要通过产品服务编号和业务编码来区分哪个产品
ecloud = Ecloud.where(productcode: params['productcode'], trial: true).first
# 注销试用的套餐
## 需要注销的套餐; 试用转商用是不会有批量操作的所以可以使用first
des_service = params['services'].select{|s| s['opttype'] == 1}.first
@ -77,12 +76,19 @@ class EcloudController < ApplicationController
create_service(add_servide, ecloud_id)
elsif params['opttype'] == 1 # 业务变更
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
ecloud.update_attributes!(eloud_params)
ecloud.ecloud_productparas.destroy
ecloud.ecloud_services.destroy
# 套餐变更
params['services'].each do |service|
end
ecloud_id = ecloud.try(:id)
# ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
# ecloud.update_attributes!(eloud_params)
# ecloud.ecloud_productparas.destroy
# ecloud.ecloud_services.destroy
#
# ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 4 # 再次重复开通
REDO
@ -271,9 +277,11 @@ class EcloudController < ApplicationController
end
# 新增套餐
def create_service service, ecloud_id
EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
endtime: service['endtime'], ecloud_id: ecloud_id)
def create_service services, ecloud_id, productcode
services.each do |service|
EcloudService.create!(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
endtime: service['endtime'], ecloud_id: ecloud_id, productcode: productcode)
end
end
def check_sign

@ -1,5 +1,5 @@
class EcloudService < ActiveRecord::Base
attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid
attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid, :productcode
belongs_to :ecloud
has_many :ecloud_serviece_serviceparas
end

@ -0,0 +1,5 @@
class AddProductcodeToUcloudService < ActiveRecord::Migration
def change
add_column :ecloud_services, :productcode, :string
end
end
Loading…
Cancel
Save