liumiao
2021-01-28 d7423f755f88074bb16ea835ab2810e36a7b816b
根据学员获取课次
1 files added
2 files modified
62 ■■■■ changed files
app/Http/Controllers/Api/v1/ClassScheduleController.php 34 ●●●● patch | view | raw | blame | history
app/Models/CourseTableModel.php 2 ●●● patch | view | raw | blame | history
app/Models/CourseTableTeacherModuleModel.php 26 ●●●●● 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\CourseTableTeacherModuleModel;
use App\Models\FaceAttendanceModel;
use App\Models\Portal\UserModel;
use App\Models\StudentsModel;
@@ -277,7 +278,7 @@
    {
        //获取班级人脸签到记录学员
        $coWhere = ["cs.classCode" => $classCode, "cs.status" => 1, "cs.isDelete" => 0, "cs.courseStatus" => 1, "cs.isDeleteReason" => 0, "s.status" => 1, "s.courseStatus" => 1, "s.isDelete" => 0];
        $coSelect = ["s.username", "s.name", "s.englishName", "s.phoneNumber as phone", "s.headPhoto", "fa.faceImg", "fa.createdTime", "fa.type as signInType"];
        $coSelect = ["s.username", "s.name", "s.englishName", "s.phoneNumber as phone", "s.faceImg as headPhoto", "fa.faceImg", "fa.createdTime", "fa.type as signInType"];
        $query = CombineOrdersModel::getClassStudentsSignInList($classNumber, $contentTime);
        $classStudents = CombineOrdersModel::getDataJoinList($query, $coWhere, $coSelect);
        $classMap = [];
@@ -341,8 +342,9 @@
        }
        $date = $request->post("date");
        $orgId = $request->post("orgId", 43);
        $orgId = $request->post("orgId");
        $roleIdArr = $request->post("roleIdArr");
        $courseTableId = $request->post("courseTableId");
        $teacherId = $this->getAndCheckTeacherId(); //236523
        if(empty($date))
        {
@@ -354,6 +356,10 @@
        //获取开始结束日期
        $dateInfo = $this->getthemonth($date);
        $where = " and ct.startTime between '{$dateInfo[0]}' and  '{$dateInfo[1]}'";
        if(is_numeric($courseTableId) && $courseTableId > 0)
        {
            $where .= " and ct.id =" . $courseTableId;
        }
        switch ($roleId)
        {
            case 1:
@@ -361,7 +367,22 @@
                $list = CourseTableModel::queryRoleJoinList($where);
                break;
            case 2:
                $where .= " and ct.staffId =" . $teacherId;
                $tWhere = ["UserId" => $teacherId, "isDelete" => 0];
                $teacherList = CourseTableTeacherModuleModel::getRecordListCondition($tWhere, ["classNumber", "classCode"])->toArray();
                if(empty($teacherList))
                {
                    return $this->_response(null, ResponseCode::COMMON_ERROR, "数据为空");
                }
                $classNumberMap = "";
                $classCodeMap = [];
                foreach($teacherList as $val)
                {
                    $classNumberMap .= "'" . $val["classNumber"] . "',";
                    $classCodeMap[] = $val["classCode"];
                }
                $classNumber = implode(',', array_unique(explode(',', rtrim($classNumberMap, ','))));
                $classCode = implode(',', array_unique($classCodeMap));
                $where .= " and ct.classNumber in ({$classNumber}) and ct.classCode in ({$classCode})";
                $list = CourseTableModel::queryRoleJoinList($where);
                break;
            case 3:
@@ -371,7 +392,6 @@
            default:
                return $this->_response("", ResponseCode::PARAM_ERROR, "参数错误");
        }
        $classCodeArr = [];
        $homeTeacherId = [];
        foreach($list as $lVal)
@@ -419,7 +439,7 @@
                        break;
                }
            }
            $val["teacherName"] = !empty($teacherName[$val["classCode"]]) ? implode(",", array_values(array_unique($teacherName[$val["classCode"]]))) : '';//教师名字
            $val["teacherName"] = !empty($teacherName[$val["classCode"] . '-' . $val['classNumber']]) ? implode(",", array_values(array_unique($teacherName[$val["classCode"] . '-' . $val['classNumber']]))) : '';//教师名字
            $val["homeBakers"] = !empty($homeTeacherList[$val["hometeacherId"]]) ? $homeTeacherList[$val["hometeacherId"]] : ''; //家培师名字
            $val["notNum"] = $classStudentsNum ? ($classStudentsNum - $signIn > 0 ? $classStudentsNum - $signIn : 0) : 0; //未签到
            $val["checkedInNum"] = count($recordList);//签到
@@ -531,12 +551,12 @@
    {
        // 获取教师
        $tWhere = ["ctm.classCode" => ["wherein" => array_unique($classCodeArr)], "ctm.isDelete" => 0];
        $tSelect = ["u.RealCnName", "u.EnName", "ctm.classCode"];
        $tSelect = ["u.RealCnName", "u.EnName", "ctm.classCode", "ctm.classNumber"];
        $tUserInfo = CourseTableModel::getDataJoinList(CourseTableModel::queryTeacherList(), $tWhere, $tSelect);
        $teacherName = [];
        foreach($tUserInfo as $tKey => $tVal)
        {
            $teacherName[$tVal["classCode"]][] = !empty($tVal["EnName"]) ? $tVal["EnName"] : $tVal["RealCnName"];
            $teacherName[$tVal["classCode"] . "-" . $tVal["classNumber"]][] = !empty($tVal["EnName"]) ? $tVal["EnName"] : $tVal["RealCnName"];
        }
        return $teacherName;
app/Models/CourseTableModel.php
@@ -32,7 +32,7 @@
    {
        $sql = "
                select  ct.id as courseTableId,ct.staffId,ct.orgId,ct.classNumber,ct.classCode,ct.sectionid,ct.week,ct.hometeacherId,
                  ctt.contentTime,cr.roomname,c.className,left(ct.startTime,10) AS startTime,c.className,c.classHour  from anni_coursetable as ct
                  ctt.contentTime,cr.roomname,c.className,left(ct.startTime,10) AS startTime,c.className,c.classHour,ctt.id as cTimeId  from anni_coursetable as ct
                left join anni_coursetabletime as ctt on ct.classCode = ctt.classCode and ct.week = ctt.week
                left join anni_classroom as cr on  ct.orgId = cr.orgId and ct.sectionid = cr.id
                left join anni_class as c on  ct.classCode = c.classCode
app/Models/CourseTableTeacherModuleModel.php
New file
@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use App\Models\Model;
use Illuminate\Support\Facades\DB;
class CourseTableTeacherModuleModel extends Model
{
    //use SoftDeletes;
    /**
     * @var string
     */
    protected $table = 'anni_coursetableteachermodule';
    protected $primaryKey = 'id';
    public $incrementing = true;
    protected $guarded = [];
    const UPDATED_AT = null;
    const CREATED_AT = null;
}