12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\api\ChuanglanSmsApi;
- use app\common\api\VerifyApi;
- use app\common\api\TalentLogApi;
- use app\common\api\TalentState;
- use app\common\model\MessageRecord;
- use app\enterprise\model\Talent as TalentModel;
- use app\common\api\TalentConditionApi;
- use app\common\api\DictApi;
- use app\common\api\EnterpriseApi;
- use think\facade\Db;
- use app\admin\model\User;
- use app\common\api\MenuApi;
- use app\admin\model\Menu;
- use app\admin\model\SysRelation;
- use app\common\api\CompanyApi;
- /**
- * Description of Talent
- *
- * @author sgq
- */
- class Talent extends AdminController {
- public function common_check() {
- $request = $this->request;
- $params = $request->param();
- $id = $params["id"];
- $info = VerifyApi::getTalentInfoById($id);
- if (in_array($info["checkState"], [TalentState::BASE_VERIFY_FAIL, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_REJECT, TalentState::BASE_REVERIFY_FAIL])) {
- return view("talentInfo_base_check", ["info" => $info]);
- } else {
- switch ($info["enterpriseType"]) {
- case 1:
- return view("talentInfo_common_check", ["info" => $info]);
- case 2:
- return view("talentInfo_common_checkIC", ["info" => $info]);
- }
- }
- }
- public function cancel_verify() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $msg = $params["msg"];
- if ($msg == "") {
- return json(["msg" => "请填写审核不通过的原因"]);
- }
- $ids_arr = array_filter(explode(",", $ids));
- $counts = 0;
- foreach ($ids_arr as $id) {
- $ti = VerifyApi::getOne($id);
- $data["id"] = $id;
- if ($ti["checkState"] == TalentState::FST_SUBMIT) {
- $data["checkState"] = TalentState::BASE_VERIFY_FAIL;
- TalentLogApi::write(1, $id, TalentState::BASE_VERIFY_FAIL, $msg, 1);
- TalentModel::update($data);
- $counts++;
- } else if ($ti["checkState"] == TalentState::SCND_SAVE) {
- $data["checkState"] = TalentState::FST_VERIFY_FAIL;
- TalentLogApi::write(1, $id, TalentState::FST_VERIFY_FAIL, $msg, 1);
- TalentModel::update($data);
- $counts++;
- } else {
- return json(["msg" => "不在审核范围"]);
- }
- }
- return json(["code" => 200, sprintf("%d个申请已审核失败", $counts)]);
- }
- public function base_verify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- public function base_verify_list() {
- $params = $this->request->param();
- return json(VerifyApi::getList($params));
- }
- public function base_reverify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- public function base_reverify_list() {
- $params = $this->request->param();
- return json(VerifyApi::getList($params));
- }
- /**
- * 部门初审
- * @auth {{/talentInfo/gotoIndex/-1}}
- */
- public function dept_fst_verify() {
- return view();
- }
- /**
- * 初审
- * @auth {{/talentInfo/gotoIndex/1}}
- */
- public function fst_verify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- /**
- * 初审-审核
- * @auth {{/talentInfo/firstCheck}}
- */
- public function fst_check() {
-
- }
- /**
- * 初审-修改驳回字段
- * @auth {{/talentInfo/updateFieldsAndFiles}}
- */
- public function updateFieldsAndFiles() {
-
- }
- /**
- * 初审-审核不通过
- * @auth {{/talentInfo/setNotPass}}
- */
- public function dis_pass() {
-
- }
- /**
- * 部门审核
- * @auth {{/talentInfo/gotoIndex/2}}
- */
- public function dept_verify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- /**
- * 复审
- * @auth {{/talentInfo/gotoIndex/3}}
- */
- public function re_verify() {
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["enterprises" => $enterprises]);
- }
- /**
- * 复审-撤销复核
- * @auth {{/talentInfo/cancleThirdCheck}}
- */
- public function cancel_check() {
-
- }
- /**
- * 预备人才库
- * @auth {{/talentInfo/gotoIndex/4}}
- */
- public function pre_list() {
- if (session("user")["type"] == 1) {
- $message = [
- "typeName" => "晋江市优秀人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
- "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
- ];
- } else {
- $message = [
- "typeName" => "晋江市集成电路产业优秀人才认定", "address" => "福建(晋江)集成电路产业园官方网站及微信公众号", "dep" => "集成电路产业园区",
- "phone" => "0595-82250007、0595-82250001", "email" => "jjjcdr@163.com"
- ];
- }
- $enterprises = EnterpriseApi::getSimpleList();
- return view("", ["message" => $message, "enterprises" => $enterprises]);
- }
- public function selectNeedCheckData() {
- $params = $this->request->param();
- return json(["code" => 200, "obj" => VerifyApi::getPublicList($params)]);
- }
- /**
- * 预备人才库-核查征信
- * @auth {{/talentInfo/prepareHczx}}
- */
- public function prepareHczx() {
- $ids = $this->request->param("ids");
- $ids_arr = array_filter(explode(",", $ids));
- if (!$ids_arr) {
- $res = ["code" => 500, "msg" => "没有选择导出的名单"];
- echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
- }
- $where[] = ["ti.id", "in", $ids_arr];
- $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.name,ti.card_type,ti.card_number,e.name as enterpriseName,e.description")->where($where)->select();
- if (!$list) {
- $res = ["code" => 500, "msg" => "没有可以导出的内容"];
- echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
- }
- $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
- $rows = [];
- $i = 1;
- $card_types = DictApi::selectByParentCode("card_type");
- foreach ($list as $item) {
- $row = [
- $i, $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], $item["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- $filename = "优秀人才核查征信名单导出";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-征信通过
- * @auth {{/talentInfo/hczxPass}}
- */
- public function hczxPass() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "征信通过";
- $state = TalentState::ZX_PASS; //征信通过
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("核查征信完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-征信失信
- * @auth {{/talentInfo/hczxReject}}
- */
- public function hczxReject() {
- $params = $this->request->param();
- $id = $params["id"];
- $msg = $params["outMsg"];
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- $msg = "征信失信:" . $msg;
- $state = TalentState::ZX_FAIL; //征信不通过
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
- return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- return json(["code" => 200, "msg" => "已设置征信失信"]);
- }
- return json(["msg" => "设置征信失信失败"]);
- }
- /**
- * 预备人才库-公示预览
- * @auth {{/talentInfo/publicExportBefore}}
- */
- public function publicExportBefore() {
- $params = $this->request->param();
- $ids_arr = array_filter(explode(",", $params["ids"]));
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
- if ($ids_arr) {
- $where[] = ["id", "in", $ids_arr];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ZX_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- }
- if ($rows) {
- $filename = "优秀人才公示预览导出";
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公示导出
- * @auth {{/talentInfo/publicExport}}
- */
- public function publicExport() {
- $params = $this->request->param();
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
- $startTime = $params["startTime"];
- $endTime = $params["endTime"];
- if (!strtotime($startTime) || !strtotime($endTime))
- return json(["msg" => "时间格式错误"]);
- $where[] = ["checkState", "=", TalentState::ANNOUNCED];
- $where[] = ["publicBatch", "between", [$startTime, $endTime]];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- if ($rows) {
- $filename = "优秀人才公示导出";
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公示
- * @auth {{/talentInfo/preparePublic}}
- */
- public function preparePublic() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $publicBatch = $params["batch"];
- if (!$publicBatch || strlen($publicBatch) != 6 || !is_numeric($publicBatch))
- return json(["msg" => "公示批次错误"]);
- $isMessage = $params["isMessage"] == 1 ? true : false;
- if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
- return json(["msg" => "短信参数不能为空"]);
- }
- $ids = array_filter(explode(",", $ids));
- $msg = "已公示";
- $state = TalentState::ANNOUNCED; //公示
- $total = count($ids);
- $error = 0;
- $success = 0;
- $phones = [];
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ZX_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
- $success++;
- $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
- $phones[] = $ep->agentPhone;
- } else {
- $error++;
- }
- }
- $phones = array_unique(array_filter($phones));
- if ($isMessage && $phones) {
- $sms = new \app\common\api\ChuanglanSmsApi();
- $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
- $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
- while ($phone = array_shift($phones)) {
- $result = $sms->sendSMS($phone, $tpl_content);
- $result = json_decode($result, true);
- $recordId = getStringId();
- $record_data = [
- 'id' => $recordId,
- 'bizId' => $recordId,
- 'type' => 2,
- 'smsType' => 1,
- 'phone' => $phone,
- 'params' => '公示',
- 'templateCode' => $tpl_content,
- 'state' => $result['code'] == 0 ? 2 : 3,
- 'sendingDate' => date("Y-m-d H:i:s", time()),
- 'createTime' => date("Y-m-d H:i:s", time()),
- 'msg' => $result['errorMsg']
- ];
- MessageRecord::create($record_data);
- }
- }
- return json(["code" => 200, "msg" => sprintf("公示完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-公示再审核
- * @auth {{/talentInfo/prepareCheck}}
- */
- public function prepareCheck() {
- $params = $this->request->param();
- $id = $params["id"];
- $checkState = $params["checkState"];
- $msg = $params["checkMsg"];
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- if ($checkState == 1) {
- $msg = "公示再审核通过:" . $msg;
- $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
- } else {
- $msg = "公示再审核不通过:" . $msg;
- $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
- }
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
- return json(["msg" => "当前记录不是公示状态,无法审核"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- return json(["code" => 200, "msg" => "公示再审核完成"]);
- }
- return json(["msg" => "公示再审核失败"]);
- }
- /**
- * 预备人才库-公示通过(批量)
- * @auth {{/talentInfo/publicPass}}
- */
- public function publicPass() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "公示再审核批量通过";
- $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("公示再审核完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-公布预览
- * @auth {{/talentInfo/publishExportBefore}}
- */
- public function publishExportBefore() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- if ($ids) {
- $where[] = ["id", "in", $ids];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- }
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
- $filename = "优秀人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公布导出
- * @auth {{/talentInfo/publishExport}}
- */
- public function publishExport() {
- $params = $this->request->param();
- $startTime = $params["startTime"];
- $endTime = $params["endTime"];
- if (!strtotime($startTime) || !strtotime($endTime))
- return json(["msg" => "时间格式错误"]);
- $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
- $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
- $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
- $rows = [];
- $i = 1;
- $talentArranges = DictApi::selectByParentCode("talent_arrange");
- foreach ($list as $item) {
- $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
- $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
- $checkLog = TalentLogApi::getLastLog($item["id"], 1);
- $row = [
- $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::PUBLISH_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
- ];
- $rows[] = $row;
- $i++;
- }
- $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
- $filename = "优秀人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
- if ($rows) {
- export($columns, $rows, $filename);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');</script>";
- }
- /**
- * 预备人才库-公布
- * @auth {{/talentInfo/publish}}
- */
- public function publish() {
- $params = $this->request->param();
- $id = $params["id"];
- $msg = $params["checkMsg"];
- $checkState = $params["checkState"];
- $batch = $params["batch"];
- if ($checkState == 1) {
- $state = TalentState::PUBLISH_PASS;
- $msg = "公布审核通过:" . $msg;
- } else {
- $state = TalentState::PUBLISH_FAIL;
- $msg = "公布审核不通过:" . $msg;
- }
- if (!$batch || !strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- if (!$msg)
- return json(["msg" => "请填写审核意见"]);
- $state = TalentState::PUBLISH_PASS; //公示再审核通过
- $batch = $params["batch"];
- if (!strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
- return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
- }
- if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
- return json(["code" => 200, "msg" => "公布审核完成"]);
- }
- return json(["msg" => "公布审核失败"]);
- }
- /**
- * 预备人才库-批量公布通过
- * @auth {{/talentInfo/preparePublish}}
- */
- public function preparePublish() {
- $params = $this->request->param();
- $ids = $params["ids"];
- $ids = array_filter(explode(",", $ids));
- $msg = "批量公布";
- $state = TalentState::PUBLISH_PASS; //公示再审核通过
- $batch = $params["batch"];
- if (!strtotime($batch))
- return json(["msg" => "公布批次时间错误"]);
- $total = count($ids);
- $error = 0;
- $success = 0;
- foreach ($ids as $id) {
- $talent_info = VerifyApi::getOne($id);
- if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
- $error++;
- continue;
- }
- if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
- $success++;
- } else {
- $error++;
- }
- }
- return json(["code" => 200, "msg" => sprintf("公布完成:共提交%d个人才,通过%d个,失败%d个", $total, $success, $error)]);
- }
- /**
- * 预备人才库-批量发放人才码
- * @auth {{/talentInfo/prepareCertification}}
- */
- public function prepareCertification() {
- $lockFile = fopen("send_certificate.lock", "a");
- if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
- //查询所有待发放人才码的数据
- $params = $this->request->param();
- $ids = array_filter(explode(",", $params["ids"]));
- //晋江市优秀人才证书:当前年份+层次+四位递增数字
- //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
- Db::startTrans();
- $talent_max_no = [];
- $user = session("user");
- try {
- $talent_list = VerifyApi::getListByIds($ids);
- $year = date("Y");
- foreach ($talent_list as $talent_info) {
- if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
- Db::rollback();
- return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
- }
- $no_prefix = $year . $talent_info["talent_arrange"];
- $where[] = ["certificateNo", "like", $no_prefix . "%"];
- $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
- if (!$max_no) {
- $max_no = $no_prefix . "0001";
- } else {
- $new_no = intval(substr($max_no, 5)) + 1;
- $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
- }
- //更新证书编号
- $data["id"] = $talent_info["id"];
- $data["certificateNo"] = $max_no;
- $data["checkState"] = TalentState::CERTIFICATED;
- $data["isPublic"] = 5;
- Db::table("new_talent_info")->update($data);
- //写入日志
- $log["last_state"] = TalentState::PUBLISH_PASS;
- $log["id"] = getStringId();
- $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
- $log["type"] = 1;
- $log["mainId"] = $talent_info["id"];
- $log["companyId"] = $user["companyId"];
- $log["active"] = 1;
- $log["description"] = "人才码为:" . $max_no;
- $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
- $log["createTime"] = date("Y-m-d H:i:s");
- Db::table("new_talent_checklog")->insert($log);
- $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
- }
- Db::commit();
- return json(["code" => 200, "msg" => "发放人才码成功"]);
- } catch (\Exception $e) {
- Db::rollback();
- return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
- }
- flock($lockFile, LOCK_UN);
- } else {
- return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
- }
- }
- /**
- * 预备人才库-撤销公布
- * @auth {{/talentInfo/prepareCanclePublish}}
- */
- public function pre_cancel_publish() {
-
- }
- /**
- * 基本条件审核-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function baseCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::BASE_VERIFY_PASS; //基础信息审核成功
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::FST_SAVE; //退回提交材料阶段
- $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 基本条件审核-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function baseSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 1);
- }
- /**
- * 基本条件复审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function baseReCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::BASE_REVERIFY_PASS; //基础信息复审成功
- } else if ($params["checkState"] == 2) {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::FST_SUBMIT; //退回待基础审核状态
- $log_checkState = TalentState::BASE_REVERIFY_REJECT; //日志记录拒绝状态
- } else {
- $log_checkState = $checkState = TalentState::BASE_REVERIFY_FAIL; //审核失败
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 基本条件复审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function baseReSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 2);
- }
- /**
- * 初审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function fstCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功,并取消设置越过部门并审
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- $data["pass_dept_check"] = 0;
- } else if ($params["checkState"] == 4) {
- if ($talent_info["highProcess"] < 4)
- return json(["msg" => "只有曾经通过部门并审,初审时才可以选择直接跳过部门并审阶段"]);
- //审核成功,并设置越过部门并审。附加条件:最高进度曾经通过部门并审4(包含部门并审)
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- $data["pass_dept_check"] = $talent_info["highProcess"] >= 4 ? 1 : 0;
- } else if ($params["checkState"] == 5) {
- //选择重审部门
- if ($talent_info["highProcess"] < 4)
- return json(["msg" => "只有曾经通过部门并审,初审时才可以选择再次审核的部门"]);
- if (!$params["companys"])
- return json(["msg" => "请选择需要再次审核的部门"]);
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
- $re_check_companys = array_filter(explode(",", $talent_info["re_check_companys"]));
- foreach ($re_check_companys as $reCompanyId) {
- if (!in_array($reCompanyId, $companyIds)) {
- return json(["msg" => "错误的部门"]);
- }
- }
- $log_checkState = $checkState = TalentState::FST_VERIFY_PASS; //初审成功
- $data["pass_dept_check"] = 0;
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::SCND_SAVE; //退回材料编辑状态
- $log_checkState = TalentState::FST_VERIFY_REJECT; //日志记录拒绝状态
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- $data["re_check_companys"] = $params["companys"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 初审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function fstSubmitCheck($talent_info) {
- $nowProcess = 3;
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log || $log["active"] == 1)
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- }
- $userIds = [];
- if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
- $data["first_dept_check_time"] = date("Y-m-d H:i:s");
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
- if ($talent_info["re_check_companys"]) {
- $unpass_companyIds = array_filter(explode(",", $talent_info["re_check_companys"]));
- } else {
- //这边去除已经审核通过的单位,主要通过日志是否存在记录。
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- $unpass_companyIds = array_diff($companyIds, (array) $pass_companyIds); //排除已经通过的单位
- if (!$unpass_companyIds) {
- $data["pass_dept_check"] = 1; //部门已经全部审核过了,跳过部门审核
- }
- }
- if ($unpass_companyIds) {
- sort($unpass_companyIds);
- TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
- //初审通过发送短信通知并审部门
- $privs = ["/admin/talent/dept_check"];
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["companyId", "in", $unpass_companyIds];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id");
- }
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $log["new_state"];
- TalentModel::update($data);
- TalentLogApi::setActive($log["id"], 1);
- $this->sendMsgByState($talent_info, $log["new_state"], $userIds);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- /**
- * 部门审核-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @return type json
- */
- private function deptCheck(\think\Request $request, $talent_info, $companys) {
- if ($talent_info["pass_dept_check"] == 1)
- return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
- //$pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- //if (in_array($this->user["companyId"], $pass_companyIds))
- //return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
- $un_check_companyIds = TalentLogApi::getUnCheckDepts($talent_info["id"]); //未审核提交的单位
- if (!in_array($this->user["companyId"], $un_check_companyIds))
- return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
- $checkState = TalentState::DEPT_VERIFY_PASS; //审核成功
- } else {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::SCND_SUBMIT; //退回待初审
- $log_checkState = TalentState::FST_VERIFY_PASS; //当前状态不变
- $talent_condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- if (!$talent_condition["companyWithFileType"])
- return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
- $cwfts = explode(";", $talent_condition["companyWithFileType"]);
- $company_setting = [];
- foreach ($cwfts as $cwft) {
- $_company_setting = explode(":", $cwft);
- if ($_company_setting[0] == $this->user["companyId"]) {
- $company_setting = explode(",", $_company_setting[1]);
- break;
- }
- }
- if (!$company_setting)
- return json(["msg" => "尚未设置单位可审的附件,请联系管理员设置后再进行审批"]);
- //$data["modify_fields"] = $params["fields"];
- $original_modify_files = explode(",", $talent_info["modify_files"]);
- $_current_modify_files = explode(",", $params["files"]);
- $unselect_files = array_diff($company_setting, $_current_modify_files); //比较设置和当前提交的,取差值集,既是可选而未选的附件集合
- $new_modify_files = array_unique(array_merge($original_modify_files, $_current_modify_files)); //合并当前提交及库中原来保存的值
- foreach ($new_modify_files as $key => $item) {
- if (in_array($item, $unselect_files))
- unset($new_modify_files[$key]);
- }
- $data["modify_files"] = implode(",", array_unique($new_modify_files));
- }
- $fst_dept_check_time = $talent_info["first_dept_check_time"];
- $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $fst_dept_check_time);
- if (!$dept_log)
- return json(["msg" => "未匹配日志,审核失败"]);
- if ($dept_log["active"] == 1)
- return json(["msg" => "您的部门已经审核过了"]);
- $data["id"] = $talent_info["id"];
- TalentModel::update($data);
- //修改日志
- TalentLogApi::rewrite($dept_log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 部门审核-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function deptSubmitCheck($talent_info, $companys) {
- if ($talent_info["pass_dept_check"] == 1)
- return json(["msg" => "不在审核范围。(初审部门已经选择跳过部门并审阶段)"]);
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "您的部门不在该申请的并审部门列表中。"]);
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"]); //已经通过的单位
- if (in_array($this->user["companyId"], $pass_companyIds))
- return json(["msg" => "您的部门已经审核过了,无需重复审核。"]);
- $dept_log = TalentLogApi::getLogByCompanyId($talent_info["id"], $this->user["companyId"], $talent_info["first_dept_check_time"]);
- if (!$dept_log)
- return json(["msg" => "未匹配日志,审核失败"]);
- if ($dept_log["state"] == $dept_log["new_state"])
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if ($dept_log["active"] == 1)
- return json(["msg" => "您的部门已经审核过了"]);
- if ($talent_info["re_check_companys"]) {
- $companys = array_filter(explode(",", $talent_info["re_check_companys"]));
- $pass_companyIds = TalentLogApi::getPassDepts($talent_info["id"], $talent_info["first_dept_check_time"]); //重审单位中已经通过的单位
- }
- $over = $pass_companyIds ? count($pass_companyIds) : 0; //完成度,如果重审之前已有通过审核的部门,不用再审,直接按通过算
- $error = 0; //失败数
- $nowProcess = 4;
- $over++;
- if ($dept_log["new_state"] == TalentState::SCND_SUBMIT) {
- $error++;
- }
- $logs = TalentLogApi::getListLogByTime($talent_info["id"], $talent_info["first_dept_check_time"]);
- for ($i = 0; $i < count($logs); $i++) {
- if (!in_array($logs[$i]["companyId"], $pass_companyIds)) {
- $over += $logs[$i]["active"] == 1 ? 1 : 0;
- if ($logs[$i]["new_state"] == TalentState::SCND_SUBMIT) {
- $error++;
- }
- }
- }
- if ($over == count($companys)) {
- //全部已审核
- $checkState = TalentState::SCND_SUBMIT;
- $log_checkState = TalentState::DEPT_VERIFY_REJECT;
- if ($error == 0) {
- $log_checkState = $checkState = TalentState::DEPT_VERIFY_PASS;
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $checkState;
- $data["first_dept_check_time"] = null;
- $data["re_check_companys"] = null;
- TalentModel::update($data);
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
- if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
- //部门驳回发送短信通知
- $privs = ["admin/talent/fst_check"];
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id");
- $this->sendMsgByState($talent_info, $log_checkState, $userIds);
- }
- }
- TalentLogApi::setActive($dept_log["id"], 1);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- /**
- * 复审-提交未保存
- * @param \think\Request $request
- * @param type $talent_info
- * @param type json
- */
- private function reCheck(\think\Request $request, $talent_info) {
- $params = $request->param();
- if ($params["checkState"] == 3) {
- //审核成功
- $log_checkState = $checkState = TalentState::REVERIFY_PASS; //复核成功
- } else if ($params["checkState"] == 2) {
- //审核驳回并记录需要修改的字段和上传文件
- $checkState = TalentState::SCND_SUBMIT; //退回待初审
- $log_checkState = TalentState::REVERIFY_REJECT; //日志记录拒绝状态
- } else {
- $log_checkState = $checkState = TalentState::REVERIFY_FAIL; //审核失败
- }
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log)
- return json(["msg" => "日志数据异常,保存失败"]);
- if ($log["active"] == 0) {
- TalentLogApi::rewrite($log["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- } else {
- TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], $params["checkMsg"]);
- }
- $data["id"] = $talent_info["id"];
- $data["modify_files"] = $params["files"];
- $data["modify_fields"] = $params["fields"];
- TalentModel::update($data);
- return json(["code" => 200, "msg" => "保存成功"]);
- }
- /**
- * 复审-提交审核
- * @param type $talent_info
- * @return type json
- */
- private function reSubmitCheck($talent_info) {
- return $this->commonSubmitCheck($talent_info, 5);
- }
- private function commonSubmitCheck($talent_info, $nowProcess) {
- $log = TalentLogApi::getLastLog($talent_info["id"], 1);
- if (!$log || $log["active"] == 1)
- return json(["msg" => "请先保存审核状态,再提交审核"]);
- if (in_array($log["new_state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
- $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
- }
- $data["id"] = $talent_info["id"];
- $data["checkState"] = $log["new_state"];
- TalentModel::update($data);
- TalentLogApi::setActive($log["id"], 1);
- $userIds = [];
- if (in_array($data["checkState"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
- //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
- //从征信审核权限,逆推征信部门
- if ($data["checkState"] == TalentState::REVERIFY_PASS) {
- $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
- } else {
- $privs = ["admin/talent/fst_check"];
- }
- $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
- $where = [];
- $where[] = ["menuid", "in", $menuIds];
- $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
- $where = [];
- $where[] = ["status", "=", 1];
- $where[] = ["roleid", "in", $roleIds];
- $where[] = ["roleid", "<>", 1];
- $userIds = User::where($where)->column("id");
- }
- $this->sendMsgByState($talent_info, $data["checkState"], $userIds);
- return json(["code" => 200, "msg" => "审核成功"]);
- }
- private function sendMsgByState($talent_info, $state, $userIds = []) {
- $phones = [];
- $template = "";
- $type = 0;
- $processName = "";
- $userId = 0;
- $name = null;
- switch ($state) {
- case TalentState::BASE_VERIFY_PASS://基础信息审核通过发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核通过,请及时登录申报系统并进行人才认定的信息申报填写。";
- break;
- case TalentState::BASE_REJECT://基础信息审核驳回发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
- break;
- case TalentState::BASE_VERIFY_FAIL://基础信息审核不通过发送短信通知用户
- $type = 2;
- $processName = "基础信息审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才基础信息审核不通过,原因是:{$log['description']}。";
- break;
- case TalentState::FST_VERIFY_PASS://初审通过发送短信通知并审部门
- $type = 1;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】您的部门有新的人才认定申报需要审批,请及时登录审批系统处理。";
- break;
- case TalentState::FST_VERIFY_REJECT; //初审驳回发送短信通知用户
- $type = 2;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
- break;
- case TalentState::FST_VERIFY_FAIL://初审不通过发送短信通知用户
- $type = 2;
- $processName = "初级审核";
- $template = "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核不通过,原因是:{$log['description']}。";
- break;
- case TalentState::DEPT_VERIFY_REJECT://并审驳回发送短信通知初审部门
- $type = 1;
- $processName = "部门并审";
- $template = "【晋江市人才服务平台】有人才认定申报在并审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
- break;
- case TalentState::REVERIFY_PASS://复核通过发短信通知征信部门
- $type = 1;
- $processName = "复审";
- $template = "【晋江市人才服务平台】有新的人才认定申报通过复审进入征信阶段,请及时登录审批系统处理。";
- break;
- case TalentState::REVERIFY_REJECT://复核驳回发短信通知初审部门
- $type = 1;
- $processName = "复审";
- $template = "【晋江市人才服务平台】有人才认定申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
- break;
- }
- if ($type == 1) {
- $where = [];
- $where[] = ["id", "in", $userIds];
- $phones = User::where($where)->column("phone");
- $phones = array_unique(array_filter($phones));
- }
- if ($type == 2) {
- $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
- $phones[] = $ep->agentPhone;
- $userId = $ep->id;
- $name = $ep->name;
- }
- if ($phones && $template) {
- while ($phone = array_shift($phones)) {
- $smsapi = new ChuanglanSmsApi();
- $result = $smsapi->sendSMS($phone, $template);
- $result = json_decode($result, true);
- $id = getStringId();
- $record_data = [
- 'id' => $id,
- 'userId' => $userId,
- 'bizId' => $id,
- 'type' => $type,
- 'smsType' => 2,
- 'name' => $name,
- 'phone' => $phone,
- 'params' => $processName,
- 'templateCode' => $template,
- 'state' => $result['code'] == 0 ? 2 : 3,
- 'sendingDate' => date("Y-m-d H:i:s", time()),
- 'createTime' => date("Y-m-d H:i:s", time()),
- 'msg' => $result['errorMsg']
- ];
- MessageRecord::create($record_data);
- }
- }
- }
- public function check() {
- //公共调度方法
- $request = $this->request;
- $params = $request->param();
- $check = $params["checkState"];
- $check_msg = trim($params["checkMsg"]);
- $files = $params["files"];
- $fields = $params["fields"];
- $id = $params["id"];
- $talent_info = VerifyApi::getOne($id);
- $checkState = $talent_info["checkState"];
- if (!$talent_info) {
- return json(["msg" => "数据错误"]);
- }
- if (!$check) {
- return json(["msg" => "请选择审核状态"]);
- }
- if (!$check_msg) {
- return json(["msg" => "请填写审核说明"]);
- }
- if ($checkState == TalentState::FST_SUBMIT) {
- return $this->baseCheck($request, $talent_info);
- } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
- return $this->baseReCheck($request, $talent_info);
- } else if ($checkState == TalentState::SCND_SUBMIT) {
- return $this->fstCheck($request, $talent_info);
- } else if ($checkState == TalentState::FST_VERIFY_PASS) {
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- if ($companys && $talent_info["pass_dept_check"] != 1) {
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "你的部门不在并审部门列表"]);
- return $this->deptCheck($request, $talent_info, $companys);
- } else {
- return $this->reCheck($request, $talent_info);
- }
- } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
- return $this->reCheck($request, $talent_info);
- } else {
- return json(["msg" => "不在审核范围内,保存失败"]);
- }
- }
- public function submitCheck() {
- //公共调度方法
- $id = $this->request->param("id");
- $talent_info = VerifyApi::getOne($id);
- $checkState = $talent_info["checkState"];
- if (!$talent_info) {
- return json(["msg" => "数据错误"]);
- }
- if ($checkState == TalentState::FST_SUBMIT) {
- return $this->baseSubmitCheck($talent_info);
- } else if ($checkState == TalentState::BASE_VERIFY_PASS) {
- return $this->baseReSubmitCheck($talent_info);
- } else if ($checkState == TalentState::SCND_SUBMIT) {
- return $this->fstSubmitCheck($talent_info);
- } else if ($checkState == TalentState::FST_VERIFY_PASS) {
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- if ($companys && $talent_info["pass_dept_check"] != 1) {
- if (!in_array($this->user["companyId"], $companys))
- return json(["msg" => "你的部门不在并审部门列表"]);
- return $this->deptSubmitCheck($talent_info, $companys);
- } else {
- return $this->reSubmitCheck($talent_info);
- }
- } else if ($checkState == TalentState::DEPT_VERIFY_PASS) {
- return $this->reSubmitCheck($talent_info);
- } else {
- return json(["msg" => "不在审核范围内,审核失败"]);
- }
- }
- public function validateIsCheck() {
- $params = $this->request->param();
- $id = $params["id"];
- $talent_info = VerifyApi::getOne($id);
- $fstLog = TalentLogApi::getFstLog($id, 1);
- $isMix = false;
- if (in_array($fstLog["state"], [TalentState::SCND_SAVE, TalentState::SCND_SUBMIT])) {
- //初次提交是待初审状态,则为新的混合基础信息和人才认证信息的申报
- $isMix = true;
- }
- $enterprise = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
- if ($talent_info) {
- $checkState = $talent_info["checkState"];
- // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5基审复核通过 6基审复核驳回 7基审复核失败 8保存补充材料未提交 9提交补充材料进入初审 10初审通过 11初审驳回 12部门审核通过 13部门审核驳回 14复核通过 15复核驳回 16复核失败
- $process = 0;
- if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS, TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS])) {
- switch ($checkState) {
- case TalentState::FST_SUBMIT:
- $fields = DictApi::getTalentFields(1);
- $field_tmp = [];
- foreach ($fields as $key => $field) {
- $field_tmp[] = ["key" => $key, "value" => $field];
- }
- $where[] = ["project", "=", 1];
- $where[] = ["step", "=", 1];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $enterprise["type"]];
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
- /* foreach ($files as $key => $file) {
- $options = array_filter(explode(",", $file["option"]));
- if ($options) {
- switch ($file["rel"]) {
- case "talent_type":
- $allow_tags = array_filter(explode(",", $file["enterprise_tag"]));
- if ($allow_tags && !in_array($enterprise["enterpriseTag"], $allow_tags)) {
- unset($files[$key]);
- break;
- }
- if (!in_array($talent_info["talent_type"], $options)) {
- unset($files[$key]);
- break;
- }
- break;
- case "birthday":
- $birthYear = substr($talent_info["birthday"], 0, 4);
- $currentYear = date("Y");
- $age = $currentYear - $birthYear;
- if ($age < $options[0]) {
- unset($files[$key]);
- break;
- }
- break;
- }
- }
- } */
- $process = 1;
- break;
- case TalentState::BASE_VERIFY_PASS:
- $fields = DictApi::getTalentFields(1);
- $field_tmp = [];
- foreach ($fields as $key => $field) {
- $field_tmp[] = ["key" => $key, "value" => $field];
- }
- $where[] = ["project", "=", 1];
- $where[] = ["step", "=", 1];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $enterprise["type"]];
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
- $process = 2;
- break;
- case TalentState::SCND_SUBMIT:
- $fields = DictApi::getTalentFields(2);
- $process = 3;
- break;
- case TalentState::FST_VERIFY_PASS:
- $tc = TalentConditionApi::getOne($talent_info["talent_condition"]);
- if ($tc["companyIds"] && $talent_info["pass_dept_check"] != 1) {
- $process = 4;
- $fields = DictApi::getTalentFields(3);
- } else {
- $process = 5;
- $fields = DictApi::getTalentFields(2);
- }
- break;
- case TalentState::DEPT_VERIFY_PASS:
- $process = 5;
- $fields = DictApi::getTalentFields(2);
- break;
- }
- if ($isMix) {
- if ($enterprise["type"] == 2) {
- $fields = DictApi::getTalentFields_IC();
- } else {
- $fields = DictApi::getTalentFields(4);
- }
- }
- if ($checkState != TalentState::FST_SUBMIT) {
- //$fields = DictApi::getTalentFields(2);
- $field_tmp = [];
- if ($fields) {
- foreach ($fields as $key => $field) {
- $field_tmp[] = ["key" => $key, "value" => $field];
- }
- }
- $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
- $companys = array_filter(explode(",", $condition["companyIds"]));
- $_companys = [];
- foreach ($companys as $companyId) {
- $company = CompanyApi::getOne($companyId);
- $_companys[] = $company;
- }
- if ($process == 4 && $enterprise["type"] == 1) {
- $where = [];
- $where[] = ["delete", "=", 0];
- $cwfts = explode(";", $condition["companyWithFileType"]);
- foreach ($cwfts as $cwft) {
- $_company_setting = explode(":", $cwft);
- if ($_company_setting[0] == $this->user["companyId"]) {
- $where[] = ["id", "in", explode(",", $_company_setting[1])];
- break;
- }
- }
- if ($where) {
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
- } else {
- $files = [];
- }
- } else {
- $where = [];
- $whr = [];
- if (!$isMix) {
- $where[] = ["step", "=", 2];
- }
- $where[] = ["project", "=", 1];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $enterprise["type"]];
- $where[] = ["isConditionFile", "<>", 1];
- $where[] = ["delete", "=", 0];
- if ($condition && $condition["bindFileTypes"]) {
- $whr[] = ["id", "in", explode(",", $condition["bindFileTypes"])];
- $files = \think\facade\Db::table("new_common_filetype")->whereOr([$where, $whr])->select();
- } else {
- $files = \think\facade\Db::table("new_common_filetype")->where($where)->select();
- }
- }
- }
- $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
- $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
- return json(["code" => 200, "obj" => ["process" => $process, "talentInfo" => $talent_info, "fieldList" => $field_tmp, "fileList" => $files, "companys" => $_companys]]);
- } else {
- return json(["msg" => "该申报不在审核范围内,无法审核"]);
- }
- }
- }
- public function findFieldsAndFiles() {
-
- }
- public function baseVerifyListExport() {
- $this->commonExport(1);
- }
- public function baseReverifyListExport() {
- $this->commonExport(2);
- }
- public function fstVerifyListExport() {
- $this->commonExport(3);
- }
- public function deptVerifyListExport() {
- $this->commonExport(4);
- }
- public function reVerifyListExport() {
- $this->commonExport(5);
- }
- public function preListExport() {
- $this->commonExport(6);
- }
- private function commonExport($process) {
- $params = $this->request->param();
- $fields = $params["export"];
- if (!$fields)
- return json(["msg" => "请选择要导出的数据"]);
- $names = DictApi::getTalentFields(4);
- $names["industryFieldNew"] = "产业领域";
- $names["enterpriseName"] = "单位名称";
- $names["enterpriseTag"] = "单位标签";
- $names["street"] = "所属镇街";
- $names["checkState"] = "审核状态";
- $names["checkMsg"] = "审核意见";
- $list = VerifyApi::getExportDatas($process, $fields);
- foreach ($fields as $field) {
- $columns[] = $names[$field];
- }
- $datas = [];
- for ($i = 0; $i < count($list); $i++) {
- $data = [];
- for ($n = 0; $n < count($fields); $n++) {
- $data[] = $list[$i][$fields[$n]];
- }
- $datas[] = $data;
- }
- if ($datas) {
- export($columns, $datas);
- exit();
- }
- echo "<script>parent.layer.alert('没有可以导出的数据');window.history.go(-1);</script>";
- }
- public function getPhones() {
- $list = VerifyApi::getListByProcess($this->request->param("process"));
- $result = [];
- if ($list) {
- foreach ($list as $item) {
- if ($item["phone"] && $item["name"]) {
- $result[] = sprintf("%s:%s", $item["name"], $item["phone"]);
- }
- }
- }
- return json(["code" => 200, "obj" => implode(";", $result)]);
- }
- public function getEnterprisePhones() {
- $list = VerifyApi::getListByProcess($this->request->param("process"));
- $result = [];
- if ($list) {
- foreach ($list as $item) {
- if ($item["agentName"] && $item["agentPhone"]) {
- $result[] = sprintf("%s:%s", $item["agentName"], $item["agentPhone"]);
- }
- }
- }
- return json(["code" => 200, "obj" => implode(";", $result)]);
- }
- }
|