liumiao
2021-01-29 ad78226de95ceff4daedd5baec00b976cdacc325
根据学员获取课次
1 files modified
30 ■■■■■ changed files
app/Http/Controllers/Api/v1/ClassScheduleController.php 30 ●●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/ClassScheduleController.php
@@ -395,8 +395,10 @@
        }
        $classCodeArr = [];
        $homeTeacherId = [];
        $staffIdArr = [];
        foreach($list as $lVal)
        {
            $staffIdArr[] = $lVal["staffId"];
            $classCodeArr[] = $lVal["classCode"];
            $homeTeacherId[] = $lVal["hometeacherId"];
        }
@@ -418,6 +420,10 @@
        //获取人脸签到
        $faceList = $this->getFaceList($classCodeArr);
        //获取面授班级教师
        $staffUser = $this->getStaffUser($staffIdArr);
        $mapList = [];
        foreach($list as $val)
        {
@@ -440,14 +446,16 @@
                        break;
                }
            }
            if($val["classMode"] == 2)
            if($val["staffId"] > 0)
            {
                $teacherName = !empty($teacherName[$val["classCode"] . '-' . $val['classNumber']]) ? implode(",", array_values(array_unique($teacherName[$val["classCode"] . '-' . $val['classNumber']]))) : '';
                $teacherName = !empty($staffUser[$val["staffId"]]) ? $staffUser[$val["staffId"]] : '';
            }
            else
            {
                $teacherName = $val["teacherName"];
                $teacherName = !empty($teacherName[$val["classCode"] . '-' . $val['classNumber']]) ? implode(",", array_values(array_unique($teacherName[$val["classCode"] . '-' . $val['classNumber']]))) : '';
            }
            $val["teacherName"] = $teacherName;//教师名字
            $val["homeBakers"] = !empty($homeTeacherList[$val["hometeacherId"]]) ? $homeTeacherList[$val["hometeacherId"]] : ''; //家培师名字
            $val["notNum"] = $classStudentsNum ? ($classStudentsNum - $signIn > 0 ? $classStudentsNum - $signIn : 0) : 0; //未签到
@@ -575,6 +583,22 @@
    }
    /**
     * @param $staffIdMap
     * @return array
     * 获取面授班级教师
     */
    public function getStaffUser($staffIdMap)
    {
        $list = UserModel::getRecordListCondition(["StaffId" => ["wherein" => $staffIdMap]], ["EnName", "RealCnName", "StaffId"])->toArray();
        $mapList = [];
        foreach($list as $val)
        {
            $mapList[$val["StaffId"]] = !empty($val["EnName"]) ? $val["EnName"] : $val["RealCnName"];
        }
        return $mapList;
    }
    /**
     * @param $date
     * @return array
     * 获取开始和结束日期