From eb56a134d3eac44b469663c9b7dd279f739565c9 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Fri, 11 Nov 2016 09:28:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=BE=AE=E4=BF=A1=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E6=B6=88=E6=81=AF=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=B9=B6=E4=B8=94=E5=8F=AA=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=BB=99=E5=AD=A6=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_common.rb | 52 +++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 199566691..c87cd3d42 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -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) - 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 + # 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 + + #动态的更新 def update_activity update_course_activity(self.class, self.id)