ExamineLogic.php 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <?php
  2. namespace app\oa\logic;
  3. use app\admin\model\Common;
  4. use app\oa\model\Examine;
  5. use think\Db;
  6. use think\Validate;
  7. class ExamineLogic extends Common
  8. {
  9. private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回'];
  10. /**
  11. * 导入数据查询
  12. * @param $request
  13. *
  14. * @author alvin guogaobo
  15. * @version 1.0 版本号
  16. * @since 2021/2/27 0027 17:34
  17. */
  18. public function getDataList($request)
  19. {
  20. $userModel = new \app\admin\model\User();
  21. $fileModel = new \app\admin\model\File();
  22. $recordModel = new \app\admin\model\Record();
  23. $examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
  24. $user_id = $request['user_id'];
  25. $bi = $request['bi_types'];
  26. $check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
  27. unset($request['by']);
  28. unset($request['bi_types']);
  29. unset($request['user_id']);
  30. unset($request['check_status']);
  31. unset($request['examine_by']);
  32. $request = $this->fmtRequest($request);
  33. $map = $request['map'] ?: [];
  34. if (isset($map['search']) && $map['search']) {
  35. //普通筛选
  36. $map['examine.content'] = ['like', '%' . $map['search'] . '%'];
  37. } else {
  38. $map = where_arr($map, 'oa', 'examine', 'index'); //高级筛选
  39. }
  40. unset($map['search']);
  41. //审批类型
  42. $map['examine.category_id'] = $map['examine.category_id'] ?: array('gt', 0);
  43. $map_str = '';
  44. $logmap = '';
  45. switch ($examine_by) {
  46. case 'all' :
  47. //如果超管则能看到全部
  48. if (!isSuperAdministrators($user_id)) {
  49. $map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " ) OR ( flow_user_id LIKE '%," . $user_id . ",%' OR `flow_user_id` = " . $user_id . " ) )";
  50. }
  51. break;
  52. case '1' :
  53. $map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
  54. break; //待审
  55. case '2' :
  56. $map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " )
  57. OR ( flow_user_id LIKE '%," . $user_id . ",%' OR `flow_user_id` = " . $user_id . " ) )";
  58. // $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
  59. break; //已审
  60. default:
  61. $map['examine.create_user_id'] = $user_id;
  62. break;
  63. }
  64. $order = 'examine.create_time desc,examine.update_time desc';
  65. //发起时间
  66. if ($map['examine.between_time'][0] && $map['examine.between_time'][1]) {
  67. $start_time = $map['examine.between_time'][0];
  68. $end_time = $map['examine.between_time'][1];
  69. $map['examine.create_time'] = array('between', array($start_time, $end_time));
  70. }
  71. unset($map['examine.between_time']);
  72. //审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
  73. if (isset($check_status)) {
  74. if ($check_status == 'all') {
  75. $map['examine.check_status'] = ['egt', 0];
  76. if (isSuperAdministrators($user_id)) {
  77. unset($map['examine.create_user_id']);
  78. }
  79. } elseif ($check_status == 4) {
  80. $map['examine.check_status'] = ['eq', 3];
  81. } elseif ($check_status == 0) {
  82. $map['examine.check_status'] = ['<=', 1];
  83. } else {
  84. $map['examine.check_status'] = $check_status;
  85. }
  86. } else {
  87. if ($examine_by == 'all') {
  88. $map['examine.check_status'] = ['egt', 0];
  89. } elseif ($examine_by == 1) {
  90. $map['examine.check_status'] = ['elt', 1];
  91. } elseif ($examine_by == 2) {
  92. $map['examine.check_status'] = ['egt', 2];
  93. }
  94. }
  95. $join = [
  96. ['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
  97. ['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
  98. ];
  99. $list_view = db('oa_examine')
  100. ->alias('examine')
  101. ->where($map_str)
  102. ->where($map)
  103. ->join($join);
  104. $res = [];
  105. $list = $list_view
  106. ->page($request['page'], $request['limit'])
  107. ->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
  108. ->order($order)
  109. ->select();
  110. foreach ($list as $k => $v) {
  111. $causeCount = 0;
  112. $causeTitle = '';
  113. $duration = $v['duration'] ?: '0.0';
  114. $money = $v['money'] ?: '0.00';
  115. $list[$k]['causeTitle'] = $causeTitle;
  116. $list[$k]['causeCount'] = $causeCount ?: 0;
  117. $item = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->select();
  118. if ($item) {
  119. foreach ($item as $key => $value) {
  120. if($v['check_status']==4){
  121. $usernames = '';
  122. }else{
  123. $usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
  124. }
  125. //关联业务
  126. $relationArr = [];
  127. $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
  128. $item[$key]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
  129. arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
  130. arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
  131. arrayToString(array_column($relationArr['customerList'], 'name'));
  132. $res[] = [
  133. 'category_name' => $v['category_name'],
  134. 'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
  135. 'realname' => $v['realname'],
  136. 'check_status_info' => $this->statusArr[(int)$v['check_status']],
  137. 'examine_name' => implode($usernames, ','),
  138. 'content' => $v['content'],
  139. 'remark' => $v['remark'],
  140. 'duration' => $v['duration'],
  141. 'vehicle' => $value['vehicle'],
  142. 'trip' => $value['trip'],
  143. 'money' => $value['money'],
  144. 'traffic' => $value['traffic'],
  145. 'stay' => $value['stay'],
  146. 'diet' => $value['diet'],
  147. 'other' => $value['other'],
  148. 'start_address' => $value['start_address'],
  149. 'end_address' => $value['end_address'],
  150. 'start_time' => !empty($value['start_time']) ? date('Y-m-d H:i:s', $value['start_time']) : null,
  151. 'end_time' => !empty($value['end_time']) ? date('Y-m-d H:i:s', $value['end_time']) : null,
  152. 'description' => $value['description'],
  153. 'replyList' => str_replace(',', ' ', $item[$key]['relation']),
  154. ];
  155. }
  156. } else {
  157. $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
  158. $list[$k]['start_time'] = !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null;
  159. $list[$k]['end_time'] = !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null;
  160. if($v['check_status']==4){
  161. $usernames = '';
  162. }else{
  163. $usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
  164. }
  165. //关联业务
  166. $relationArr = [];
  167. $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
  168. $list[$k]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
  169. arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
  170. arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
  171. arrayToString(array_column($relationArr['customerList'], 'name'));
  172. $res[] = [
  173. 'category_name' => $v['category_name'],
  174. 'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
  175. 'realname' => $v['realname'],
  176. 'check_status_info' => $this->statusArr[(int)$v['check_status']],
  177. 'examine_name' => implode($usernames, ','),
  178. 'content' => $v['content'],
  179. 'remark' => $v['remark'],
  180. 'duration' => $v['duration'],
  181. 'vehicle' => '',
  182. 'money' => $v['money'],
  183. 'traffic' => '',
  184. 'stay' => '',
  185. 'diet' => '',
  186. 'other' => '',
  187. 'start_address' => '',
  188. 'end_address' => '',
  189. 'start_time' => !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null,
  190. 'end_time' => !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null,
  191. 'description' => '',
  192. 'replyList' => str_replace(',', ' ', $item[$key]['relation']),
  193. ];
  194. }
  195. }
  196. return $res;
  197. }
  198. /**
  199. * 审批导出
  200. * @param $param
  201. * @return mixed
  202. */
  203. public function excelExport($param)
  204. {
  205. $excelModel = new \app\admin\model\Excel();
  206. $data = $this->getDataList($param);
  207. $list = [];
  208. switch ($param['category_id']) {
  209. case '1' :
  210. $field_list = [
  211. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  212. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  213. '2' => ['name' => '创建人', 'field' => 'realname'],
  214. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  215. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  216. '5' => ['name' => '备注', 'field' => 'description'],
  217. '6' => ['name' => '关联业务', 'field' => 'replyList'],
  218. ];
  219. break;
  220. case '2' :
  221. $field_list = [
  222. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  223. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  224. '2' => ['name' => '创建人', 'field' => 'realname'],
  225. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  226. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  227. '5' => ['name' => '审批内容', 'field' => 'content'],
  228. '6' => ['name' => '开始时间', 'field' => 'start_time'],
  229. '7' => ['name' => '结束时间', 'field' => 'end_time'],
  230. '8' => ['name' => '时长', 'field' => 'duration'],
  231. '9' => ['name' => '备注', 'field' => 'description'],
  232. '10' => ['name' => '关联业务', 'field' => 'replyList'],
  233. ];
  234. break;
  235. case '3' :
  236. $field_list = [
  237. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  238. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  239. '2' => ['name' => '创建人', 'field' => 'realname'],
  240. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  241. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  242. '5' => ['name' => '出差事由', 'field' => 'content'],
  243. '6' => ['name' => '备注', 'field' => 'remark'],
  244. '7' => ['name' => '出差总天数', 'field' => 'duration'],
  245. '8' => ['name' => '交通工具', 'field' => 'vehicle'],
  246. '9' => ['name' => '单程往返', 'field' => 'trip'],
  247. '10' => ['name' => '出发城市', 'field' => 'start_address'],
  248. '11' => ['name' => '目的城市', 'field' => 'end_address'],
  249. '12' => ['name' => '开始时间', 'field' => 'start_time'],
  250. '13' => ['name' => '结束时间', 'field' => 'end_time'],
  251. '14' => ['name' => '出差备注', 'field' => 'description'],
  252. '15' => ['name' => '时长', 'field' => 'duration'],
  253. '16' => ['name' => '关联业务', 'field' => 'replyList'],
  254. ];
  255. break;
  256. case '4' :
  257. $field_list = [
  258. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  259. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  260. '2' => ['name' => '创建人', 'field' => 'realname',],
  261. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  262. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  263. '5' => ['name' => '加班原因', 'field' => 'content'],
  264. '6' => ['name' => '开始时间', 'field' => 'start_time'],
  265. '7' => ['name' => '结束时间', 'field' => 'end_time'],
  266. '8' => ['name' => '加班总天数', 'field' => 'duration'],
  267. '9' => ['name' => '备注', 'field' => 'description'],
  268. '10' => ['name' => '关联业务', 'field' => 'replyList'],
  269. ];
  270. break;
  271. case '5':
  272. $field_list = [
  273. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  274. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  275. '2' => ['name' => '创建人', 'field' => 'realname'],
  276. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  277. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  278. '5' => ['name' => '差旅内容', 'field' => 'content'],
  279. '6' => ['name' => '报销总金额', 'field' => 'money'],
  280. '7' => ['name' => '备注', 'field' => 'remark'],
  281. '8' => ['name' => '出发城市', 'field' => 'start_address'],
  282. '9' => ['name' => '目的城市', 'field' => 'end_address'],
  283. '10' => ['name' => '开始时间', 'field' => 'start_time'],
  284. '11' => ['name' => '结束时间', 'field' => 'end_time'],
  285. '12' => ['name' => '交通费', 'field' => 'traffic'],
  286. '13' => ['name' => '住宿费', 'field' => 'stay'],
  287. '14' => ['name' => '餐饮费', 'field' => 'diet'],
  288. '15' => ['name' => '其他费用', 'field' => 'other'],
  289. '16' => ['name' => '合计', 'field' => 'money'],
  290. '17' => ['name' => '费用明细描述', 'field' => 'description'],
  291. '18' => ['name' => '关联业务', 'field' => 'relation'],
  292. ];
  293. break;
  294. case '6' :
  295. $field_list = [
  296. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  297. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  298. '2' => ['name' => '创建人', 'field' => 'realname'],
  299. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  300. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  301. '5' => ['name' => '借款事由', 'field' => 'content'],
  302. '6' => ['name' => '开始时间', 'field' => 'start_time'],
  303. '7' => ['name' => '结束时间', 'field' => 'end_time'],
  304. '8' => ['name' => '借款金额', 'field' => 'money'],
  305. '9' => ['name' => '备注', 'field' => 'description'],
  306. '10' => ['name' => '关联业务', 'field' => 'replyList'],
  307. ];
  308. break;
  309. default :
  310. $field_list = [
  311. '0' => ['name' => '审批类型', 'field' => 'category_name'],
  312. '1' => ['name' => '创建时间', 'field' => 'create_time'],
  313. '2' => ['name' => '创建人', 'field' => 'realname'],
  314. '3' => ['name' => '状态', 'field' => 'check_status_info'],
  315. '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
  316. '5' => ['name' => '备注', 'field' => 'description'],
  317. '6' => ['name' => '关联业务', 'field' => 'replyList'],
  318. ];
  319. }
  320. $file_name = 'oa_examine';
  321. return $excelModel->dataExportCsv($file_name, $field_list, $data);
  322. }
  323. /**
  324. * 审批数据
  325. * @param $param
  326. */
  327. public function myExamine($param)
  328. {
  329. $param['status'] = $param['status'] == 'all' ? 3 : $param['status'];
  330. $auth_user_ids = getSubUserId(true, 0, $param['user_id']);
  331. $user_id = $param['user_id'];
  332. $where = [];
  333. $whereOr = [];
  334. if ($param['status'] == 0) {
  335. $where['a.check_status'] = ['elt', 1];
  336. $whereOr = function ($query) use ($user_id) {
  337. $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
  338. };
  339. } elseif ($param['status'] == 1) {
  340. $where['a.check_status'] = ['in', [2, 3]];
  341. $whereOr = function ($query) use ($user_id) {
  342. $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
  343. };
  344. } elseif ($param['status'] == 3) {
  345. $where['a.check_status'] = ['lt', 5];
  346. $whereOr = function ($query) use ($user_id) {
  347. $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
  348. };
  349. }
  350. $userModel = new \app\admin\model\User();
  351. switch ($param['type']) {
  352. case '1':
  353. //合同
  354. $list = db('crm_contract')
  355. ->alias('a')
  356. ->join('__CRM_CUSTOMER__ customer', 'a.customer_id = customer.customer_id', 'LEFT')
  357. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  358. ->join('__ADMIN_EXAMINE_FLOW__ examine_flow', 'examine_flow.flow_id = a.flow_id', 'LEFT')
  359. ->where($where)
  360. ->where($whereOr)
  361. ->field(
  362. 'a.contract_id as catagory_id,a.name,a.create_time,a.check_status,a.create_user_id,a.check_user_id,a.flow_user_id,
  363. customer.name as customer_name,
  364. a.customer_id,user.realname,examine_flow.name as examine_name'
  365. )
  366. ->page($param['page'], $param['limit'])
  367. ->order('a.create_time desc')
  368. ->select();
  369. foreach ($list as $k => $v) {
  370. $list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
  371. $list[$k]['customer_id_info']['name'] = $v['customer_name'];
  372. $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
  373. }
  374. $dataCount = db('crm_contract')
  375. ->alias('a')
  376. ->join('__CRM_CUSTOMER__ customer', 'a.customer_id = customer.customer_id', 'LEFT')
  377. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  378. ->where($where)
  379. ->where($whereOr)
  380. ->count();
  381. break;
  382. case '2':
  383. //回款
  384. $list = db('crm_receivables')
  385. ->alias('a')
  386. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  387. ->join('__ADMIN_EXAMINE_FLOW__ examine_flow', 'examine_flow.flow_id = a.flow_id', 'LEFT')
  388. ->join('__CRM_CONTRACT__ contract', 'a.contract_id = contract.contract_id', 'LEFT')
  389. ->where($where)
  390. ->where($whereOr)
  391. ->field(
  392. 'a.receivables_id as catagory_id ,a.number as name,a.create_time,a.check_status,a.check_user_id,a.flow_user_id,
  393. contract.name as contract_name,a.create_user_id,a.contract_id,user.realname,examine_flow.name as examine_name'
  394. )
  395. ->page($param['page'], $param['limit'])
  396. ->order('a.create_time desc')
  397. ->select();
  398. $dataCount = db('crm_receivables')
  399. ->alias('a')
  400. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  401. ->join('__CRM_CONTRACT__ contract', 'a.contract_id = contract.contract_id', 'LEFT')
  402. ->where($where)
  403. ->where($whereOr)
  404. ->count();
  405. foreach ($list as $k => $v) {
  406. $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
  407. $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
  408. $list[$k]['contract_id_info']['name'] = $v['contract_name'];
  409. }
  410. break;
  411. case '3':
  412. $list = db('crm_invoice')
  413. ->alias('a')
  414. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  415. ->join('__ADMIN_EXAMINE_FLOW__ examine_flow', 'examine_flow.flow_id = a.flow_id', 'LEFT')
  416. ->where($where)
  417. ->where($whereOr)
  418. ->field(
  419. 'a.invoice_id as catagory_id ,a.invoice_apple_number as name,a.create_time,a.check_status,a.create_user_id,a.check_user_id,a.flow_user_id,user.realname,examine_flow.name as examine_name'
  420. )
  421. ->page($param['page'], $param['limit'])
  422. ->order('a.create_time desc')
  423. ->select();
  424. foreach ($list as $k => $v) {
  425. $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
  426. }
  427. $dataCount = db('crm_invoice')
  428. ->alias('a')
  429. ->join('__ADMIN_USER__ user', 'user.id = a.create_user_id', 'LEFT')
  430. ->where($where)
  431. ->where($whereOr)
  432. ->count();
  433. break;
  434. }
  435. foreach ($list as $key => $v) {
  436. $list[$key]['create_time'] = date('Y-m-d H:i:s', $v['create_time']) ?: '';
  437. }
  438. $data = [];
  439. $data['page']['list'] = $list;
  440. $data['page']['dataCount'] = $dataCount ?: 0;
  441. if ($param['page'] != 1 && ($param['page'] * $param['limit']) >= $dataCount) {
  442. $data['page']['firstPage'] = false;
  443. $data['page']['lastPage'] = true;
  444. } else if ($param['page'] != 1 && (int)($param['page'] * $param['limit']) < $dataCount) {
  445. $data['page']['firstPage'] = false;
  446. $data['page']['lastPage'] = false;
  447. } else if ($param['page'] == 1) {
  448. $data['page']['firstPage'] = true;
  449. $data['page']['lastPage'] = false;
  450. }
  451. return $data;
  452. }
  453. /**
  454. * @param $workIds
  455. * @param $userId
  456. *
  457. * @author alvin guogaobo
  458. * @version 1.0 版本号
  459. * @since 2021/4/16 0016 14:00
  460. */
  461. public function setWorkOrder($examineIds, $userId)
  462. {
  463. $data = [];
  464. foreach ($examineIds AS $key => $value) {
  465. $data[] = [
  466. 'work_id' => $value,
  467. 'user_id' => $userId,
  468. 'order' => $key + 1
  469. ];
  470. }
  471. if (!empty($data)) {
  472. if (db('oa_examine_order')->where('user_id', $userId)->delete() === false) return false;
  473. if (db('oa_examine_order')->insertAll($data) === false) return false;
  474. }
  475. return true;
  476. }
  477. }