移动云企业业务开通重构

dev_SaaS
huang 6 years ago
parent 0e445b3209
commit 2b28b60828

@ -1,4 +1,16 @@
#encoding=utf-8
# 云启训练场EduCoder个人版 产品编码appId 9200108
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder个人版 固定包月 9200108001
# 固定包月 9200108002
# 固定包月 9200108003
# ---------------------------------------------------
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder院校版 包月+按license 9200109001
# 包月+按license 9200109002
# 云启训练场EduCoder院校版 产品编码appId 9200109
require 'net/http'
require 'digest'
@ -45,9 +57,32 @@ class EcloudController < ApplicationController
userid: params['userid'], username: params['username'], useralias: params['useralias'], mobile: params['mobile'],
email: params['email'], productcode: params['productcode'], begintime: params['begintime'],
endtime: params['endtime'])
services = params['services'].first
EcloudService.create(opttype: services['opttype'], code: services['code'], begintime: services['begintime'],
endtime: services['endtime'], ecloud_id: ecloud.try(:id))
# 业务列表
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.try(: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.try(:id))
end
end
# 为管理员单独创建一条账号,企业账号
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'])
render :json => {result: true, errmsg: ""}
rescue Exception => e
@ -79,6 +114,7 @@ class EcloudController < ApplicationController
end
# 用户业务开通与变更接口
# 授权statu为1取消授权status为0
def ps_new
begin
user_params = params['users']

@ -1,7 +1,11 @@
#encoding=utf-8
class Ecloud < ActiveRecord::Base
attr_accessible :applyno, :begintime, :bossorderid, :custcode, :custid, :custname, :custtype, :ecordercode, :endtime,
:mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email,
:effecttime, :operatime
has_many :ecloud_service # 业务列表
has_many :ecloud_productparas # 开通参数列表
has_one :ecloud_user
has_one :ecloud_service
end

@ -0,0 +1,4 @@
class EcloudProductpara < ActiveRecord::Base
attr_accessible :key, :value, :ecloud_id
belongs_to :ecloud
end

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

@ -0,0 +1,4 @@
class EcloudServieceServicepara < ActiveRecord::Base
attr_accessible :key, :value, :ecloud_service_id
belongs_to :ecloud_service
end

@ -0,0 +1,11 @@
class CreateEcloudProductpara < ActiveRecord::Migration
def change
create_table :ecloud_productparas do |t|
t.string :key
t.string :value
t.integer :ecloud_id
t.timestamps
end
end
end

@ -0,0 +1,11 @@
class CreateEcloudServieceServicepara < ActiveRecord::Migration
def change
create_table :ecloud_serviece_serviceparas do |t|
t.string :key
t.string :value
t.integer :ecloud_service_id
t.timestamps
end
end
end

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :ecloud_productpara, :class => 'EcloudProductparas' do
key "MyString"
value "MyString"
end
end

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :ecloud_serviece_servicepara, :class => 'EcloudServieceServicepara' do
key "MyString"
value "MyString"
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EcloudProductparas, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe EcloudServieceServicepara, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save