|
|
@ -1,4 +1,16 @@
|
|
|
|
#encoding=utf-8
|
|
|
|
#encoding=utf-8
|
|
|
|
|
|
|
|
# 云启训练场(EduCoder)个人版 产品编码(appId) 9200108
|
|
|
|
|
|
|
|
# 产品名称 计费类型 套餐编码
|
|
|
|
|
|
|
|
# 云启训练场(EduCoder)个人版 固定包月 9200108001
|
|
|
|
|
|
|
|
# 固定包月 9200108002
|
|
|
|
|
|
|
|
# 固定包月 9200108003
|
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
|
|
|
|
# 产品名称 计费类型 套餐编码
|
|
|
|
|
|
|
|
# 云启训练场(EduCoder))院校版 包月+按license 9200109001
|
|
|
|
|
|
|
|
# 包月+按license 9200109002
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 云启训练场(EduCoder))院校版 产品编码(appId) 9200109
|
|
|
|
|
|
|
|
|
|
|
|
require 'net/http'
|
|
|
|
require 'net/http'
|
|
|
|
require 'digest'
|
|
|
|
require 'digest'
|
|
|
|
|
|
|
|
|
|
|
@ -6,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]
|
|
|
@ -30,21 +43,65 @@ class EcloudController < ApplicationController
|
|
|
|
Digest::MD5.hexdigest("client_id=#{CLIENT_ID}client_key=#{CLIENT_SECRET}timestamp=#{timestamp}").upcase
|
|
|
|
Digest::MD5.hexdigest("client_id=#{CLIENT_ID}client_key=#{CLIENT_SECRET}timestamp=#{timestamp}").upcase
|
|
|
|
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'],
|
|
|
|
ecloud_id = 0
|
|
|
|
trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], custtype: params['custtype'],
|
|
|
|
if params['opttype'] == 0 # 开通企业/个人业务
|
|
|
|
custcode: params['custcode'], registersource: params['registersource'], custname: params['custname'],
|
|
|
|
ecloud = Ecloud.create!(eloud_params)
|
|
|
|
userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'],
|
|
|
|
ecloud_id = ecloud.try(:id)
|
|
|
|
email: params['email'], productcode: params['productcode'], begintime: params['begintime'],
|
|
|
|
elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
|
|
|
|
endtime: params['endtime'])
|
|
|
|
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first
|
|
|
|
services = params['services'].first
|
|
|
|
ecloud.update_attributes!(eloud_params)
|
|
|
|
EcloudService.create(opttype: services['opttype'], code: services['code'], begintime: services['begintime'],
|
|
|
|
ecloud.ecloud_productparas.destroy
|
|
|
|
endtime: services['endtime'], ecloud_id: ecloud.try(:id))
|
|
|
|
ecloud.ecloud_services.destroy
|
|
|
|
|
|
|
|
ecloud_id = ecloud.try(: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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 应用开通参数
|
|
|
|
|
|
|
|
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: ""}
|
|
|
|
render :json => {result: true, errmsg: ""}
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
@ -55,11 +112,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'], 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'])
|
|
|
@ -76,6 +133,7 @@ class EcloudController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 用户业务开通与变更接口
|
|
|
|
# 用户业务开通与变更接口
|
|
|
|
|
|
|
|
# 授权statu为1,取消授权status为0
|
|
|
|
def ps_new
|
|
|
|
def ps_new
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
user_params = params['users']
|
|
|
|
user_params = params['users']
|
|
|
@ -202,6 +260,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']
|
|
|
@ -210,4 +278,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
|
|
|
|