IntegralVerify.php 51 KB

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