区分是课程邀请,还是意见反馈

This commit is contained in:
guange 2016-07-09 10:13:05 +08:00
parent f5b4bc3e43
commit 8279d9385c
4 changed files with 23 additions and 2 deletions

View File

@ -8,7 +8,11 @@ class WechatsController < ActionController::Base
# default text responder when no other match
on :text do |request, content|
#邀请码
if join_request
sendBindClass(request, {invite_code: content})
else
request.reply.text '您的意见已收到,感谢您的反馈!'
end
end
# When receive 'help', will trigger this responder
@ -142,6 +146,11 @@ class WechatsController < ActionController::Base
end
end
def join_request(request)
openid = request[:FromUserName]
wl = WechatLog.where(openid: openid).order('id desc').first
wl && JSON(wl.request_raw)["EventKey"] == 'JOIN_CLASS'
end
def sendBindClass(request, params)
begin

4
app/models/wechat_log.rb Normal file
View File

@ -0,0 +1,4 @@
#coding=utf-8
#
class WechatLog < ActiveRecord::Base
end

View File

@ -0,0 +1,5 @@
class AddIndexOpenidToWechatLogs < ActiveRecord::Migration
def change
add_index(:wechat_logs, :openid)
end
end

View File

@ -11,7 +11,8 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160708091258) do
ActiveRecord::Schema.define(:version => 20160709015740) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
t.string "act_type", :null => false
@ -2185,6 +2186,8 @@ ActiveRecord::Schema.define(:version => 20160708091258) do
t.datetime "created_at", :null => false
end
add_index "wechat_logs", ["openid"], :name => "index_wechat_logs_on_openid"
create_table "wiki_content_versions", :force => true do |t|
t.integer "wiki_content_id", :null => false
t.integer "page_id", :null => false