二维码识别 项目和班级区分
This commit is contained in:
parent
c1bd3b6bf1
commit
2c86ae3eb2
|
@ -8,8 +8,6 @@ class WechatsController < ActionController::Base
|
||||||
# default text responder when no other match
|
# default text responder when no other match
|
||||||
on :text do |request, content|
|
on :text do |request, content|
|
||||||
#邀请码
|
#邀请码
|
||||||
logger.debug "!!!!!!!!!!!fankui"
|
|
||||||
logger.info request
|
|
||||||
if join_class_request(request)
|
if join_class_request(request)
|
||||||
sendBindClass(request, {invite_code: content})
|
sendBindClass(request, {invite_code: content})
|
||||||
elsif join_project_request(request)
|
elsif join_project_request(request)
|
||||||
|
@ -45,16 +43,18 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
# When subscribe user scan scene_id in public account
|
# When subscribe user scan scene_id in public account
|
||||||
on :scan, with: 'scene_id' do |request, ticket|
|
on :scan, with: 'scene_id' do |request, ticket|
|
||||||
logger.debug "!!!!!!!!!!!scene_id"
|
|
||||||
logger.info request
|
|
||||||
sendBindClass(request, {ticket: ticket})
|
sendBindClass(request, {ticket: ticket})
|
||||||
end
|
end
|
||||||
|
|
||||||
# When no any on :scan responder can match subscribe user scaned scene_id
|
# When no any on :scan responder can match subscribe user scaned scene_id
|
||||||
on :event, with: 'scan' do |request|
|
on :event, with: 'scan' do |request|
|
||||||
logger.debug "!!!!!!!!!!!scan"
|
|
||||||
logger.info request
|
|
||||||
if request[:EventKey].present?
|
if request[:EventKey].present?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sendBindClass(request, {ticket: request[:Ticket]})
|
sendBindClass(request, {ticket: request[:Ticket]})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -215,6 +215,39 @@ class WechatsController < ActionController::Base
|
||||||
end
|
end
|
||||||
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)
|
def default_msg(request)
|
||||||
uw = user_binded?(request[:FromUserName])
|
uw = user_binded?(request[:FromUserName])
|
||||||
if uw && uw.user
|
if uw && uw.user
|
||||||
|
|
Loading…
Reference in New Issue