| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010 | 
							- <?php
 
- namespace app\enterprise\controller;
 
- use app\common\api\EducationApi;
 
- use app\enterprise\common\EnterpriseController;
 
- use app\enterprise\api\TalentApi;
 
- use app\enterprise\model\Talent as TalentModel;
 
- use think\facade\Db;
 
- use think\facade\Log;
 
- use app\common\api\EnterpriseApi;
 
- use app\common\api\DictApi;
 
- use app\common\api\TalentLogApi;
 
- use app\common\api\TalentState;
 
- use think\exception\ValidateException;
 
- use app\enterprise\validate\TalentInfo;
 
- use app\common\state\ProjectState;
 
- use app\common\api\BatchApi;
 
- use app\common\state\CommonConst;
 
- use app\common\api\TalentConditionApi;
 
- // 0正在填写 1保存未提交 2已提交未审核 3已审核 4驳回 5保存补充材料未提交 6提交补充材料进入初审 7初审通过 8初审驳回 9部门审核通过 10部门审核驳回 11复核通过 12复核驳回 13复核失败
 
- /**
 
-  * Description of Talent
 
-  *
 
-  * @author sgq
 
-  */
 
- class Talent extends EnterpriseController {
 
-     public function index() {
 
-         $isMix = $this->request->param("isMix");
 
-         $tpl = "";
 
-         if ($isMix == 1) {
 
-             $tpl = "newIndex";
 
-         }
 
-         switch ($this->user["type"]) {
 
-             case CommonConst::ENTERPRISE_WJ:
 
-                 $tpl = "/talent/hospital/index";
 
-                 break;
 
-         }
 
-         return view($tpl, ['type' => $this->user["type"]]);
 
-     }
 
-     public function list() {
 
-         $step = 2;
 
-         $res = TalentApi::getList($this->request, $step);
 
-         return json($res);
 
-     }
 
-     public function zrIndex() {
 
-         return view();
 
-     }
 
-     /**
 
-      * 新人才申报企业端统一申报入口,混合基础信息及人才信息
 
-      */
 
-     public function apply(\think\Request $request) {
 
-         $type = $this->user["type"];
 
-         $tpl = "";
 
-         switch ($type) {
 
-             case CommonConst::ENTERPRISE_NORMAL:
 
-                 $tpl = "apply"; //晋江人才
 
-                 break;
 
-             case CommonConst::ENTERPRISE_JC:
 
-                 $tpl = "ic_apply"; //集成电路
 
-                 break;
 
-             case CommonConst::ENTERPRISE_WJ:
 
-                 $tpl = "/talent/hospital/apply"; //卫健医院
 
-                 break;
 
-             case CommonConst::ENTERPRISE_GJ:
 
-                 $tpl = "/talent/school/apply"; //高教学校
 
-                 break;
 
-         }
 
-         $param = $request->param();
 
-         $id = isset($param["id"]) ? $param["id"] : 0;
 
-         $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         if ($info["isImport"]) {
 
-             //$tpl = "no_file_apply"; //晋江人才
 
-         }
 
-         $ep = EnterpriseApi::getOne($this->user["uid"]);
 
-         if (!chkEnterpriseFull($ep))
 
-             return;
 
-         $tagList = DictApi::selectByParentCode('enterprise_tag');
 
-         $streetList = DictApi::selectByParentCode('street');
 
-         $industryFieldNew = DictApi::selectByParentCode('industry_field');
 
-         $ep->enterpristTagName = $tagList[$ep->enterpriseTag];
 
-         $ep->streetName = $streetList[$ep->street];
 
-         $ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
 
-             return $this->view($request);
 
-             exit();
 
-         }
 
-         if ($request->isPost()) {
 
-             $checkState = $info["checkState"] ?: 0;
 
-             if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE || $checkState == 0) {
 
-                 switch ($type) {
 
-                     case CommonConst::ENTERPRISE_NORMAL:
 
-                         $this->mixSave($info, $request, TalentState::SCND_SAVE);
 
-                         exit();
 
-                         break;
 
-                     case CommonConst::ENTERPRISE_JC:
 
-                         $this->icSave($info, $request, TalentState::SCND_SAVE);
 
-                         exit();
 
-                         break;
 
-                     case CommonConst::ENTERPRISE_WJ:
 
-                         if ($ep->isGeneral == 1 || ($ep->isGeneral == 2 && !\app\common\api\Nhc::hasGeneralHospital($ep->medicalCommunityId))) {
 
-                             $this->wjSave($info, $request, TalentState::SCND_SAVE);
 
-                         } else {
 
-                             $this->wjSave($info, $request, TalentState::FST_SAVE);
 
-                         }
 
-                         exit();
 
-                         break;
 
-                     case CommonConst::ENTERPRISE_GJ:
 
-                         $this->gjSave($info, $request, TalentState::SCND_SAVE);
 
-                         exit();
 
-                         break;
 
-                 }
 
-             } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
 
-                 $res = ["msg" => "审核不通过,不能再保存"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $res = ["msg" => "已提交审核,请耐心等待"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         $checkState = $info["checkState"] ?: 0;
 
-         $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $this->user["type"])["batch"];
 
-         $info["enterprise"] = $ep;
 
-         if ($type == CommonConst::ENTERPRISE_WJ) {
 
-             $info["talent_type_list"] = DictApi::findChildDictByCode("wj_talent_type");
 
-         } else {
 
-             $info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
 
-         }
 
-         if ($info["talent_condition"]) {
 
-             $info["isSalary"] = TalentConditionApi::getOne($info["talent_condition"])["isSalary"] ?: 0;
 
-         }
 
-         $modify_fields = explode(",", $info["modify_fields"]);
 
-         if ($info["talent_condition"] && $info["real_state"] == TalentState::FST_VERIFY_REJECT && in_array("talent_condition", $modify_fields)) {
 
-             //高教或者以后有相同类型的附件分栏且带有认定附件,需要特殊加入认定附件进入
 
-             $condition = TalentConditionApi::getOne($info["talent_condition"]);
 
-             if ($condition && $condition["bindFileTypes"]) {
 
-                 $modify_files = array_filter(explode(",", $info["modify_files"]));
 
-                 $bindFileTypes = explode(",", $condition["bindFileTypes"]);
 
-                 $modify_files = array_merge($modify_files, $bindFileTypes);
 
-                 $info["modify_files"] = implode(",", $modify_files);
 
-             }
 
-         }
 
-         return view($tpl, ["year" => $batch, "checkState" => $checkState, "row" => $info]);
 
-     }
 
-     /**
 
-      * 旧第二步
 
-      * @param \think\Request $request
 
-      * @return type
 
-      */
 
-     public function second(\think\Request $request) {
 
-         if ($this->user["type"] != 1)
 
-             return "此入口仅供晋江市人才申报,晋江集成电路人才请使用新统一申报入口";
 
-         $params = $request->param();
 
-         $id = $params["id"];
 
-         $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         if ($request->isPost()) {
 
-             if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
 
-                 $res = ["msg" => "没有对应的人才认定申报信息"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $checkState = $info["checkState"];
 
-             if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
 
-                 $this->save($info, $request, TalentState::SCND_SAVE);
 
-                 exit();
 
-             } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
 
-                 $res = ["msg" => "审核不通过,不能再保存"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $res = ["msg" => "已提交审核,请耐心等待"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         $enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
 
-         $info["enterprise"] = $enterprise_info;
 
-         $batch = $info["apply_year"] ?: BatchApi::getValidBatch(ProjectState::TALENT, $enterprise_info["type"])["batch"];
 
-         return view("second", ["year" => $batch, "row" => $info]);
 
-     }
 
-     public function view(\think\Request $request) {
 
-         switch ($this->user["type"]) {
 
-             case CommonConst::ENTERPRISE_NORMAL:
 
-                 $tpl = "view"; //晋江人才
 
-                 break;
 
-             case CommonConst::ENTERPRISE_JC:
 
-                 $tpl = "ic_view"; //集成电路
 
-                 break;
 
-             case CommonConst::ENTERPRISE_WJ:
 
-                 $tpl = "/talent/hospital/view"; //卫健医院
 
-                 break;
 
-             case CommonConst::ENTERPRISE_GJ:
 
-                 $tpl = "/talent/school/view"; //高教学校
 
-                 break;
 
-         }
 
-         $id = $request->param("id");
 
-         $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         if ($info["isImport"]) {
 
-             //$tpl = "no_file_view";
 
-         }
 
-         return view($tpl, ["row" => $info]);
 
-     }
 
-     /**
 
-      * 提交表单(旧第二步)
 
-      */
 
-     public function submit() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
 
-             $res = ["msg" => "没有对应的人才认定申报信息"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
 
-             $field_dict = \app\common\api\DictApi::getTalentFields(2);
 
-             $no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
 
-                 "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
 
-             $where = [];
 
-             $where[] = ["rel", "=", "study_abroad"];
 
-             $where[] = ["step", "=", 2];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
 
-             $abroad_file_ids = null;
 
-             if ($abroad_files)
 
-                 $abroad_file_ids = array_column($abroad_files, "id");
 
-             if ($params["study_abroad"] == 1) {
 
-                 $no_empty[] = "abroad_school";
 
-                 $no_empty[] = "abroad_major";
 
-             }
 
-             if (in_array($params["source"], [1, 3])) {
 
-                 $no_empty[] = "source_batch";
 
-                 $no_empty[] = "fujian_highcert_pubtime";
 
-                 $no_empty[] = "fujian_highcert_exptime";
 
-                 if ($params["source"] == 3) {
 
-                     $no_empty[] = "source_city";
 
-                 }
 
-             }
 
-             if (in_array($params["source"], [2, 4])) {
 
-                 $no_empty[] = "source_batch";
 
-                 $no_empty[] = "quanzhou_highcert_pubtime";
 
-                 $no_empty[] = "quanzhou_highcert_exptime";
 
-                 if ($params["source"] == 4) {
 
-                     $no_empty[] = "source_county";
 
-                 }
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
 
-             if ($condition_info["isSalary"] == 1) {
 
-                 $no_empty[] = "annual_salary";
 
-             }
 
-             $no_empty = array_filter($no_empty);
 
-             $return = [];
 
-             foreach ($no_empty as $key) {
 
-                 if (!$params[$key]) {
 
-                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
 
-                 }
 
-             }
 
-             if (count($return) > 0) {
 
-                 $res = ["msg" => implode("<br>", $return)];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5])) {
 
-                 $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
 
-                 $whr[] = ["must", "=", 1];
 
-             }
 
-             $where = [];
 
-             $where[] = ["step", "=", 2];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             if ($whr) {
 
-                 $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
 
-             } else {
 
-                 $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             }
 
-             $ft_ids = array_column($filetypes, "id");
 
-             if ($params["study_abroad"] == 1) {
 
-                 //选中留学,如果存在留学附件变成必传
 
-                 $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
 
-             } else {
 
-                 //没选中,留学附件就算设成必传也不用验证
 
-                 $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
 
-             }
 
-             $whr = [];
 
-             $whr[] = ["typeId", "in", $ft_ids];
 
-             $whr[] = ["mainId", "=", $id];
 
-             $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
 
-             $upload_type_counts = count($distinct_filetypes);
 
-             if ($upload_type_counts != count($ft_ids)) {
 
-                 $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $this->save($info, $this->request, TalentState::SCND_SUBMIT);
 
-         } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
 
-             $res = ["msg" => "审核不通过,不能再提交审核"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         $res = ["msg" => "已提交审核,请耐心等待"];
 
-         echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-         exit;
 
-     }
 
-     public function submitToCheck() {
 
-         switch ($this->user["type"]) {
 
-             case CommonConst::ENTERPRISE_NORMAL:
 
-                 return $this->submitToCheck_JJRC();
 
-             case CommonConst::ENTERPRISE_JC:
 
-                 return $this->submitToCheck_IC();
 
-             case CommonConst::ENTERPRISE_WJ:
 
-                 return $this->submitToCheck_WJ();
 
-             case CommonConst::ENTERPRISE_GJ:
 
-                 return $this->submitToCheck_GJ();
 
-         }
 
-     }
 
-     /**
 
-      * 提交表单(新:混合基础信息人才申报信息)晋江人才
 
-      */
 
-     private function submitToCheck_JJRC() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if ($checkState == TalentState::SCND_SAVE || !$id) {
 
-             $field_dict = \app\common\api\DictApi::getTalentFields(4, $info["isImport"]);
 
-             $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type", "experience", "education",
 
-                 "talent_arrange", "talent_condition", "identifyGetTime", "bank", "bank_number", "bank_branch_name",
 
-                 "bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"]; //"highest_degree", "graduate_school", "major",
 
-             $where = [];
 
-             $where[] = ["rel", "=", "study_abroad"];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             $abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
 
-             $abroad_file_ids = null;
 
-             if ($abroad_files)
 
-                 $abroad_file_ids = array_column($abroad_files, "id");
 
-             if (in_array($params["talent_type"], [1, 2])) {
 
-                 $no_empty[] = "tax_insurance_month";
 
-                 $no_empty[] = "labor_contract_rangetime";
 
-             }
 
-             if ($params["talent_type"] == 3) {
 
-                 $no_empty[] = "pre_import_type";
 
-             }
 
-             if ($params["study_abroad"] == 1) {
 
-                 $no_empty[] = "abroad_school";
 
-                 $no_empty[] = "abroad_major";
 
-             }
 
-             if (in_array($params["source"], [1, 3])) {
 
-                 //$no_empty[] = "source_batch";
 
-                 //$no_empty[] = "fujian_highcert_pubtime";
 
-                 //$no_empty[] = "fujian_highcert_exptime";
 
-                 if ($params["source"] == 3) {
 
-                     $no_empty[] = "source_city";
 
-                 }
 
-             }
 
-             if (in_array($params["source"], [2, 4])) {
 
-                 //$no_empty[] = "source_batch";
 
-                 //$no_empty[] = "quanzhou_highcert_pubtime";
 
-                 //$no_empty[] = "quanzhou_highcert_exptime";
 
-                 if ($params["source"] == 4) {
 
-                     $no_empty[] = "source_county";
 
-                 }
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
 
-             if ($condition_info["isSalary"] == 1) {
 
-                 $no_empty[] = "annual_salary";
 
-             }
 
-             $no_empty = array_filter($no_empty);
 
-             $return = [];
 
-             foreach ($no_empty as $key) {
 
-                 if (!$params[$key]) {
 
-                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
 
-                 }
 
-             }
 
-             if (count($return) > 0) {
 
-                 $res = ["msg" => implode("<br>", $return)];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $isMatchZhiren = $info["isImport"] && $params["isMatchZhiren"] == 1 ? true : false;
 
-             if ($condition_info["bindFileTypes"] && in_array($info["source"], [3, 4, 5]) && !$isMatchZhiren) {
 
-                 $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
 
-                 $whr[] = ["must", "=", 1];
 
-             }
 
-             $where = [];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             if ($whr) {
 
-                 $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
 
-             } else {
 
-                 $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             }
 
-             $age = 0;
 
-             if ($params["birthday"]) {
 
-                 $birthtime = strtotime($params["birthday"]);
 
-                 $currentYear = date("Y");
 
-                 $currentMonth = date("n");
 
-                 $birthdayYear = date("Y", $birthtime);
 
-                 $birthdayMonth = date("n", $birthtime);
 
-                 $age = ($currentYear * 12 + $currentMonth - $birthdayYear * 12 - $birthdayMonth) / 12;
 
-             }
 
-             $ft_ids = [];
 
-             $deletes = [];
 
-             foreach ($filetypes as $ft) {
 
-                 if ($ft["option"]) {
 
-                     if ($ft["rel"] == "birthday") {
 
-                         if ($age < $ft["option"]) {
 
-                             $deletes[] = $ft["id"];
 
-                             continue;
 
-                         }
 
-                     } else {
 
-                         $selectVal = $params[$ft["rel"]];
 
-                         $conditions = array_filter(explode(",", $ft["option"]));
 
-                         if (!in_array($selectVal, $conditions)) {
 
-                             $deletes[] = $ft["id"];
 
-                             continue;
 
-                         }
 
-                     }
 
-                 }
 
-                 $ft_ids[] = $ft["id"];
 
-             }
 
-             if ($params["study_abroad"] == 1) {
 
-                 //选中留学,如果存在留学附件变成必传
 
-                 $ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
 
-             } else {
 
-                 //没选中,留学附件就算设成必传也不用验证
 
-                 $ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
 
-             }
 
-             $whr = [];
 
-             if ($id) {
 
-                 $whr[] = ["mainId", "=", $id];
 
-             } else {
 
-                 if ($params["uploadFiles"])
 
-                     $whr[] = ["id", "in", $params["uploadFiles"]];
 
-             }
 
-             $whr[] = ["typeId", "in", $ft_ids];
 
-             $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
 
-             $upload_type_counts = count($distinct_filetypes);
 
-             if ($upload_type_counts != count($ft_ids)) {
 
-                 $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             return $this->mixSave($info, $this->request, TalentState::SCND_SUBMIT);
 
-         } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
 
-             $res = ["msg" => "审核不通过,不能再提交审核"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         $res = ["msg" => "已提交审核,请耐心等待"];
 
-         echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-         exit;
 
-     }
 
-     /**
 
-      * 提交表单(新:混合基础信息人才申报信息)晋江电路
 
-      */
 
-     private function submitToCheck_IC() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
 
-             return json(["msg" => "没有对应的人才认定申报信息"]);
 
-         }
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if ($checkState == TalentState::SCND_SAVE) {
 
-             $field_dict = \app\common\api\DictApi::getTalentFields_IC();
 
-             $no_empty = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "nation", "politics", "break_faith",
 
-                 "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad", "position", "cur_entry_time", "labor_contract_rangetime",
 
-                 "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime",
 
-                 "bank", "bank_branch_name", "bank_account", "experience", "education"];
 
-             $no_empty = array_filter($no_empty);
 
-             $return = [];
 
-             foreach ($no_empty as $key) {
 
-                 if (!$info[$key]) {
 
-                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
 
-                 }
 
-             }
 
-             if (count($return) > 0) {
 
-                 return json(["msg" => implode("<br>", $return)]);
 
-             }
 
-             $where = [];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             $ft_ids = array_column($filetypes, "id");
 
-             $whr = [];
 
-             $whr[] = ["typeId", "in", $ft_ids];
 
-             $whr[] = ["mainId", "=", $id];
 
-             $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
 
-             $upload_type_counts = count($distinct_filetypes);
 
-             if ($upload_type_counts != count($ft_ids)) {
 
-                 return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
 
-             }
 
-             return $this->icSave($info, $this->request, TalentState::SCND_SUBMIT);
 
-         } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
 
-             return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
 
-         }
 
-         return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
 
-     }
 
-     /**
 
-      * 提交表单:卫健
 
-      */
 
-     private function submitToCheck_WJ() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
 
-             $res = ["msg" => "没有对应的人才认定申报信息"];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
 
-             $field_dict = \app\common\api\DictApi::getTalentFields_WJ();
 
-             $no_empty = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
 
-                 "highest_degree", "graduate_school", "major", "position", "cur_entry_time", "labor_contract_rangetime",
 
-                 "talent_arrange", "talent_condition",
 
-                 "bank", "bank_account", "bank_number", "bank_branch_name"];
 
-             $no_empty = array_filter($no_empty);
 
-             $return = [];
 
-             foreach ($no_empty as $key) {
 
-                 if (!$params[$key]) {
 
-                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
 
-                 }
 
-             }
 
-             if (count($return) > 0) {
 
-                 $res = ["msg" => implode("<br>", $return)];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
 
-             if ($condition_info["bindFileTypes"]) {
 
-                 $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
 
-                 $whr[] = ["must", "=", 1];
 
-             }
 
-             $where = [];
 
-             $where[] = ["project", "=", ProjectState::TALENT];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             if ($whr) {
 
-                 $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
 
-             } else {
 
-                 $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             }
 
-             $ft_ids = array_column($filetypes, "id");
 
-             $whr = [];
 
-             $whr[] = ["typeId", "in", $ft_ids];
 
-             $whr[] = ["mainId", "=", $id];
 
-             $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
 
-             $upload_type_counts = count($distinct_filetypes);
 
-             if ($upload_type_counts != count($ft_ids)) {
 
-                 $res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-                 exit;
 
-             }
 
-             if ($checkState == TalentState::FST_SAVE) {
 
-                 $ep = EnterpriseApi::getOne($this->user["uid"]);
 
-                 if ($ep->isGeneral == 2 && !\app\common\api\Nhc::hasGeneralHospital($ep->medicalCommunityId)) {
 
-                     return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
 
-                 }
 
-                 return $this->wjSave($info, $this->request, TalentState::FST_SUBMIT);
 
-             } else {
 
-                 return $this->wjSave($info, $this->request, TalentState::SCND_SUBMIT);
 
-             }
 
-         } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
 
-             $res = ["msg" => "审核不通过,不能再提交审核", "code" => 500];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-             exit;
 
-         }
 
-         $res = ["msg" => "已提交审核,请耐心等待", "code" => 500];
 
-         echo sprintf("<script>parent.TalentInfoInfoDlg.submitCallback(%s);</script>", json_encode($res));
 
-         exit;
 
-     }
 
-     /**
 
-      * 提交表单:高教
 
-      */
 
-     private function submitToCheck_GJ() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
 
-             return json(["msg" => "没有对应的人才认定申报信息"]);
 
-         }
 
-         if ($info) {
 
-             $info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if ($checkState == TalentState::SCND_SAVE) {
 
-             $field_dict = \app\common\api\DictApi::getTalentFields_GJ();
 
-             $no_empty = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "talent_type",
 
-                 "position", "cur_entry_time", "labor_contract_rangetime", "highest_degree", "graduate_school", "major", "study_abroad", "phone",
 
-                 "talent_arrange", "talent_condition", "identifyGetTime",
 
-                 "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
 
-             if ($info["study_abroad"] == 1) {
 
-                 $no_empty[] = "abroad_school";
 
-                 $no_empty[] = "abroad_major";
 
-             }
 
-             $no_empty = array_filter($no_empty);
 
-             $return = [];
 
-             foreach ($no_empty as $key) {
 
-                 if (!$info[$key]) {
 
-                     $return[] = sprintf("请填写“%s”", $field_dict[$key]);
 
-                 }
 
-             }
 
-             if (count($return) > 0) {
 
-                 return json(["msg" => implode("<br>", $return)]);
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($info["talent_condition"]);
 
-             if ($condition_info["bindFileTypes"]) {
 
-                 $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
 
-                 $whr[] = ["must", "=", 1];
 
-             }
 
-             $where = [];
 
-             $where[] = ["project", "=", ProjectState::TALENT];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["isConditionFile", "<>", 1];
 
-             if ($whr) {
 
-                 $filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
 
-             } else {
 
-                 $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             }
 
-             $ft_ids = array_column($filetypes, "id");
 
-             $whr = [];
 
-             $whr[] = ["typeId", "in", $ft_ids];
 
-             $whr[] = ["mainId", "=", $id];
 
-             $distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select()->toArray();
 
-             $upload_type_counts = count($distinct_filetypes);
 
-             if ($upload_type_counts != count($ft_ids)) {
 
-                 return json(["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"]);
 
-             }
 
-             return $this->gjSave($info, $this->request, TalentState::SCND_SUBMIT);
 
-         } else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
 
-             return json(["msg" => "审核不通过,不能再提交审核", "code" => 500]);
 
-         }
 
-         return json(["msg" => "已提交审核,请耐心等待", "code" => 500]);
 
-     }
 
-     /**
 
-      * 保存表单(旧第二步)
 
-      * @param type $info talent_info
 
-      * @param type $param request->param();
 
-      */
 
-     private function save($info, \think\Request $request, $checkState) {
 
-         try {
 
-             $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
 
-             if ($batch["code"] != 200) {
 
-                 throw new ValidateException($batch["msg"]);
 
-             }
 
-             $param = $request->param();
 
-             validate(TalentInfo::class)->check($param);
 
-             $data["apply_year"] = $batch["batch"];
 
-             $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
 
-                 "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
 
-                 "talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
 
-                 "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
 
-             foreach ($all_valid_keys as $key) {
 
-                 $data[$key] = trim($param[$key]);
 
-             }
 
-             if ($data["study_abroad"] == 1) {
 
-                 $data["abroad_school"] = $param["abroad_school"];
 
-                 $data["abroad_major"] = $param["abroad_major"];
 
-             } else {
 
-                 $data["abroad_school"] = null;
 
-                 $data["abroad_major"] = null;
 
-             }
 
-             switch ($data["source"]) {
 
-                 case 1:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
 
-                     $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
 
-                     $data["source_city"] = null;
 
-                     break;
 
-                 case 2:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
 
-                     $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
 
-                     $data["source_county"] = null;
 
-                     break;
 
-                 case 3:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
 
-                     $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
 
-                     $data["source_city"] = $param["source_city"];
 
-                     break;
 
-                 case 4:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
 
-                     $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
 
-                     $data["source_county"] = $param["source_county"];
 
-                     break;
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
 
-             if ($condition_info["isSalary"] == 1) {
 
-                 $data["annual_salary"] = $param["annual_salary"];
 
-             } else {
 
-                 $data["annual_salary"] = null;
 
-             }
 
-             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
 
-                 //真实状态8是驳回,需要判断什么字段可以提交                
 
-                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
 
-                 $tmp_data = $data;
 
-                 $data = [];
 
-                 foreach ($modify_fields as $field) {
 
-                     $data[$field] = $tmp_data[$field];
 
-                 }
 
-             }
 
-             $data["checkState"] = $checkState;
 
-             $data["id"] = $info["id"];
 
-             $success_msg = "提交成功";
 
-             $error_msg = "提交失败";
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $last_log = TalentLogApi::getLastLog($data["id"], 1);
 
-                 if ($last_log["new_state"] != TalentState::SCND_SAVE) {
 
-                     TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
 
-                 }
 
-                 TalentModel::update($data);
 
-             } else if ($checkState == TalentState::SCND_SUBMIT) {
 
-                 $success_msg = "提交成功";
 
-                 $error_msg = "提交失败";
 
-                 $data["new_submit_time"] = date("Y-m-d H:i:s");
 
-                 TalentModel::update($data);
 
-                 TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-             $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
 
-             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         } catch (ValidateException $e) {
 
-             $res = ["msg" => $e->getMessage()];
 
-             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         }
 
-     }
 
-     /**
 
-      * 保存表单(新:混合基础信息人才申报信息)
 
-      * @param type $info talent_info
 
-      * @param type $param request->param();
 
-      */
 
-     private function mixSave($info, \think\Request $request, $checkState) {
 
-         try {
 
-             $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
 
-             if ($batch["code"] != 200) {
 
-                 throw new ValidateException($batch["msg"]);
 
-             }
 
-             $param = $request->param();
 
-             validate(TalentInfo::class)->check($param);
 
-             $id = $param["id"];
 
-             if ($id) {
 
-                 if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
 
-                     throw new ValidateException("没有对应的人才认定申报信息");
 
-                 }
 
-             }
 
-             $files = $param["uploadFiles"];
 
-             $data["headimgurl"] = $info["headimgurl"];
 
-             if ($request->file()) {
 
-                 $headimg = $request->file("photo");
 
-                 $upload = new \app\common\api\UploadApi();
 
-                 $result = $upload->uploadOne($headimg, "image", "talent/photo");
 
-                 if ($result->code != 200) {
 
-                     throw new ValidateException($result->msg);
 
-                 }
 
-                 $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 
-                 $width = imagesx($file);
 
-                 $height = imagesy($file);
 
-                 //免冠二寸照长宽413:579
 
-                 if ($width * 579 != $height * 413) {
 
-                     @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件                    
 
-                     throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-                 }
 
-                 if ($info && $info["headimgurl"]) {
 
-                     //如果新照片符合像素要求,则删除旧照片
 
-                     $old_head_url = "storage/" . $info["headimgurl"];
 
-                     if (file_exists($old_head_url))
 
-                         @unlink($old_head_url);
 
-                 }
 
-                 $data["headimgurl"] = $result->filepath;
 
-             }
 
-             if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
 
-                 throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-             $where = [];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["type", "=", $this->user["type"]];
 
-             $where[] = ["must", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["delete", "=", 0];
 
-             $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
 
-             $age = 0;
 
-             if ($param["birthday"]) {
 
-                 $birthday = $param["birthday"];
 
-                 $birthdayYear = substr($birthday, 0, 4);
 
-                 $currentYear = date("Y");
 
-                 $age = $currentYear - $birthdayYear;
 
-             }
 
-             $ft_ids = [];
 
-             $deletes = [];
 
-             foreach ($filetypes as $ft) {
 
-                 if ($ft["option"]) {
 
-                     if ($ft["rel"] == "birthday") {
 
-                         if ($age < $ft["option"]) {
 
-                             $deletes[] = $ft["id"];
 
-                             continue;
 
-                         }
 
-                     } else {
 
-                         $selectVal = $param[$ft["rel"]];
 
-                         $conditions = array_filter(explode(",", $ft["option"]));
 
-                         if (!in_array($selectVal, $conditions)) {
 
-                             $deletes[] = $ft["id"];
 
-                             continue;
 
-                         }
 
-                     }
 
-                 }
 
-                 $ft_ids[] = $ft["id"];
 
-             }
 
-             $data["apply_year"] = $batch["batch"];
 
-             $data["isMatchZhiren"] = $param["isMatchZhiren"] ?: 0;
 
-             $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
 
-                 "import_way", "cur_entry_time", "position",
 
-                 "source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
 
-                 "talent_arrange", "talent_condition", "identifyGetTime", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
 
-                 "study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
 
-             foreach ($all_valid_keys as $key) {
 
-                 $data[$key] = trim($param[$key]);
 
-             }
 
-             $data["return"] = 0; //流出晋江满3年后又返回晋江的,只有talent_type=2时可以填写且非必填
 
-             if (in_array($data["talent_type"], [1, 2])) {
 
-                 $data["tax_insurance_month"] = $param["tax_insurance_month"];
 
-                 $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
 
-                 $data["salary_pay_way"] = $param["salary_pay_way"];
 
-                 $data["salary_pay_month"] = $param["salary_pay_month"];
 
-                 $data["fst_work_time"] = $param["fst_work_time"];
 
-                 $data['pre_import_type'] = null;
 
-                 if ($data["talent_type"] == 2) {
 
-                     $data["return"] = $param["return"];
 
-                 }
 
-             } else {
 
-                 $data["tax_insurance_month"] = null;
 
-                 $data["labor_contract_rangetime"] = null;
 
-                 $data["salary_pay_way"] = null;
 
-                 $data["salary_pay_month"] = null;
 
-                 $data["fst_work_time"] = null;
 
-                 $data['pre_import_type'] = $param["pre_import_type"];
 
-             }
 
-             if ($data["study_abroad"] == 1) {
 
-                 $data["abroad_school"] = $param["abroad_school"];
 
-                 $data["abroad_major"] = $param["abroad_major"];
 
-             } else {
 
-                 $data["abroad_school"] = null;
 
-                 $data["abroad_major"] = null;
 
-             }
 
-             switch ($data["source"]) {
 
-                 case 1:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
 
-                     $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
 
-                     $data["source_city"] = null;
 
-                     break;
 
-                 case 2:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
 
-                     $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
 
-                     $data["source_county"] = null;
 
-                     break;
 
-                 case 3:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
 
-                     $data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
 
-                     $data["source_city"] = $param["source_city"];
 
-                     break;
 
-                 case 4:
 
-                     $data["source_batch"] = $param["source_batch"];
 
-                     $data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
 
-                     $data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
 
-                     $data["source_county"] = $param["source_county"];
 
-                     break;
 
-             }
 
-             $condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
 
-             if ($condition_info["isSalary"] == 1) {
 
-                 $data["annual_salary"] = $param["annual_salary"];
 
-             } else {
 
-                 $data["annual_salary"] = null;
 
-             }
 
-             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
 
-                 //真实状态11是驳回,需要判断什么字段可以提交                
 
-                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
 
-                 $tmp_data = $data;
 
-                 $data = [];
 
-                 foreach ($modify_fields as $field) {
 
-                     $data[$field] = $tmp_data[$field];
 
-                 }
 
-             }
 
-             $data["check_companys"] = $condition_info["companyIds"];
 
-             $data["checkState"] = $checkState;
 
-             $data["id"] = $id;
 
-             $success_msg = "提交成功";
 
-             $error_msg = "提交失败";
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $success_msg = "保存成功";
 
-                 if ($data["id"]) {
 
-                     //编辑
 
-                     $data["updateTime"] = date("Y-m-d H:i:s");
 
-                     TalentModel::update($data);
 
-                     $last_log = TalentLogApi::getLastLog($data["id"], 1);
 
-                     if ($last_log["new_state"] != TalentState::SCND_SAVE) {
 
-                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
 
-                     } else {
 
-                         if (!$last_log["companyId"]) {
 
-                             TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
 
-                         }
 
-                     }
 
-                 } else {
 
-                     //新增
 
-                     $data["enterprise_id"] = $this->user["uid"];
 
-                     $data["createTime"] = date("Y-m-d H:i:s");
 
-                     $id = TalentModel::insertGetId($data);
 
-                     TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
 
-                     $whr = [];
 
-                     $whr[] = ["fileId", "in", $files];
 
-                     $upd_checklog["mainId"] = $id;
 
-                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 
-                 }
 
-             } else if ($checkState == TalentState::SCND_SUBMIT) {
 
-                 if (!$info["first_submit_time"]) {
 
-                     $data["first_submit_time"] = date("Y-m-d H:i:s");
 
-                 } else {
 
-                     $data["new_submit_time"] = date("Y-m-d H:i:s");
 
-                 }
 
-                 if ($data["id"]) {
 
-                     $data["updateTime"] = date("Y-m-d H:i:s");
 
-                     TalentModel::update($data);
 
-                 } else {
 
-                     //新增
 
-                     $data["enterprise_id"] = $this->user["uid"];
 
-                     $data["createTime"] = date("Y-m-d H:i:s");
 
-                     $id = TalentModel::insertGetId($data);
 
-                     $whr = [];
 
-                     $whr[] = ["fileId", "in", $files];
 
-                     $upd_checklog["mainId"] = $id;
 
-                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 
-                 }
 
-                 TalentLogApi::write(1, $id, $checkState, "确认提交审核", 1);
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-             if ($id) {
 
-                 if ($deletes) {
 
-                     //删除多余的附件,一般是选择人才类型留下来的
 
-                     $whr = [];
 
-                     $whr[] = ["typeId", "in", $deletes];
 
-                     $whr[] = ["id", "in", $files];
 
-                     $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
 
-                     $_logfileIds[] = [];
 
-                     foreach ($_wait_del_files as $_del_file) {
 
-                         $_logfileIds[] = $_del_file["id"];
 
-                         @unlink("storage/" . $_del_file["url"]);
 
-                     }
 
-                     Db::table("new_talent_file")->where($whr)->delete();
 
-                     if ($_logfileIds) {
 
-                         $whr = [];
 
-                         $whr[] = ["fileId", "in", $_logfileIds];
 
-                         $_upd_checklog["description"] = "删除附件";
 
-                         $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
 
-                         $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
 
-                         Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
 
-                     }
 
-                 }
 
-                 $whr = [];
 
-                 $whr[] = ["id", "in", $files];
 
-                 Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
 
-                 $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-         } catch (ValidateException $e) {
 
-             $res = ["msg" => $e->getMessage()];
 
-             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         } catch (\think\Exception $e) {
 
-             $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
 
-             $logInfo = [
 
-                 "enterprise_id" => $this->user["uid"],
 
-                 "data" => $data,
 
-                 "controller" => $this->request->controller(),
 
-                 "action" => $this->request->action(),
 
-                 "errCode" => $e->getCode(),
 
-                 "errMsg" => $e->getMessage()
 
-             ];
 
-             Log::write($logInfo, "error");
 
-             $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         }
 
-     }
 
-     private function icSave($info, \think\Request $request, $checkState) {
 
-         try {
 
-             $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
 
-             if ($batch["code"] != 200) {
 
-                 throw new ValidateException($batch["msg"]);
 
-             }
 
-             $param = $request->param();
 
-             validate(TalentInfo::class)->check($param);
 
-             $id = $param["id"];
 
-             if ($id) {
 
-                 if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
 
-                     throw new ValidateException("没有对应的人才认定申报信息");
 
-                 }
 
-             }
 
-             $files = $param["uploadFiles"];
 
-             $data["headimgurl"] = $info["headimgurl"];
 
-             if ($request->file()) {
 
-                 $headimg = $request->file("photo");
 
-                 $upload = new \app\common\api\UploadApi();
 
-                 $result = $upload->uploadOne($headimg, "image", "talent/photo");
 
-                 if ($result->code == 500) {
 
-                     throw new ValidateException($result->msg);
 
-                 }
 
-                 $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 
-                 $width = imagesx($file);
 
-                 $height = imagesy($file);
 
-                 //免冠二寸照长宽413:579
 
-                 if ($width * 579 != $height * 413) {
 
-                     @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件                    
 
-                     throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-                 }
 
-                 if ($info && $info["headimgurl"]) {
 
-                     //如果新照片符合像素要求,则删除旧照片
 
-                     $old_head_url = "storage/" . $info["headimgurl"];
 
-                     if (file_exists($old_head_url))
 
-                         @unlink($old_head_url);
 
-                 }
 
-                 $data["headimgurl"] = $result->filepath;
 
-             }
 
-             if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
 
-                 throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-             $data["apply_year"] = $batch["batch"];
 
-             $all_valid_keys = ["name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education", "break_faith",
 
-                 "phone", "email", "highest_degree", "graduate_school", "major", "study_abroad",
 
-                 "position", "cur_entry_time", "labor_contract_rangetime",
 
-                 "talent_arrange", "talent_condition", "identifyConditionName", "identifyGetTime", "title", "pro_qua",
 
-                 "bank", "bank_branch_name", "bank_account", "description"];
 
-             foreach ($all_valid_keys as $key) {
 
-                 $value = trim($param[$key]);
 
-                 if ($value) {
 
-                     $data[$key] = $value;
 
-                 }
 
-             }
 
-             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
 
-                 //真实状态11是驳回,需要判断什么字段可以提交                
 
-                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
 
-                 $tmp_data = $data;
 
-                 $data = [];
 
-                 foreach ($modify_fields as $field) {
 
-                     $data[$field] = $tmp_data[$field];
 
-                 }
 
-             }
 
-             $success_msg = "提交成功";
 
-             $error_msg = "提交失败";
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $data["checkState"] = $checkState;
 
-                 $data["id"] = $id;
 
-                 $success_msg = "保存成功";
 
-                 if ($data["id"]) {
 
-                     //编辑
 
-                     $data["updateTime"] = date("Y-m-d H:i:s");
 
-                     TalentModel::update($data);
 
-                     $last_log = TalentLogApi::getLastLog($data["id"], 1);
 
-                     if ($last_log["new_state"] != TalentState::SCND_SAVE) {
 
-                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
 
-                     } else {
 
-                         if (!$last_log["companyId"]) {
 
-                             TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
 
-                         }
 
-                     }
 
-                 } else {
 
-                     //新增
 
-                     $data["enterprise_id"] = $this->user["uid"];
 
-                     $data["createTime"] = date("Y-m-d H:i:s");
 
-                     $id = TalentModel::insertGetId($data);
 
-                     TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
 
-                     $whr = [];
 
-                     $whr[] = ["fileId", "in", $files];
 
-                     $upd_checklog["mainId"] = $id;
 
-                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 
-                 }
 
-                 $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else if ($checkState == TalentState::SCND_SUBMIT) {
 
-                 unset($data);
 
-                 $data["checkState"] = $checkState;
 
-                 $data["id"] = $id;
 
-                 if (!$info["first_submit_time"]) {
 
-                     $data["first_submit_time"] = date("Y-m-d H:i:s");
 
-                 } else {
 
-                     $data["new_submit_time"] = date("Y-m-d H:i:s");
 
-                 }
 
-                 $data["updateTime"] = date("Y-m-d H:i:s");
 
-                 TalentModel::update($data);
 
-                 TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
 
-                 return json(["msg" => $success_msg, "code" => 200]);
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-         } catch (ValidateException $e) {
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $res = ["msg" => $e->getMessage()];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 return json(["msg" => $e->getMessage()]);
 
-             }
 
-         } catch (\think\Exception $e) {
 
-             $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
 
-             $logInfo = [
 
-                 "enterprise_id" => $this->user["uid"],
 
-                 "data" => $data,
 
-                 "controller" => $this->request->controller(),
 
-                 "action" => $this->request->action(),
 
-                 "errCode" => $e->getCode(),
 
-                 "errMsg" => $e->getMessage()
 
-             ];
 
-             Log::write($logInfo, "error");
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 return json($res);
 
-             }
 
-         }
 
-     }
 
-     /**
 
-      * 卫健保存
 
-      * @param type $info
 
-      * @param \think\Request $request
 
-      * @param type $checkState
 
-      * @return type
 
-      * @throws ValidateException
 
-      */
 
-     private function wjSave($info, \think\Request $request, $checkState) {
 
-         $callback = "infoCallback";
 
-         if (in_array($checkState, [TalentState::FST_SUBMIT, TalentState::SCND_SUBMIT])) {
 
-             $callback = "submitCallback";
 
-         }
 
-         try {
 
-             $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
 
-             if ($batch["code"] != 200) {
 
-                 throw new ValidateException($batch["msg"]);
 
-             }
 
-             $param = $request->param();
 
-             validate(TalentInfo::class)->check($param);
 
-             $id = $param["id"];
 
-             if ($id) {
 
-                 if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
 
-                     throw new ValidateException("没有对应的人才认定申报信息");
 
-                 }
 
-             }
 
-             $files = $param["uploadFiles"];
 
-             $data["headimgurl"] = $info["headimgurl"];
 
-             if ($request->file()) {
 
-                 $headimg = $request->file("photo");
 
-                 $upload = new \app\common\api\UploadApi();
 
-                 $result = $upload->uploadOne($headimg, "image", "talent/photo");
 
-                 if ($result->code == 500) {
 
-                     throw new ValidateException($result->msg);
 
-                 }
 
-                 $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 
-                 $width = imagesx($file);
 
-                 $height = imagesy($file);
 
-                 //免冠二寸照长宽413:579
 
-                 if ($width * 579 != $height * 413) {
 
-                     @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件                    
 
-                     throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-                 }
 
-                 if ($info && $info["headimgurl"]) {
 
-                     //如果新照片符合像素要求,则删除旧照片
 
-                     $old_head_url = "storage/" . $info["headimgurl"];
 
-                     if (file_exists($old_head_url))
 
-                         @unlink($old_head_url);
 
-                 }
 
-                 $data["headimgurl"] = $result->filepath;
 
-             }
 
-             if (!$data["headimgurl"] && ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT))
 
-                 throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-             $data["apply_year"] = $batch["batch"];
 
-             $all_valid_keys = ["name", "sex", "nation", "politics", "card_type", "card_number", "birthday", "talent_type",
 
-                 "highest_degree", "graduate_school", "major", "study_abroad", "abroad_school", "abroad_major",
 
-                 "position", "cur_entry_time", "labor_contract_rangetime", "title", "fst_city_work_time",
 
-                 "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition",
 
-                 "phone", "email", "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education"];
 
-             foreach ($all_valid_keys as $key) {
 
-                 $value = trim($param[$key]);
 
-                 if ($value) {
 
-                     $data[$key] = $value;
 
-                 }
 
-             }
 
-             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT || $info["real_state"] == TalentState::BASE_REJECT) {
 
-                 //真实状态11是驳回,需要判断什么字段可以提交                
 
-                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
 
-                 $tmp_data = $data;
 
-                 $data = [];
 
-                 foreach ($modify_fields as $field) {
 
-                     $data[$field] = $tmp_data[$field];
 
-                 }
 
-             }
 
-             $data["checkState"] = $checkState;
 
-             $data["id"] = $id;
 
-             $success_msg = "提交成功";
 
-             $error_msg = "提交失败";
 
-             if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::FST_SAVE) {
 
-                 $success_msg = "保存成功";
 
-                 if ($data["id"]) {
 
-                     //编辑
 
-                     $data["updateTime"] = date("Y-m-d H:i:s");
 
-                     TalentModel::update($data);
 
-                     $last_log = TalentLogApi::getLastLog($data["id"], 1);
 
-                     if ($last_log["new_state"] != TalentState::SCND_SAVE && $last_log["new_state"] != TalentState::FST_SAVE) {
 
-                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
 
-                     } else {
 
-                         if (!$last_log["companyId"]) {
 
-                             TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
 
-                         }
 
-                     }
 
-                 } else {
 
-                     //新增
 
-                     $data["enterprise_id"] = $this->user["uid"];
 
-                     $data["createTime"] = date("Y-m-d H:i:s");
 
-                     $id = TalentModel::insertGetId($data);
 
-                     TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
 
-                     $whr = [];
 
-                     $whr[] = ["fileId", "in", $files];
 
-                     $upd_checklog["mainId"] = $id;
 
-                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 
-                 }
 
-                 //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-                 //exit();
 
-             } else if ($checkState == TalentState::SCND_SUBMIT || $checkState == TalentState::FST_SUBMIT) {
 
-                 if (!$info["first_submit_time"]) {
 
-                     $data["first_submit_time"] = date("Y-m-d H:i:s");
 
-                 } else {
 
-                     $data["new_submit_time"] = date("Y-m-d H:i:s");
 
-                 }
 
-                 $data["updateTime"] = date("Y-m-d H:i:s");
 
-                 TalentModel::update($data);
 
-                 TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
 
-                 //$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 //echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-                 //exit();
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-             if ($id) {
 
-                 $whr = [];
 
-                 $whr[] = ["id", "in", $files];
 
-                 Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
 
-                 $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 //$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-         } catch (ValidateException $e) {
 
-             $res = ["msg" => $e->getMessage()];
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         } catch (\think\Exception $e) {
 
-             $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
 
-             $logInfo = [
 
-                 "enterprise_id" => $this->user["uid"],
 
-                 "data" => $data,
 
-                 "controller" => $this->request->controller(),
 
-                 "action" => $this->request->action(),
 
-                 "errCode" => $e->getCode(),
 
-                 "errMsg" => $e->getMessage()
 
-             ];
 
-             Log::write($logInfo, "error");
 
-             echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
 
-             exit();
 
-         }
 
-     }
 
-     private function gjSave($info, \think\Request $request, $checkState) {
 
-         try {
 
-             $batch = BatchApi::checkBatchValid(["type" => ProjectState::TALENT, "year" => $info["apply_year"], "first_submit_time" => $info["first_submit_time"]], $this->user["type"]);
 
-             if ($batch["code"] != 200) {
 
-                 throw new ValidateException($batch["msg"]);
 
-             }
 
-             $param = $request->param();
 
-             validate(TalentInfo::class)->check($param);
 
-             $id = $param["id"];
 
-             if ($id) {
 
-                 if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
 
-                     throw new ValidateException("没有对应的人才认定申报信息");
 
-                 }
 
-             }
 
-             $files = $param["uploadFiles"];
 
-             $data["headimgurl"] = $info["headimgurl"];
 
-             if ($request->file()) {
 
-                 $headimg = $request->file("photo");
 
-                 $upload = new \app\common\api\UploadApi();
 
-                 $result = $upload->uploadOne($headimg, "image", "talent/photo");
 
-                 if ($result->code == 500) {
 
-                     throw new ValidateException($result->msg);
 
-                 }
 
-                 $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
 
-                 $width = imagesx($file);
 
-                 $height = imagesy($file);
 
-                 //免冠二寸照长宽413:579
 
-                 if ($width * 579 != $height * 413) {
 
-                     @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件                    
 
-                     throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-                 }
 
-                 if ($info && $info["headimgurl"]) {
 
-                     //如果新照片符合像素要求,则删除旧照片
 
-                     $old_head_url = "storage/" . $info["headimgurl"];
 
-                     if (file_exists($old_head_url))
 
-                         @unlink($old_head_url);
 
-                 }
 
-                 $data["headimgurl"] = $result->filepath;
 
-             }
 
-             if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
 
-                 throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
 
-             $data["apply_year"] = $batch["batch"];
 
-             $all_valid_keys = ["name", "nation", "card_type", "card_number", "sex", "birthday", "politics", "nationality", "province", "city", "county", "talent_type",
 
-                 "position", "cur_entry_time", "labor_contract_rangetime",
 
-                 "highest_degree", "graduate_school", "major", "study_abroad", "title", "pro_qua", "phone", "email",
 
-                 "is_fujian_talent", "is_jinjiang_talent", "talent_arrange", "talent_condition", "identifyGetTime",
 
-                 "bank", "bank_account", "bank_number", "bank_branch_name", "experience", "education", "parent_talent_level", "parent_talent_condition"];
 
-             foreach ($all_valid_keys as $key) {
 
-                 $value = trim($param[$key]);
 
-                 if ($value) {
 
-                     $data[$key] = $value;
 
-                 }
 
-             }
 
-             if ($data["study_abroad"] == 1) {
 
-                 $data["abroad_school"] = $param["abroad_school"];
 
-                 $data["abroad_major"] = $param["abroad_major"];
 
-             }
 
-             if ($data["study_abroad"] == 2) {
 
-                 $data["abroad_school"] = null;
 
-                 $data["abroad_major"] = null;
 
-             }
 
-             if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
 
-                 //真实状态11是驳回,需要判断什么字段可以提交                
 
-                 $modify_fields = array_filter(explode(",", $info["modify_fields"]));
 
-                 $tmp_data = $data;
 
-                 $data = [];
 
-                 foreach ($modify_fields as $field) {
 
-                     $data[$field] = $tmp_data[$field];
 
-                 }
 
-             }
 
-             $success_msg = "提交成功";
 
-             $error_msg = "提交失败";
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $data["checkState"] = $checkState;
 
-                 $data["id"] = $id;
 
-                 $success_msg = "保存成功";
 
-                 if ($data["id"]) {
 
-                     //编辑
 
-                     $data["updateTime"] = date("Y-m-d H:i:s");
 
-                     TalentModel::update($data);
 
-                     $last_log = TalentLogApi::getLastLog($data["id"], 1);
 
-                     if ($last_log["new_state"] != TalentState::SCND_SAVE) {
 
-                         TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
 
-                     } else {
 
-                         if (!$last_log["companyId"]) {
 
-                             TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
 
-                         }
 
-                     }
 
-                 } else {
 
-                     //新增
 
-                     $data["enterprise_id"] = $this->user["uid"];
 
-                     $data["createTime"] = date("Y-m-d H:i:s");
 
-                     $id = TalentModel::insertGetId($data);
 
-                     TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
 
-                     $whr = [];
 
-                     $whr[] = ["fileId", "in", $files];
 
-                     $upd_checklog["mainId"] = $id;
 
-                     Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
 
-                 }
 
-                 $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else if ($checkState == TalentState::SCND_SUBMIT) {
 
-                 unset($data);
 
-                 $data["checkState"] = $checkState;
 
-                 $data["id"] = $id;
 
-                 if (!$info["first_submit_time"]) {
 
-                     $data["first_submit_time"] = date("Y-m-d H:i:s");
 
-                 } else {
 
-                     $data["new_submit_time"] = date("Y-m-d H:i:s");
 
-                 }
 
-                 $data["updateTime"] = date("Y-m-d H:i:s");
 
-                 TalentModel::update($data);
 
-                 TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
 
-                 return json(["msg" => $success_msg, "code" => 200]);
 
-             } else {
 
-                 throw new ValidateException($error_msg);
 
-             }
 
-         } catch (ValidateException $e) {
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 $res = ["msg" => $e->getMessage()];
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 return json(["msg" => $e->getMessage()]);
 
-             }
 
-         } catch (\think\Exception $e) {
 
-             $res = ["msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
 
-             $logInfo = [
 
-                 "enterprise_id" => $this->user["uid"],
 
-                 "data" => $data,
 
-                 "controller" => $this->request->controller(),
 
-                 "action" => $this->request->action(),
 
-                 "errCode" => $e->getCode(),
 
-                 "errMsg" => $e->getMessage()
 
-             ];
 
-             Log::write($logInfo, "error");
 
-             if ($checkState == TalentState::SCND_SAVE) {
 
-                 echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
 
-                 exit();
 
-             } else {
 
-                 return json($res);
 
-             }
 
-         }
 
-     }
 
-     public function delete() {
 
-         $id = $this->request->param("talentInfoId");
 
-         $info = Talent::chkIsOwner($id, $this->user["uid"]);
 
-         if (!$info) {
 
-             return json(["msg" => "操作失败"]);
 
-         }
 
-         $checkState = $info["checkState"];
 
-         if (in_array($checkState, [0, 1])) {
 
-             $log = TalentLogApi::getLastLog($id, 1);
 
-             if ($log["state"] > 1) {
 
-                 //有提交审核记录
 
-                 return json(["msg" => "该申报已提交审核,无法删除"]);
 
-             }
 
-         }
 
-         $data["id"] = $id;
 
-         $data["updateTime"] = date("Y-m-d H:i:s");
 
-         $data["delete"] = 1;
 
-         TalentModel::update($data);
 
-         return json(["msg" => "删除成功"]);
 
-     }
 
-     public function detail() {
 
-         $id = $this->request->param("id");
 
-         $info = $this->getInfoById($id);
 
-         return json($info);
 
-     }
 
-     public function getInfoById($id) {
 
-         $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         if ($info["enterprise_id"] != $this->user["uid"]) {
 
-             return [];
 
-         }
 
-         return $info;
 
-     }
 
-     public function findTalentInfoInLibrary() {
 
-         $where = [];
 
-         $sList = [];
 
-         $type = $this->request->param('type');
 
-         if ($type == ProjectState::QUIT) {
 
-             $_where = [];
 
-             $_where[] = ["checkState", "not in", [3]];
 
-             $_where[] = ["delete", "<>", 1];
 
-             $idCards = Db::table("un_talent_quit")->where($_where)->column("idCard");
 
-             $sList = array_merge($sList, (array) $idCards);
 
-             $where[] = ["active", "=", 1];
 
-         }
 
-         if ($type == ProjectState::BANKCHANGE) {
 
-             $_where = [];
 
-             $_where[] = ["checkState", "not in", [3]];
 
-             $_where[] = ["delete", "<>", 1];
 
-             $idCards = Db::table("un_talent_bank_change")->where($_where)->column("idCard");
 
-             $sList = array_merge($sList, (array) $idCards);
 
-         }
 
-         if ($type == ProjectState::LEVELCHANGE) {
 
-             $_where = [];
 
-             $_where[] = ["checkState", "not in", [35, -1]];
 
-             $_where[] = ["isPublic", "<", 5];
 
-             $_where[] = ["delete", "<>", 1];
 
-             $idCards = Db::table("un_talent_type_change")->where($_where)->column("idCard");
 
-             $sList = array_merge($sList, (array) $idCards);
 
-         }
 
-         $where[] = ["enterprise_id", "=", $this->user["uid"]];
 
-         $where[] = ["checkState", "=", TalentState::CERTIFICATED];
 
-         $where[] = ["isEffect", "<>", 4];
 
-         if ($sList) {
 
-             $where[] = ["card_number", "not in", $sList];
 
-         }
 
-         $result = TalentModel::where($where)->field("id,name")->select()->toArray();
 
-         return json($result);
 
-     }
 
-     public function findTalentInfoByChangeId() {
 
-         $where = [];
 
-         $id = $this->request->param('id');
 
-         $type = $this->request->param('type');
 
-         if ($type == ProjectState::QUIT) {
 
-             $info = Db::table("un_talent_quit")->where("id", $id)->find();
 
-         }
 
-         if ($type == ProjectState::LEVELCHANGE) {
 
-             $info = Db::table("un_talent_type_change")->where("id", $id)->find();
 
-         }
 
-         if ($type == ProjectState::BANKCHANGE) {
 
-             $info = Db::table("un_talent_bank_change")->where("id", $id)->find();
 
-         }
 
-         if (strlen($info["talentId"]) == 19) {
 
-             $where[] = ["enterprise_id", "=", $this->user["uid"]];
 
-             $where[] = ["card_number", "=", $info["idCard"]];
 
-             $where[] = ["delete", "=", 0];
 
-             $where[] = ["checkState", "=", TalentState::CERTIFICATED];
 
-         } else {
 
-             $where[] = ["id", "=", $info["talentId"]];
 
-         }
 
-         $result = TalentModel::where($where)->field("id,name")->select()->toArray();
 
-         return json($result);
 
-     }
 
-     public function getTalentBasicById() {
 
-         $id = $this->request["id"];
 
-         $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         /* if(FengStringUtil.isNotEmpAndNull(year)){
 
-           StringBuilder sb = new StringBuilder();
 
-           List<TalentAllowancecontractDetail> contractDetailList = new ArrayList<>();     //保存上一年度的工作单位
 
-           TalentAllowanceInfo info = new TalentAllowanceInfo();
 
-           info.setType(ti.getType());
 
-           info.setYear(year);
 
-           info.setFirstInJJTime(ti.getFirstInJJTime());
 
-           ApiTalentAllowanceController.getConcatList(ti,info,year,sb,contractDetailList);
 
-           int active = AllowanceSelectUtil.validMyqy(contractDetailList,ti,info);
 
-           ti.setActive(active);
 
-           } */
 
-         return $ti;
 
-     }
 
-     /**
 
-      * 
 
-      */
 
-     public function getTalentInfoFromOldLibrary() {
 
-         $responseObj = new \stdClass();
 
-         $responseObj->code = 500;
 
-         $ep = EnterpriseApi::getOne($this->user["uid"]);
 
-         $pIdCard = \StrUtil::getRequestDecodeParam($this->request, "idCard");
 
-         $eIdCard = $ep->idCard;
 
-         $where = [];
 
-         $where[] = ["e.idCard", "=", $eIdCard];
 
-         $where[] = ["ti.idCard", "=", $pIdCard];
 
-         $old = Db::table("un_talent_info")->alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterpriseId")->field("ti.*")->where($where)->order("ti.createTime desc")->find();
 
-         if ($old) {
 
-             $responseObj->code = 200;
 
-             $responseObj->info = $old;
 
-             return $responseObj;
 
-         }
 
-         return $responseObj;
 
-     }
 
-     public function findTalentByEnterpriseInLibrary() {
 
-         $year = $this->request["year"];
 
-         $type = $this->request["type"];
 
-         $res = [];
 
-         $ids = null;
 
-         //根据申报年度查询当前企业已申报的人才
 
-         if ($type == 1) {  //津补贴
 
-             $where = [];
 
-             $where[] = ["year", "=", $year];
 
-             $where[] = ["enterpriseId", "=", $this->user["uid"]];
 
-             $talentAllowances = \app\common\model\TalentAllowance::where($where)->select()->toArray();
 
-             $ids = array_unique(array_column($talentAllowances, "talentId"));
 
-         } else if ($type == 2) {    //购房补贴
 
-             //allowanceWrapper.eq("year",year).eq("enterpriseId",sessionUser.getId()).setSqlSelect("talentId");
 
-             //List<Housepurchase> allowanceInfoList = this.housepurchaseService.selectList(allowanceWrapper);
 
-             //ids = allowanceInfoList.stream().map(Housepurchase :: getTalentId).distinct().collect(Collectors.joining(","));
 
-         }
 
-         $whr = [];
 
-         $whr[] = ["ti.checkState", "=", TalentState::CERTIFICATED];
 
-         $whr[] = ["ti.enterprise_id", "=", $this->user["uid"]];
 
-         $whr[] = ["e.type", "=", $this->user["type"]];
 
-         $whr[] = ["ti.id", "not in", $ids];
 
-         $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.*")->where($whr)->select()->toArray();
 
-         foreach ($list as $info) {
 
-             $info["enterpriseName"] = $this->user["name"];
 
-             if (strtotime($year . "-12-31") >= strtotime($info["identifyMonth"])) {
 
-                 $res[] = $info;
 
-             } else {
 
-                 $whereTypeChange = [];
 
-                 $whereTypeChange[] = ["talentId", "=", $info["id"]];
 
-                 $whereTypeChange[] = ["checkState", "=", \app\common\state\MainState::PASS];
 
-                 $whereTypeChange[] = ["isPublic", "=", 6];
 
-                 $typeChanges = \app\enterprise\model\TalentTypeChange::where($whereTypeChange)->select()->toArray();
 
-                 foreach ($typeChanges as $typeChange) {
 
-                     if (strtotime($year . "-12-31") >= strtotime($typeChange["oldIdentifyMonth"])) {
 
-                         $res[] = $info;
 
-                         break;
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         return $res;
 
-     }
 
-     /**
 
-      * 审核列表页
 
-      */
 
-     public function examineCenter() {
 
-         $tpl = "";
 
-         switch ($this->user["type"]) {
 
-             case CommonConst::ENTERPRISE_WJ:
 
-                 $tpl = "/talent/hospital/examine_center"; //卫健医院
 
-                 break;
 
-         }
 
-         return view($tpl);
 
-     }
 
-     /**
 
-      * 审核列表页
 
-      */
 
-     public function examineList() {
 
-         $res = TalentApi::getHospitalExamineList($this->request);
 
-         return json($res);
 
-     }
 
-     public function examinePage() {
 
-         $id = $this->request->param("id");
 
-         $info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         return view("/talent/hospital/view", ["row" => $info]);
 
-     }
 
-     /**
 
-      * 医院人才申报审核保存
 
-      * @return type
 
-      */
 
-     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 = \app\common\api\VerifyApi::getOne($id);
 
-         if (!$talent_info) {
 
-             return json(["msg" => "数据错误"]);
 
-         }
 
-         $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
 
-         $checkState = $talent_info["checkState"];
 
-         if ($this->user["isGeneral"] != 1) {
 
-             return json(["msg" => "非总院账号,无法审核"]);
 
-         }
 
-         if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
 
-             return json(["msg" => "不能审核其它非本医共体医院"]);
 
-         }
 
-         if (!$check) {
 
-             return json(["msg" => "请选择审核状态"]);
 
-         }
 
-         if (!$check_msg) {
 
-             return json(["msg" => "请填写审核说明"]);
 
-         }
 
-         if ($checkState == TalentState::FST_SUBMIT) {
 
-             if ($params["checkState"] == 3) {
 
-                 //审核成功
 
-                 $log_checkState = $checkState = TalentState::SCND_SUBMIT; //待初审
 
-             } else {
 
-                 //审核驳回并记录需要修改的字段和上传文件
 
-                 $checkState = TalentState::FST_SAVE; //退回材料编辑状态
 
-                 $log_checkState = TalentState::BASE_REJECT; //日志记录拒绝状态
 
-             }
 
-             $log = TalentLogApi::getLastLog($id, 1);
 
-             if (!$log && !$talent_info["oldId"])
 
-                 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" => "保存成功"]);
 
-         } else {
 
-             return json(["msg" => "不在审核范围内,保存失败"]);
 
-         }
 
-     }
 
-     /**
 
-      * 医院人才申报审核
 
-      * @return type
 
-      */
 
-     public function submitCheck() {
 
-         $id = $this->request->param("id");
 
-         $talent_info = \app\common\api\VerifyApi::getOne($id);
 
-         if (!$talent_info) {
 
-             return json(["msg" => "数据错误"]);
 
-         }
 
-         $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
 
-         $checkState = $talent_info["checkState"];
 
-         if ($this->user["isGeneral"] != 1) {
 
-             return json(["msg" => "非总院账号,无法审核"]);
 
-         }
 
-         if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
 
-             return json(["msg" => "不能审核其它非本医共体医院"]);
 
-         }
 
-         if ($checkState == TalentState::FST_SUBMIT) {
 
-             $nowProcess = 1;
 
-             $log = TalentLogApi::getLastLog($talent_info["id"], 1);
 
-             if (!$log || $log["active"] == 1)
 
-                 return json(["msg" => "请先保存审核状态,再提交审核"]);
 
-             if (in_array($log["new_state"], [TalentState::SCND_SUBMIT])) {
 
-                 $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);
 
-             if ($log["state"] == TalentState::BASE_REJECT) {
 
-                 $this->sendMsg($enterprise["id"], $log["description"]);
 
-             }
 
-             return json(["code" => 200, "msg" => "审核成功"]);
 
-         } else {
 
-             return json(["msg" => "不在审核范围内,审核失败"]);
 
-         }
 
-     }
 
-     public function findFieldsAndFiles() {
 
-         $id = $this->request["id"];
 
-         $talentInfo = TalentApi::getOne($id);
 
-         $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
 
-         $responseObj = new \stdClass();
 
-         if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
 
-             $fields = DictApi::getTalentFields_WJ();
 
-             $field_tmp = [];
 
-             if ($fields) {
 
-                 foreach ($fields as $key => $field) {
 
-                     $field_tmp[] = ["key" => $key, "value" => $field];
 
-                 }
 
-             }
 
-             $condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
 
-             $where = [];
 
-             $whr = [];
 
-             $where[] = ["project", "=", 1];
 
-             $where[] = ["active", "=", 1];
 
-             $where[] = ["type", "=", CommonConst::ENTERPRISE_WJ];
 
-             $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])->order("sn asc")->select();
 
-             } else {
 
-                 $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
 
-             }
 
-             $responseObj->code = 200;
 
-             $responseObj->id = $id;
 
-             $responseObj->fileList = $files;
 
-             $responseObj->fieldList = $field_tmp;
 
-             $responseObj->select = [
 
-                 "files" => array_filter(explode(",", $talentInfo["modify_files"])),
 
-                 "fields" => array_filter(explode(",", $talentInfo["modify_fields"]))
 
-             ];
 
-         } else {
 
-             $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
 
-         }
 
-         return json($responseObj);
 
-     }
 
-     /**
 
-      * 初审-修改驳回字段
 
-      * @auth {{/talentInfo/updateFieldsAndFiles}}
 
-      */
 
-     public function updateFieldsAndFiles() {
 
-         $id = $this->request["id"];
 
-         $fields = array_filter(explode(",", $this->request["fields"]));
 
-         $files = array_filter(explode(",", $this->request["files"]));
 
-         $talentInfo = TalentApi::getOne($id);
 
-         $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
 
-         $responseObj = new \stdClass();
 
-         if ($talentInfo["checkState"] == TalentState::FST_SAVE && $lastLog["state"] == TalentState::BASE_REJECT) {
 
-             if (!$fields && !$files) {
 
-                 $responseObj->msg = "请选择可修改的字段或附件!";
 
-                 return json($responseObj);
 
-             }
 
-             try {
 
-                 $data["id"] = $id;
 
-                 $data["modify_fields"] = $fields ? implode(",", $fields) : null;
 
-                 $data["modify_files"] = $files ? implode(",", $files) : null;
 
-                 TalentModel::update($data);
 
-                 $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);
 
-         }
 
-     }
 
-     private function sendMsg($enterprise_id, $description = "") {
 
-         $ep = EnterpriseApi::getOne($enterprise_id);
 
-         if ($ep->agentPhone) {
 
-             $smsapi = new \app\common\api\ChuanglanSmsApi();
 
-             $result = $smsapi->sendSMS($phone, $template);
 
-             $result = json_decode($result, true);
 
-             $id = getStringId();
 
-             $record_data = [
 
-                 'id' => $id,
 
-                 'userId' => $ep->id,
 
-                 'bizId' => $result["msgId"],
 
-                 'type' => 2,
 
-                 'smsType' => 2,
 
-                 'name' => $ep->name,
 
-                 'phone' => $ep->agentPhone,
 
-                 'params' => "总院审核",
 
-                 'templateCode' => "【晋江市人才服务平台】尊敬的用户,您提交的人才认定申报审核驳回,原因是:{$description},请及时登录申报系统修改并重新提交。",
 
-                 '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']
 
-             ];
 
-             \app\admin\model\MessageRecord::create($record_data);
 
-         }
 
-     }
 
-     public function validateIsCheck() {
 
-         $params = $this->request->param();
 
-         $id = $params["id"];
 
-         $talent_info = \app\common\api\VerifyApi::getTalentInfoById($id);
 
-         $enterprise = EnterpriseApi::getOne($talent_info["enterprise_id"]);
 
-         if ($talent_info) {
 
-             $checkState = $talent_info["checkState"];
 
-             if ($this->user["isGeneral"] != 1) {
 
-                 return json(["msg" => "非总院账号,无法审核"]);
 
-             }
 
-             if ($this->user["medicalCommunityId"] != $enterprise["medicalCommunityId"]) {
 
-                 return json(["msg" => "不能审核其它非本医共体医院"]);
 
-             }
 
-             if ($checkState != TalentState::FST_SUBMIT) {
 
-                 return json(["msg" => "该申报不在审核范围内,无法审核"]);
 
-             }
 
-             $fields = DictApi::getTalentFields_WJ();
 
-             $field_tmp = [];
 
-             if ($fields) {
 
-                 foreach ($fields as $key => $field) {
 
-                     $field_tmp[] = ["key" => $key, "value" => $field];
 
-                 }
 
-             }
 
-             $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
 
-             $where = [];
 
-             $whr = [];
 
-             $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])->order("sn asc")->select();
 
-             } else {
 
-                 $files = \think\facade\Db::table("new_common_filetype")->where($where)->order("sn asc")->select();
 
-             }
 
-             $talent_info["files"] = array_filter(explode(",", $talent_info["modify_files"]));
 
-             $talent_info["fields"] = array_filter(explode(",", $talent_info["modify_fields"]));
 
-             /* 保存的审核内容start */
 
-             $last_log = TalentLogApi::getLastLog($id, ProjectState::TALENT, 0, ["active", "=", 0]);
 
-             $check = ["msg" => $last_log["description"]];
 
-             if ($last_log["state"] == TalentState::BASE_VERIFY_PASS) {
 
-                 $check["checkState"] = 3;
 
-             }
 
-             if ($last_log["new_state"] == TalentState::FST_SAVE && $last_log["state"] == TalentState::BASE_REJECT) {
 
-                 $check["checkState"] = 2;
 
-             }
 
-             /* 保存的审核内容end */
 
-             return json(["code" => 200, "obj" => ["talentInfo" => $talent_info, "check" => $check, "fieldList" => $field_tmp, "fileList" => $files]]);
 
-         }
 
-     }
 
- //    public function mixDelete() {
 
- //        $id = $this->request->param("talentInfoId");
 
- //        $info = TalentApi::chkIsOwner($id, $this->user["uid"]);
 
- //        if (!$info) {
 
- //            return json(["msg" => "操作失败"]);
 
- //        }
 
- //        $checkState = $info["checkState"];
 
- //        if (in_array($checkState, [0, TalentState::SCND_SAVE])) {
 
- //            $data["id"] = $id;
 
- //            $data["delete"] = 1;
 
- //            TalentModel::update($data);
 
- //            return json(["msg" => "删除成功"]);
 
- //        }
 
- //        return json(["msg" => "该申报已提交审核,无法删除"]);
 
- //    }
 
- }
 
 
  |