diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb
index ccadba89c..d1568a5e0 100644
--- a/app/controllers/homework_commons_controller.rb
+++ b/app/controllers/homework_commons_controller.rb
@@ -522,7 +522,7 @@ class HomeworkCommonsController < ApplicationController
 
               tip_exception("截止时间不能早于等于当前时间") if setting[:end_time] <= strf_time(Time.now)
               tip_exception("截止时间不能早于发布时间") if setting[:publish_time] > setting[:end_time]
-              tip_exception("截止时间不能早于课堂结束时间") if setting[:end_time] > strf_time(@course.end_date.end_of_day)
+              tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && setting[:end_time] > strf_time(@course.end_date.end_of_day)
 
               group_settings.none_published.update_all(publish_time: setting[:publish_time])
               group_settings.none_end.update_all(end_time: setting[:end_time])
@@ -1048,7 +1048,8 @@ class HomeworkCommonsController < ApplicationController
   def publish_homework
     tip_exception("请至少选择一个分班") if params[:group_ids].blank? && @course.course_groups.size != 0
     tip_exception("缺少截止时间参数") if params[:end_time].blank?
-    tip_exception("截止时间必须晚于当前时间") if params[:end_time] <= strf_time(Time.now)
+    tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now)
+    tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
 
     homeworks = @course.homework_commons.where(id: params[:homework_ids])
     homeworks = homeworks.includes(:homework_group_settings, :homework_detail_manual)
@@ -1067,6 +1068,7 @@ class HomeworkCommonsController < ApplicationController
               if @course.course_groups.where(id: publish_groups).size == @course.course_groups.size
                 homework.homework_group_settings.destroy_all
                 homework.unified_setting = true
+                homework.end_time = params[:end_time]
               else
                 homework.unified_setting = false
                 # 创建作业分班设置:homework_group_setting
@@ -1085,7 +1087,7 @@ class HomeworkCommonsController < ApplicationController
 
             homework.publish_time = Time.now
 
-            # 截止时间不为空的保持原状,为空的改为一个月后, 非统一设置的更新为最大分班截止时间
+            # 截止时间的处理
             if homework.end_time.nil?
               homework.end_time = params[:end_time]
             elsif homework.max_group_end_time