From 19ece63edbe0c4fdaff60f06bb40594c78e96df0 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Mar 2019 17:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E4=BA=91=E8=81=94=E8=B0=83?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ecloud_controller.rb | 20 +++++++++++++------- app/models/ecloud.rb | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/controllers/ecloud_controller.rb b/app/controllers/ecloud_controller.rb index 82c7286e..dd64daf4 100644 --- a/app/controllers/ecloud_controller.rb +++ b/app/controllers/ecloud_controller.rb @@ -33,12 +33,14 @@ class EcloudController < ApplicationController # ecordercode 唯一标志一个企业的订购关系 def bs_new begin - Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], - trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], - 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']) + ecloud = Ecloud.create!(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], + trial: params['trial'], bossorderid: params['bossorderid'], custid: params['custid'], + 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']) + EcloudService.create(opttype: params['services']['opttype'], code: params['services']['code'], begintime: params['services']['begintime'], + endtime: params['services']['endtime'], ecloud_id: ecloud.try(:id)) render :json => {result: true, errmsg: ""} rescue Exception => e @@ -50,7 +52,11 @@ class EcloudController < ApplicationController # 企业更新 def bs_update ecloud = Ecloud.where(custid: params['custid']).first - ecloud.update_attribute() + ecloud.update_attribute(applyno: params['applyno'], ecordercode: params['ecordercode'], opttype: params['opttype'], + custid: params['custid'], custcode: params['custcode'], productcode: params['productcode'], + operatime: params['operatime'], effecttime: params['effecttime']) + ecloud.ecloud_services.update_attributes(packagecode: params['services']['packagecode'], bossorderid: params['services']['bossorderid']) + end # 用户业务开通接口 diff --git a/app/models/ecloud.rb b/app/models/ecloud.rb index 6810be96..ffd2ebd6 100644 --- a/app/models/ecloud.rb +++ b/app/models/ecloud.rb @@ -1,6 +1,6 @@ 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 - has_many :ecloud_users - has_many :ecloud_services + has_one :ecloud_users + has_one :ecloud_services end