|
|
@ -18,6 +18,7 @@ class EcloudController < ApplicationController
|
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
|
|
|
|
|
|
|
|
# before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update]
|
|
|
|
# before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update]
|
|
|
|
|
|
|
|
before_filter :save_para
|
|
|
|
|
|
|
|
|
|
|
|
before_filter :user_setup
|
|
|
|
before_filter :user_setup
|
|
|
|
# before_filter :require_login, only: [:authorize]
|
|
|
|
# before_filter :require_login, only: [:authorize]
|
|
|
@ -45,44 +46,49 @@ class EcloudController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 企业开通
|
|
|
|
# 企业/个人业务开通
|
|
|
|
# applyno 申请单号,唯一
|
|
|
|
# applyno 申请单号,唯一
|
|
|
|
# ecordercode 唯一标志一个企业的订购关系
|
|
|
|
# ecordercode 唯一标志一个企业的订购关系
|
|
|
|
|
|
|
|
# params['opttype']:操作类型。0开通;1变更;2试用转商用;4再次开通
|
|
|
|
def bs_new
|
|
|
|
def bs_new
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
ecloud = Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'],
|
|
|
|
if params['opttype'] == 0 # 开通企业/个人业务
|
|
|
|
trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], custtype: params['custtype'],
|
|
|
|
ecloud = Ecloud.create!(eloud_params)
|
|
|
|
custcode: params['custcode'], registersource: params['registersource'], custname: params['custname'],
|
|
|
|
# 业务列表
|
|
|
|
userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'],
|
|
|
|
services = params['services']
|
|
|
|
email: params['email'], productcode: params['productcode'], begintime: params['begintime'],
|
|
|
|
if services.present?
|
|
|
|
endtime: params['endtime'])
|
|
|
|
services.each do |service|
|
|
|
|
# 业务列表
|
|
|
|
es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
|
|
|
|
services = params['services']
|
|
|
|
endtime: service['endtime'], ecloud_id: ecloud.try(:id))
|
|
|
|
if services.present?
|
|
|
|
if service['serviceparas'].present?
|
|
|
|
services.each do |service|
|
|
|
|
service['serviceparas'].each do |servicepara|
|
|
|
|
es = EcloudService.create(opttype: service['opttype'], code: service['code'], begintime: service['begintime'],
|
|
|
|
EcloudServieceServicepara.create!(ecloud_service_id: es.id, key: servicepara['key'], value: servicepara['value'])
|
|
|
|
endtime: service['endtime'], ecloud_id: ecloud.try(:id))
|
|
|
|
end
|
|
|
|
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.try(:id))
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 为管理员单独创建一条账号,企业账号
|
|
|
|
# 为管理员单独创建一条账号,企业账号
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
render :json => {result: true, errmsg: ""}
|
|
|
|
render :json => {result: true, errmsg: ""}
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
@ -93,11 +99,11 @@ class EcloudController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 企业更新
|
|
|
|
# 企业/个人业务变更、注销
|
|
|
|
def bs_update
|
|
|
|
def bs_update
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
ecloud = Ecloud.where(applyno: params['applyno']).first
|
|
|
|
ecloud = Ecloud.where(custid: params['custid']).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'])
|
|
|
@ -227,6 +233,16 @@ class EcloudController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|
|
|
|
|
def eloud_params
|
|
|
|
|
|
|
|
return {applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'],
|
|
|
|
|
|
|
|
trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], custtype: params['custtype'],
|
|
|
|
|
|
|
|
custcode: params['custcode'], registersource: params['registersource'], custname: params['custname'],
|
|
|
|
|
|
|
|
userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'],
|
|
|
|
|
|
|
|
email: params['email'], productcode: params['productcode'], begintime: params['begintime'],
|
|
|
|
|
|
|
|
endtime: params['endtime']}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_sign
|
|
|
|
def check_sign
|
|
|
|
sign = sign(params['timestamp'])
|
|
|
|
sign = sign(params['timestamp'])
|
|
|
|
if sign != params['sign']
|
|
|
|
if sign != params['sign']
|
|
|
@ -235,4 +251,8 @@ class EcloudController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_para
|
|
|
|
|
|
|
|
EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'], custcode: params['custcode'])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|