IntegralVerify.php 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\TalentLogApi;
  6. use app\common\model\MessageRecord;
  7. use app\common\api\DictApi;
  8. use app\common\api\EnterpriseApi;
  9. use think\facade\Db;
  10. use app\admin\model\User;
  11. use app\common\api\MenuApi;
  12. use app\admin\model\SysRelation;
  13. use app\common\api\CompanyApi;
  14. use app\common\api\IntegralRecordApi;
  15. use app\common\state\ProjectState;
  16. use app\common\state\IntegralState;
  17. use app\common\model\IntegralRecord;
  18. use app\common\model\IntegralDetail;
  19. /**
  20. * Description of Talent
  21. *
  22. * @author sgq
  23. */
  24. class IntegralVerify extends AdminController {
  25. public function fst_verify() {
  26. $enterprises = EnterpriseApi::getSimpleList();
  27. return view("", ["enterprises" => $enterprises]);
  28. }
  29. public function re_verify() {
  30. $enterprises = EnterpriseApi::getSimpleList();
  31. return view("", ["enterprises" => $enterprises]);
  32. }
  33. public function list() {
  34. $res = IntegralRecordApi::getListByProcess($this->request->param());
  35. return json($res);
  36. }
  37. public function detail() {
  38. $request = $this->request;
  39. $params = $request->param();
  40. $id = $params["id"];
  41. $row = IntegralRecordApi::getOne($id);
  42. foreach ($row["items"] as $key => $item) {
  43. $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
  44. $integralItem = json_decode($redis->hGet("IntegralItem", $item["item_id"]), true);
  45. $integralProject = json_decode($redis->hGet("IntegralProject", $integralItem["projectId"]), true);
  46. $row["items"][$key]["itemName"] = $integralItem["name"];
  47. $row["items"][$key]["unit"] = $integralItem["unit"];
  48. $row["items"][$key]["projectName"] = $integralProject["name"];
  49. $row["items"][$key]["projectType"] = $integralProject["projectType"];
  50. }
  51. return view("", ["row" => $row]);
  52. }
  53. public function cancel_verify() {
  54. $params = $this->request->param();
  55. $ids = $params["ids"];
  56. $msg = $params["msg"];
  57. if ($msg == "") {
  58. return json(["msg" => "请填写审核不通过的原因"]);
  59. }
  60. $ids_arr = array_filter(explode(",", $ids));
  61. $counts = 0;
  62. foreach ($ids_arr as $id) {
  63. $record = IntegralRecordApi::getOne($id);
  64. $data["id"] = $id;
  65. if ($record["checkState"] == IntegralState::SUBMIT) {
  66. $data["checkState"] = IntegralState::VERIFY_FAIL;
  67. TalentLogApi::write(ProjectState::INTEGRAL, $id, IntegralState::VERIFY_FAIL, $msg, 1);
  68. IntegralRecord::update($data);
  69. $counts++;
  70. } else if ($record["checkState"] == IntegralState::VERIFY_PASS) {
  71. $data["checkState"] = IntegralState::REVERIFY_FAIL;
  72. TalentLogApi::write(ProjectState::INTEGRAL, $id, IntegralState::REVERIFY_FAIL, $msg, 1);
  73. IntegralRecord::update($data);
  74. $counts++;
  75. } else {
  76. return json(["msg" => "不在审核范围"]);
  77. }
  78. }
  79. return json(["code" => 200, sprintf("%d个申请已审核不通过", $counts)]);
  80. }
  81. /**
  82. * 预备积分库
  83. */
  84. public function pre_list() {
  85. if ($this->user["type"] == 1) {
  86. $message = [
  87. "typeName" => "晋江市现代产业体系人才积分评定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
  88. "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
  89. ];
  90. } else {
  91. $message = [
  92. "typeName" => "晋江市集成电路产业优秀人才积分评定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
  93. "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
  94. ];
  95. }
  96. $enterprises = EnterpriseApi::getSimpleList();
  97. return view("", ["message" => $message, "enterprises" => $enterprises]);
  98. }
  99. /**
  100. * 人才积分库
  101. */
  102. public function library() {
  103. $enterprises = EnterpriseApi::getSimpleList();
  104. return view("", ["enterprises" => $enterprises]);
  105. }
  106. public function veto() {
  107. $type = $this->request["type"];
  108. $card_type = $this->request["card_type"];
  109. $card_number = $this->request["card_number"];
  110. $enterprise_id = $this->request["enterprise_id"];
  111. $where = [];
  112. $enterpriseList = [];
  113. if ($type == 1) {
  114. $where[] = ["enterprise_id", "=", $enterprise_id];
  115. $enterpriseList = EnterpriseApi::getSimpleList([["type", "=", $this->user["type"]]]);
  116. } else {
  117. $where[] = ["card_type", "=", $card_type];
  118. $where[] = ["card_number", "=", $card_number];
  119. $whr[] = ["card_type", "=", $card_type];
  120. $whr[] = ["card_number", "=", $card_number];
  121. $whr[] = ["checkState", "=", IntegralState::SUCCESS];
  122. $irecord = Db::table("new_integral_record")->where($whr)->find();
  123. }
  124. $veto = Db::table("new_integral_veto")->where($where)->find();
  125. $veto["name"] = $irecord["name"];
  126. return json(["code" => 200, "veto" => $veto, "enterprises" => $enterpriseList]);
  127. }
  128. public function submitVeto() {
  129. $checkState = $this->request["checkState"];
  130. $checkMsg = $this->request["checkMsg"];
  131. $type = $this->request["type"];
  132. $card_type = $this->request["card_type"];
  133. $card_number = $this->request["card_number"];
  134. $enterprise_id = $this->request["enterprise_id"];
  135. $active = 0;
  136. if ($checkState == 1)
  137. $active = 1;
  138. if (!$type)
  139. return json(["msg" => "不确定的类型"]);
  140. if (!$checkMsg)
  141. return json(["msg" => "请填写意见"]);
  142. if ($type == 1) {
  143. if (!$enterprise_id)
  144. return json(["msg" => "不确定的企业"]);
  145. $where[] = ["enterprise_id", "=", $enterprise_id];
  146. } else {
  147. if (!$card_type || !$card_number)
  148. return json(["msg" => "不确定的个人"]);
  149. $where[] = ["card_type", "=", $card_type];
  150. $where[] = ["card_number", "=", $card_number];
  151. }
  152. $veto = Db::table("new_integral_veto")->where($where)->find();
  153. $checkActive = $veto["active"] == 1 ? 1 : 0;
  154. if ($active == $checkActive && $active == 1) {
  155. return json(["msg" => "已经被一票否决,无需重复操作"]);
  156. }
  157. if ($active == $checkActive && $active === 0) {
  158. return json(["msg" => "未被一票否决或者已经恢复,操作失败"]);
  159. }
  160. try {
  161. $data["active"] = $active;
  162. $data["description"] = $checkMsg;
  163. if ($veto) {
  164. $data["id"] = $veto["id"];
  165. $data["updateTime"] = date("Y-m-d H:i:s");
  166. $data["updateUser"] = $this->user["uid"];
  167. } else {
  168. if ($type == 1) {
  169. $data["enterprise_id"] = $enterprise_id;
  170. } else {
  171. $data["card_type"] = $card_type;
  172. $data["card_number"] = $card_number;
  173. }
  174. $data["createTime"] = date("Y-m-d H:i:s");
  175. $data["createUser"] = $this->user["uid"];
  176. }
  177. Db::table("new_integral_veto")->save($data);
  178. return json(["code" => 200, "msg" => "提交成功"]);
  179. } catch (\think\db\exception\DbException $e) {
  180. return json(["msg" => "数据异常,操作失败\n\r" . $e->getMessage()]);
  181. }
  182. }
  183. /**
  184. * 历史积分
  185. */
  186. public function integralLog() {
  187. $cardType = $this->request["cardType"];
  188. $cardNumber = $this->request["cardNumber"];
  189. $where[] = ["card_type", "=", $cardType];
  190. $where[] = ["card_number", "=", $cardNumber];
  191. $where[] = ["checkState", "=", IntegralState::SUCCESS];
  192. $enterprise_ids = IntegralRecord::where($where)->column("enterprise_id");
  193. $enterprises = EnterpriseApi::getSimpleList([["id", "in", $enterprise_ids]]);
  194. return view("", ["enterprises" => $enterprises, "cardType" => $cardType, "cardNumber" => $cardNumber]);
  195. }
  196. public function selectNeedCheckData() {
  197. $params = $this->request->param();
  198. return json(["code" => 200, "obj" => IntegralRecordApi::getPublicList($params)]);
  199. }
  200. /**
  201. * 预备人才库-核查征信
  202. */
  203. public function prepareHczx() {
  204. $ids = $this->request->param("ids");
  205. $ids_arr = array_filter(explode(",", $ids));
  206. if (!$ids_arr) {
  207. $res = ["code" => 500, "msg" => "没有选择导出的名单"];
  208. echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
  209. }
  210. $where[] = ["ir.id", "in", $ids_arr];
  211. $list = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->field("ir.name,ir.card_type,ir.card_number,e.name as enterpriseName,e.description")->where($where)->select();
  212. if (!$list) {
  213. $res = ["code" => 500, "msg" => "没有可以导出的内容"];
  214. echo sprintf("<script>IntegralInfo.callBack(%s);</script>", json_encode($res));
  215. }
  216. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  217. $rows = [];
  218. $i = 1;
  219. $card_types = DictApi::selectByParentCode("card_type");
  220. foreach ($list as $item) {
  221. $row = [
  222. $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
  223. ];
  224. $rows[] = $row;
  225. $i++;
  226. }
  227. $filename = "积分申报核查征信名单导出";
  228. if ($rows) {
  229. export($columns, $rows, $filename);
  230. exit();
  231. }
  232. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  233. }
  234. /**
  235. * 预备人才库-征信通过
  236. */
  237. public function hczxPass() {
  238. $params = $this->request->param();
  239. $ids = $params["ids"];
  240. $ids = array_filter(explode(",", $ids));
  241. $msg = "征信通过";
  242. $state = IntegralState::ZX_PASS; //征信通过
  243. $total = count($ids);
  244. $error = 0;
  245. $success = 0;
  246. foreach ($ids as $id) {
  247. $record = IntegralRecordApi::getOne($id);
  248. if ($record["checkState"] != IntegralState::REVERIFY_PASS) {
  249. $error++;
  250. continue;
  251. }
  252. if (IntegralRecordApi::setPublic($id, $state, $msg)) {
  253. $success++;
  254. } else {
  255. $error++;
  256. }
  257. }
  258. return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  259. }
  260. /**
  261. * 预备人才库-征信失信
  262. */
  263. public function hczxReject() {
  264. $params = $this->request->param();
  265. $id = $params["id"];
  266. $msg = $params["outMsg"];
  267. if (!$msg)
  268. return json(["msg" => "请填写审核意见"]);
  269. $msg = "征信失信:" . $msg;
  270. $state = IntegralState::ZX_FAIL; //征信不通过
  271. $record = IntegralRecordApi::getOne($id);
  272. if ($record["checkState"] != IntegralState::REVERIFY_PASS) {
  273. return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
  274. }
  275. if (IntegralRecordApi::setPublic($id, $state, $msg)) {
  276. return json(["code" => 200, "msg" => "已设置征信失信"]);
  277. }
  278. return json(["msg" => "设置征信失信失败"]);
  279. }
  280. /**
  281. * 预备人才库-公示预览
  282. */
  283. public function publicExportBefore() {
  284. $params = $this->request->param();
  285. $ids_arr = array_filter(explode(",", $params["ids"]));
  286. $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
  287. if ($ids_arr) {
  288. $where[] = ["ir.id", "in", $ids_arr];
  289. $list = IntegralRecord::alias("ir")->where($where)
  290. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  291. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  292. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  293. ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
  294. $rows = [];
  295. $i = 1;
  296. $card_types = DictApi::selectByParentCode("card_type");
  297. foreach ($list as $item) {
  298. $tmp_items = [];
  299. $total_points = 0;
  300. foreach ($item["detail"] as $_item) {
  301. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  302. $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
  303. $total_points += $_item["point"];
  304. }
  305. $row = [
  306. $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ZX_PASS ? "审核通过" : "审核不通过", $item["description"]
  307. ];
  308. $rows[] = $row;
  309. $i++;
  310. }
  311. }
  312. if ($rows) {
  313. $filename = "积分申报公示预览导出";
  314. export($columns, $rows, $filename);
  315. exit();
  316. }
  317. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  318. }
  319. /**
  320. * 预备人才库-公示导出
  321. */
  322. public function publicExport() {
  323. $params = $this->request->param();
  324. $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
  325. $startTime = $params["startTime"];
  326. $endTime = $params["endTime"];
  327. if (!strtotime($startTime) || !strtotime($endTime))
  328. return json(["msg" => "时间格式错误"]);
  329. $where[] = ["ir.checkState", "=", IntegralState::ANNOUNCED];
  330. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  331. $list = IntegralRecord::alias("ir")->where($where)
  332. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  333. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  334. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  335. ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
  336. $rows = [];
  337. $i = 1;
  338. $card_types = DictApi::selectByParentCode("card_type");
  339. foreach ($list as $item) {
  340. $tmp_items = [];
  341. $total_points = 0;
  342. foreach ($item["detail"] as $_item) {
  343. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  344. $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
  345. $total_points += $_item["point"];
  346. }
  347. $row = [
  348. $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ANNOUNCED ? "审核通过" : "审核不通过", $item["description"]
  349. ];
  350. $rows[] = $row;
  351. $i++;
  352. }
  353. if ($rows) {
  354. $filename = "积分申报公示导出";
  355. export($columns, $rows, $filename);
  356. exit();
  357. }
  358. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  359. }
  360. /**
  361. * 预备人才库-公示
  362. */
  363. public function preparePublic() {
  364. $params = $this->request->param();
  365. $ids = $params["ids"];
  366. $publicBatch = $params["batch"];
  367. if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
  368. return json(["msg" => "公示批次错误"]);
  369. $isMessage = $params["isMessage"] == 1 ? true : false;
  370. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  371. return json(["msg" => "短信参数不能为空"]);
  372. }
  373. $ids = array_filter(explode(",", $ids));
  374. $msg = "已公示";
  375. $state = IntegralState::ANNOUNCED; //公示
  376. $total = count($ids);
  377. $error = 0;
  378. $success = 0;
  379. $phones = [];
  380. foreach ($ids as $id) {
  381. $record = IntegralRecordApi::getOne($id);
  382. if ($record["checkState"] != IntegralState::ZX_PASS) {
  383. $error++;
  384. continue;
  385. }
  386. if (IntegralRecordApi::setPublic($id, $state, $msg, $publicBatch)) {
  387. $success++;
  388. $phones[] = $record["enterprise"]->agentPhone;
  389. } else {
  390. $error++;
  391. }
  392. }
  393. $phones = array_unique(array_filter($phones));
  394. if ($isMessage && $phones) {
  395. $sms = new \app\common\api\ChuanglanSmsApi();
  396. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  397. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  398. while ($phone = array_shift($phones)) {
  399. $result = $sms->sendSMS($phone, $tpl_content);
  400. $result = json_decode($result, true);
  401. $recordId = getStringId();
  402. $record_data = [
  403. 'id' => $recordId,
  404. 'bizId' => $result["msgId"],
  405. 'type' => 2,
  406. 'smsType' => 1,
  407. 'phone' => $phone,
  408. 'params' => '公示',
  409. 'templateCode' => $tpl_content,
  410. 'state' => $result['code'] == 0 ? 2 : 3,
  411. 'sendingDate' => date("Y-m-d H:i:s", time()),
  412. 'createTime' => date("Y-m-d H:i:s", time()),
  413. 'msg' => $result['errorMsg']
  414. ];
  415. MessageRecord::create($record_data);
  416. }
  417. }
  418. return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  419. }
  420. /**
  421. * 预备人才库-公示再审核
  422. */
  423. public function prepareCheck() {
  424. $params = $this->request->param();
  425. $id = $params["id"];
  426. $checkState = $params["checkState"];
  427. $msg = $params["checkMsg"];
  428. if (!$msg)
  429. return json(["msg" => "请填写审核意见"]);
  430. if ($checkState == 1) {
  431. $msg = "公示再审核通过:" . $msg;
  432. $state = IntegralState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  433. } else {
  434. $msg = "公示再审核不通过:" . $msg;
  435. $state = IntegralState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
  436. }
  437. $record = IntegralRecordApi::getOne($id);
  438. if ($record["checkState"] != IntegralState::ANNOUNCED) {
  439. return json(["msg" => "当前记录不是公示状态,无法审核"]);
  440. }
  441. if (IntegralRecordApi::setPublic($id, $state, $msg)) {
  442. return json(["code" => 200, "msg" => "公示再审核完成"]);
  443. }
  444. return json(["msg" => "公示再审核失败"]);
  445. }
  446. /**
  447. * 预备人才库-公示通过(批量)
  448. */
  449. public function publicPass() {
  450. $params = $this->request->param();
  451. $ids = $params["ids"];
  452. $ids = array_filter(explode(",", $ids));
  453. $msg = "公示再审核批量通过";
  454. $state = IntegralState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
  455. $total = count($ids);
  456. $error = 0;
  457. $success = 0;
  458. foreach ($ids as $id) {
  459. $record = IntegralRecordApi::getOne($id);
  460. if ($record["checkState"] != IntegralState::ANNOUNCED) {
  461. $error++;
  462. continue;
  463. }
  464. if (IntegralRecordApi::setPublic($id, $state, $msg)) {
  465. $success++;
  466. } else {
  467. $error++;
  468. }
  469. }
  470. return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  471. }
  472. /**
  473. * 预备人才库-公布预览
  474. */
  475. public function publishExportBefore() {
  476. $params = $this->request->param();
  477. $ids = $params["ids"];
  478. $ids = array_filter(explode(",", $ids));
  479. if ($ids) {
  480. $where[] = ["ir.id", "in", $ids];
  481. $list = IntegralRecord::alias("ir")->where($where)
  482. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  483. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  484. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  485. ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
  486. $rows = [];
  487. $i = 1;
  488. $card_types = DictApi::selectByParentCode("card_type");
  489. foreach ($list as $item) {
  490. $tmp_items = [];
  491. $total_points = 0;
  492. foreach ($item["detail"] as $_item) {
  493. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  494. $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
  495. $total_points += $_item["point"];
  496. }
  497. $row = [
  498. $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $item["description"]
  499. ];
  500. $rows[] = $row;
  501. $i++;
  502. }
  503. }
  504. $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
  505. $filename = "积分申报" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  506. if ($rows) {
  507. export($columns, $rows, $filename);
  508. exit();
  509. }
  510. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  511. }
  512. /**
  513. * 预备人才库-公布导出
  514. */
  515. public function publishExport() {
  516. $params = $this->request->param();
  517. $startTime = $params["startTime"];
  518. $endTime = $params["endTime"];
  519. if (!strtotime($startTime) || !strtotime($endTime))
  520. return json(["msg" => "时间格式错误"]);
  521. $where[] = ["ir.checkState", "=", IntegralState::PUBLISH_PASS];
  522. $where[] = ["ir.getTime", "between", [$startTime, $endTime]];
  523. $list = IntegralRecord::alias("ir")->where($where)
  524. ->leftJoin("sys_batch b", "b.id=ir.batch_id")
  525. ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
  526. ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where md5(concat(createTime,mainId,`type`)) in (select md5(concat(max(createTime),mainId,`type`)) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
  527. ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
  528. $rows = [];
  529. $i = 1;
  530. $card_types = DictApi::selectByParentCode("card_type");
  531. foreach ($list as $item) {
  532. $tmp_items = [];
  533. $total_points = 0;
  534. foreach ($item["detail"] as $_item) {
  535. $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
  536. $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
  537. $total_points += $_item["point"];
  538. }
  539. $row = [
  540. $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::PUBLISH_PASS ? "审核通过" : "审核不通过", $item["description"]
  541. ];
  542. $rows[] = $row;
  543. $i++;
  544. }
  545. $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
  546. $filename = "积分申报" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
  547. if ($rows) {
  548. export($columns, $rows, $filename);
  549. exit();
  550. }
  551. echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
  552. }
  553. /**
  554. * 预备人才库-公布
  555. */
  556. public function publish() {
  557. $params = $this->request->param();
  558. $id = $params["id"];
  559. $msg = $params["checkMsg"];
  560. $checkState = $params["checkState"];
  561. $batch = $params["batch"];
  562. if ($checkState == 1) {
  563. $state = IntegralState::PUBLISH_PASS;
  564. $msg = "公布审核通过:" . $msg;
  565. } else {
  566. $state = IntegralState::PUBLISH_FAIL;
  567. $msg = "公布审核不通过:" . $msg;
  568. }
  569. if (!$batch || !strtotime($batch))
  570. return json(["msg" => "公布批次时间错误"]);
  571. if (!$msg)
  572. return json(["msg" => "请填写审核意见"]);
  573. $state = IntegralState::PUBLISH_PASS; //公示再审核通过
  574. $batch = $params["batch"];
  575. if (!strtotime($batch))
  576. return json(["msg" => "公布批次时间错误"]);
  577. $record = IntegralRecordApi::getOne($id);
  578. if ($record["checkState"] != IntegralState::ANNOUNCED_REVERIFY_PASS) {
  579. return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
  580. }
  581. if (IntegralRecordApi::setPublic($id, $state, $msg, $batch)) {
  582. return json(["code" => 200, "msg" => "公布审核完成"]);
  583. }
  584. return json(["msg" => "公布审核失败"]);
  585. }
  586. /**
  587. * 预备人才库-批量公布通过
  588. */
  589. public function preparePublish() {
  590. $params = $this->request->param();
  591. $ids = $params["ids"];
  592. $ids = array_filter(explode(",", $ids));
  593. $msg = "批量公布";
  594. $state = IntegralState::PUBLISH_PASS; //公示再审核通过
  595. $batch = $params["batch"];
  596. if (!strtotime($batch))
  597. return json(["msg" => "公布批次时间错误"]);
  598. $total = count($ids);
  599. $error = 0;
  600. $success = 0;
  601. foreach ($ids as $id) {
  602. $record = IntegralRecordApi::getOne($id);
  603. if ($record["checkState"] != IntegralState::ANNOUNCED_REVERIFY_PASS) {
  604. $error++;
  605. continue;
  606. }
  607. if (IntegralRecordApi::setPublic($id, $state, $msg, $batch)) {
  608. $success++;
  609. } else {
  610. $error++;
  611. }
  612. }
  613. return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
  614. }
  615. /**
  616. * 预备人才库-批量发放人才码
  617. */
  618. public function prepareCertification() {
  619. $lockFile = fopen("send_certificate.lock", "a");
  620. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  621. $params = $this->request->param();
  622. $ids = array_filter(explode(",", $params["ids"]));
  623. Db::startTrans();
  624. $user = $this->user;
  625. try {
  626. $record_list = IntegralRecordApi::getListByIds($ids);
  627. $year = date("Y");
  628. foreach ($record_list as $record) {
  629. if ($record["checkState"] != IntegralState::PUBLISH_PASS) {
  630. Db::rollback();
  631. return json(["msg" => "只能对公布通过的对象发放积分,请核查待发放积分名单后再重新发放积分"]);
  632. }
  633. $data["id"] = $record["id"];
  634. $data["checkState"] = IntegralState::SUCCESS;
  635. $data["isPublic"] = 5;
  636. Db::table("new_integral_record")->update($data);
  637. //写入日志
  638. $log["last_state"] = IntegralState::PUBLISH_PASS;
  639. $log["id"] = getStringId();
  640. $log["state"] = $log["new_state"] = IntegralState::SUCCESS;
  641. $log["type"] = ProjectState::INTEGRAL;
  642. $log["mainId"] = $record["id"];
  643. $log["companyId"] = $user["companyId"];
  644. $log["active"] = 1;
  645. $log["description"] = "积分申报成功";
  646. $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
  647. $log["createTime"] = date("Y-m-d H:i:s");
  648. Db::table("new_talent_checklog")->insert($log);
  649. }
  650. Db::commit();
  651. return json(["code" => 200, "msg" => "发放积分成功"]);
  652. } catch (\Exception $e) {
  653. Db::rollback();
  654. return json(["msg" => "发放积分失败:" . $e->getMessage()]);
  655. }
  656. flock($lockFile, LOCK_UN);
  657. } else {
  658. return json(["msg" => "同一时间只能有一个管理员进行发放积分操作"]);
  659. }
  660. }
  661. /**
  662. * 预备人才库-撤销公布
  663. */
  664. public function pre_cancel_publish() {
  665. }
  666. /**
  667. * 初审-提交未保存
  668. * @param \think\Request $request
  669. * @param type $record
  670. * @return type json
  671. */
  672. private function fstCheck(\think\Request $request, $record) {
  673. $params = $request->param();
  674. if ($params["checkState"] == 1) {
  675. //审核成功,并取消设置越过部门并审
  676. $log_checkState = $checkState = IntegralState::VERIFY_PASS; //初审成功
  677. } else if ($params["checkState"] == 2) {
  678. //审核驳回并记录需要修改的字段和上传文件
  679. $checkState = IntegralState::SAVE; //退回材料编辑状态
  680. $log_checkState = IntegralState::VERIFY_REJECT; //日志记录拒绝状态
  681. } else {
  682. $checkState = IntegralState::VERIFY_FAIL;
  683. }
  684. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  685. if (!$log)
  686. return json(["msg" => "日志数据异常,保存失败"]);
  687. if ($log["active"] == 0) {
  688. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  689. } else {
  690. TalentLogApi::write(ProjectState::INTEGRAL, $record["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  691. }
  692. $data["id"] = $record["id"];
  693. $data["modify_files"] = $params["files"];
  694. $data["modify_fields"] = $params["fields"];
  695. IntegralRecord::update($data);
  696. return json(["code" => 200, "msg" => "保存成功"]);
  697. }
  698. /**
  699. * 初审-提交审核
  700. * @param type $record
  701. * @return type json
  702. */
  703. private function fstSubmitCheck($record) {
  704. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  705. if (!$log || $log["active"] == 1)
  706. return json(["msg" => "请先保存审核状态,再提交审核"]);
  707. if ($log["new_state"] == IntegralState::VERIFY_PASS) {
  708. $data["modify_files"] = null;
  709. $data["modify_fields"] = null;
  710. }
  711. $data["id"] = $record["id"];
  712. $data["checkState"] = $log["new_state"];
  713. IntegralRecord::update($data);
  714. TalentLogApi::setActive($log["id"], 1);
  715. $userIds = [];
  716. if (in_array($log["state"], [IntegralState::VERIFY_PASS])) {
  717. //初审成功需要发送短信给复核部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  718. //从复核权限,逆推复核人员
  719. $codes = ["integralVerify_reCheck"];
  720. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  721. $where = [];
  722. $where[] = ["menuid", "in", $menuIds];
  723. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  724. $where = [];
  725. $where[] = ["status", "=", 1];
  726. $where[] = ["type", "=", $this->user["type"]];
  727. $where[] = ["roleid", "<>", 1];
  728. $regstr = ",(" . implode("|", $roleIds) . "),";
  729. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  730. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  731. }
  732. $this->sendMsgByState($record, $log["state"], $userIds);
  733. return json(["code" => 200, "msg" => "审核成功"]);
  734. }
  735. /**
  736. * 复审-提交未保存
  737. * @param \think\Request $request
  738. * @param type $record
  739. * @param type json
  740. */
  741. private function reCheck(\think\Request $request, $record) {
  742. $params = $request->param();
  743. $data["modify_files"] = null;
  744. $data["modify_fields"] = null;
  745. $totalPoints = 0;
  746. if ($params["checkState"] == 1) {
  747. //审核成功
  748. $log_checkState = $checkState = IntegralState::REVERIFY_PASS; //复核成功
  749. foreach ($record->detail as $item) {
  750. $result = IntegralRecordApi::calIntegral($record["enterprise_id"], $record["card_type"], $record["card_number"], $item["item_id"], $item["amount"]);
  751. $totalPoints += $result->points;
  752. $iData["id"] = $item["id"];
  753. $iData["point"] = $result->points;
  754. IntegralDetail::update($iData);
  755. }
  756. $data["totalPoints"] = $totalPoints;
  757. } else if ($params["checkState"] == 2) {
  758. //审核驳回并记录需要修改的字段和上传文件
  759. $checkState = IntegralState::SUBMIT; //退回待初审
  760. $log_checkState = IntegralState::REVERIFY_REJECT; //日志记录拒绝状态
  761. $data["modify_files"] = $params["files"];
  762. $data["modify_fields"] = $params["fields"];
  763. } else {
  764. $log_checkState = $checkState = IntegralState::REVERIFY_FAIL; //审核失败
  765. }
  766. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  767. if (!$log)
  768. return json(["msg" => "日志数据异常,保存失败"]);
  769. if ($log["active"] == 0) {
  770. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  771. } else {
  772. TalentLogApi::write(ProjectState::INTEGRAL, $record["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  773. }
  774. $data["id"] = $record["id"];
  775. IntegralRecord::update($data);
  776. return json(["code" => 200, "msg" => "保存成功"]);
  777. }
  778. /**
  779. * 复审-提交审核
  780. * @param type $record
  781. * @return type json
  782. */
  783. private function reSubmitCheck($record) {
  784. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  785. if (!$log || $log["active"] == 1)
  786. return json(["msg" => "请先保存审核状态,再提交审核"]);
  787. $data["id"] = $record["id"];
  788. $data["checkState"] = $log["new_state"];
  789. IntegralRecord::update($data);
  790. TalentLogApi::setActive($log["id"], 1);
  791. $userIds = [];
  792. if (in_array($log["state"], [IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_REJECT])) {
  793. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  794. //从征信审核权限,逆推征信部门
  795. if ($data["checkState"] == IntegralState::REVERIFY_PASS) {
  796. $codes = ["integralVerify_hczxReject", "integralVerify_firstCheck_hczxPass"];
  797. } else {
  798. $codes = ["integralVerify_firstCheck"];
  799. }
  800. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  801. $where = [];
  802. $where[] = ["menuid", "in", $menuIds];
  803. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  804. $where = [];
  805. $where[] = ["status", "=", 1];
  806. $where[] = ["type", "=", $this->user["type"]];
  807. $where[] = ["roleid", "<>", 1];
  808. $regstr = ",(" . implode("|", $roleIds) . "),";
  809. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  810. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  811. }
  812. $this->sendMsgByState($record, $log["state"], $userIds);
  813. return json(["code" => 200, "msg" => "审核成功"]);
  814. }
  815. private function sendMsgByState($record, $state, $userIds = []) {
  816. $phones = [];
  817. $template = "";
  818. $type = 0;
  819. $processName = "";
  820. $userId = 0;
  821. $name = null;
  822. switch ($state) {
  823. case IntegralState::VERIFY_PASS://初审通过发送短信通知并审部门
  824. $type = 1;
  825. $processName = "积分申报-初级审核";
  826. $template = "【晋江市人才服务平台】您的部门有新的积分申报需要审批,请及时登录审批系统处理。";
  827. break;
  828. case IntegralState::VERIFY_REJECT; //初审驳回发送短信通知用户
  829. $type = 2;
  830. $processName = "积分申报-初级审核";
  831. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  832. break;
  833. case IntegralState::VERIFY_FAIL://初审不通过发送短信通知用户
  834. $type = 2;
  835. $processName = "积分申报-初级审核";
  836. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
  837. break;
  838. case IntegralState::REVERIFY_PASS://复核通过发短信通知征信部门
  839. $type = 1;
  840. $processName = "积分申报-复审";
  841. $template = "【晋江市人才服务平台】有新的积分申报通过复审进入征信阶段,请及时登录审批系统处理。";
  842. break;
  843. case IntegralState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  844. $type = 1;
  845. $processName = "积分申报-复审";
  846. $template = "【晋江市人才服务平台】有积分申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  847. break;
  848. case IntegralState::REVERIFY_FAIL://并审驳回发送短信通知初审部门
  849. $type = 2;
  850. $processName = "积分申报-复审";
  851. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
  852. break;
  853. }
  854. if ($type == 1) {
  855. $where = [];
  856. $where[] = ["id", "in", $userIds];
  857. $phones = User::where($where)->column("phone");
  858. $phones = array_unique(array_filter($phones));
  859. }
  860. if ($type == 2) {
  861. $ep = EnterpriseApi::getOne($record['enterprise_id']);
  862. $phones[] = $ep->agentPhone;
  863. $userId = $ep->id;
  864. $name = $ep->name;
  865. }
  866. if ($phones && $template) {
  867. while ($phone = array_shift($phones)) {
  868. $smsapi = new ChuanglanSmsApi();
  869. $result = $smsapi->sendSMS($phone, $template);
  870. $result = json_decode($result, true);
  871. $id = getStringId();
  872. $record_data = [
  873. 'id' => $id,
  874. 'userId' => $userId,
  875. 'bizId' => $result["msgId"],
  876. 'type' => $type,
  877. 'smsType' => 2,
  878. 'name' => $name,
  879. 'phone' => $phone,
  880. 'params' => $processName,
  881. 'templateCode' => $template,
  882. 'state' => $result['code'] == 0 ? 2 : 3,
  883. 'sendingDate' => date("Y-m-d H:i:s", time()),
  884. 'createTime' => date("Y-m-d H:i:s", time()),
  885. 'msg' => $result['errorMsg']
  886. ];
  887. MessageRecord::create($record_data);
  888. }
  889. }
  890. }
  891. public function check() {
  892. //公共调度方法
  893. $request = $this->request;
  894. $params = $request->param();
  895. $check = $params["checkState"];
  896. $check_msg = trim($params["checkMsg"]);
  897. $files = $params["files"];
  898. $fields = $params["fields"];
  899. $id = $params["id"];
  900. $record = IntegralRecordApi::getOne($id);
  901. $checkState = $record["checkState"];
  902. if (!$record) {
  903. return json(["msg" => "数据错误"]);
  904. }
  905. if (!$check) {
  906. return json(["msg" => "请选择审核状态"]);
  907. }
  908. if (!$check_msg) {
  909. return json(["msg" => "请填写审核说明"]);
  910. }
  911. if ($check == 2 && !$files && $fields) {
  912. return json(["msg" => "请选择可修改的字段或项目"]);
  913. }
  914. if ($checkState == IntegralState::SUBMIT) {
  915. return $this->fstCheck($request, $record);
  916. } else if ($checkState == IntegralState::VERIFY_PASS) {
  917. return $this->reCheck($request, $record);
  918. } else {
  919. return json(["msg" => "不在审核范围内,保存失败"]);
  920. }
  921. }
  922. public function submitCheck() {
  923. //公共调度方法
  924. $id = $this->request->param("id");
  925. $record = IntegralRecordApi::getOne($id);
  926. $checkState = $record["checkState"];
  927. if (!$record) {
  928. return json(["msg" => "数据错误"]);
  929. }
  930. if ($checkState == IntegralState::SUBMIT) {
  931. return $this->fstSubmitCheck($record);
  932. } else if ($checkState == IntegralState::VERIFY_PASS) {
  933. return $this->reSubmitCheck($record);
  934. } else {
  935. return json(["msg" => "不在审核范围内,审核失败"]);
  936. }
  937. }
  938. public function validateIsCheck() {
  939. $params = $this->request->param();
  940. $id = $params["id"];
  941. $record = IntegralRecordApi::getOne($id);
  942. $enterprise = \app\common\model\Enterprise::findOrEmpty($record["enterprise_id"]);
  943. if ($record) {
  944. $items = $record["detail"]->toArray(); //项目明细
  945. $checkState = $record["checkState"];
  946. if (in_array($checkState, [IntegralState::SUBMIT, IntegralState::VERIFY_PASS])) {
  947. $fields = DictApi::getIntegralFields();
  948. $field_tmp = [];
  949. foreach ($fields as $key => $field) {
  950. $field_tmp[] = ["key" => $key, "value" => $field];
  951. }
  952. $record["files"] = $record["modify_files"];
  953. $record["fields"] = array_filter(explode(",", $record["modify_fields"]));
  954. return json(["code" => 200, "obj" => ["record" => $record, "fieldList" => $field_tmp]]);
  955. } else {
  956. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  957. }
  958. }
  959. }
  960. public function findFieldsAndFiles() {
  961. $id = $this->request["id"];
  962. $record = IntegralRecordApi::getOne($id);
  963. $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
  964. $responseObj = new \stdClass();
  965. if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
  966. $items = $record["detail"]->toArray(); //项目明细
  967. $checkState = $record["checkState"];
  968. $fields = DictApi::getIntegralFields();
  969. $field_tmp = [];
  970. foreach ($fields as $key => $field) {
  971. $field_tmp[] = ["key" => $key, "value" => $field];
  972. }
  973. $record["files"] = $record["modify_files"];
  974. $record["fields"] = array_filter(explode(",", $record["modify_fields"]));
  975. return json(["code" => 200, "obj" => ["record" => $record, "fieldList" => $field_tmp]]);
  976. $responseObj->code = 200;
  977. $responseObj->id = $id;
  978. $responseObj->obj = ["record" => $record, "fieldList" => $field_tmp];
  979. } else {
  980. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  981. }
  982. return json($responseObj);
  983. }
  984. public function updateFieldsAndFiles() {
  985. $id = $this->request["id"];
  986. $fields = array_filter(explode(",", $this->request["fields"]));
  987. $files = array_filter(explode(",", $this->request["files"]));
  988. $record = IntegralRecordApi::getOne($id);
  989. $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
  990. $responseObj = new \stdClass();
  991. if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
  992. if (!$fields && !$files) {
  993. $responseObj->msg = "请选择可修改的字段或附件!";
  994. return json($responseObj);
  995. }
  996. try {
  997. $data["id"] = $id;
  998. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  999. $data["modify_files"] = $files ? implode(",", $files) : null;
  1000. IntegralRecord::update($data);
  1001. $responseObj->code = 200;
  1002. $responseObj->msg = "驳回字段修改成功";
  1003. return json($responseObj);
  1004. } catch (\think\db\exception\DbException $e) {
  1005. $responseObj->msg = $e->getMessage();
  1006. return json($responseObj);
  1007. }
  1008. } else {
  1009. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1010. return json($responseObj);
  1011. }
  1012. }
  1013. public function fstVerifyListExport() {
  1014. $this->commonExport(1);
  1015. }
  1016. public function reVerifyListExport() {
  1017. $this->commonExport(2);
  1018. }
  1019. public function preListExport() {
  1020. $this->commonExport(3);
  1021. }
  1022. private function commonExport($process) {
  1023. $params = $this->request->param();
  1024. $fields = $params["export"];
  1025. if (!$fields)
  1026. return json(["msg" => "请选择要导出的数据"]);
  1027. $names = DictApi::getIntegralFields();
  1028. $names["enterpriseName"] = "单位名称";
  1029. $names["street"] = "所属镇街";
  1030. $names["project"] = "申报项目";
  1031. $names["checkState"] = "审核状态";
  1032. $names["checkMsg"] = "审核意见";
  1033. $names["year"] = "申报年度";
  1034. $list = IntegralRecordApi::getExportDatas($process, $fields);
  1035. foreach ($fields as $field) {
  1036. $columns[] = $names[$field];
  1037. }
  1038. $datas = [];
  1039. for ($i = 0; $i < count($list); $i++) {
  1040. $data = [];
  1041. for ($n = 0; $n < count($fields); $n++) {
  1042. $data[] = $list[$i][$fields[$n]];
  1043. }
  1044. $datas[] = $data;
  1045. }
  1046. if ($datas) {
  1047. export($columns, $datas);
  1048. exit();
  1049. }
  1050. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1051. }
  1052. public function getPhones() {
  1053. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1054. $result = [];
  1055. if ($list) {
  1056. foreach ($list as $item) {
  1057. if ($item["phone"] && $item["name"]) {
  1058. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1059. }
  1060. }
  1061. }
  1062. return json(["code" => 200, "obj" => implode(";", $result)]);
  1063. }
  1064. public function getEnterprisePhones() {
  1065. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1066. $result = [];
  1067. if ($list) {
  1068. foreach ($list as $item) {
  1069. if ($item["agentName"] && $item["agentPhone"]) {
  1070. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1071. }
  1072. }
  1073. }
  1074. return json(["code" => 200, "obj" => implode(";", $result)]);
  1075. }
  1076. }