liumiao
2021-01-29 c52c2d3e5e4c0ef9fe763b3a18ba15a773a7b42f
根据学员获取课次
2 files modified
51 ■■■■■ changed files
app/Http/Controllers/Api/v1/ClassScheduleController.php 40 ●●●●● patch | view | raw | blame | history
app/Library/CommonFun.php 11 ●●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/ClassScheduleController.php
@@ -102,7 +102,7 @@
                $name = $val["name"];
            }
            $val["name"] = $name;
            $val["faceImg"] = $this->fun->stitchingPath($val["faceImg"]);
            $val["faceImg"] = $this->fun->getFacePath($val["faceImg"]);
            $val["createdTime"] = substr($val["createdTime"], 2, 14) . " 打卡";
            $mapList[] = $val;
        }
@@ -299,8 +299,8 @@
            }
            $csVal["name"] = $name;
            $csVal["signInType"] = $csVal["signInType"] > 0 ? $csVal["signInType"] : 0;
            $csVal["headPhoto"] = $this->fun->stitchingPath($csVal["headPhoto"]);
            $csVal["faceImg"] = $this->fun->stitchingPath($csVal["faceImg"]);
            $csVal["headPhoto"] = $this->fun->getFacePath($csVal["headPhoto"]);
            $csVal["faceImg"] = $this->fun->getFacePath($csVal["faceImg"]);
            $csVal["createdTime"] = !empty($csVal["createdTime"]) ? substr($csVal["createdTime"], 11, 16) : '';
            $classMap[] = $csVal;
        }
@@ -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,7 +446,17 @@
                        break;
                }
            }
            $val["teacherName"] = !empty($teacherName[$val["classCode"] . '-' . $val['classNumber']]) ? implode(",", array_values(array_unique($teacherName[$val["classCode"] . '-' . $val['classNumber']]))) : '';//教师名字
            if($val["staffId"] > 0)
            {
                $teacherName = !empty($staffUser[$val["staffId"]]) ? $staffUser[$val["staffId"]] : '';
            }
            else
            {
                $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; //未签到
            $val["checkedInNum"] = count($recordList);//签到
@@ -567,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
     * 获取开始和结束日期
app/Library/CommonFun.php
@@ -13,6 +13,17 @@
{
    /**
     * 获取人脸
     * @param $path
     * @return string
     */
    public function getFacePath($path) {
        if ($path == '') {
            return $path;
        }
        return 'https://face.anniekids.com' . trim($path).'?x-oss-process=style/thumb';
    }
    /**
     * Notes: 拼接路径
     * User: zzy
     * Date: 2020/3/30