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)