liumiao
2021-01-25 e60d035f8be402c530efa141aac3f85334aa3b4e
根据学员获取课次
3 files modified
62 ■■■■■ changed files
app/Http/Controllers/Api/v1/ClassScheduleController.php 43 ●●●●● patch | view | raw | blame | history
app/Models/StudentsModel.php 18 ●●●●● patch | view | raw | blame | history
routes/api.php 1 ●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/ClassScheduleController.php
@@ -9,6 +9,7 @@
use App\Models\ClassStudentsModel;
use App\Models\CombineOrdersModel;
use App\Models\CourseTableModel;
use App\Models\FaceAttendanceModel;
use App\Models\Portal\UserModel;
use App\Models\StudentsModel;
use Illuminate\Http\Request;
@@ -21,6 +22,48 @@
    /**
     * @param Request $request
     * 学员课程
     */
    public function studentsCourse(Request $request)
    {
        $rule = [
            'username' => 'required', //学员号
            'startTime' => 'required', //开始日期
        ];
        $message = $this->_validate($request, $rule);
        if(!empty($message))
        {
            return $this->_response(null, ResponseCode::PARAM_ERROR, $message);
        }
        //根据学员查询当天的所有课次
        $username = $request->post("username");
        $startTime = $request->post("startTime");
        $where = ["s.username" => $username, "s.status" => 1, "s.courseStatus" => 1, "s.isDelete" => 0,
            "ct.isDelete" => 0, "ct.status" => 1, "ct.startTime" => $startTime];
        $select = ["ct.classNumber", "ctt.contentTime", "c.className", "ct.classCode"];
        $list = StudentsModel::getDataJoinList(StudentsModel::studentCourseList(), $where, $select);
        //查询当天学员已经打过卡的学员
        $faceList = FaceAttendanceModel::getRecordListCondition(["dates" => $startTime, "username" => $username], ["classCode", "classNumber", "contentTime"])->toArray();
        $mapFace = [];
        foreach($faceList as $f_val)
        {
            $mapFace[$f_val["classCode"] . "-" . $f_val["classNumber"] . "-" . $f_val["contentTime"]] = $f_val;
        }
        $mapList = [];
        foreach($list as $l_val)
        {
            if(empty($mapFace[$l_val["classCode"] . "-" . $l_val["classNumber"] . "-" . $l_val["contentTime"]]))
            {
                $mapList[] = $l_val;
            }
        }
        return $this->_response($mapList);
    }
    /**
     * @param Request $request
     * 人脸打卡列表
     */
    public function humanFaceSignInList(Request $request)
app/Models/StudentsModel.php
@@ -25,4 +25,22 @@
        return $query;
    }
    /**
     * @return mixed
     * 根据学员获取课程
     */
    public static function studentCourseList()
    {
        $query = \DB::table("anni_students as s")
            ->leftjoin("anni_classstudent as cs", "cs.username", "=", "s.username")
            ->leftjoin("anni_class as c", "cs.classCode", "=", "c.classCode")
            ->leftjoin("anni_coursetable as ct", "cs.classCode", "=", "ct.classCode")
            ->join("anni_coursetabletime as ctt", function($query) {
                $query->on("ct.classCode", "=", "ctt.classCode")
                    ->on("ct.week", "=", "ctt.week")
                    ->on("ct.classCode", "=", "ctt.classCode");
            });
        return $query;
    }
}
routes/api.php
@@ -70,6 +70,7 @@
        $api->post('/ClassSchedule/getClassScheduleDetails', 'ClassScheduleController@classScheduleDetails');       //课表详情
        $api->post('/ClassSchedule/setClassHour', 'ClassScheduleController@updateClassHour');                       //修改课时
        $api->post('/ClassSchedule/getHumanFaceSignInList', 'ClassScheduleController@humanFaceSignInList');         //人脸打卡list
        $api->post('/ClassSchedule/getStudentsCourse', 'ClassScheduleController@studentsCourse');                   //学员课程
        /*******************************  end  lium ****************************************/