Merge branch 'educoder' into develop

dev_haigong
cxt 6 years ago
commit 1675c4e1c0

@ -65,15 +65,62 @@ 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
# 云启训练场EduCoder个人版 产品编码appId 9200108
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder个人版 固定包月 9200108001
# 固定包月 9200108002
# 固定包月 9200108003
# ---------------------------------------------------
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder院校版 包月+按license 9200109001
# 包月+按license 9200109002
# 云启训练场EduCoder院校版 产品编码appId 9200109
def ecloud_auth subject_id
# euser = EcloudUser.where("userid =? and opttype not in(3, 5)", User.current.id).first
# if euser.present? # 开通过业务
# # 获取用户的套餐信息
# e_service = euser.ecloud_services.where("opttype != 1")
# # 如果用户开通过服务
# if e_service.present?
# if e_service.count >1 # 说明有重复开通过业务
# else
# code = e_service.first.try(:code)
#
# end
# end
# else
# false # 没开通过服务,或者服务被禁用则不允许访问
# end
#
#
#
#
# if e_service.count > 1 # 说明有重复订购过套餐
# else
# code = e_service.try(:code)
# end
# service_count = euser.ecloud_services.where("opttype != 1").try(:code)
#
# end
# 如果不是Ecloud过来的用户则不改变用户的使用状态及权限按现有模式即可
end
# 根据业务确定权限
def ecloud_services_auth code, subject_id
subject = Subject.find(subject_id)
subject_level = subject.subject_level_system.try(:level)
# case code
# when "9200108001"
# subject_level.to_i == 1 ? true : false
# when "9200108002"
#
# end
# 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 ||

@ -33,10 +33,18 @@ class EcloudController < ApplicationController
def trustie_login
end
CLIENT_ID = '1022'
CLIENT_SECRET = '2112037a-6d7a-432b-9081-feb1153d8668'
ROOT_URl = 'http://localhost:3000'
SERVER_URL = "https://221.176.54.92:9081/restful/services/"
# 测试环境
# CLIENT_ID = '1022'
# CLIENT_SECRET = '2112037a-6d7a-432b-9081-feb1153d8668'
# SERVER_URL = "https://221.176.54.92:9081/restful/services/"
#
# 正式环境
CLIENT_ID = '1056'
CLIENT_SECRET = '2e84256a-3de4-4713-9e02-10ee88a14592'
SERVER_URL = "https://221.176.53.130:44390/services/"
## 签名
def sign(timestamp)
@ -55,12 +63,12 @@ class EcloudController < ApplicationController
begin
if params['opttype'] == 0 # 开通企业/个人业务
ecloud = Ecloud.create!(eloud_params)
create_service(params['services'], ecloud.try(:id))
create_service(params['services'], ecloud.try(:id)) if params['services'].present?
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?
# 为管理员添加一条记录
# 开通的时候都是用户的opttype也是0
# 如果管理员已经存在,则不用重复开通
euser = EcloudUser.where(id: params['userid'], custid: params['custid']).first
euser = EcloudUser.where(userid: 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'],
@ -88,7 +96,8 @@ class EcloudController < ApplicationController
elsif params['opttype'] == 1 # 业务变更
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
# 套餐变更
# 新增业务
# 操作代码 0新增业务1注销业务2修改业务
# # 新增服务
add_service = params['services'].select{|s| s['opttype'] == 0}
create_service(add_service, ecloud.try(:id)) if add_service.present?
@ -106,8 +115,8 @@ class EcloudController < ApplicationController
if edt_services.present?
edt_services.each do |es|
ese = EcloudService.where(ecloud_id: ecloud.try(:id), code: es['code']).first
ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime'])
create_serviceparas es['serviceparas'].first, ese.id
ese.update_attributes!(opttype: es['opttype'], begintime: es['begintime'], endtime: es['endtime']) if ese.present?
create_serviceparas(es['serviceparas'].first, ese.id) if ese.present?
end
end
@ -120,6 +129,7 @@ class EcloudController < ApplicationController
# ecloud_id = ecloud.try(:id)
elsif params['opttype'] == 4 # 再次重复开通
# 再次申请开通,这种情况就是累加时间
ecloud = Ecloud.where(custid: params['custid'], custcode: params['custcode'], productcode: params['productcode']).first
create_service(params['services'], ecloud.try(:id))
create_product_params(params['productparas'], ecloud.try(:id)) if params['productparas'].present?

@ -113,7 +113,7 @@ class StudentWorkController < ApplicationController
pass_consume_time += (game.cost_time / 60.0).to_f
end
all_time += (game.cost_time / 60.0).to_f
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0
if myshixun.user_id == @work.user.id
@game_user_query << [game.id, game.outputs.first.try(:query_index).to_i]
end

@ -5,7 +5,7 @@ module ShixunsHelper
def myshixun_exp myshixun
score = 0
myshixun.games.each do |game|
score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0
end
score
end

@ -1,3 +1,4 @@
# 操作代码 0新增业务1注销业务2修改业务
class EcloudService < ActiveRecord::Base
attr_accessible :begintime, :code, :endtime, :opttype, :ecloud_id, :packagecode, :bossorderid
belongs_to :ecloud

@ -81,7 +81,7 @@
<td><%= user_query.blank? ? "--" : user_query.first[1] %></td>
<td><%= game.try(:end_time).nil? ? "--" : format_time(game.end_time) %></td>
<td><%= game.consumes_time %></td>
<td><%= game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i %> / <%= game.challenge.st == 1 ? game.challenge.choose_score : game.challenge.score %></td>
<td><%= game.status == 2 ? (game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i) : 0 %> / <%= game.challenge.st == 1 ? game.challenge.choose_score : game.challenge.score %></td>
</tr>
<% end %>
</tbody>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 297 KiB

Loading…
Cancel
Save