企业用户如果创建了不重复创建

dev_shixuns
huang 6 years ago
parent 493872bb5b
commit 836542759c

@ -65,6 +65,15 @@ class ApplicationController < ActionController::Base
include Redmine::MenuManager::MenuController include Redmine::MenuManager::MenuController
helper Redmine::MenuManager::MenuHelper 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 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 || 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 || major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0 ||

@ -59,10 +59,14 @@ class EcloudController < ApplicationController
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present? create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?
# 为管理员添加一条记录 # 为管理员添加一条记录
# 开通的时候都是用户的opttype也是0 # 开通的时候都是用户的opttype也是0
EcloudUser.create!(custid: params['custid'], opttype: params['opttype'], userid: params['userid'], # 如果管理员已经存在,则不用重复开通
username: params['username'], useralias: params['useralias'], euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first
mobile: params['mobile'], email: params['email'], begintime: params['begintime'], unless euser
endtime: params['endtime']) 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 # 试用转商用 # 变更企业/个人业务 elsif params['opttype'] == 2 # 试用转商用 # 变更企业/个人业务
# 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐) # 业务列表:注销业务(注销试用的套餐),另一个业务项的操作代码是:新增业务(开通商用的套餐)
# 需要通过产品服务编号和业务编码来区分哪个产品 # 需要通过产品服务编号和业务编码来区分哪个产品

@ -1,3 +1,4 @@
class EcloudUser < ActiveRecord::Base class EcloudUser < ActiveRecord::Base
# opttype: # user['opttype']: 操作类型0开通1变更3: 取消授权4暂停5恢复
attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid
end end

@ -1,3 +1,4 @@
# encoding: utf-8
class CreateShixunStudentWorks < ActiveRecord::Migration 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) 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)

@ -1,3 +1,4 @@
# encoding: utf-8
class MigrateShixunWorks1 < ActiveRecord::Migration 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) 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)

Loading…
Cancel
Save