From cc9dac4b67b4f27adfb87ff40431e14afdf4369d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Mar 2020 22:05:57 +0800 Subject: [PATCH] tiaoz --- app/controllers/application_controller.rb | 2 +- .../weapps/attendances_controller.rb | 10 +++++----- .../course_member_attendances_controller.rb | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15e795bdb..fa4648852 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,7 +330,7 @@ class ApplicationController < ActionController::Base end if !User.current.logged? && Rails.env.development? - User.current = User.find 1 + User.current = User.find 3117 end diff --git a/app/controllers/weapps/attendances_controller.rb b/app/controllers/weapps/attendances_controller.rb index 57e1e10df..19823d42b 100644 --- a/app/controllers/weapps/attendances_controller.rb +++ b/app/controllers/weapps/attendances_controller.rb @@ -62,11 +62,11 @@ class Weapps::AttendancesController < ApplicationController where("attendance_date = '#{current_date}' and start_time <= '#{current_end_time}' and end_time > '#{current_end_time}'") @history_count = @history_attendances.size - # 当前签到如果存在快捷签到,则直接签到 - quick_attendances = @current_attendances.where(mode: "QUICK") - if quick_attendances.present? - student_direct_attendance quick_attendances, member - end + # 当前签到如果存在快捷签到,则直接签到(不在这里处理) + # quick_attendances = @current_attendances.where(mode: "QUICK") + # if quick_attendances.present? + # student_direct_attendance quick_attendances, member + # end student_attendance_ids = @history_attendances.pluck(:id) student_attendance_ids += @current_attendances.present? ? @current_attendances.pluck(:id) : [] diff --git a/app/controllers/weapps/course_member_attendances_controller.rb b/app/controllers/weapps/course_member_attendances_controller.rb index 7e315fc85..5e92d5928 100644 --- a/app/controllers/weapps/course_member_attendances_controller.rb +++ b/app/controllers/weapps/course_member_attendances_controller.rb @@ -28,19 +28,24 @@ class Weapps::CourseMemberAttendancesController < ApplicationController end def create - tip_exception("签到码不能为空") if params[:code].blank? - tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE"].include?(params[:attendance_mode]) + tip_exception("签到码不能为空") if params[:attendance_mode] != "QUICK" && params[:code].blank? + tip_exception("attendance_mode参数不对") unless ["NUMBER", "QRCODE", "QUICK"].include?(params[:attendance_mode]) - attendance = CourseAttendance.find_by(attendance_code: params[:code]) - tip_exception("签到码输入有误") if attendance.blank? || attendance.course.blank? + if params[:attendance_mode] == "QUICK" + attendance = CourseAttendance.find_by(id: params[:attendance_id]) + else + attendance = CourseAttendance.find_by(attendance_code: params[:code]) + end + tip_exception("该签到不存在") if attendance.blank? || attendance.course.blank? member = attendance.course.students.find_by(user_id: current_user.id) - tip_exception("签到码输入有误") if member.blank? + tip_exception("该签到不存在") if member.blank? tip_exception("不在签到时间内") unless attendance.current_attendance? - tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] == "QRCODE" - tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] == "NUMBER" + tip_exception("只支持数字签到") if attendance.mode != "ALL" && attendance.mode == "NUMBER" && params[:attendance_mode] != "NUMBER" + tip_exception("只支持二维码签到") if attendance.mode != "ALL" && attendance.mode == "QRCODE" && params[:attendance_mode] != "QRCODE" + tip_exception("只支持快捷签到") if attendance.mode == "QUICK" && params[:attendance_mode] != "QUICK" current_attendance = attendance.course_member_attendances.find_by(user_id: current_user.id) if current_attendance.present?