|
|
|
@ -50,6 +50,7 @@ class EcloudController < ApplicationController
|
|
|
|
|
# applyno 申请单号,唯一
|
|
|
|
|
# ecordercode 唯一标志一个企业的订购关系
|
|
|
|
|
# params['opttype']:操作类型。0开通;1变更;2试用转商用;4再次开通
|
|
|
|
|
# 业务列表opttype: 0新增;1注销;2修改
|
|
|
|
|
def bs_new
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
@ -58,11 +59,23 @@ class EcloudController < ApplicationController
|
|
|
|
|
ecloud = Ecloud.create!(eloud_params)
|
|
|
|
|
ecloud_id = ecloud.try(:id)
|
|
|
|
|
elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
|
|
|
|
|
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
|
|
|
|
|
ecloud.update_attributes!(eloud_params)
|
|
|
|
|
ecloud.ecloud_productparas.destroy
|
|
|
|
|
ecloud.ecloud_services.destroy
|
|
|
|
|
ecloud_id = ecloud.try(:id)
|
|
|
|
|
# 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐)
|
|
|
|
|
# 需要通过产品服务编号和业务编码来区分哪个产品
|
|
|
|
|
ecloud = Ecloud.where(productcode: params['productcode'], trial: true).first
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 注销试用的套餐
|
|
|
|
|
## 需要注销的套餐; 试用转商用是不会有批量操作的,所以可以使用first
|
|
|
|
|
des_service = params['services'].select{|s| s['opttype'] == 1}.first
|
|
|
|
|
esd = EcloudService.where(ecloud_id: ecloud.try(:id), code: des_service['code']).first
|
|
|
|
|
ecloud.update_attribute(:trial, false)
|
|
|
|
|
esd.update_attributes!(opttype: des_service['opttype'], begintime: des_service['begintime'], endtime: des_service['endtime'])
|
|
|
|
|
|
|
|
|
|
# 试用转商用是不会有批量操作的
|
|
|
|
|
# 新增业务
|
|
|
|
|
add_servide = params['services'].select{|s| s['opttype'] == 0}.first
|
|
|
|
|
create_service(add_servide, ecloud_id)
|
|
|
|
|
|
|
|
|
|
elsif params['opttype'] == 1 # 业务变更
|
|
|
|
|
ecloud = Ecloud.where(bossorderid: params['bossorderid']).first
|
|
|
|
|
ecloud.update_attributes!(eloud_params)
|
|
|
|
@ -76,34 +89,34 @@ class EcloudController < ApplicationController
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 应用开通参数
|
|
|
|
|
productparas = params['productparas']
|
|
|
|
|
if productparas.present?
|
|
|
|
|
productparas.each do |productpara|
|
|
|
|
|
EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud_id)
|
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 非试用情况下,为管理员单独创建一条账号,企业账号
|
|
|
|
|
unless params['trial']
|
|
|
|
|
EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'],
|
|
|
|
|
username: params['username'], useralias: params['useralias'],
|
|
|
|
|
mobile: params['mobile'], email: params['email'])
|
|
|
|
|
end
|
|
|
|
|
# # 应用开通参数
|
|
|
|
|
# productparas = params['productparas']
|
|
|
|
|
# if productparas.present?
|
|
|
|
|
# productparas.each do |productpara|
|
|
|
|
|
# EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud_id)
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
#
|
|
|
|
|
# # 非试用情况下,为管理员单独创建一条账号,企业账号
|
|
|
|
|
# unless params['trial']
|
|
|
|
|
# EcloudUser.create!(ecloud_id: ecloud.try(:id), opttype: params['opttype'], userid: params['userid'],
|
|
|
|
|
# username: params['username'], useralias: params['useralias'],
|
|
|
|
|
# mobile: params['mobile'], email: params['email'])
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
render :json => {result: true, errmsg: ""}
|
|
|
|
|
rescue Exception => e
|
|
|
|
@ -257,6 +270,11 @@ class EcloudController < ApplicationController
|
|
|
|
|
endtime: params['endtime']}
|
|
|
|
|
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)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def check_sign
|
|
|
|
|
sign = sign(params['timestamp'])
|
|
|
|
|