123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <?php
- namespace app\admin\server\medical;
- use app\admin\model\MedicalCareSubject;
- class SubjectServer
- {
- /**
- * Notes:获取业务员列表
- * @param string $keywords
- * @param int $page
- * @param int $limit
- * @return array
- * User: ZQ
- * Date: 2022/9/27
- */
- public static function getSubjectList($page, $limit,string $keywords)
- {
- [$list,$count] = MedicalCareSubject::getSubjectList($page, $limit, $keywords);
- if (!empty($list)){
- foreach ($list as $k => $v){
- $list[$k]['subject_create_time'] = date('Y-m-d H:i:s', $v['subject_create_time']);
- if (!empty($v['children'])){
- foreach ($v['children'] as $key => $val){
- $list[$k]['children'][$key]['subject_create_time'] = date('Y-m-d H:i:s', $val['subject_create_time']);
- }
- }
- }
- }
- return compact('list', 'page', 'limit', 'count');
- }
- /**
- * Notes:修改业务员
- * @param string $subject_name
- * @param string $subject_type
- * @param string $subject_sort
- * @param int $subject_id
- * @param int $subject_pid
- * @return int
- * User: ZQ
- * Date: 2022/9/13
- */
- public static function updateSubject($subject_id, $subject_pid, $subject_name, $subject_type, $subject_sort)
- {
- MedicalCareSubject::affairBegin();
- try {
- $where = [];
- $where['subject_id'] = $subject_id;
- $data = [];
- if (!empty($subject_name)){
- $data['subject_name'] = $subject_name;
- }
- if (!empty($subject_pid)){
- $data['subject_pid'] = $subject_pid;
- }
- if (!empty($subject_type)){
- $data['subject_type'] = $subject_type;
- }
- if (!empty($subject_sort)){
- $data['subject_sort'] = $subject_sort;
- }
- $result = MedicalCareSubject::where($where)->update($data);
- if ($result !== false){
- MedicalCareSubject::affairCommit();
- return true;
- }
- throw new \Exception('操作失败!');
- }catch (\Exception $exception){
- MedicalCareSubject::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:删除业务员
- * @param int $subject_id
- * @return int
- * User: ZQ
- * Date: 2022/9/3
- */
- public static function delSubject($subject_id)
- {
- MedicalCareSubject::affairBegin();
- try {
- $where = [];
- $where['subject_id'] = $subject_id;
- $data['subject_del'] = 1;
- $result = MedicalCareSubject::where($where)->update($data);
- if (!empty($result)){
- MedicalCareSubject::affairCommit();
- return true;
- }else{
- return false;
- }
- }catch (\Exception $exception){
- MedicalCareSubject::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:查询子集
- * @param int $subject_id
- * @return array
- * User: ZQ
- * Date: 2022/9/3
- */
- public static function childrenCheck($subject_id)
- {
- $where = [];
- $where['subject_pid'] = $subject_id;
- $where['subject_del'] = 0;
- $result = MedicalCareSubject::where($where)->select()->get()->toArray();
- return $result;
- }
- /**
- * Notes: 添加业务员
- * @param int $subject_pid
- * @param string $subject_name
- * @param int $subject_type
- * @param int $subject_sort
- * @return int
- * User: ZQ
- * Date: 2022/9/14
- */
- public static function insertSubject($subject_pid, $subject_name, $subject_type, $subject_sort)
- {
- MedicalCareSubject::affairBegin();
- try {
- $data = [];
- $data['subject_name'] = $subject_name;
- $data['subject_pid'] = $subject_pid;
- $data['subject_type'] = $subject_type;
- $data['subject_sort'] = $subject_sort;
- $data['subject_create_time'] = time();
- $result = MedicalCareSubject::insertGetId($data);
- if (!empty($result)){
- MedicalCareSubject::affairCommit();
- return $result;
- }
- throw new \Exception('操作失败!');
- }catch (\Exception $exception){
- MedicalCareSubject::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:查询业务员
- * @param int $subject_id
- * @return int
- * User: ZQ
- * Date: 2022/9/13
- */
- public static function subjectInfo($subject_id)
- {
- $where = [];
- $where['subject_del'] = 0;
- $where['subject_id'] = $subject_id;
- $result = MedicalCareSubject::where($where)->first();
- if (!empty($result)){
- $result['subject_create_time'] = date('Y-m-d H:i:s',$result['subject_create_time']);
- }
- return $result;
- }
- /**
- * Notes:修改状态
- * @param int $subject_status
- * @param int $subject_id
- * @return int
- * User: ZQ
- * Date: 2022/9/3
- */
- public static function updateStatus($subject_id, $subject_status)
- {
- MedicalCareSubject::affairBegin();
- try {
- $where = [];
- $where['subject_id'] = $subject_id;
- $data = [];
- $data['subject_status'] = $subject_status;
- $result = MedicalCareSubject::where($where)->update($data);
- if ($result !== false){
- MedicalCareSubject::affairCommit();
- return true;
- }
- throw new \Exception('操作失败!');
- }catch (\Exception $exception){
- MedicalCareSubject::affairRollback();
- throw new \Exception($exception->getMessage(), 500);
- }
- }
- /**
- * Notes:获取列表
- * @return array
- * User: yym
- * Date: 2022/10/26
- */
- public static function getDoctorSubjectList()
- {
- $list = MedicalCareSubject::getDoctorSubjectList();
- $data = array();
- if(!empty($list))
- {
- foreach ($list as $k => $item)
- {
- if(isset($item['children']) && !empty($item['children']))
- {
- foreach ($item['children'] as $row)
- {
- switch ($row['subject_type']){
- case 2://特需
- $type = '特需';
- break;
- case 1://专家
- $type = '专家';
- break;
- default:
- $type = '普通';
- break;
- }
- $row['subject_name'] = $type . '【' . $item['subject_name'] . '/' . $row['subject_name'] . '】';
- $data[] = $row;
- }
- }
- }
- }
- return $data;
- }
- }
|