From 2c86ae3eb21582ff7d378a2856be89a66f88303d Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 1 Aug 2016 15:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E8=AF=86=E5=88=AB?= =?UTF-8?q?=20=E9=A1=B9=E7=9B=AE=E5=92=8C=E7=8F=AD=E7=BA=A7=E5=8C=BA?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 45 +++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index bf4e1fade..118aea0f2 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -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