123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 审批
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\oa\controller;
  8. use app\admin\controller\ApiCommon;
  9. use app\admin\model\Message;
  10. use app\admin\model\User;
  11. use think\Hook;
  12. use app\oa\logic\ExamineLogic;
  13. use think\Request;
  14. use think\Db;
  15. class Examine extends ApiCommon
  16. {
  17. /**
  18. * 用于判断权限
  19. * @permission 无限制
  20. * @allow 登录用户可访问
  21. * @other 其他根据系统设置
  22. **/
  23. public function _initialize()
  24. {
  25. $action = [
  26. 'permission'=>[''],
  27. 'allow'=>['index','save','read','update','delete','categorylist','check','revokecheck','category','categorysave','categoryupdate','categorydelete','categoryenables','excelexport','myexamine']
  28. ];
  29. Hook::listen('check_auth',$action);
  30. $request = Request::instance();
  31. $a = strtolower($request->action());
  32. if (!in_array($a, $action['permission'])) {
  33. parent::_initialize();
  34. }
  35. //权限判断
  36. // $unAction = ['index','save','read','update','delete','categorylist','check','revokecheck','excelexport',];
  37. $unAction = ['index','save','read','update','delete','categorylist','check','revokecheck','category','categorysave','categoryupdate','categorydelete','categoryenables','excelexport','myexamine'];
  38. if (!in_array($a, $unAction) && !checkPerByAction('admin', 'oa', 'examine')) {
  39. header('Content-Type:application/json; charset=utf-8');
  40. exit(json_encode(['code'=>102,'error'=>'无权操作']));
  41. }
  42. }
  43. /**
  44. * 审批列表
  45. * @author Michael_xu
  46. * @return
  47. */
  48. public function index()
  49. {
  50. $examineModel = model('Examine');
  51. $param = $this->param;
  52. $userInfo = $this->userInfo;
  53. $param['user_id'] = $userInfo['id'];
  54. $data = $examineModel->getDataList($param);
  55. return resultArray(['data' => $data]);
  56. }
  57. /**
  58. * 审核列表导出
  59. * @return \think\response\Json|void
  60. */
  61. public function excelExport(){
  62. $param = $this->param;
  63. $userInfo = $this->userInfo;
  64. $param['user_id'] = $userInfo['id'];
  65. $ExamineLogic = new ExamineLogic();
  66. $data = $ExamineLogic->excelExport($param);
  67. return $data;
  68. }
  69. /**
  70. * 添加审批
  71. * @author Michael_xu
  72. * @param
  73. * @return
  74. */
  75. public function save()
  76. {
  77. $examineModel = model('Examine');
  78. $param = $this->param;
  79. $userInfo = $this->userInfo;
  80. $param['create_user_id'] = $userInfo['id'];
  81. $category_id = $param['category_id'];
  82. //审核判断(是否有符合条件的审批流)
  83. $examineFlowModel = new \app\admin\model\ExamineFlow();
  84. $examineStepModel = new \app\admin\model\ExamineStep();
  85. if (!$examineFlowModel->checkExamine($param['create_user_id'], 'oa_examine', $category_id)) {
  86. return resultArray(['error' => '暂无审批人,无法创建']);
  87. }
  88. //获取审批相关信息
  89. $examineFlowData = $examineFlowModel->getFlowByTypes($param['create_user_id'], 'oa_examine', $category_id);
  90. if (!$examineFlowData) {
  91. return resultArray(['error' => '无可用审批流,请联系管理员']);
  92. }
  93. $param['flow_id'] = $examineFlowData['flow_id'];
  94. //获取审批人信息
  95. if ($examineFlowData['config'] == 1) {
  96. //固定审批流
  97. $nextStepData = $examineStepModel->nextStepUser($userInfo['id'], $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
  98. $check_user_id = $nextStepData['next_user_ids'] ? : '';
  99. $param['order_id'] = 1;
  100. } else {
  101. $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
  102. }
  103. if (!$check_user_id) {
  104. return resultArray(['error' => '无可用审批人,请联系管理员']);
  105. }
  106. $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
  107. //流程审批人
  108. // $flow_user_id = $examineFlowModel->getUserByFlow($examineFlowData['flow_id'], $userInfo['id']);
  109. // $param['flow_user_id'] = $flow_user_id ? arrayToString($flow_user_id) : '';
  110. $res = $examineModel->createData($param);
  111. if ($res) {
  112. $categoryModel = new \app\oa\model\ExamineCategory();
  113. $categoryInfo = $categoryModel->getDataById($category_id);
  114. actionLog($res['examine_id'], '', '', '创建了审批');
  115. return resultArray(['data' => '添加成功']);
  116. } else {
  117. return resultArray(['error' => $examineModel->getError()]);
  118. }
  119. }
  120. /**
  121. * 审批详情
  122. * @author Michael_xu
  123. * @param
  124. * @return
  125. */
  126. public function read()
  127. {
  128. $examineModel = model('Examine');
  129. $userModel = new \app\admin\model\User();
  130. $examineFlowModel = new \app\admin\model\ExamineFlow();
  131. $param = $this->param;
  132. $userInfo = $this->userInfo;
  133. $data = $examineModel->getDataById($param['id']);
  134. //权限判断(创建人、审批人、管理员)
  135. $adminIds = $userModel->getAdminId(); //管理员
  136. $checkUserIds = $examineFlowModel->getUserByFlow($data['flow_id'], $data['create_user_id'], $data['check_user_id']);
  137. if (($userInfo['id'] != $data['create_user_id']) && !in_array($userInfo['id'],$adminIds) && !in_array($userInfo['id'],$checkUserIds)) {
  138. return resultArray(['error' => '没有权限']);
  139. }
  140. if (!$data) {
  141. return resultArray(['error' => $examineModel->getError()]);
  142. }
  143. return resultArray(['data' => $data]);
  144. }
  145. /**
  146. * 编辑审批
  147. * @author Michael_xu
  148. * @param
  149. * @return
  150. */
  151. public function update()
  152. {
  153. $examineModel = model('Examine');
  154. $param = $this->param;
  155. $userInfo = $this->userInfo;
  156. $param['create_user_id'] = $userInfo['id'];
  157. $dataInfo = db('oa_examine')->where(['examine_id' => $param['id']])->find();
  158. if (!$dataInfo) {
  159. return resultArray(['error' => '数据不存在或已删除']);
  160. }
  161. //权限判断
  162. if ($userInfo['id'] != $dataInfo['create_user_id']) {
  163. return resultArray(['error' => '没有权限']);
  164. }
  165. if (!in_array($dataInfo['check_status'],['3','4'])) {
  166. return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
  167. }
  168. //审核判断(是否有符合条件的审批流)
  169. $examineFlowModel = new \app\admin\model\ExamineFlow();
  170. $examineStepModel = new \app\admin\model\ExamineStep();
  171. if (!$examineFlowModel->checkExamine($dataInfo['create_user_id'], 'oa_examine', $dataInfo['category_id'])) {
  172. return resultArray(['error' => '暂无审批人,无法创建']);
  173. }
  174. //获取审批相关信息
  175. $examineFlowData = $examineFlowModel->getFlowByTypes($dataInfo['create_user_id'], 'oa_examine', $dataInfo['category_id']);
  176. if (!$examineFlowData) {
  177. return resultArray(['error' => '无可用审批流,请联系管理员']);
  178. }
  179. $param['flow_id'] = $examineFlowData['flow_id'];
  180. //获取审批人信息
  181. if ($examineFlowData['config'] == 1) {
  182. //固定审批流
  183. $nextStepData = $examineStepModel->nextStepUser($dataInfo['create_user_id'], $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
  184. $next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
  185. $check_user_id = $next_user_ids ? : '';
  186. $param['order_id'] = 1;
  187. } else {
  188. $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
  189. }
  190. if (!$check_user_id) {
  191. return resultArray(['error' => '无可用审批人,请联系管理员']);
  192. }
  193. $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
  194. $param['check_status'] = 0;
  195. //流程审批人
  196. // $flow_user_id = $examineFlowModel->getUserByFlow($examineFlowData['flow_id'], $dataInfo['create_user_id']);
  197. // $param['flow_user_id'] = $flow_user_id ? arrayToString($flow_user_id) : '';
  198. $param['flow_user_id'] = '';
  199. $res = $examineModel->updateDataById($param, $param['id']);
  200. if ($res) {
  201. //将审批记录至为无效
  202. $examineRecordModel = new \app\admin\model\ExamineRecord();
  203. $examineRecordModel->setEnd(['types' => 'oa_examine','types_id' => $param['id']]);
  204. $categoryModel = new \app\oa\model\ExamineCategory();
  205. $categoryInfo = $categoryModel->getDataById($dataInfo['category_id']);
  206. actionLog($param['id'], '', '', '新建了审批');
  207. return resultArray(['data' => '编辑成功']);
  208. } else {
  209. return resultArray(['error' => $examineModel->getError()]);
  210. }
  211. }
  212. /**
  213. * 删除审批(逻辑删)
  214. * @author Michael_xu
  215. * @param
  216. * @return
  217. */
  218. public function delete()
  219. {
  220. $examineModel = model('Examine');
  221. $param = $this->param;
  222. $userInfo = $this->userInfo;
  223. $dataInfo = db('oa_examine')->where(['examine_id' => $param['id']])->find();
  224. if (!$dataInfo) {
  225. return resultArray(['error' => '数据不存在或已删除']);
  226. }
  227. $adminTypes = adminGroupTypes($userInfo['id']);
  228. if (in_array($dataInfo['check_status'], [2,3])) {
  229. return resultArray(['error' => '已审批,不可删除']);
  230. }
  231. if (!in_array($dataInfo['check_status'],['4']) && !in_array(1,$adminTypes)) {
  232. return resultArray(['error' => '不可删除,请先撤销审核']);
  233. }
  234. //权限判断
  235. if ($userInfo['id'] != $dataInfo['create_user_id']) {
  236. return resultArray(['error' => '无权操作']);
  237. }
  238. $data = $examineModel->delDataById($param['id']);
  239. if (!$data) {
  240. return resultArray(['error' => $examineModel->getError()]);
  241. }
  242. $fileModel = new \app\admin\model\File();
  243. //删除关联附件
  244. $fileModel->delRFileByModule('oa_examine',$param['id']);
  245. # 删除记录
  246. actionLog($param['id'], '', '', '删除了审批');
  247. # 删除活动记录
  248. Db::name('crm_activity')->where(['activity_type' => 9, 'activity_type_id' => $param['id']])->delete();
  249. return resultArray(['data' => '删除成功']);
  250. }
  251. /**
  252. * 审批类型(列表)
  253. * @author Michael_xu
  254. * @param
  255. * @return
  256. */
  257. public function category()
  258. {
  259. $categoryModel = model('ExamineCategory');
  260. $param = $this->param;
  261. $data = $categoryModel->getDataList($param);
  262. return resultArray(['data' => $data]);
  263. }
  264. /**
  265. * 审批类型(创建)
  266. * @author Michael_xu
  267. * @param
  268. * @return
  269. */
  270. public function categorySave()
  271. {
  272. $categoryModel = model('ExamineCategory');
  273. $param = $this->param;
  274. $userInfo = $this->userInfo;
  275. $param['create_user_id'] = $userInfo['id'];
  276. $res = $categoryModel->createData($param);
  277. if ($res) {
  278. return resultArray(['data' => $res]);
  279. } else {
  280. return resultArray(['error' => $categoryModel->getError()]);
  281. }
  282. }
  283. /**
  284. * 审批类型(编辑)
  285. * @author Michael_xu
  286. * @param
  287. * @return
  288. */
  289. public function categoryUpdate()
  290. {
  291. $categoryModel = model('ExamineCategory');
  292. $examineFlowModel = new \app\admin\model\ExamineFlow();
  293. $examineStepModel = new \app\admin\model\ExamineStep();
  294. $param = $this->param;
  295. $userInfo = $this->userInfo;
  296. $category_id = $param['id'];
  297. $dataInfo = $categoryModel->getDataById($category_id);
  298. if (!$dataInfo) {
  299. return resultArray(['error' => '数据不存在或已删除']);
  300. }
  301. //将当前审批流标记为已删除,重新创建审批流(目的:保留审批流程记录)
  302. // $newData = db('admin_examine_flow')->where(['flow_id' => $dataInfo['flow_id']])->find();
  303. $param['name'] = $param['title'].'流程';
  304. $param['types'] = 'oa_examine';
  305. $param['types_id'] = $category_id;
  306. $param['user_ids'] = arrayToString($param['user_ids']);
  307. $param['structure_ids'] = arrayToString($param['structure_ids']);
  308. $param['update_user_id'] = $userInfo['id'];
  309. $param['create_time'] = time();
  310. $param['update_time'] = time();
  311. $param['status'] = 1;
  312. $resUpdate = $examineFlowModel->createData($param);
  313. if ($resUpdate) {
  314. if ($param['config'] == 1) {
  315. $resStep = $examineStepModel->createStepData($param['step'], $resUpdate['flow_id']);
  316. if (!$resStep) {
  317. return resultArray(['error' => $examineStepModel->getError()]);
  318. }
  319. }
  320. if ($dataInfo['flow_id']) {
  321. $upData = [];
  322. $upData['is_deleted'] = 1;
  323. $upData['delete_time'] = time();
  324. $upData['delete_user_id'] = $userInfo['id'];
  325. $upData['status'] = 0;
  326. $resFlow = db('admin_examine_flow')->where(['flow_id' => $dataInfo['flow_id']])->update($upData);
  327. if (!$resFlow) {
  328. return resultArray(['error' => '编辑失败']);
  329. }
  330. }
  331. $param['flow_id'] = $resUpdate['flow_id'];
  332. $res = $categoryModel->updateDataById($param, $param['id']);
  333. if (!$res) {
  334. return resultArray(['error' => $categoryModel->getError()]);
  335. }
  336. return resultArray(['data' => '编辑成功']);
  337. } else {
  338. return resultArray(['error' => $examineFlowModel->getError()]);
  339. }
  340. }
  341. /**
  342. * 审批类型(逻辑删)
  343. * @author Michael_xu
  344. * @param
  345. * @return
  346. */
  347. public function categoryDelete()
  348. {
  349. $categoryModel = model('ExamineCategory');
  350. $param = $this->param;
  351. $userInfo = $this->userInfo;
  352. $data = $categoryModel->signDelById($param['id'], $userInfo['id']);
  353. if (!$data) {
  354. return resultArray(['error' => $categoryModel->getError()]);
  355. }
  356. return resultArray(['data' => '删除成功']);
  357. }
  358. /**
  359. * 审批类型状态(启用、停用)
  360. * @author Michael_xu
  361. * @param ids array
  362. * @param status 1启用,0禁用
  363. * @return
  364. */
  365. public function categoryEnables()
  366. {
  367. $categoryModel = model('ExamineCategory');
  368. $param = $this->param;
  369. $userInfo = $this->userInfo;
  370. $id = [$param['id']];
  371. $data = $categoryModel->enableDatas($id, $param['status']);
  372. if (!$data) {
  373. return resultArray(['error' => $categoryModel->getError()]);
  374. }
  375. return resultArray(['data' => '操作成功']);
  376. }
  377. /**
  378. * 审批类型列表(创建时)
  379. * @author Michael_xu
  380. * @return
  381. */
  382. public function categoryList()
  383. {
  384. $param = $this->param;
  385. $userInfo = $this->userInfo;
  386. $where = [];
  387. $where['is_deleted'] = ['neq',1];
  388. $where['status'] = ['eq',1];
  389. $list = db('oa_examine_category')
  390. ->where($where)
  391. ->where(function ($query) use ($userInfo){
  392. $query->where('`user_ids` = "" AND `structure_ids` = ""')
  393. ->whereOr(function($query) use ($userInfo){
  394. $query->where('structure_ids','like','%,'.$userInfo['structure_id'].',%')
  395. ->whereOr('user_ids','like','%,'.$userInfo['id'].',%');
  396. });
  397. })->select();
  398. return resultArray(['data' => $list]);
  399. }
  400. /**
  401. * 审批审核
  402. * @author Michael_xu
  403. * @param
  404. * @return
  405. */
  406. public function check()
  407. {
  408. $param = $this->param;
  409. $userInfo = $this->userInfo;
  410. $user_id = $userInfo['id'];
  411. $examineModel = model('Examine');
  412. $examineStepModel = new \app\admin\model\ExamineStep();
  413. $examineRecordModel = new \app\admin\model\ExamineRecord();
  414. $examineFlowModel = new \app\admin\model\ExamineFlow();
  415. $examineData = [];
  416. $examineData['update_time'] = time();
  417. $examineData['check_status'] = 1; //0待审核,1审核通中,2审核通过,3审核未通过
  418. //权限判断
  419. if (!$examineStepModel->checkExamine($user_id, 'oa_examine', $param['id'])) {
  420. return resultArray(['error' => $examineStepModel->getError()]);
  421. };
  422. //审批主体详情
  423. $dataInfo = $examineModel->getDataById($param['id']);
  424. $flowInfo = $examineFlowModel->getDataById($dataInfo['flow_id']);
  425. $is_end = 0; // 1审批结束
  426. $status = $param['status'] ? 1 : 0; //1通过,0驳回
  427. $checkData = [];
  428. $checkData['check_user_id'] = $user_id;
  429. $checkData['types'] = 'oa_examine';
  430. $checkData['types_id'] = $param['id'];
  431. $checkData['check_time'] = time();
  432. $checkData['content'] = $param['content'];
  433. $checkData['flow_id'] = $dataInfo['flow_id'];
  434. $checkData['order_id'] = $dataInfo['order_id'] ? : 1;
  435. $checkData['status'] = $status;
  436. if ($status == 1) {
  437. if ($flowInfo['config'] == 1) {
  438. //固定流程
  439. //获取下一审批信息
  440. $nextStepData = $examineStepModel->nextStepUser($dataInfo['create_user_id'], $dataInfo['flow_id'], 'oa_examine', $param['id'], $dataInfo['order_id'], $user_id);
  441. $next_user_ids = $nextStepData['next_user_ids'] ? : [];
  442. $examineData['order_id'] = $nextStepData['order_id'] ? : '';
  443. if (!$next_user_ids) {
  444. $is_end = 1;
  445. //审批结束
  446. $checkData['check_status'] = !empty($status) ? 2 : 3;
  447. // $examineData['check_user_id'] = '';
  448. } else {
  449. //修改主体相关审批信息
  450. $examineData['check_user_id'] = arrayToString($next_user_ids);
  451. }
  452. } else {
  453. //自选流程
  454. $is_end = $param['is_end'] ? 1 : '';
  455. $check_user_id = $param['check_user_id'] ? : '';
  456. if ($is_end !== 1 && empty($check_user_id)) {
  457. return resultArray(['error' => '请选择下一审批人']);
  458. }
  459. $examineData['check_user_id'] = arrayToString($param['check_user_id']);
  460. }
  461. if ($is_end == 1) {
  462. $checkData['check_status'] = !empty($status) ? 2 : 3;
  463. // $examineData['check_user_id'] = '';
  464. $examineData['check_status'] = 2;
  465. }
  466. } else {
  467. //审批驳回
  468. $is_end = 1;
  469. $examineData['check_status'] = 3;
  470. //将审批记录至为无效
  471. // $examineRecordModel->setEnd(['types' => 'oa_examine','types_id' => $param['id']]);
  472. }
  473. //已审批人ID
  474. $examineData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']),[$user_id])) : arrayToString([$user_id]);
  475. $resExamine = db('oa_examine')->where(['examine_id' => $param['id']])->update($examineData);
  476. if ($resExamine) {
  477. $lastExamine = db('oa_examine')->where(['examine_id' => $param['id']])->update(['last_user_id'=> $examineData['flow_user_id']]);
  478. //审批记录
  479. $resRecord = $examineRecordModel->createData($checkData);
  480. //审核通过
  481. if ($is_end == 1 && !empty($status)) {
  482. // 审批通过消息告知审批提交人
  483. (new Message())->send(
  484. Message::EXAMINE_PASS,
  485. [
  486. 'title' => $dataInfo['category_name'],
  487. 'action_id' => $param['id']
  488. ],
  489. $dataInfo['create_user_id']
  490. );
  491. } else {
  492. if ($status) {
  493. // 通过后发送消息给下一审批人
  494. (new Message())->send(
  495. Message::EXAMINE_TO_DO,
  496. [
  497. 'from_user' => User::where(['id' => $dataInfo['create_user_id']])->value('realname'),
  498. 'title' => $dataInfo['category_name'],
  499. 'action_id' => $param['id']
  500. ],
  501. stringToArray($examineData['check_user_id'])
  502. );
  503. } else {
  504. // 审批驳回消息告知审批提交人
  505. (new Message())->send(
  506. Message::EXAMINE_REJECT,
  507. [
  508. 'title' => $dataInfo['category_name'],
  509. 'action_id' => $param['id']
  510. ],
  511. $dataInfo['create_user_id']
  512. );
  513. }
  514. }
  515. return resultArray(['data' => '审批成功']);
  516. } else {
  517. return resultArray(['error' => '审批失败,请重试!']);
  518. }
  519. }
  520. /**
  521. * 审批撤销审核
  522. * @author Michael_xu
  523. * @param
  524. * @return
  525. */
  526. public function revokeCheck()
  527. {
  528. $param = $this->param;
  529. $userInfo = $this->userInfo;
  530. $user_id = $userInfo['id'];
  531. $examine_id = $param['id'];
  532. $examineModel = model('Examine');
  533. $examineRecordModel = new \app\admin\model\ExamineRecord();
  534. $userModel = new \app\admin\model\User();
  535. $examineData = [];
  536. $examineData['update_time'] = time();
  537. $examineData['check_status'] = 0; //0待审核,1审核通中,2审核通过,3审核未通过
  538. //审批主体详情
  539. $dataInfo = db('oa_examine')->where(['examine_id' => $examine_id])->find();
  540. //权限判断(创建人或管理员)
  541. if ($dataInfo['check_status'] == 2) {
  542. return resultArray(['error' => '已审批结束,不能撤销']);
  543. }
  544. if ($dataInfo['check_status'] == 4) {
  545. return resultArray(['error' => '无需撤销']);
  546. }
  547. $admin_user_ids = $userModel->getAdminId();
  548. if ($dataInfo['create_user_id'] !== $user_id && !in_array($user_id, $admin_user_ids)) {
  549. return resultArray(['error' => '没有权限']);
  550. }
  551. $is_end = 0; // 1审批结束
  552. $status = 2; //1通过,0驳回, 2撤销
  553. $checkData = [];
  554. $checkData['check_user_id'] = $user_id;
  555. $checkData['types'] = 'oa_examine';
  556. $checkData['types_id'] = $param['id'];
  557. $checkData['check_time'] = time();
  558. $checkData['content'] = $param['content'];
  559. $checkData['flow_id'] = $dataInfo['flow_id'];
  560. $checkData['order_id'] = $dataInfo['order_id'];
  561. $checkData['status'] = $status;
  562. $examineData['check_status'] = 4;
  563. # 如果将审批人置空,会导致普通员工在右上角消息中无法查看审批
  564. $examineData['check_user_id'] = $dataInfo['check_user_id'];
  565. $examineData['flow_user_id'] = '';
  566. $resExamine = db('oa_examine')->where(['examine_id' => $examine_id])->update($examineData);
  567. if ($resExamine) {
  568. //将审批记录至为无效
  569. $examineRecordModel->setEnd(['types' => 'oa_examine','types_id' => $examine_id]);
  570. //审批记录
  571. $resRecord = $examineRecordModel->createData($checkData);
  572. return resultArray(['data' => '撤销成功']);
  573. } else {
  574. return resultArray(['error' => '撤销失败,请重试!']);
  575. }
  576. }
  577. /**
  578. * 我的审批
  579. * @return mixed
  580. */
  581. public function myExamine(){
  582. $param = $this->param;
  583. $userInfo = $this->userInfo;
  584. $param['user_id'] = $userInfo['id'];
  585. $ExamineLogic = new ExamineLogic();
  586. $data = $ExamineLogic->myExamine($param);
  587. return resultArray(['data' => $data]);
  588. }
  589. }