作业微信通知消息改为异步发送并且只发送给学生

This commit is contained in:
yuanke 2016-11-11 09:28:10 +08:00
parent 5a99b632b8
commit eb56a134d3
1 changed files with 41 additions and 11 deletions

View File

@ -73,20 +73,50 @@ class HomeworkCommon < ActiveRecord::Base
if self.homework_detail_manual.comment_status == 0
self.course_messages.destroy_all
else
# self.course.members.each do |m|
# # if m.user_id != self.user_id
# #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
# rolesids = []
# m.roles.each do |role|
# rolesids << role.id
# end
# if rolesids.include?(10)
# count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
# if count == 0
# ws = WechatService.new
# name = self.course.syllabus.nil? ? self.course.name : self.course.syllabus.title+" • "+self.course.name
# ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name}#{l(:label_new_homework_template)}", name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
# end
# end
# # end
# end
self.delay.send_homework_wechat_message_delay
end
end
end
#作业微信通知delay
def send_homework_wechat_message_delay
self.course.members.each do |m|
# if m.user_id != self.user_id
#self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
rolesids = []
m.roles.each do |role|
rolesids << role.id
end
if rolesids.include?(10)
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
if count == 0
ws = WechatService.new
name = self.course.syllabus.nil? ? self.course.name : self.course.syllabus.title+""+self.course.name
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name}#{l(:label_new_homework_template)}", name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
end
end
# end
end
end
end
end
#动态的更新
def update_activity
update_course_activity(self.class, self.id)