Commit 1b0aed19 authored by hujun's avatar hujun

反复转勤

parent bde568a4
...@@ -66,15 +66,12 @@ class BrokerService ...@@ -66,15 +66,12 @@ class BrokerService
$where['site_id'] = $data['site_id']; $where['site_id'] = $data['site_id'];
$agent_data = $this->m_agent->verifyUser($field, '', $where); $agent_data = $this->m_agent->verifyUser($field, '', $where);
if (!empty($agent_data['status']) && $agent_data['status'] == 3) { if (!empty($agent_data) && $agent_data['status'] == 0) {
$result['msg'] = '该用户已转勤';
}
if (!empty($agent_data)) {
$result['msg'] = '该用户已存在'; $result['msg'] = '该用户已存在';
return $result; return $result;
} }
$agent_old = $this->m_agent->getAgentById($field, ['phone' => $data['phone'], 'status' => 0]); $agent_old = $this->m_agent->getAgentById($field, ['phone' => $data['phone'], 'status' => 0]);
if (empty($data['confirm_old']) && !empty($agent_old[0]['id'])) { if (empty($data['confirm_old']) && (!empty($agent_old[0]['id']) || $agent_data['status'] == 3)) {
$result['msg'] = '转勤'; $result['msg'] = '转勤';
return $result; return $result;
} else { } else {
...@@ -120,8 +117,14 @@ class BrokerService ...@@ -120,8 +117,14 @@ class BrokerService
} }
if ($is_new_id) { if ($is_new_id) {
$change_old_id = $agent_old[0]['id'];
$id = $this->m_agent->saveAgent($data); $id = $this->m_agent->saveAgent($data);
} elseif ($agent_data['status'] == 3) {
$change_old_id = $agent_old[0]['id'];
$id = $this->m_agent->saveAgent(['id'=>$agent_data['id'],'status'=>0]);
$this->m_agent->saveAgent(['id'=>$agent_old[0]['id'],'status'=>3]);
} else { } else {
$change_old_id = $agent_old[0]['id'];
//将原来的id作为新的 //将原来的id作为新的
$data['id'] = $agent_old[0]['id']; $data['id'] = $agent_old[0]['id'];
$id = $this->m_agent->saveAgent($data); $id = $this->m_agent->saveAgent($data);
...@@ -148,7 +151,7 @@ class BrokerService ...@@ -148,7 +151,7 @@ class BrokerService
$result['data'] = ['id' => $id]; $result['data'] = ['id' => $id];
$result['msg'] = $msg; $result['msg'] = $msg;
if ($change_old_id) { if ($change_old_id && ($change_old_id != $id)) {
$m_user = new Users(); $m_user = new Users();
$update_user = $update_house = []; $update_user = $update_house = [];
$user_id_arr = $m_user->getUserByWhereColumn(['agent_id' => $change_old_id], 'id'); $user_id_arr = $m_user->getUserByWhereColumn(['agent_id' => $change_old_id], 'id');
...@@ -173,13 +176,6 @@ class BrokerService ...@@ -173,13 +176,6 @@ class BrokerService
$house_id_arr = array_unique($house_id_arr); $house_id_arr = array_unique($house_id_arr);
$record_data['house_id'] = empty($house_id_arr) ? "" : implode(',', $house_id_arr); $record_data['house_id'] = empty($house_id_arr) ? "" : implode(',', $house_id_arr);
$m_records = new AOperatingRecords();
$record_data['remark'] = '转勤,旧id:'.$change_old_id;
$record_data['type'] = 0;
$record_data['operation_id'] = $operation_id;
$record_data['agent_id'] = $id;
$m_records->insertData($record_data);
if (!empty($update_user)) { if (!empty($update_user)) {
$m_user->updateUserAll($update_user); $m_user->updateUserAll($update_user);
} }
...@@ -188,6 +184,16 @@ class BrokerService ...@@ -188,6 +184,16 @@ class BrokerService
$m_house->updateUserAll($update_house); $m_house->updateUserAll($update_house);
} }
} }
if ($data['confirm_old'] == 1) {
$m_records = new AOperatingRecords();
$record_data['remark'] = '转勤,旧id:'.$change_old_id;
$record_data['type'] = 0;
$record_data['operation_id'] = $operation_id;
$record_data['agent_id'] = $id;
$m_records->insertData($record_data);
}
} else { } else {
$result['msg'] = '新增或编辑失败'; $result['msg'] = '新增或编辑失败';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment