二维码识别 项目和班级区分

This commit is contained in:
yuanke 2016-08-01 15:09:36 +08:00
parent c1bd3b6bf1
commit 2c86ae3eb2
1 changed files with 39 additions and 6 deletions

View File

@ -8,8 +8,6 @@ class WechatsController < ActionController::Base
# default text responder when no other match
on :text do |request, content|
#邀请码
logger.debug "!!!!!!!!!!!fankui"
logger.info request
if join_class_request(request)
sendBindClass(request, {invite_code: content})
elsif join_project_request(request)
@ -45,16 +43,18 @@ class WechatsController < ActionController::Base
# When subscribe user scan scene_id in public account
on :scan, with: 'scene_id' do |request, ticket|
logger.debug "!!!!!!!!!!!scene_id"
logger.info request
sendBindClass(request, {ticket: ticket})
end
# When no any on :scan responder can match subscribe user scaned scene_id
on :event, with: 'scan' do |request|
logger.debug "!!!!!!!!!!!scan"
logger.info request
if request[:EventKey].present?
sendBindClass(request, {ticket: request[:Ticket]})
end
end
@ -215,6 +215,39 @@ class WechatsController < ActionController::Base
end
end
def checkTicket(request,params)
begin
uw = user_binded?(request[:FromUserName])
if !uw
return sendBind(request)
end
course = nil
course = Course.where(qrcode: params[:ticket]).first if params[:ticket]
course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code]
if course
return join_class(params, uw.user, request)
else
project = nil
project = Project.where(qrcode: params[:ticket]).first if params[:ticket]
project = Project.where(invite_code: params[:invite_code]).first if params[:invite_code]
if project
return join_project(params, uw.user, request)
end
end
raise "该二维码已失效!"
rescue => e
logger.error e.inspect
logger.error e.backtrace.join("\n")
return request.reply.text e
end
end
def default_msg(request)
uw = user_binded?(request[:FromUserName])
if uw && uw.user