From 0f4886906a284a87c348b42f6a0ce1f71b0f4cb7 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 14:40:26 +0800 Subject: [PATCH 01/11] =?UTF-8?q?ecloud=E6=8E=88=E6=9D=83=E5=92=8C?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=8E=88=E6=9D=83=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 9af476cf..096275bb 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -81,15 +81,13 @@ class EcloudController < ApplicationController # 用户业务开通与变更接口 def ps_new begin - user_param = params['users'].first - # ecloud_user = EcloudUser.where(:custid => params['custid'], :userid => user_param['userid']).first - # if ecloud_user.present? - # render :json => {code: 500, msg: "你已开通过该业务"} - # else - EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], - username: user_param['username'], useralias: user_param['useralias'], - mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, - endtime: user_param['endtime'].to_s, status: 1) + user_params = params['users'] + user_params.each do |user_param| + EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], + username: user_param['username'], useralias: user_param['useralias'], + mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, + endtime: user_param['endtime'].to_s, status: 1) + end render :json => {success: true, errmsg: ""} # end rescue Exception => e @@ -99,13 +97,15 @@ class EcloudController < ApplicationController end # 用户业务状态变更 + # 授权statu为1,取消授权status为0 def ps_update begin - ecloud = Ecloud.where(applyno: params['applyno']).first - user_param = params['users'].first - ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first + user_params = params['users'] + user_params.each do |user_param| + ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first + ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0) + end - ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0) render :json => {success: true, errmsg: ""} # else # render :json => {code: 404, msg: "企业ID不存在"} From 6f15d83b8724508a67151289e0a49e94399dc5ab Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 13 Mar 2019 15:11:24 +0800 Subject: [PATCH 02/11] Merge branch 'develop' of http://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop # Conflicts: # app/controllers/ecloud_controller.rb --- app/controllers/ecloud_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 096275bb..e1eaced2 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -157,6 +157,10 @@ class EcloudController < ApplicationController def get(url) uri = URI(url) res = Net::HTTP.start(uri.host, uri.port, use_ssl: url.start_with?('https')) do |http| + + ## TODO + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + req = Net::HTTP::Get.new(uri) #req['Content-Type'] = 'application/json' # The body needs to be a JSON string, use whatever you know to parse Hash to JSON @@ -170,6 +174,8 @@ class EcloudController < ApplicationController def post(url) uri = URI(url) res = Net::HTTP.start(uri.host, uri.port, use_ssl: url.start_with?('https')) do |http| + ## TODO + http.verify_mode = OpenSSL::SSL::VERIFY_NONE req = Net::HTTP::Post.new(uri) #req['Content-Type'] = 'application/json' # The body needs to be a JSON string, use whatever you know to parse Hash to JSON From 5c0e656dd3e2cb674e85c08e999823d0ab29257e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 13 Mar 2019 15:15:43 +0800 Subject: [PATCH 03/11] Merge branch 'develop' of http://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop # Conflicts: # app/controllers/ecloud_controller.rb --- app/controllers/ecloud_controller.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index e1eaced2..a9518cef 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -173,17 +173,14 @@ class EcloudController < ApplicationController def post(url) uri = URI(url) - res = Net::HTTP.start(uri.host, uri.port, use_ssl: url.start_with?('https')) do |http| - ## TODO - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - req = Net::HTTP::Post.new(uri) - #req['Content-Type'] = 'application/json' - # The body needs to be a JSON string, use whatever you know to parse Hash to JSON - #req.body = {a: 1}.to_json - http.request(req) - end - res.body + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = url.start_with?('https') + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + + response.body end def decode(s) From 0a176e78ad85da021378073e281ef271d61f836d Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 13 Mar 2019 15:19:40 +0800 Subject: [PATCH 04/11] Merge branch 'develop' of http://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into develop # Conflicts: # app/controllers/ecloud_controller.rb --- app/controllers/ecloud_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index a9518cef..4da750ce 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -177,7 +177,7 @@ class EcloudController < ApplicationController http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = url.start_with?('https') http.verify_mode = OpenSSL::SSL::VERIFY_NONE - request = Net::HTTP::Get.new(uri.request_uri) + request = Net::HTTP::Post.new(uri.request_uri) response = http.request(request) response.body From 7e35e1af0d6755eecb92fc77833b5b36b9d4defd Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 13 Mar 2019 15:35:19 +0800 Subject: [PATCH 05/11] json --- app/controllers/ecloud_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 4da750ce..1039bede 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -178,6 +178,8 @@ class EcloudController < ApplicationController http.use_ssl = url.start_with?('https') http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(uri.request_uri) + request['Content-Type'] = 'application/json' + request['Accept'] = 'application/json' response = http.request(request) response.body From e04f29aa4461d5f52d3362d1f99a55a4511410e0 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 13 Mar 2019 15:39:34 +0800 Subject: [PATCH 06/11] json --- app/controllers/ecloud_controller.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 1039bede..242f7675 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -156,19 +156,16 @@ class EcloudController < ApplicationController private def get(url) uri = URI(url) - res = Net::HTTP.start(uri.host, uri.port, use_ssl: url.start_with?('https')) do |http| - ## TODO - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - - req = Net::HTTP::Get.new(uri) - #req['Content-Type'] = 'application/json' - # The body needs to be a JSON string, use whatever you know to parse Hash to JSON - #req.body = {a: 1}.to_json - http.request(req) - end + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = url.start_with?('https') + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + request = Net::HTTP::Get.new(uri.request_uri) + request['Content-Type'] = 'application/json' + request['Accept'] = 'application/json' + response = http.request(request) - res.body + response.body end def post(url) From e09c93f93dba4f45198ceabe70f89d3ff7f37306 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 13 Mar 2019 17:30:14 +0800 Subject: [PATCH 07/11] DEVELOPMENT COMMUNITY --- app/views/welcome/index.html.erb | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index f9a52452..146ccfdc 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -51,17 +51,6 @@ - -
-
-

精选实训

-

SELECTED TRAINING

-
- 更多 -
- <%= render :partial => "shixuns/shixun_item", :locals => {:shixuns => @shixuns} %> -
-
@@ -77,6 +66,20 @@
+ +
+
+

开发社区

+

DEVELOPMENT COMMUNITY

+
+ 更多 +
+ <%= render :partial => "shixuns/shixun_item", :locals => {:shixuns => @shixuns} %> +
+
+ + +
From 29b2a85e8dfa5b28a37f8090db014d09594ee0f2 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 13 Mar 2019 17:34:54 +0800 Subject: [PATCH 08/11] COURSE --- app/views/welcome/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 146ccfdc..f7a6dbc4 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -56,7 +56,7 @@

实训课程

-

TRAINING PATH

+

TRAINING COURSE

更多
From 2b28b608283a3fac3eeb72116423c07da72a9910 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 18:27:11 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E4=BA=91=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E4=B8=9A=E5=8A=A1=E5=BC=80=E9=80=9A=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 42 +++++++++++++++++-- app/models/ecloud.rb | 6 ++- app/models/ecloud_productpara.rb | 4 ++ app/models/ecloud_service.rb | 2 + app/models/ecloud_serviece_servicepara.rb | 4 ++ ...0190313090326_create_ecloud_productpara.rb | 11 +++++ ...0416_create_ecloud_serviece_servicepara.rb | 11 +++++ spec/factories/ecloud_productparas.rb | 7 ++++ .../factories/ecloud_serviece_serviceparas.rb | 7 ++++ spec/models/ecloud_productparas_spec.rb | 5 +++ .../ecloud_serviece_servicepara_spec.rb | 5 +++ 11 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 app/models/ecloud_productpara.rb create mode 100644 app/models/ecloud_serviece_servicepara.rb create mode 100644 db/migrate/20190313090326_create_ecloud_productpara.rb create mode 100644 db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb create mode 100644 spec/factories/ecloud_productparas.rb create mode 100644 spec/factories/ecloud_serviece_serviceparas.rb create mode 100644 spec/models/ecloud_productparas_spec.rb create mode 100644 spec/models/ecloud_serviece_servicepara_spec.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 096275bb..54a97aa6 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -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'] diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index fc23d00a..b9f81d5b 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -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 diff --git a/app/models/ecloud_productpara.rb b/app/models/ecloud_productpara.rb new file mode 100644 index 00000000..ec1b94bc --- /dev/null +++ b/app/models/ecloud_productpara.rb @@ -0,0 +1,4 @@ +class EcloudProductpara < ActiveRecord::Base + attr_accessible :key, :value, :ecloud_id + belongs_to :ecloud +end diff --git a/app/models/ecloud_service.rb b/app/models/ecloud_service.rb index 596ad684..4a388ed4 100644 --- a/app/models/ecloud_service.rb +++ b/app/models/ecloud_service.rb @@ -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 diff --git a/app/models/ecloud_serviece_servicepara.rb b/app/models/ecloud_serviece_servicepara.rb new file mode 100644 index 00000000..91bb0a0d --- /dev/null +++ b/app/models/ecloud_serviece_servicepara.rb @@ -0,0 +1,4 @@ +class EcloudServieceServicepara < ActiveRecord::Base + attr_accessible :key, :value, :ecloud_service_id + belongs_to :ecloud_service +end diff --git a/db/migrate/20190313090326_create_ecloud_productpara.rb b/db/migrate/20190313090326_create_ecloud_productpara.rb new file mode 100644 index 00000000..df1271d6 --- /dev/null +++ b/db/migrate/20190313090326_create_ecloud_productpara.rb @@ -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 diff --git a/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb b/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb new file mode 100644 index 00000000..22da21dd --- /dev/null +++ b/db/migrate/20190313090416_create_ecloud_serviece_servicepara.rb @@ -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 diff --git a/spec/factories/ecloud_productparas.rb b/spec/factories/ecloud_productparas.rb new file mode 100644 index 00000000..c206a57f --- /dev/null +++ b/spec/factories/ecloud_productparas.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :ecloud_productpara, :class => 'EcloudProductparas' do + key "MyString" +value "MyString" + end + +end diff --git a/spec/factories/ecloud_serviece_serviceparas.rb b/spec/factories/ecloud_serviece_serviceparas.rb new file mode 100644 index 00000000..5a1f5e7d --- /dev/null +++ b/spec/factories/ecloud_serviece_serviceparas.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :ecloud_serviece_servicepara, :class => 'EcloudServieceServicepara' do + key "MyString" +value "MyString" + end + +end diff --git a/spec/models/ecloud_productparas_spec.rb b/spec/models/ecloud_productparas_spec.rb new file mode 100644 index 00000000..ec9a177f --- /dev/null +++ b/spec/models/ecloud_productparas_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudProductparas, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/ecloud_serviece_servicepara_spec.rb b/spec/models/ecloud_serviece_servicepara_spec.rb new file mode 100644 index 00000000..0ea7e787 --- /dev/null +++ b/spec/models/ecloud_serviece_servicepara_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudServieceServicepara, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 03b67d1b4d4e9d8975d9309bea0bd18667a8ce8f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 20:28:52 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=94=A8=E6=88=B7=E8=A1=8C=E4=B8=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 78 ++++++++++++------- app/models/ecloud_log.rb | 3 + .../20190313115011_create_ecloud_logs.rb | 13 ++++ db/migrate/20190313120249_change_clo.rb | 16 ++++ spec/factories/ecloud_logs.rb | 7 ++ spec/models/ecloud_log_spec.rb | 5 ++ 6 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 app/models/ecloud_log.rb create mode 100644 db/migrate/20190313115011_create_ecloud_logs.rb create mode 100644 db/migrate/20190313120249_change_clo.rb create mode 100644 spec/factories/ecloud_logs.rb create mode 100644 spec/models/ecloud_log_spec.rb diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 94470166..63c9ad27 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -18,6 +18,7 @@ class EcloudController < ApplicationController skip_before_filter :verify_authenticity_token # before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] + before_filter :save_para before_filter :user_setup # before_filter :require_login, only: [:authorize] @@ -45,44 +46,49 @@ class EcloudController < ApplicationController end - # 企业开通 + # 企业/个人业务开通 # applyno 申请单号,唯一 # ecordercode 唯一标志一个企业的订购关系 + # params['opttype']:操作类型。0开通;1变更;2试用转商用;4再次开通 def bs_new ActiveRecord::Base.transaction do begin - ecloud = Ecloud.create!(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']) - # 业务列表 - 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']) + if params['opttype'] == 0 # 开通企业/个人业务 + ecloud = Ecloud.create!(eloud_params) + # 业务列表 + 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 - end - # 应用开通参数 - productparas = params['productparas'] - if productparas.present? - productparas.each do |productpara| - EcloudProductpara.create!(key: productpara['key'], value: productpara['value'], ecloud_id: ecloud.try(:id)) + # 应用开通参数 + 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 - 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']) + # 为管理员单独创建一条账号,企业账号 + 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']) + + 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: ""} rescue Exception => e @@ -93,11 +99,11 @@ class EcloudController < ApplicationController end end - # 企业更新 + # 企业/个人业务变更、注销 def bs_update ActiveRecord::Base.transaction do 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'], custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], operatime: params['operatime'], effecttime: params['effecttime']) @@ -227,6 +233,16 @@ class EcloudController < ApplicationController end 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 sign = sign(params['timestamp']) if sign != params['sign'] @@ -235,4 +251,8 @@ class EcloudController < ApplicationController end end + def save_para + EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'], custcode: params['custcode']) + end + end diff --git a/app/models/ecloud_log.rb b/app/models/ecloud_log.rb new file mode 100644 index 00000000..4e187aa5 --- /dev/null +++ b/app/models/ecloud_log.rb @@ -0,0 +1,3 @@ +class EcloudLog < ActiveRecord::Base + attr_accessible :para_value, :url, :applyno, :custid, :custcode +end diff --git a/db/migrate/20190313115011_create_ecloud_logs.rb b/db/migrate/20190313115011_create_ecloud_logs.rb new file mode 100644 index 00000000..c5a9f3a8 --- /dev/null +++ b/db/migrate/20190313115011_create_ecloud_logs.rb @@ -0,0 +1,13 @@ +class CreateEcloudLogs < ActiveRecord::Migration + def change + create_table :ecloud_logs do |t| + t.string :url + t.string :applyno + t.integer :custid + t.string :custcode + t.string :para_value + + t.timestamps + end + end +end diff --git a/db/migrate/20190313120249_change_clo.rb b/db/migrate/20190313120249_change_clo.rb new file mode 100644 index 00000000..794aa56c --- /dev/null +++ b/db/migrate/20190313120249_change_clo.rb @@ -0,0 +1,16 @@ +class ChangeClo < ActiveRecord::Migration + def up + change_column :eclouds, :begintime, :bigint, :limit => 20 + change_column :eclouds, :endtime, :bigint, :limit => 20 + change_column :eclouds, :operatime, :bigint, :limit => 20 + change_column :eclouds, :effecttime, :bigint, :limit => 20 + change_column :ecloud_services, :endtime, :bigint, :limit => 20 + change_column :ecloud_services, :begintime, :bigint, :limit => 20 + change_column :ecloud_users, :begintime, :bigint, :limit => 20 + change_column :ecloud_users, :endtime, :bigint, :limit => 20 + change_column :ecloud_logs, :para_value, :longtext + end + + def down + end +end diff --git a/spec/factories/ecloud_logs.rb b/spec/factories/ecloud_logs.rb new file mode 100644 index 00000000..e442e25d --- /dev/null +++ b/spec/factories/ecloud_logs.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :ecloud_log do + url "MyString" +params "" + end + +end diff --git a/spec/models/ecloud_log_spec.rb b/spec/models/ecloud_log_spec.rb new file mode 100644 index 00000000..25126a65 --- /dev/null +++ b/spec/models/ecloud_log_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe EcloudLog, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 4c58e97d94bcb857c50d6c593dab0298a28152f9 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Mar 2019 21:22:24 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E5=BE=85=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 65 +++++++++++++++++----------- app/models/ecloud.rb | 4 +- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 63c9ad27..216df8df 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -53,41 +53,56 @@ class EcloudController < ApplicationController def bs_new ActiveRecord::Base.transaction do begin + ecloud_id = 0 if params['opttype'] == 0 # 开通企业/个人业务 ecloud = Ecloud.create!(eloud_params) - # 业务列表 - 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 + 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) + 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.try(:id)) - 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']) - - 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: ""} @@ -103,7 +118,7 @@ class EcloudController < ApplicationController def bs_update ActiveRecord::Base.transaction do begin - ecloud = Ecloud.where(custid: params['custid']).first + ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode']).first ecloud.update_attributes!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], operatime: params['operatime'], effecttime: params['effecttime']) diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index b9f81d5b..293948f3 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -4,8 +4,8 @@ class Ecloud < ActiveRecord::Base :mobile, :opttype, :productcode, :registersource, :string, :trial, :useralias, :userid, :username, :email, :effecttime, :operatime - has_many :ecloud_service # 业务列表 - has_many :ecloud_productparas # 开通参数列表 + has_many :ecloud_services, :dependent => :destroy # 业务列表 + has_many :ecloud_productparas, :dependent => :destroy # 开通参数列表 has_one :ecloud_user end