IntegralVerify.php 50 KB

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