dev_haigong
cxt 6 years ago
commit b0386586c9

@ -5,7 +5,7 @@ require 'digest'
class EcloudController < ApplicationController class EcloudController < ApplicationController
skip_before_filter :verify_authenticity_token skip_before_filter :verify_authenticity_token
before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update] # before_filter :check_sign, only: [:ps_new, :ps_update, :bs_new, :bs_update]
before_filter :user_setup before_filter :user_setup
# before_filter :require_login, only: [:authorize] # before_filter :require_login, only: [:authorize]
@ -86,11 +86,11 @@ class EcloudController < ApplicationController
# if ecloud_user.present? # if ecloud_user.present?
# render :json => {code: 500, msg: "你已开通过该业务"} # render :json => {code: 500, msg: "你已开通过该业务"}
# else # else
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) endtime: user_param['endtime'].to_s, status: 1)
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)
@ -103,10 +103,10 @@ class EcloudController < ApplicationController
begin begin
ecloud = Ecloud.where(applyno: params['applyno']).first ecloud = Ecloud.where(applyno: params['applyno']).first
user_param = params['users'].first user_param = params['users'].first
ecloud_user = ecloud.ecloud_user ecloud_user = EcloudUser.where(userid: user_param['userid'], status: 1).first
ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid']) ecloud_user.update_attributes(opttype: user_param['opttype'], userid: user_param['userid'], status: 0)
render :json => {success: true, errmsg: ""} render :json => {success: true, errmsg: ""}
# else # else
# render :json => {code: 404, msg: "企业ID不存在"} # render :json => {code: 404, msg: "企业ID不存在"}
# 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 attr_accessible :begintime, :email, :endtime, :mobile, :opttype, :paras, :useralias, :userid, :username, :custid, :status, :ecloud_id
end end

@ -12,7 +12,7 @@
option = { option = {
grid: { grid: {
left: '3%', left: '3%',
right: '7%', right: '9%',
bottom: '3%', bottom: '3%',
containLabel: true containLabel: true
}, },

@ -0,0 +1,39 @@
class AddScoreForPassGames < ActiveRecord::Migration
def up
games = Game.where("final_score = 0 and status = 2 and answer_open = 0 and end_time > '2019-03-08 00:00:00'").includes(:challenge)
puts "game_count: #{games.count}"
games.find_each do |game|
puts "#{game.id}"
challenge = game.challenge
# 选择题和实践题的分数
score = challenge.choose_score
user = game.user
game.update_column(:final_score, score)
# 奖励金币和提供记录
grade = Grade.where(:user_id => user.id, :container_id => game.id, :container_type => "Game").first
if grade.nil?
Grade.create!(:user_id => user.id,
:container_id => game.id,
:container_type => "Game",
:score => score,
:created_at => game.end_time,
:updated_at => game.end_time)
user.update_column(:grade, (score + user.grade.to_i))
end
# 经验奖励
experience = Experience.where(:user_id => user.id, :container_id => game.id, :container_type => "Game").first
if experience.nil?
Experience.create!(:user_id => user.id,
:container_id => game.id,
:container_type => "Game",
:score => score,
:created_at => game.end_time,
:updated_at => game.end_time)
user.update_column(:experience, (score + user.experience.to_i))
end
end
end
def down
end
end

@ -0,0 +1,5 @@
class AddEcloudIdToEcloudUser < ActiveRecord::Migration
def change
add_column :ecloud_users, :ecloud_id, :integer
end
end

@ -0,0 +1,5 @@
class AddStatusToEcloudUser < ActiveRecord::Migration
def change
add_column :ecloud_users, :status, :integer, :limit => 1
end
end
Loading…
Cancel
Save