IntegralVerify.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  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. return json(["code" => 200, "msg" => "发放积分成功"]);
  653. } catch (\Exception $e) {
  654. Db::rollback();
  655. return json(["msg" => "发放积分失败:" . $e->getMessage()]);
  656. }
  657. flock($lockFile, LOCK_UN);
  658. } else {
  659. return json(["msg" => "同一时间只能有一个管理员进行发放积分操作"]);
  660. }
  661. }
  662. /**
  663. * 预备人才库-撤销公布
  664. */
  665. public function pre_cancel_publish() {
  666. }
  667. /**
  668. * 初审-提交未保存
  669. * @param \think\Request $request
  670. * @param type $record
  671. * @return type json
  672. */
  673. private function fstCheck(\think\Request $request, $record) {
  674. $params = $request->param();
  675. if ($params["checkState"] == 1) {
  676. //审核成功,并取消设置越过部门并审
  677. $log_checkState = $checkState = IntegralState::VERIFY_PASS; //初审成功
  678. } else if ($params["checkState"] == 2) {
  679. //审核驳回并记录需要修改的字段和上传文件
  680. $checkState = IntegralState::SAVE; //退回材料编辑状态
  681. $log_checkState = IntegralState::VERIFY_REJECT; //日志记录拒绝状态
  682. } else {
  683. $checkState = IntegralState::VERIFY_FAIL;
  684. }
  685. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  686. if (!$log)
  687. return json(["msg" => "日志数据异常,保存失败"]);
  688. if ($log["active"] == 0) {
  689. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  690. } else {
  691. TalentLogApi::write(ProjectState::INTEGRAL, $record["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  692. }
  693. $data["id"] = $record["id"];
  694. $data["modify_files"] = $params["files"];
  695. $data["modify_fields"] = $params["fields"];
  696. IntegralRecord::update($data);
  697. return json(["code" => 200, "msg" => "保存成功"]);
  698. }
  699. /**
  700. * 初审-提交审核
  701. * @param type $record
  702. * @return type json
  703. */
  704. private function fstSubmitCheck($record) {
  705. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  706. if (!$log || $log["active"] == 1)
  707. return json(["msg" => "请先保存审核状态,再提交审核"]);
  708. if ($log["new_state"] == IntegralState::VERIFY_PASS) {
  709. $data["modify_files"] = null;
  710. $data["modify_fields"] = null;
  711. }
  712. $data["id"] = $record["id"];
  713. $data["checkState"] = $log["new_state"];
  714. IntegralRecord::update($data);
  715. TalentLogApi::setActive($log["id"], 1);
  716. $userIds = [];
  717. if (in_array($log["state"], [IntegralState::VERIFY_PASS])) {
  718. //初审成功需要发送短信给复核部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  719. //从复核权限,逆推复核人员
  720. $codes = ["integralVerify_reCheck"];
  721. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  722. $where = [];
  723. $where[] = ["menuid", "in", $menuIds];
  724. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  725. $where = [];
  726. $where[] = ["status", "=", 1];
  727. $where[] = ["type", "=", $this->user["type"]];
  728. $where[] = ["roleid", "<>", 1];
  729. $regstr = ",(" . implode("|", $roleIds) . "),";
  730. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  731. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  732. }
  733. $this->sendMsgByState($record, $log["state"], $userIds);
  734. return json(["code" => 200, "msg" => "审核成功"]);
  735. }
  736. /**
  737. * 复审-提交未保存
  738. * @param \think\Request $request
  739. * @param type $record
  740. * @param type json
  741. */
  742. private function reCheck(\think\Request $request, $record) {
  743. $params = $request->param();
  744. $data["modify_files"] = null;
  745. $data["modify_fields"] = null;
  746. $totalPoints = 0;
  747. if ($params["checkState"] == 1) {
  748. //审核成功
  749. $log_checkState = $checkState = IntegralState::REVERIFY_PASS; //复核成功
  750. foreach ($record->detail as $item) {
  751. $result = IntegralRecordApi::calIntegral($record["enterprise_id"], $record["card_type"], $record["card_number"], $item["item_id"], $item["amount"]);
  752. $totalPoints += $result->points;
  753. $iData["id"] = $item["id"];
  754. $iData["point"] = $result->points;
  755. IntegralDetail::update($iData);
  756. }
  757. $data["totalPoints"] = $totalPoints;
  758. } else if ($params["checkState"] == 2) {
  759. //审核驳回并记录需要修改的字段和上传文件
  760. $checkState = IntegralState::SUBMIT; //退回待初审
  761. $log_checkState = IntegralState::REVERIFY_REJECT; //日志记录拒绝状态
  762. $data["modify_files"] = $params["files"];
  763. $data["modify_fields"] = $params["fields"];
  764. } else {
  765. $log_checkState = $checkState = IntegralState::REVERIFY_FAIL; //审核失败
  766. }
  767. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  768. if (!$log)
  769. return json(["msg" => "日志数据异常,保存失败"]);
  770. if ($log["active"] == 0) {
  771. TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  772. } else {
  773. TalentLogApi::write(ProjectState::INTEGRAL, $record["id"], [$log_checkState, $checkState], $params["checkMsg"]);
  774. }
  775. $data["id"] = $record["id"];
  776. IntegralRecord::update($data);
  777. return json(["code" => 200, "msg" => "保存成功"]);
  778. }
  779. /**
  780. * 复审-提交审核
  781. * @param type $record
  782. * @return type json
  783. */
  784. private function reSubmitCheck($record) {
  785. $log = TalentLogApi::getLastLog($record["id"], ProjectState::INTEGRAL);
  786. if (!$log || $log["active"] == 1)
  787. return json(["msg" => "请先保存审核状态,再提交审核"]);
  788. $data["id"] = $record["id"];
  789. $data["checkState"] = $log["new_state"];
  790. IntegralRecord::update($data);
  791. TalentLogApi::setActive($log["id"], 1);
  792. $userIds = [];
  793. if (in_array($log["state"], [IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_REJECT])) {
  794. //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
  795. //从征信审核权限,逆推征信部门
  796. if ($data["checkState"] == IntegralState::REVERIFY_PASS) {
  797. $codes = ["integralVerify_hczxReject", "integralVerify_firstCheck_hczxPass"];
  798. } else {
  799. $codes = ["integralVerify_firstCheck"];
  800. }
  801. $menuIds = MenuApi::getMenuIdsByCodes($codes);
  802. $where = [];
  803. $where[] = ["menuid", "in", $menuIds];
  804. $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
  805. $where = [];
  806. $where[] = ["status", "=", 1];
  807. $where[] = ["type", "=", $this->user["type"]];
  808. $where[] = ["roleid", "<>", 1];
  809. $regstr = ",(" . implode("|", $roleIds) . "),";
  810. $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
  811. $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
  812. }
  813. $this->sendMsgByState($record, $log["state"], $userIds);
  814. return json(["code" => 200, "msg" => "审核成功"]);
  815. }
  816. private function sendMsgByState($record, $state, $userIds = []) {
  817. $phones = [];
  818. $template = "";
  819. $type = 0;
  820. $processName = "";
  821. $userId = 0;
  822. $name = null;
  823. switch ($state) {
  824. case IntegralState::VERIFY_PASS://初审通过发送短信通知并审部门
  825. $type = 1;
  826. $processName = "积分申报-初级审核";
  827. $template = "【晋江市人才服务平台】您的部门有新的积分申报需要审批,请及时登录审批系统处理。";
  828. break;
  829. case IntegralState::VERIFY_REJECT; //初审驳回发送短信通知用户
  830. $type = 2;
  831. $processName = "积分申报-初级审核";
  832. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
  833. break;
  834. case IntegralState::VERIFY_FAIL://初审不通过发送短信通知用户
  835. $type = 2;
  836. $processName = "积分申报-初级审核";
  837. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
  838. break;
  839. case IntegralState::REVERIFY_PASS://复核通过发短信通知征信部门
  840. $type = 1;
  841. $processName = "积分申报-复审";
  842. $template = "【晋江市人才服务平台】有新的积分申报通过复审进入征信阶段,请及时登录审批系统处理。";
  843. break;
  844. case IntegralState::REVERIFY_REJECT://复核驳回发短信通知初审部门
  845. $type = 1;
  846. $processName = "积分申报-复审";
  847. $template = "【晋江市人才服务平台】有积分申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
  848. break;
  849. case IntegralState::REVERIFY_FAIL://并审驳回发送短信通知初审部门
  850. $type = 2;
  851. $processName = "积分申报-复审";
  852. $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
  853. break;
  854. }
  855. if ($type == 1) {
  856. $where = [];
  857. $where[] = ["id", "in", $userIds];
  858. $phones = User::where($where)->column("phone");
  859. $phones = array_unique(array_filter($phones));
  860. }
  861. if ($type == 2) {
  862. $ep = EnterpriseApi::getOne($record['enterprise_id']);
  863. $phones[] = $ep->agentPhone;
  864. $userId = $ep->id;
  865. $name = $ep->name;
  866. }
  867. if ($phones && $template) {
  868. while ($phone = array_shift($phones)) {
  869. $smsapi = new ChuanglanSmsApi();
  870. $result = $smsapi->sendSMS($phone, $template);
  871. $result = json_decode($result, true);
  872. $id = getStringId();
  873. $record_data = [
  874. 'id' => $id,
  875. 'userId' => $userId,
  876. 'bizId' => $result["msgId"],
  877. 'type' => $type,
  878. 'smsType' => 2,
  879. 'name' => $name,
  880. 'phone' => $phone,
  881. 'params' => $processName,
  882. 'templateCode' => $template,
  883. 'state' => $result['code'] == 0 ? 2 : 3,
  884. 'sendingDate' => date("Y-m-d H:i:s", time()),
  885. 'createTime' => date("Y-m-d H:i:s", time()),
  886. 'msg' => $result['errorMsg']
  887. ];
  888. MessageRecord::create($record_data);
  889. }
  890. }
  891. }
  892. public function check() {
  893. //公共调度方法
  894. $request = $this->request;
  895. $params = $request->param();
  896. $check = $params["checkState"];
  897. $check_msg = trim($params["checkMsg"]);
  898. $files = $params["files"];
  899. $fields = $params["fields"];
  900. $id = $params["id"];
  901. $record = IntegralRecordApi::getOne($id);
  902. $checkState = $record["checkState"];
  903. if (!$record) {
  904. return json(["msg" => "数据错误"]);
  905. }
  906. if (!$check) {
  907. return json(["msg" => "请选择审核状态"]);
  908. }
  909. if (!$check_msg) {
  910. return json(["msg" => "请填写审核说明"]);
  911. }
  912. if ($check == 2 && !$files && !$fields) {
  913. return json(["msg" => "请选择可修改的字段或项目"]);
  914. }
  915. if ($checkState == IntegralState::SUBMIT) {
  916. return $this->fstCheck($request, $record);
  917. } else if ($checkState == IntegralState::VERIFY_PASS) {
  918. return $this->reCheck($request, $record);
  919. } else {
  920. return json(["msg" => "不在审核范围内,保存失败"]);
  921. }
  922. }
  923. public function submitCheck() {
  924. //公共调度方法
  925. $id = $this->request->param("id");
  926. $record = IntegralRecordApi::getOne($id);
  927. $checkState = $record["checkState"];
  928. if (!$record) {
  929. return json(["msg" => "数据错误"]);
  930. }
  931. if ($checkState == IntegralState::SUBMIT) {
  932. return $this->fstSubmitCheck($record);
  933. } else if ($checkState == IntegralState::VERIFY_PASS) {
  934. return $this->reSubmitCheck($record);
  935. } else {
  936. return json(["msg" => "不在审核范围内,审核失败"]);
  937. }
  938. }
  939. public function validateIsCheck() {
  940. $params = $this->request->param();
  941. $id = $params["id"];
  942. $record = IntegralRecordApi::getOne($id);
  943. $enterprise = \app\common\model\Enterprise::findOrEmpty($record["enterprise_id"]);
  944. if ($record) {
  945. $items = $record["detail"]->toArray(); //项目明细
  946. $checkState = $record["checkState"];
  947. if (in_array($checkState, [IntegralState::SUBMIT, IntegralState::VERIFY_PASS])) {
  948. $fields = DictApi::getIntegralFields();
  949. $field_tmp = [];
  950. foreach ($fields as $key => $field) {
  951. $field_tmp[] = ["key" => $key, "value" => $field];
  952. }
  953. $record["files"] = $record["modify_files"];
  954. $record["fields"] = array_filter(explode(",", $record["modify_fields"]));
  955. return json(["code" => 200, "obj" => ["record" => $record, "fieldList" => $field_tmp]]);
  956. } else {
  957. return json(["msg" => "该申报不在审核范围内,无法审核"]);
  958. }
  959. }
  960. }
  961. public function findFieldsAndFiles() {
  962. $id = $this->request["id"];
  963. $record = IntegralRecordApi::getOne($id);
  964. $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
  965. $responseObj = new \stdClass();
  966. if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
  967. $items = $record["detail"]->toArray(); //项目明细
  968. $checkState = $record["checkState"];
  969. $fields = DictApi::getIntegralFields();
  970. $field_tmp = [];
  971. foreach ($fields as $key => $field) {
  972. $field_tmp[] = ["key" => $key, "value" => $field];
  973. }
  974. $record["files"] = $record["modify_files"];
  975. $record["fields"] = array_filter(explode(",", $record["modify_fields"]));
  976. return json(["code" => 200, "obj" => ["record" => $record, "fieldList" => $field_tmp]]);
  977. $responseObj->code = 200;
  978. $responseObj->id = $id;
  979. $responseObj->obj = ["record" => $record, "fieldList" => $field_tmp];
  980. } else {
  981. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  982. }
  983. return json($responseObj);
  984. }
  985. public function updateFieldsAndFiles() {
  986. $id = $this->request["id"];
  987. $fields = array_filter(explode(",", $this->request["fields"]));
  988. $files = array_filter(explode(",", $this->request["files"]));
  989. $record = IntegralRecordApi::getOne($id);
  990. $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
  991. $responseObj = new \stdClass();
  992. if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
  993. if (!$fields && !$files) {
  994. $responseObj->msg = "请选择可修改的字段或附件!";
  995. return json($responseObj);
  996. }
  997. try {
  998. $data["id"] = $id;
  999. $data["modify_fields"] = $fields ? implode(",", $fields) : null;
  1000. $data["modify_files"] = $files ? implode(",", $files) : null;
  1001. IntegralRecord::update($data);
  1002. $responseObj->code = 200;
  1003. $responseObj->msg = "驳回字段修改成功";
  1004. return json($responseObj);
  1005. } catch (\think\db\exception\DbException $e) {
  1006. $responseObj->msg = $e->getMessage();
  1007. return json($responseObj);
  1008. }
  1009. } else {
  1010. $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
  1011. return json($responseObj);
  1012. }
  1013. }
  1014. public function fstVerifyListExport() {
  1015. $this->commonExport(1);
  1016. }
  1017. public function reVerifyListExport() {
  1018. $this->commonExport(2);
  1019. }
  1020. public function preListExport() {
  1021. $this->commonExport(3);
  1022. }
  1023. private function commonExport($process) {
  1024. $params = $this->request->param();
  1025. $fields = $params["export"];
  1026. if (!$fields)
  1027. return json(["msg" => "请选择要导出的数据"]);
  1028. $names = DictApi::getIntegralFields();
  1029. $names["enterpriseName"] = "单位名称";
  1030. $names["street"] = "所属镇街";
  1031. $names["project"] = "申报项目";
  1032. $names["checkState"] = "审核状态";
  1033. $names["checkMsg"] = "审核意见";
  1034. $names["year"] = "申报年度";
  1035. $list = IntegralRecordApi::getExportDatas($process, $fields);
  1036. foreach ($fields as $field) {
  1037. $columns[] = $names[$field];
  1038. }
  1039. $datas = [];
  1040. for ($i = 0; $i < count($list); $i++) {
  1041. $data = [];
  1042. for ($n = 0; $n < count($fields); $n++) {
  1043. $data[] = $list[$i][$fields[$n]];
  1044. }
  1045. $datas[] = $data;
  1046. }
  1047. if ($datas) {
  1048. export($columns, $datas);
  1049. exit();
  1050. }
  1051. echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
  1052. }
  1053. public function getPhones() {
  1054. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1055. $result = [];
  1056. if ($list) {
  1057. foreach ($list as $item) {
  1058. if ($item["phone"] && $item["name"]) {
  1059. $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
  1060. }
  1061. }
  1062. }
  1063. return json(["code" => 200, "obj" => implode(";", $result)]);
  1064. }
  1065. public function getEnterprisePhones() {
  1066. $list = VerifyApi::getListByProcess($this->request->param("process"));
  1067. $result = [];
  1068. if ($list) {
  1069. foreach ($list as $item) {
  1070. if ($item["agentName"] && $item["agentPhone"]) {
  1071. $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
  1072. }
  1073. }
  1074. }
  1075. return json(["code" => 200, "obj" => implode(";", $result)]);
  1076. }
  1077. }