From 836542759c4d936c3b1580bae5e4807df983f062 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 15 Mar 2019 14:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=94=A8=E6=88=B7=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=88=9B=E5=BB=BA=E4=BA=86=E4=B8=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 9 +++++++++ app/controllers/ecloud_controller.rb | 12 ++++++++---- app/models/ecloud_users.rb | 1 + .../20190314080802_create_shixun_student_works.rb | 1 + db/migrate/20190314111921_migrate_shixun_works_1.rb | 1 + 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 33d2e109..262efb00 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -65,6 +65,15 @@ class ApplicationController < ActionController::Base include Redmine::MenuManager::MenuController helper Redmine::MenuManager::MenuHelper + def ecloud_auth ucloud_user_id + euser = EcloudUser.where("id =? and opttype not in(3, 5)", ucloud_user_id).first + if euser.present? # 开通过业务 + # + else + false + end + end + def ec_public_auth major_school unless User.current.admin? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 || major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0 || diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 0201fd73..edf568a9 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -59,10 +59,14 @@ class EcloudController < ApplicationController create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? # 为管理员添加一条记录 # 开通的时候都是用户的opttype也是0 - EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], - username: params['username'], useralias: params['useralias'], - mobile: params['mobile'], email: params['email'], begintime: params['begintime'], - endtime: params['endtime']) + # 如果管理员已经存在,则不用重复开通 + euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first + unless euser + EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], + username: params['username'], useralias: params['useralias'], + mobile: params['mobile'], email: params['email'], begintime: params['begintime'], + endtime: params['endtime']) + end elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务 # 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐) # 需要通过产品服务编号和业务编码来区分哪个产品 diff --git a/app/models/ecloud_users.rb b/app/models/ecloud_users.rb index 9266adb7..99da0df2 100644 --- a/app/models/ecloud_users.rb +++ b/app/models/ecloud_users.rb @@ -1,3 +1,4 @@ class EcloudUser < ActiveRecord::Base + # opttype: # user['opttype']: 操作类型0:开通;1:变更;3: 取消授权;4:暂停;5:恢复; attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid end diff --git a/db/migrate/20190314080802_create_shixun_student_works.rb b/db/migrate/20190314080802_create_shixun_student_works.rb index 240adc00..99c95c5c 100644 --- a/db/migrate/20190314080802_create_shixun_student_works.rb +++ b/db/migrate/20190314080802_create_shixun_student_works.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class CreateShixunStudentWorks < ActiveRecord::Migration DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) diff --git a/db/migrate/20190314111921_migrate_shixun_works_1.rb b/db/migrate/20190314111921_migrate_shixun_works_1.rb index e3f18e34..38828b89 100644 --- a/db/migrate/20190314111921_migrate_shixun_works_1.rb +++ b/db/migrate/20190314111921_migrate_shixun_works_1.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 class MigrateShixunWorks1 < ActiveRecord::Migration DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)