微信二维码过期问题修改
This commit is contained in:
parent
ede580d03a
commit
65bd77f0ff
|
@ -495,10 +495,11 @@ class Course < ActiveRecord::Base
|
|||
|
||||
def generate_qrcode
|
||||
ticket = self.qrcode
|
||||
if !ticket || ticket.size < 10
|
||||
if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime)
|
||||
response = Wechat.api.qrcode_create_scene(invite_code, 2592000)
|
||||
logger.debug "response = #{response}"
|
||||
self.qrcode = response['ticket']
|
||||
self.qrcode_expiretime = Time.now.to_i+response['expire_seconds']
|
||||
save! && reload
|
||||
ticket = qrcode
|
||||
end
|
||||
|
|
|
@ -930,10 +930,11 @@ class Project < ActiveRecord::Base
|
|||
|
||||
def generate_qrcode
|
||||
ticket = self.qrcode
|
||||
if !ticket || ticket.size < 10
|
||||
if !ticket || ticket.size < 10 || (Time.now.to_i > self.qrcode_expiretime)
|
||||
response = Wechat.api.qrcode_create_scene(invite_code, 2592000)
|
||||
logger.debug "response = #{response}"
|
||||
self.qrcode = response['ticket']
|
||||
self.qrcode_expiretime = Time.now.to_i+response['expire_seconds']
|
||||
save!
|
||||
ticket = qrcode
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddQrcodeExpiretimeToCourses < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :courses, :qrcode_expiretime, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddQrcodeExpiretimeToProjects < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :qrcode_expiretime, :integer, :default => 0
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue