用户业务动态变更

dev_shixuns
huang 6 years ago
parent 4cf4655b26
commit 7158b0710a

@ -170,20 +170,33 @@ class EcloudController < ApplicationController
# 用户业务开通与变更接口 # 用户业务开通与变更接口
# 授权statu为1取消授权status为0 # 授权statu为1取消授权status为0
# opttype: 操作类型0开通1变更
def ps_new def ps_new
ActiveRecord::Base.transaction do
begin begin
user_params = params['users'] user_params = params['users']
user_params.each do |user_param| user_params.each do |user_param|
if user_param['opttype'] == 0 # 开通
EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'], EcloudUser.create!(custid: params['custid'], opttype: user_param['opttype'], userid: user_param['userid'],
username: user_param['username'], useralias: user_param['useralias'], username: user_param['username'], useralias: user_param['useralias'],
mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s, mobile: user_param['mobile'], email: user_param['email'], begintime: user_param['begintime'].to_s,
endtime: user_param['endtime'].to_s, status: 1) endtime: user_param['endtime'].to_s)
elsif user_param['opttype'] == 1 # 变更
ecloud_user = EcloudUser.where(custid: params['custid'], userid: user_param['userid']).first
ecloud_user.update_attributes!(opttype: user_param['opttype'], 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)
end
end end
render :json => {success: true, errmsg: ""} render :json => {success: true, errmsg: ""}
# end # end
rescue Exception => e rescue Exception => e
logger.error(e.message) logger.error(e.message)
render :json => {code: 500, msg: "#{e.message}"} render :json => {code: 500, msg: "#{e.message}"}
raise ActiveRecord::Rollback
end
end end
end end
@ -323,7 +336,8 @@ class EcloudController < ApplicationController
end end
def save_para def save_para
EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'], custcode: params['custcode']) EcloudLog.create(url: request.url, para_value: params, applyno: params['applyno'], custid: params['custid'],
custcode: params['custcode'], userid: params['userid'], username: params['username'])
end end
end end

@ -1,3 +1,3 @@
class EcloudLog < ActiveRecord::Base class EcloudLog < ActiveRecord::Base
attr_accessible :para_value, :url, :applyno, :custid, :custcode
end end

@ -1,3 +1,3 @@
class EcloudUser < ActiveRecord::Base class EcloudUser < ActiveRecord::Base
attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid, :status, :ecloud_id has_many :ecloud_user_paras
end end

@ -0,0 +1,3 @@
class EcloudUserPara < ActiveRecord::Base
belongs_to :ecloud_user
end

@ -0,0 +1,6 @@
class AddUseridToEcloudLog < ActiveRecord::Migration
def change
add_column :ecloud_logs, :userid, :integer
add_column :ecloud_logs, :username, :string
end
end

@ -0,0 +1,7 @@
class AddApplynoToEcloudUsers < ActiveRecord::Migration
def change
add_column :ecloud_users, :applyno, :string
add_column :ecloud_users, :ecordercode, :string
add_column :ecloud_users, :productcode, :string
end
end

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

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :ecloud_user_para do
key "MyString"
value "MyString"
end
end

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