12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\api\ChuanglanSmsApi;
- use app\common\api\EnterpriseApi;
- use app\common\api\LivingAllowanceApi;
- use app\common\state\LivingAllowanceState as LaState;
- use app\common\state\CommonConst;
- use app\common\model\TalentLog;
- use app\common\state\ProjectState;
- use app\common\model\LivingAllowance as LaModel;
- use app\common\api\DictApi;
- use think\facade\Db;
- /**
- * Description of LivingAllowance
- *
- * @author sgq
- */
- class LivingAllowance extends AdminController {
- public function index() {
- if ($this->user["type"] == CommonConst::ENTERPRISE_NORMAL) {
- $enterpriseList = EnterpriseApi::getMultipleList([CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]);
- } else {
- $enterpriseList = EnterpriseApi::getSimpleList();
- }
- $provinceList = \app\common\api\LocationApi::findProvinceSelect();
- $process = $this->request->param("process");
- $message = [];
- if ($this->user["type"] == 1) {
- $message["typeName"] = "晋江市硕博人才生活补贴申报";
- $message["address"] = "聚才网/人才晋江微信公众号";
- $message["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
- $message["phone"] = "0595-85633128";
- $message["email"] = "jjrc85661234@163.com";
- } else if ($this->user["type"] == 2) {
- $message["typeName"] = "晋江市硕博人才生活补贴申报";
- $message["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
- $message["dep"] = "集成电路产业园区";
- $message["phone"] = "0595-82250007、0595-82250001";
- $message["email"] = "jjjcdr@163.com";
- }
- return view("", ["enterpriseList" => $enterpriseList, "provinceList" => $provinceList, "process" => $process, "message" => $message]);
- }
- public function list() {
- $res = LivingAllowanceApi::getList($this->request->param());
- return json($res);
- }
- public function detail() {
- $id = $this->request->param("id");
- $process = $this->request->param("process");
- $info = LivingAllowanceApi::getInfoById($id);
- $info = $this->translateToChinese($info);
- return view("", ["row" => $info, "process" => $process]);
- }
- private function translateToChinese($obj) {
- if ($obj["industryFieldNew"]) {
- $obj["industryFieldNewName"] = DictApi::findByParentCodeAndCode("industry_field", $obj["industryFieldNew"])["name"];
- }
- if ($obj["industryField"]) {
- $industry_field_type = $obj["industryFieldNew"] ? $obj["industryFieldNew"] . "_field" : "un_industryField";
- $obj["industryFieldName"] = DictApi::findByParentCodeAndCode($industry_field_type, $obj["industryField"])["name"];
- }
- if ($obj["address"]) {
- $obj["streetName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
- }
- if ($obj["nationality"]) {
- $obj["nationalityName"] = DictApi::findByParentCodeAndCode("nationality", $obj["nationality"])["name"];
- }
- if ($obj["nation"]) {
- $obj["nationName"] = DictApi::findByParentCodeAndCode("nation", $obj["nation"])["name"];
- }
- if ($obj["politics"]) {
- $obj["politicsName"] = DictApi::findByParentCodeAndCode("politics", $obj["politics"])["name"];
- }
- if ($obj["highEducation"]) {
- $obj["educationName"] = DictApi::findByParentCodeAndCode("highest_degree", $obj["highEducation"])["name"];
- }
- if ($obj["introductionMode"]) {
- $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("un_introduction_mode", $obj["introductionMode"])["name"];
- }
- if ($obj["declareType"]) {
- $obj["declareTypeName"] = DictApi::findByParentCodeAndCode("un_master_education", $obj["declareType"])["name"];
- }
- if ($obj["cardType"] == 1) {
- $obj["cardTypeName"] = "身份证";
- } else if ($obj["cardType"] == 2) {
- $obj["cardTypeName"] = "通行证";
- } else if ($obj["cardType"] == 3) {
- $obj["cardTypeName"] = "护照";
- } else {
- $obj["cardTypeName"] = "未知";
- }
- return $obj;
- }
- /**
- * 校验是否在审核范围内
- * @param type $id
- * @param type $process
- * @return type
- */
- public function validateIsCheck($id, $process) {
- $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- switch ($process) {
- case 1:
- if ($oldInfo["checkState"] != LaState::LA_NEED_FIRST_CHECK && $oldInfo["checkState"] != LaState::LA_DEP_REJECT && $oldInfo["checkState"] != LaState::LA_THIRD_REJECT) {
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 2:
- $company = getCacheById("Company", $this->user["companyId"]);
- if ($oldInfo["checkState"] != LaState::LA_NEED_DEP_CHECK) {// && $oldInfo["checkState"] != LaState::LA_THIRD_REJECT
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else if ($company["code"] != CommonConst::JYJ) {
- $responseObj->msg = "部门审核仅教育局能够审核!";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 3:
- if ($oldInfo["checkState"] != LaState::LA_NEED_THIRD) {
- $responseObj->msg = "该申报不在审核范围内,无法审核";
- } else if ($oldInfo["creditStatus"] == 1) {
- $responseObj->msg = "当前申报数据未导入核查数据,无法审核";
- } else {
- $responseObj->code = 200;
- $responseObj->msg = "";
- }
- break;
- case 4:
- break;
- }
- if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $responseObj->msg = "当前账号类型没有操作权限";
- }
- if ($responseObj->code == 500) {
- return json($responseObj);
- }
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["active", "=", 2];
- $where[] = ["step", "=", $process];
- $log = TalentLog::where($where)->order("createTime desc")->find();
- if ($log) {
- $oldInfo["checkState"] = $log["state"];
- $oldInfo["checkMsg"] = $log["description"];
- } else {
- $oldInfo["checkState"] = null;
- $oldInfo["checkMsg"] = "";
- }
- $res = [];
- $res["obj"] = $oldInfo;
- if ($responseObj->code == 200) {
- $where = [];
- $where[] = ["project", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $oldInfo["type"]];
- $fileTypeList = \app\common\model\FileType::where($where)->order("sn")->select()->toArray();
- $res["fileList"] = $fileTypeList;
- }
- $responseObj->obj = $res;
- return json($responseObj);
- }
- /**
- * 审核
- * @return type
- */
- public function check() {
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- $obj = $this->request->param();
- if (!$obj) {
- $responseObj->msg = "系统错误,请联系管理员";
- return json($responseObj);
- }
- if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $responseObj->msg = "当前账号类型没有操作权限";
- return json($responseObj);
- }
- if (!$obj["checkState"]) {
- $responseObj->msg = "请选择审核状态";
- return json($responseObj);
- }
- Db::startTrans();
- try {
- //保存驳回字段
- $updData["id"] = $obj["id"];
- $updData["fields"] = $obj["fields"];
- $updData["files"] = $obj["files"];
- Db::table("md_living_allowance_info")->save($updData);
- //加入日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 2;
- $newLog["state"] = $obj["checkState"];
- $newLog["step"] = $obj["process"];
- $newLog["stateChange"] = "保存未提交";
- $newLog["description"] = $obj["checkMsg"];
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- Db::table("new_talent_checklog")->insert($newLog);
- $responseObj->code = 200;
- $responseObj->msg = "审核成功";
- Db::commit();
- return json($responseObj);
- } catch (\Exception $e) {
- Db::rollback();
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- }
- /**
- * 审核不通过
- * @return type
- */
- public function setNotPass() {
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- $ids = trim($this->request->param("ids"));
- $msg = trim($this->request->param("msg"));
- $ids = array_filter(explode(",", $ids));
- if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $responseObj->msg = "当前账号类型没有操作权限";
- return json($responseObj);
- }
- if (!$ids) {
- $responseObj->msg = "请选择需要设置审核不通过的数据";
- return json($responseObj);
- }
- if (!$msg) {
- $responseObj->msg = "请填写审核不通过的原因";
- return json($responseObj);
- }
- $where = [];
- $where[] = ["id", "in", $ids];
- $list = LaModel::where($where)->select()->toArray();
- $updates = [];
- $newLogs = [];
- $sb = [];
- Db::startTrans();
- try {
- foreach ($list as $obj) {
- if ($obj["checkState"] != LaState::LA_SAVE && $obj["checkState"] != LaState::LA_FIRST_REJECT) {
- $sb[] = $obj["name"];
- }
- $oldState = $obj["checkState"];
- $newState = LaState::LA_NOTPASS;
- $update = [
- "id" => $obj["id"],
- "checkState" => $newState,
- "checkMsg" => $msg
- ];
- $updates[] = $update;
- Db::table("md_living_allowance_info")->save($update);
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 1;
- $newLog["state"] = $newState;
- $newLog["step"] = 70; //审核不通过
- $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($newState);
- $newLog["description"] = "原因:" . $msg;
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- $newLogs[] = $newLog;
- }
- if ($sb) {
- $responseObj->msg = implode(",", $sb) . "的审核状态既不是待提交,也不是初审驳回";
- return json($responseObj);
- }
- if (!$updates || !$newLogs) {
- $responseObj->msg = "没有待审核项";
- return json($responseObj);
- }
- Db::table("new_talent_checklog")->insertAll($newLogs);
- Db::commit();
- $responseObj->code = 200;
- $responseObj->msg = "设置审核不通过成功";
- return json($responseObj);
- } catch (\Exception $e) {
- Db::rollback();
- return json(["msg" => "设置审核不通过失败:" . $e->getMessage()]);
- }
- }
- public function submitCheck() {
- $id = $this->request->param("id");
- $process = $this->request->param("process");
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- if (!$id) {
- $responseObj->msg = "系统错误,请联系管理员!";
- return json($responseObj);
- }
- if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $responseObj->msg = "当前账号类型没有操作权限";
- return json($responseObj);
- }
- $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $oldState = $oldInfo["checkState"];
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["active", "=", 2];
- $where[] = ["step", "=", $process];
- $oldLog = TalentLog::where($where)->order("createTime desc")->find();
- if (!$oldLog) {
- $responseObj->msg = "请先审核后再提交";
- return json($responseObj);
- }
- $company = getCacheById("Company", $this->user["companyId"]);
- if ($process == 2 && $company["code"] != CommonConst::JYJ) {
- $responseObj->msg = "部门审核仅教育局能够审核!";
- return $responseObj;
- }
- $updData = [];
- $updData["id"] = $id;
- if (!$oldInfo["highProcess"]) {
- $updData["highProcess"] = $process;
- } else {
- $updData["highProcess"] = $oldInfo["highProcess"] < $process ? $process : $oldInfo["highProcess"];
- }
- switch ($process) {
- case 1:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["isPay"] = -1;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_FIRST_REJECT;
- //MessageRecord record = new MessageRecord(old.getId(), 2, 2, old.getName(), old.getPhone(), null, SmsProperties.MASTER_ALLOWANCE_REJECT);
- //Sms253Util.sendMessage(record);
- }
- //审核通过
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_NEED_DEP_CHECK;
- if (!$oldInfo["firstPassTime"]) {
- $updData["firstPassTime"] = date("Y-m-d H:i:s");
- }
- }
- //审核通过,跳过部门并审
- if ($oldLog["state"] == 4) {
- if ($oldInfo["highProcess"] != 3) {
- $responseObj->msg = "只有曾经通过部门并审才可以选择跳过部门并审";
- return json($responseObj);
- }
- $updData["checkState"] = LaState::LA_NEED_THIRD;
- $_updData = $this->calculateAmount($oldInfo);
- $updData = array_merge($updData, $_updData);
- }
- break;
- case 2:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- $updData["recommendIsPay"] = -1;
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_DEP_REJECT;
- $updData["creditStatus"] = 1;
- $updData["recommendAmount"] = null;
- $updData["recommendAmountDesc"] = "";
- $updData["recommendJudgmentDetails"] = "";
- $updData["recommendIsPay"] = 0;
- }
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_NEED_THIRD;
- if (!$oldInfo["firstDepPassTime"]) {
- $updData["firstDepPassTime"] = date("Y-m-d H:i:s");
- }
- $_updData = $this->calculateAmount($oldInfo);
- $updData = array_merge($updData, $_updData);
- }
- break;
- case 3:
- if ($oldLog["state"] == -1) {
- $updData["checkState"] = LaState::LA_NOTPASS;
- $updData["recommendAmount"] = 0;
- $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
- $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
- $updData["recommendIsPay"] = -1;
- }
- if ($oldLog["state"] == 2) {
- $updData["checkState"] = LaState::LA_THIRD_REJECT;
- $updData["creditStatus"] = 1;
- $updData["recommendAmount"] = null;
- $updData["recommendAmountDesc"] = "";
- $updData["recommendJudgmentDetails"] = "";
- $updData["recommendIsPay"] = 0;
- }
- if ($oldLog["state"] == 3) {
- $updData["checkState"] = LaState::LA_PASS;
- $updData["isPublic"] = 2;
- }
- break;
- }
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $id;
- $newLog["active"] = 1;
- $newLog["state"] = $oldLog["state"];
- $newLog["step"] = $process;
- $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($updData["checkState"]);
- $newLog["description"] = $oldLog["description"];
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- Db::startTrans();
- try {
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["active", "=", 2];
- Db::table("new_talent_checklog")->where($where)->delete();
- Db::table("new_talent_checklog")->insert($newLog);
- Db::table("md_living_allowance_info")->save($updData);
- Db::commit();
- if ($process == 1 && $oldLog["state"] == 2) {
- //驳回到用户发送短信通知
- $ep = EnterpriseApi::getOne($oldInfo["enterpriseId"]);
- $tpl_content = "【晋江市人才服务平台】您好!您提交申请的硕博人才生活补贴因信息填写错误或上传不完整已被退回,请及时联系人才联络员登录申报系统查看审核意见并重新提交。";
- $sms = new ChuanglanSmsApi();
- $result = $sms->sendSMS($ep["agentPhone"], $tpl_content, true);
- $result = json_decode($result, true);
- $record_data = [
- 'id' => getStringId(),
- 'userId' => $oldInfo["enterpriseId"],
- 'bizId' => $result["msgId"],
- 'type' => 2,
- 'smsType' => 2,
- 'phone' => $ep["agentPhone"],
- 'name' => $oldInfo["enterpriseName"],
- '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']
- ];
- Db::table("new_message_record")->insert($record_data);
- }
- $responseObj->code = 200;
- $responseObj->msg = "提交审核成功";
- return json($responseObj);
- } catch (\think\db\exception\DbException $e) {
- Db::rollback();
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- }
- /**
- * 查询需要处理的数据
- */
- public function selectNeedCheckData() {
- $response = new \stdClass();
- $response->code = 500;
- $user = $this->user;
- $type = $this->request->param("type");
- $id = $this->request->param("id");
- $name = \StrUtil::getRequestDecodeParam($this->request, "name");
- $sex = $this->request->param("sex");
- $checkState = $this->request->param("checkState");
- if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $response->msg = "当前账号类型没有操作权限";
- return json($response);
- }
- $where = [];
- if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
- $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
- } else {
- $where[] = ["type", "=", $user["type"]];
- }
- if ($name) {
- $where[] = ["name", "like", "%" . $name . "%"];
- }
- if ($sex) {
- $where[] = ["sex", "=", $sex];
- }
- if ($checkState) {
- $where[] = ["checkState", "=", $checkState];
- }
- switch ($type) {
- case 1:
- $where[] = ["isPublic", "=", 1];
- $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
- break;
- case 2:
- $where[] = ["isPublic", "=", 1];
- $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
- break;
- case 3: //公示
- case 7: //公示预览
- $where[] = ["isPublic", "=", 2];
- $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
- break;
- case 4:
- $where[] = ["isPublic", "=", 3];
- $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
- break;
- case 6:
- $where[] = ["isPublic", "=", 4];
- $where[] = ["checkState", "=", LaState::LA_PASS];
- break;
- }
- $list = Db::table("md_living_allowance_info")->field("id,idCard,name,enterpriseName,checkState")->where($where)->select()->toArray();
- $response->obj = ["rows" => $list, "total" => count($list)];
- $response->code = 200;
- return json($response);
- }
- /**
- * 通用导出
- * @return type
- */
- public function commonExport() {
- $response = new \stdClass();
- $response->code = 500;
- $request = $this->request;
- $user = $this->user;
- if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $response->msg = "当前账号类型没有操作权限";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- $process = $request["process"];
- $names = \StrUtil::getRequestDecodeParam($request, "names");
- $values = \StrUtil::getRequestDecodeParam($request, "values");
- $title = array_filter(explode(",", $names)); //exce标题
- $keys = array_filter(explode(",", $values)); //标题对应的字段
- $where = [];
- if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
- $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
- } else {
- $where[] = ["type", "=", $user["type"]];
- }
- if ($_where = LivingAllowanceApi::setLivingAllowanceCheckStateCondition($request->param())) {
- $where = array_merge($where, $_where);
- }
- if ($_where2 = LivingAllowanceApi::getWhereByParams($request->param())) {
- $where = array_merge($where, $_where2);
- }
- if (in_array("declareTypeName", $keys)) {
- $declareTypeMap = DictApi::selectByParentCode("un_master_education");
- }
- if (in_array("nationalityName", $keys)) {
- $nationalityMap = DictApi::selectByParentCode("nationality");
- }
- if (in_array("nationName", $keys)) {
- $nationaMap = DictApi::selectByParentCode("nation");
- }
- if (in_array("industryFieldNewName", $keys)) {
- $industryFieldNewMap = DictApi::selectByParentCode("industry_field");
- }
- if (in_array("industryFieldName", $keys)) {
- $industryFieldMap = DictApi::selectByParentCode("un_industryField");
- }
- if (in_array("streetName", $keys)) {
- $streetMap = DictApi::selectByParentCode("street");
- }
- if (in_array("politicsName", $keys)) {
- $politicsMap = DictApi::selectByParentCode("politics");
- }
- if (in_array("educationName", $keys)) {
- $highEducationMap = DictApi::selectByParentCode("highest_degree");
- }
- if (in_array("introductionModeName", $keys)) {
- $introductionModeMap = DictApi::selectByParentCode("un_introduction_mode");
- }
- $list = LaModel::where($where)->select()->toArray();
- $nationalityOldAndNew = [
- "01" => "cn",
- "02" => "cn_hk",
- "03" => "cn_mc",
- "04" => "cn_tw",
- "05" => "us",
- "06" => "en",
- "07" => "jp",
- "08" => "co",
- "09" => "nl",
- "10" => "sg",
- "11" => "other"
- ];
- foreach ($list as $key => $item) {
- if (in_array("declareTypeName", $keys)) {
- $list[$key]["declareTypeName"] = $declareTypeMap[$item["declareType"]];
- }
- if (in_array("nationalityName", $keys)) {
- $list[$key]["nationalityName"] = $nationalityMap[$item["nationality"]] ?: $nationalityMap[$nationalityOldAndNew[$item["nationality"]]];
- }
- if (in_array("nationName", $keys)) {
- $list[$key]["nationName"] = $nationaMap[$item["nation"]];
- }
- if (in_array("industryFieldNewName", $keys)) {
- $list[$key]["industryFieldNewName"] = $industryFieldNewMap[$item["industryFieldNew"]];
- }
- if (in_array("industryFieldName", $keys)) {
- if ($item["industryFieldNew"]) {
- $list[$key]["industryFieldName"] = DictApi::findByParentCodeAndCode($item["industryFieldNew"] . "_field", $item["industryField"])["name"];
- } else {
- $list[$key]["industryFieldName"] = $industryFieldMap[$item["industryField"]];
- }
- }
- if (in_array("streetName", $keys)) {
- $list[$key]["streetName"] = $streetMap[$item["address"]];
- }
- if (in_array("politicsName", $keys)) {
- $list[$key]["politicsName"] = $politicsMap[$item["politics"]];
- }
- if (in_array("educationName", $keys)) {
- $list[$key]["educationName"] = $highEducationMap[$item["highEducation"]];
- }
- if (in_array("introductionModeName", $keys)) {
- $list[$key]["introductionModeName"] = $introductionModeMap[$item["introductionMode"]];
- }
- if (in_array("introductionMethodName", $keys)) {
- $list[$key]["introductionMethodName"] = $item["introductionMethod"] == 1 ? "新引进" : "其他";
- }
- if (in_array("sexName", $keys)) {
- $list[$key]["sexName"] = $item["sex"] == 1 ? "男" : "女";
- }
- if (in_array("cardTypeName", $keys)) {
- switch ($item["cardType"]) {
- case 1:
- $list[$key]["cardTypeName"] = "身份证";
- break;
- case 2:
- $list[$key]["cardTypeName"] = "通行证";
- break;
- case 3:
- $list[$key]["cardTypeName"] = "护照";
- break;
- default:
- $list[$key]["cardTypeName"] = "未知";
- break;
- }
- }
- if (in_array("isPublicName", $keys)) {
- switch ($item["isPublic"]) {
- case 1:
- $list[$key]["isPublicName"] = "待核查征信";
- break;
- case 2:
- $list[$key]["isPublicName"] = "待公示";
- break;
- case 3:
- $list[$key]["isPublicName"] = "公示中";
- break;
- case 4:
- $list[$key]["isPublicName"] = "待兑现";
- break;
- case 5:
- $list[$key]["isPublicName"] = "已兑现";
- break;
- }
- }
- if (in_array("studyAbroadName", $keys)) {
- $list[$key]["studyAbroadName"] = $item["studyAbroad"] == 1 ? "是" : "否";
- }
- if (in_array("recommendIsPayName", $keys)) {
- if ($item["recommendIsPay"] == -1) {
- $list[$key]["recommendIsPayName"] = "不予兑现";
- }
- if ($item["recommendIsPay"] == 0) {
- $list[$key]["recommendIsPayName"] = "未知";
- }
- if ($item["recommendIsPay"] == 1) {
- $list[$key]["recommendIsPayName"] = "待兑现";
- }
- if ($item["recommendIsPay"] == 2) {
- $list[$key]["recommendIsPayName"] = "已兑现";
- }
- }
- if (in_array("isPayName", $keys)) {
- if ($item["isPay"] == -1) {
- $list[$key]["isPayName"] = "不予兑现";
- }
- if ($item["isPay"] == 0) {
- $list[$key]["isPayName"] = "未知";
- }
- if ($item["isPay"] == 1) {
- $list[$key]["isPayName"] = "待兑现";
- }
- if ($item["isPay"] == 2) {
- $list[$key]["isPayName"] = "已兑现";
- }
- }
- if (in_array("creditStatusName", $keys)) {
- if ($item["creditStatus"] == 1) {
- $list[$key]["creditStatusName"] = "待核查征信";
- }
- if ($item["creditStatus"] == 2) {
- $list[$key]["creditStatusName"] = "征信通过";
- }
- if ($item["creditStatus"] == 3) {
- $list[$key]["creditStatusName"] = "征信失信";
- }
- }
- if ($process && in_array("checkStateName", $keys)) {
- switch ($process) {
- case 1:
- if ($item["checkState"] == -1) {
- $list[$key]["checkStateName"] = "审核不通过";
- } else if ($item["checkState"] == 1) {
- $list[$key]["checkStateName"] = "待提交";
- } else if ($item["checkState"] == 10) {
- $list[$key]["checkStateName"] = "已驳回";
- } else if ($item["checkState"] == 15 || $item["checkState"] >= 25 || $item["checkState"] >= 35) {
- $list[$key]["checkStateName"] = "已通过";
- } else if ($item["checkState"] == 7) {
- $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "重新提交" : "待审核";
- } else if ($item["checkState"] == 20) {
- $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "上级驳回" : "待审核";
- }
- break;
- case 3:
- if ($item["checkState"] == -1) {
- $list[$key]["checkStateName"] = "审核不通过";
- } else if ($item["checkState"] == 25) {
- $list[$key]["checkStateName"] = $item["highProcess"] >= 3 ? "重新提交" : "待审核";
- } else if ($item["checkState"] == 30 || $item["checkState"] <= 20) {
- $list[$key]["checkStateName"] = "已驳回";
- } else if ($item["checkState"] == 35) {
- $list[$key]["checkStateName"] = "已通过";
- }
- break;
- case 4:
- if ($item["checkState"] == -1) {
- $list[$key]["checkStateName"] = "审核不通过";
- } else if ($item["checkState"] == 35) {
- $list[$key]["checkStateName"] = "已通过";
- }
- break;
- case 5:
- $list[$key]["checkStateName"] = "已通过";
- break;
- }
- }
- }
- $fileName = "硕博人才生活补贴申报导出";
- if ($process == 1) {
- $fileName = "硕博人才生活补贴初审导出";
- } else if ($process == 2) {
- $fileName = "硕博人才生活补贴部门审核导出";
- } else if ($process == 3) {
- $fileName = "硕博人才生活补贴复核导出";
- } else if ($process == 4) {
- $fileName = "硕博人才生活补贴兑现导出";
- }
- $rows = [];
- foreach ($list as $item) {
- $row = [];
- foreach ($keys as $k) {
- $row[] = $item[$k];
- }
- $rows[] = $row;
- }
- if (!$rows) {
- $response->msg = "没有可导出的内容";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- export($title, $rows, $fileName);
- }
- /**
- * 导出核查征信名单
- * @auth {{/talentInfo/exportHczx}}
- */
- public function exportHczx() {
- $response = new \stdClass();
- $response->code = 500;
- $user = $this->user;
- if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $response->msg = "当前账号类型没有操作权限";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- $where = [];
- $ids = array_filter(explode(",", $this->request->param("ids")));
- $where[] = ["id", "in", $ids];
- $list = LaModel::where($where)->select()->toArray();
- $nationalitys = DictApi::selectByParentCode("nationality"); //查询国籍字典表
- if (!$list) {
- $response->msg = "暂无可核查征信的数据";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- $title = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
- $exportList = [];
- for ($i = 0; $i < count($list); $i++) {
- $tmp = $list[$i];
- $exportList[] = [
- $i + 1, $tmp["name"], $nationalitys[$tmp["nationality"]], $tmp["idCard"], $tmp["enterpriseName"], $tmp["outMsg"], $tmp["actualSocialSecurity"], $tmp["actualTax"], $tmp["actualBusinessRegistration"]
- ];
- }
- $fileName = "硕博人才生活补贴核查征信名单导出";
- export($title, $exportList, $fileName);
- }
- /**
- * 公示预览
- */
- public function exportPublic() {
- $response = new \stdClass();
- $response->code = 500;
- $user = $this->user;
- $ids = array_filter(explode(",", $this->request->param("ids")));
- $batch = date("Ym");
- //查询需要公示的数据(勾选)
- $where = [];
- $where[] = ["id", "in", $ids];
- $list = LaModel::where($where)->order("enterpriseId")->select()->toArray();
- $rows = [];
- for ($i = 0; $i < count($list); $i++) {
- $obj = $list[$i];
- $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
- $obj["sn"] = $i + 1;
- if ($obj["checkState"] == LaState::LA_NOTPASS) {
- $where = [];
- $where[] = ["mainId", "=", $obj["id"]];
- $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["step", "=", 3];
- $where[] = ["state", "<>", 8];
- $log = TalentLog::where($where)->order("createTime desc")->find();
- if ($log && $log["state"] == -1) {
- $obj["description"] = $log["description"];
- }
- if ($obj["outMsg"]) {
- $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
- }
- $obj["stateName"] = "审核不通过";
- }
- if ($obj["checkState"] == LaState::LA_PASS) {
- $obj["stateName"] = "审核通过";
- }
- $rows[] = [
- $obj["sn"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
- ];
- }
- $title = ["序号", "姓名", "性别", "工作单位", "审核状态", "备注"];
- $fileName = "硕博人才生活补贴申报第" . $batch . "批次公示导出";
- $titleName = "";
- if ($user["type"] == 1) {
- $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
- }
- if ($user["type"] == 2) {
- $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
- }
- export($title, $rows, $fileName, [], $titleName);
- }
- /**
- * 公示导出
- */
- public function publicExport() {
- $response = new \stdClass();
- $response->code = 500;
- $user = $this->user;
- if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
- $response->msg = "当前账号类型没有操作权限";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- $startTime = $this->request["startTime"];
- $endTime = $this->request["endTime"];
- $where = [];
- $where[] = ["publicBatch", "between", [$startTime, $endTime]];
- if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
- $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
- } else {
- $where[] = ["type", "=", $user["type"]];
- }
- $list = LaModel::where($where)->order("publicBatch")->select()->toArray();
- if (!$list) {
- $response->msg = "所选时间段内无公示数据";
- return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
- }
- $rows = [];
- for ($i = 0; $i < count($list); $i++) {
- $obj = $list[$i];
- $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
- $obj["sn"] = $i + 1;
- if ($obj["checkState"] == LaState::LA_NOTPASS) {
- $where = [];
- $where[] = ["mainId", "=", $obj["id"]];
- $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["step", "=", 3];
- $where[] = ["state", "<>", 8];
- $log = TalentLog::where($where)->order("createTime desc")->find();
- if ($log && $log["state"] == -1) {
- $obj["description"] = $log["description"];
- }
- if ($obj["outMsg"]) {
- $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
- }
- $obj["stateName"] = "审核不通过";
- }
- if ($obj["checkState"] == LaState::LA_PASS) {
- $obj["stateName"] = "审核通过";
- }
- $rows[] = [
- $obj["sn"], $obj["publicBatch"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
- ];
- }
- $title = ["序号", "公示批次", "姓名", "性别", "工作单位", "审核状态", "备注"];
- $fileName = "硕博人才生活补贴公示导出";
- $titleName = "";
- if ($user["type"] == 1) {
- $titleName = $startTime . "至" . $endTime . "硕博人才生活补贴申报公示名单";
- }
- if ($user["type"] == 2) {
- $titleName = $startTime . "至" . $endTime . "硕博人才生活补贴申报公示名单";
- }
- export($title, $rows, $fileName, [], $titleName);
- }
- /**
- * 导入征信核查结果
- * @auth {{/talentInfo/importProject}}
- */
- public function importProject(\think\Request $request) {
- $response = new \stdClass();
- $response->code = 500;
- if (!$request->file()) {
- $response->msg = "没有导入文件";
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- $file = $request->file("file");
- if (!isExcelFile($file->getMime())) {
- $response->msg = "不是正确的Excel文件";
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- $path = $file->getRealPath();
- $rows = getExcelDatas($path);
- $titleRow = array_shift($rows); //去标题
- $titles = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
- Db::startTrans();
- try {
- for ($i = 0; $i < count($titles); $i++) {
- if ($titles[$i] != $titleRow[$i]) {
- $response->msg = "模板错误";
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- }
- $total = count($rows);
- if ($total == 0) {
- $response->msg = "没有数据";
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- //------------行数据校验------------------------------------------------------//
- $idCards = [];
- $sbf = [];
- for ($i = 0; $i < $total; $i++) {
- $row = $rows[$i];
- $name = trim($row[1]);
- $idCard = trim($row[3]);
- $creditStatus = trim($row[5]);
- $socialSecurity = trim($row[6]);
- $personalTax = trim($row[7]);
- $businessRegistration = trim($row[8]);
- if (\StrUtil::isEmpOrNull($name)) {
- $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
- }
- if (\StrUtil::isEmpOrNull($idCard)) {
- $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
- }
- if (\StrUtil::isEmpOrNull($creditStatus) || !in_array($creditStatus, ["无", "在逃人员", "失信被执行人", "意识形态存在问题"])) {
- $sbf[] = sprintf("第 %d 行征信格式错误,请根据核查情况填写[ 无 | 在逃人员 | 失信被执行人 | 意识形态存在问题 ]", $i + 1);
- }
- //如2022-01,2022-02,2022-03,2022-04
- $datesRegexp = "/^[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1}(?:,[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1})*$/";
- if ($socialSecurity && !preg_match($datesRegexp, $socialSecurity)) {
- $sbf[] = sprintf("第 %d 行社保核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
- }
- if ($personalTax && !preg_match($datesRegexp, $personalTax)) {
- $sbf[] = sprintf("第 %d 行个税核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
- }
- if ($businessRegistration && !preg_match($datesRegexp, $businessRegistration)) {
- $sbf[] = sprintf("第 %d 行工商注册情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
- }
- $idCards[] = $idCard;
- }
- if ($sbf) {//如果校验 通不过
- $resultStr = implode("<br>", $sbf);
- if (mb_strlen($resultStr) > 200) {
- $resultStr = mb_substr($resultStr, 0, 200) . "...";
- }
- $response->msg = $resultStr;
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- $where = [];
- $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
- $where[] = ["isPublic", "=", 1];
- $where[] = ["idCard", "in", $idCards];
- $list = Db::table("md_living_allowance_info")->where($where)->column("*", "idCard");
- for ($i = 0; $i < $total; $i++) {
- $row = $rows[$i];
- $idCard = trim($row[3]);
- $outMsg = trim($row[5]);
- $sbDetail = trim($row[6]);
- $taxDetail = trim($row[7]);
- $gsRegistDetail = trim($row[8]);
- $info = $list[$idCard];
- if ($info) {
- $info["outMsg"] = $outMsg;
- $info["actualSocialSecurity"] = $sbDetail;
- $info["actualTax"] = $taxDetail;
- $info["actualBusinessRegistration"] = $gsRegistDetail;
- $info = $this->vailIsCash($info);
- $info["creditStatus"] = $outMsg != "无" ? 3 : 2;
- Db::table("md_living_allowance_info")->save($info);
- }
- }
- $response->code = 200;
- $response->msg = "导入成功";
- Db::commit();
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- } catch (\Exception $e) {
- Db::rollback();
- $response->msg = "导入失败,系统错误:" . $e->getMessage();
- return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
- }
- }
- /**
- * 公示
- */
- public function publicBatch() {
- $response = new \stdClass();
- $response->code = 200;
- //查询需要公示的数据(勾选)
- $request = $this->request;
- $typeName = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "typeName")));
- $address = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "address")));
- $publicStartTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicStartTime")));
- $publicEndTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicEndTime")));
- $dep = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "dep")));
- $phone = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "phone")));
- $email = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "email")));
- $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
- $typeName, $address, $publicStartTime, $publicEndTime, $dep, $phone, $sms); //短信内容
- $batch = \StrUtil::getRequestDecodeParam($request, "batch");
- $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
- $where = [];
- $where[] = ["id", "in", $ids];
- $list = LaModel::where($where)->select()->toArray();
- if ($isMessage == 1 && count($list) > 1000) {
- $response->msg = "需要发送短信时公示量不能超过1000个";
- return json($response);
- }
- $newLogs = [];
- $recordList = [];
- $phones = [];
- Db::startTrans();
- try {
- for ($i = 0; $i < count($list); $i++) {
- $obj = $list[$i];
- $obj["publicBatch"] = $batch;
- $obj["isPublic"] = 3;
- Db::table("md_living_allowance_info")->save($obj);
- //添加日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 1;
- $newLog["state"] = 3;
- $newLog["step"] = 5;
- $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- $newLogs[] = $newLog;
- $phones[] = $obj["phone"];
- $record = [
- 'id' => getStringId(),
- 'bizId' => getStringId(),
- 'userId' => $obj["enterpriseId"],
- 'type' => 2,
- 'smsType' => 2,
- 'phone' => $obj["phone"],
- 'name' => $obj["enterpriseName"],
- 'params' => '公示',
- 'templateCode' => $tpl_content,
- 'state' => 3,
- 'sendingDate' => date("Y-m-d H:i:s", time()),
- 'createTime' => date("Y-m-d H:i:s", time())
- ];
- $recordList[] = $record;
- }
- Db::table("new_message_record")->insertAll($recordList);
- Db::table("new_talent_checklog")->insertAll($newLogs);
- Db::commit();
- if ($isMessage == 1 && $phones) {
- //批量发送短信
- $sms = new ChuanglanSmsApi();
- $result = $sms->sendSMS($phones, $tpl_content, true);
- $result = json_decode($result, true);
- }
- $response->msg = "公示成功";
- $response->code = 200;
- return json($response);
- } catch (\Exception $e) {
- Db::rollback();
- $response->msg = $e->getMessage();
- return json($response);
- }
- }
- /**
- * 公示再审核
- * @return type
- */
- public function afterCheck() {
- $response = new \stdClass();
- $response->code = 500;
- $id = $this->request->param("id");
- $checkState = $this->request->param("checkState");
- $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
- if (!$id) {
- $response->msg = "系统错误,请联系管理员";
- return json($response);
- }
- $old = LivingAllowanceApi::getInfoById($id);
- if ($old["isPublic"] != 3) {
- $response->msg = "当前记录不是公示中状态,无法审核";
- return json($response);
- }
- $desc = "";
- $data = [];
- $data["id"] = $id;
- if ($checkState == 2) {
- $data["checkState"] = LaState::LA_DEP_REJECT;
- $data["isPublic"] = 1;
- $data["outMsg"] = "";
- $data["creditStatus"] = 1;
- $data["recommendAmount"] = null;
- $data["recommendIsPay"] = 0;
- $data["recommendAmountDesc"] = "";
- $data["recommendJudgmentDetails"] = "";
- $desc = "(公示再审核驳回)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
- ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待核查征信</span>";
- } else if ($checkState == LaState::LA_NOTPASS) {
- $data["isPublic"] = 4;
- $data["recommendIsPay"] = -1;
- $data["recommendAmount"] = 0;
- $data["recommendAmountDesc"] = $old["recommendAmountDesc"] . ";公示再审核不通过,不予兑现;";
- $data["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . ";公示再审核不通过,不予兑现;";
- $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
- ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
- } else {
- $data["isPublic"] = 4;
- $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
- ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
- }
- $data["amount"] = $data["recommendAmount"];
- $data["isPay"] = $data["recommendIsPay"];
- $data["amountDesc"] = $data["recommendAmountDesc"];
- $data["judgmentDetails"] = $data["recommendJudgmentDetails"];
- //添加日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $id;
- $newLog["active"] = 1;
- $newLog["state"] = $checkState;
- $newLog["step"] = 6;
- $newLog["stateChange"] = $desc;
- $newLog["description"] = $checkMsg;
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- Db::startTrans();
- try {
- Db::table("new_talent_checklog")->insert($newLog);
- Db::table("md_living_allowance_info")->save($data);
- Db::commit();
- $response->code = 200;
- $response->msg = "审核成功";
- return json($response);
- } catch (\Exception $e) {
- Db::rollback();
- $response->msg = $e->getMessage();
- return json($response);
- }
- }
- /**
- * 公示通过
- */
- public function publicPass() {
- $response = new \stdClass();
- $response->code = 500;
- $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
- $where = [];
- $where[] = ["id", "in", $ids];
- $upList = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
- //添加日志
- $newLogs = [];
- Db::startTrans();
- try {
- for ($i = 0; $i < count($upList); $i++) {
- $obj = $upList[$i];
- if ($obj["isPublic"] != 3) {
- $response->msg = sprintf("第%d条记录不是公示中状态,不能公示通过", $i + 1);
- return json($response);
- }
- $obj["isPublic"] = 4;
- $obj["amount"] = $obj["recommendAmount"];
- $obj["isPay"] = $obj["recommendIsPay"];
- $obj["amountDesc"] = $obj["recommendAmountDesc"];
- $obj["judgmentDetails"] = $obj["recommendJudgmentDetails"];
- Db::table("md_living_allowance_info")->save($obj);
- //添加日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 1;
- $newLog["state"] = 3;
- $newLog["step"] = 6;
- $newLog["stateChange"] = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
- $newLog["description"] = "";
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- $newLogs[] = $newLog;
- }
- Db::table("new_talent_checklog")->insertAll($newLogs);
- Db::commit();
- $response->msg = "批量公示通过成功";
- $response->code = 200;
- return json($response);
- } catch (\Exception $e) {
- Db::rollback();
- $response->msg = $e->getMessage();
- return json($response);
- }
- }
- /**
- * 兑现
- */
- public function issue() {
- $response = new \stdClass();
- $response->code = 500;
- $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
- $where = [];
- $where[] = ["id", "in", $ids];
- $list = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
- $newLogs = [];
- Db::startTrans();
- try {
- for ($i = 0; $i < count($list); $i++) {
- $obj = $list[$i];
- if ($obj["isPublic"] != 4) {
- $response->msg = sprintf("第%d条记录不是公示通过状态,不能兑现", $i + 1);
- return json($response);
- }
- $obj["isPublic"] = 5;
- $obj["isPay"] = 2;
- Db::table("md_living_allowance_info")->save($obj);
- //添加日志
- $newLog["id"] = getStringId();
- $newLog["type"] = ProjectState::LIVINGALLOWANCE;
- $newLog["mainId"] = $obj["id"];
- $newLog["active"] = 1;
- $newLog["state"] = 3;
- $newLog["step"] = 8;
- $newLog["stateChange"] = "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>";
- $newLog["description"] = "";
- $newLog["createTime"] = date("Y-m-d H:i:s");
- $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
- $newLogs[] = $newLog;
- }
- Db::table("new_talent_checklog")->insertAll($newLogs);
- Db::commit();
- $response->code = 200;
- $response->msg = "兑现成功";
- return json($response);
- } catch (\Exception $e) {
- Db::rollback();
- $response->msg = $e->getMessage();
- return json($response);
- }
- }
- public function findFieldsAndFiles() {
- $id = $this->request["id"];
- $info = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $responseObj = new \stdClass();
- if ($info["checkState"] == LaState::LA_FIRST_REJECT) {
- $where = [];
- $where[] = ["project", "=", ProjectState::LIVINGALLOWANCE];
- $where[] = ["active", "=", 1];
- $where[] = ["type", "=", $info["type"]];
- $files = \app\common\model\FileType::where($where)->order("sn")->select()->toArray();
- $responseObj->code = 200;
- $responseObj->id = $id;
- $responseObj->fileList = $files;
- $responseObj->select = [
- "files" => array_filter(explode(",", $info["files"])),
- "fields" => array_filter(explode(",", $info["fields"]))
- ];
- } else {
- $responseObj->msg = "不是初审驳回状态不可以编辑驳回内容";
- }
- return json($responseObj);
- }
- /**
- * 初审-修改驳回字段
- */
- public function updateFieldsAndFiles() {
- $id = $this->request["id"];
- $fields = array_filter(explode(",", $this->request["fields"]));
- $files = array_filter(explode(",", $this->request["files"]));
- $info = \app\common\api\LivingAllowanceApi::getInfoById($id);
- $responseObj = new \stdClass();
- if ($info["checkState"] == LaState::LA_FIRST_REJECT) {
- if (!$fields && !$files) {
- $responseObj->msg = "请选择可修改的字段或附件!";
- return json($responseObj);
- }
- try {
- //保存驳回字段
- $updData["id"] = $id;
- $updData["fields"] = $fields ? implode(",", $fields) : null;
- $updData["files"] = $files ? implode(",", $files) : null;
- Db::table("md_living_allowance_info")->save($updData);
- $responseObj->code = 200;
- $responseObj->msg = "驳回字段修改成功";
- return json($responseObj);
- } catch (\think\db\exception\DbException $e) {
- $responseObj->msg = $e->getMessage();
- return json($responseObj);
- }
- } else {
- $responseObj->msg = "不是初审驳回状态不可以编辑驳回内容";
- return json($responseObj);
- }
- }
- /**
- * 计算兑现额度
- * @param type $oldInfo
- * @return string
- */
- private function calculateAmount($oldInfo) {
- $return = [];
- /* * 硕士研究生补贴 */
- if ($oldInfo["declareType"] == 1) {
- //硕士 master_living_allowance_ss_money
- $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
- } else {
- //博士 master_living_allowance_bs_money
- $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
- }
- $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
- $return["recommendAmount"] = $moneyStanard;
- $where = [];
- $where[] = ["cardType", "=", $oldInfo["cardType"]];
- $where[] = ["idCard", "=", $oldInfo["idCard"]];
- $where[] = ["year", "like", substr($oldInfo["year"], 0, 4) . "%"];
- $where[] = ["checkState", "=", 30];
- $where[] = ["publicState", ">=", 4];
- $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
- if ($talentAllowanceInfo) {
- $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
- if (round($balanceMoney, 2) == round(0, 2)) {
- $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
- $return["recommendAmount"] = 0;
- $return["recommendIsPay"] = -1;
- } else {
- $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
- $return["recommendAmount"] = $balanceMoney;
- }
- } else {
- $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
- }
- return $return;
- }
- /**
- * 判断申报人是否满足兑现条件
- */
- private function vailIsCash($old) {
- /* * 对申报人的信息进行校验是否满足补贴条件:
- * 第一年:合同需要在3年以上、缴纳社保3个月及以上
- * 第二、三年:社保和个税均在9个月以上
- * */
- if ($old["outMsg"] != "无") {
- $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
- if ($old["introductionMethod"] == 2) {
- $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
- $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
- $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
- if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
- }
- if ($old["applyCount"] == 1) {
- $endTime = strtotime($old["endTime"]);
- $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
- if ($endTime < $after3YearsTime) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- /* 旧政策
- * if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- } */
- //首年:新政策社保和个税其中一个满足3个月以上予以兑现
- $isActualSocialSecurityBigger3Month = $this->countByDates($old["actualSocialSecurity"]) < 3 ? false : true;
- $isActualTaxBigger3Month = $this->countByDates($old["actualTax"]) < 3 ? false : true;
- if (!$isActualSocialSecurityBigger3Month && !$isActualTaxBigger3Month) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保和个税缴纳时间均不足3个月,不予兑现;";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- $old["recommendIsPay"] = 1;
- //$old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
- if ($isActualSocialSecurityBigger3Month && $isActualTaxBigger3Month) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保及个税缴纳时间均满足3个月及以上,予以兑现;\n";
- } else if ($isActualTaxBigger3Month) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,个税缴纳时间满足3个月及以上,予以兑现;\n";
- } else {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
- }
- $_old = $this->calculateAmount($old);
- $old = array_merge($old, $_old);
- } else {
- /* 旧政策
- * if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
- $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- $old["recommendIsPay"] = 1;
- $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
- *
- */
- //非首年:新政策社保和个税其中一个满足6个月以上予以兑现
- $year = substr($old["year"], 0, 4);
- $isActualSocialSecurityBigger6Month = $this->countByDatesWithYear($old["actualSocialSecurity"], $year) < 6 ? false : true;
- $isActualTaxBigger6Month = $this->countByDatesWithYear($old["actualTax"], $year) < 6 ? false : true;
- if (!$isActualSocialSecurityBigger6Month && !$isActualTaxBigger6Month) {
- $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:社保和个税当年度缴纳时间均不足6个月,不予兑现";
- $old["recommendIsPay"] = -1;
- $old["recommendAmount"] = 0;
- return $old;
- }
- $old["recommendIsPay"] = 1;
- if ($isActualSocialSecurityBigger6Month && $isActualTaxBigger6Month) {
- $old["recommendJudgmentDetails"] = "非首年申报:个税当年度缴纳时间满足6个月及以上,个税当年度缴纳时间满足6个月及以上,予以兑现;\n";
- } else if ($isActualSocialSecurityBigger6Month) {
- $old["recommendJudgmentDetails"] = "非首年申报:社保当年度缴纳时间满足6个月及以上,予以兑现;\n";
- } else {
- $old["recommendJudgmentDetails"] = "非首年申报:个税当年度缴纳时间满足6个月及以上,予以兑现;\n";
- }
- $_old = $this->calculateAmount($old);
- $old = array_merge($old, $_old);
- }
- return $old;
- }
- /**
- * 计算月份数
- * @param type $dates
- * @return type
- */
- private function countByDates($dates) {
- $dates = $dates ?: "";
- $dateArr = array_filter(explode(",", $dates));
- $count = 0;
- for ($i = 0; $i < count($dateArr); $i++) {
- $date = $dateArr[$i];
- if ($date) {
- if (strpos($date, "-") !== false) {
- $cDateArr = explode("-", $date);
- $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
- $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
- $currentDate = $_date1;
- while ($currentDate <= $_date2) {
- $count++;
- $currentDate = date("Y-m-d", strtotime("+1 month", strtotime($currentDate)));
- }
- } else {
- $count++;
- }
- }
- }
- return $count;
- }
- /**
- * 计算月份数
- * @param type $dates
- * @return type
- */
- private function countByDatesWithYear($dates, $year) {
- $dates = $dates ?: "";
- $dateArr = array_filter(explode(",", $dates));
- $count = 0;
- for ($i = 0; $i < count($dateArr); $i++) {
- $date = $dateArr[$i];
- if ($date) {
- if (strpos($date, "-") !== false) {
- $cDateArr = explode("-", $date);
- $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
- $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
- $currentDate = $_date1;
- while ($currentDate <= $_date2) {
- $currentYear = date("Y", strtotime($currentDate));
- if ($currentYear == $year) {
- $count++;
- }
- $currentDate = date("Y-m-d", strtotime("+1 month", strtotime($currentDate)));
- }
- } else {
- // 处理单个日期
- $_date = date("Y-m-01", strtotime($date . "01"));
- if (date("Y", strtotime($_date)) == $year) {
- $count++;
- }
- }
- }
- }
- return $count;
- }
- }
|