...
|
...
|
@@ -67,15 +67,24 @@ class User extends Backend |
|
|
$this->request->get(["filter"=>json_encode($filter),'op'=>json_encode($op)]);
|
|
|
}
|
|
|
|
|
|
//所属组织
|
|
|
$basic_where = [];
|
|
|
$organization_id = $this->getOrganizationId();
|
|
|
if($organization_id > 0){
|
|
|
$basic_where['user.organization_id'] = $organization_id;
|
|
|
}
|
|
|
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams('user.id,user.username,user.nickname,user.password,user.card,user.work_address,user.studynum');
|
|
|
$total = $this->model
|
|
|
->with('group')
|
|
|
->with(['organization'])
|
|
|
->where($where)
|
|
|
->where($basic_where)
|
|
|
->order($sort, $order)
|
|
|
->count();
|
|
|
$list = $this->model
|
|
|
->with('group')
|
|
|
->with(['organization'])
|
|
|
->where($where)
|
|
|
->where($basic_where)
|
|
|
->order($sort, $order)
|
|
|
->limit($offset, $limit)
|
|
|
->select();
|
...
|
...
|
@@ -132,6 +141,8 @@ class User extends Backend |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 所属组织
|
|
|
$params['organization_id'] = $this->getOrganizationId() ?: 0;
|
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
...
|
...
|
@@ -153,6 +164,7 @@ class User extends Backend |
|
|
'third_id' => $third_id,
|
|
|
'study_id' => $study['study_id'],
|
|
|
'periodtime' => strtotime($study['periodtime']),
|
|
|
'organization_id' => $params['organization_id'], //所属组织
|
|
|
];
|
|
|
$classes_ids = Db::name('classes')->where('study_id',$study['study_id'])->where('is_major',1)->column('id');
|
|
|
foreach ($classes_ids as $class_id){
|
...
|
...
|
@@ -259,6 +271,7 @@ class User extends Backend |
|
|
'third_id' => $third_id,
|
|
|
'study_id' => $study['study_id'],
|
|
|
'periodtime' => strtotime($study['periodtime']),
|
|
|
'organization_id' => $row->organization_id, //所属组织
|
|
|
];
|
|
|
}else{
|
|
|
// 修改到期时间
|
...
|
...
|
@@ -462,7 +475,7 @@ class User extends Backend |
|
|
}
|
|
|
$row['examname'] = !empty($row['examname']) ? $row['examname'] : '';
|
|
|
if(!isset($user_study_exist[$row['username'].'-'.$row['examname']])){
|
|
|
if ($user = UserModel::where('username',$row['username'])->field('id')->find()) {
|
|
|
if ($user = UserModel::where('username',$row['username'])->field('id,organization_id')->find()) {
|
|
|
// 添加报考科目信息
|
|
|
$study = Db::name('study')->where('examname',$row['examname'])->field('id')->find();
|
|
|
$third_study = Db::name('third_study')->where('study_id',$study['id'])->where('third_id',$user['id'])->find();
|
...
|
...
|
@@ -471,6 +484,7 @@ class User extends Backend |
|
|
'third_id' => $user['id'],
|
|
|
'study_id' => $study['id'],
|
|
|
'periodtime' => intval(($row['periodtime'] - 25569) * 3600 * 24) - 28800, //转换成1970年以来的秒数
|
|
|
'organization_id' => $user['organization_id'], //所属组织
|
|
|
];
|
|
|
$classes_ids = Db::name('classes')->where('study_id',$study['id'])->where('is_major',1)->column('id');
|
|
|
foreach ($classes_ids as $class_id){
|
...
|
...
|
@@ -492,6 +506,7 @@ class User extends Backend |
|
|
if(!isset($user_exist[$row['username']])){
|
|
|
// 调整后的数据
|
|
|
unset($row['examname'],$row['periodtime']);
|
|
|
$row['organization_id'] = $this->getOrganizationId() ?: 0; //所属组织
|
|
|
$insert[] = $row;
|
|
|
$user_exist[$row['username']] = 1;
|
|
|
}
|
...
|
...
|
@@ -532,20 +547,21 @@ class User extends Backend |
|
|
}
|
|
|
// 添加报考科目
|
|
|
foreach ($insert_origin as $v){
|
|
|
$third_id = UserModel::where('username',$v['username'])->value('id');
|
|
|
$user = UserModel::where('username',$v['username'])->field('id,organization_id')->find();
|
|
|
// 添加报考科目信息
|
|
|
$study = Db::name('study')->where('examname',$v['examname'])->field('id')->find();
|
|
|
$third_study = Db::name('third_study')->where('study_id',$study['id'])->where('third_id',$third_id)->find();
|
|
|
$third_study = Db::name('third_study')->where('study_id',$study['id'])->where('third_id',$user['id'])->find();
|
|
|
if($study && !$third_study){
|
|
|
$third_study_data[] = [
|
|
|
'third_id' => $third_id,
|
|
|
'third_id' => $user['id'],
|
|
|
'study_id' => $study['id'],
|
|
|
'periodtime' => intval(($v['periodtime'] - 25569) * 3600 * 24) - 28800, //转换成1970年以来的秒数
|
|
|
'organization_id' => $user['organization_id'], //所属组织
|
|
|
];
|
|
|
$classes_ids = Db::name('classes')->where('study_id',$study['id'])->where('is_major',1)->column('id');
|
|
|
foreach ($classes_ids as $class_id){
|
|
|
$study_class_data[] = [
|
|
|
'third_id' => $third_id,
|
|
|
'third_id' => $user['id'],
|
|
|
'study_id' => $study['id'],
|
|
|
'class_id' => $class_id,
|
|
|
'playtime' => 0,
|
...
|
...
|
|