| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 | 
							- <?php
 
- namespace app\enterprise\controller;
 
- use app\enterprise\common\EnterpriseController;
 
- use app\common\model\TalentBasicChange as TbcModel;
 
- use app\common\api\TalentLogApi;
 
- use app\common\state\ProjectState;
 
- use app\common\model\TalentLog;
 
- use think\facade\Db;
 
- use app\common\api\EnterpriseApi;
 
- /**
 
-  * Description of TalentBasicChange
 
-  *
 
-  * @author sgq
 
-  */
 
- class TalentBasicChange extends EnterpriseController {
 
-     public function index() {
 
-         return view("", ["type" => $this->user["type"]]);
 
-     }
 
-     public function list() {
 
-         $type = $this->user["type"];
 
-         $params = \StrUtil::batchGetRequestDecodeParam($this->request);
 
-         $order = $params["order"] ?: "desc";
 
-         $offset = $params["offset"] ?: 0;
 
-         $limit = $params["limit"] ?: 10;
 
-         $where = [];
 
-         $where[] = ["enterpriseId", "=", $this->user["uid"]];
 
-         $where[] = ["delete", "=", 0];
 
-         if ($params["oldName"]) {
 
-             $where[] = ["oldName", "like", "%" . $params["oldName"] . "%"];
 
-         }
 
-         if ($params["oldCardType"]) {
 
-             $where[] = ["oldCardType", "=", $params["oldCardType"]];
 
-         }
 
-         if ($params["oldIdCard"]) {
 
-             $where[] = ["oldIdCard", "like", "%" . $params["oldIdCard"] . "%"];
 
-         }
 
-         if ($params["newName"]) {
 
-             $where[] = ["newName", "like", "%" . $params["newName"] . "%"];
 
-         }
 
-         if ($params["newCardType"]) {
 
-             $where[] = ["newCardType", "=", $params["newCardType"]];
 
-         }
 
-         if ($params["newIdCard"]) {
 
-             $where[] = ["newIdCard", "like", "%" . $params["newIdCard"] . "%"];
 
-         }
 
-         if ($params["checkState"]) {
 
-             $where[] = ["checkState", "=", $params["checkState"]];
 
-         }
 
-         $count = TbcModel::where($where)->count();
 
-         $list = TbcModel::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
 
-         $nationalityMap = \app\common\api\DictApi::selectByParentCode("nationality");
 
-         $nationMap = \app\common\api\DictApi::selectByParentCode("nation");
 
-         $politicalMap = \app\common\api\DictApi::selectByParentCode("politics");
 
-         $cardTypeMap = \app\common\api\DictApi::selectByParentCode("card_type");
 
-         foreach ($list as &$item) {
 
-             $item["oldNationalityName"] = $nationalityMap[$item["oldNationality"]];
 
-             $item["oldNationName"] = $nationMap[$item["oldNation"]];
 
-             $item["oldPoliticsName"] = $politicalMap[$item["oldPolitics"]];
 
-             $item["oldCardTypName"] = $cardTypeMap[$item["oldCardType"]];
 
-             $item["newNationalityName"] = $nationalityMap[$item["newNationality"]];
 
-             $item["newNationName"] = $nationMap[$item["newNation"]];
 
-             $item["newPoliticsName"] = $politicalMap[$item["newPolitics"]];
 
-             $item["newCardTypName"] = $cardTypeMap[$item["newCardType"]];
 
-         }unset($item);
 
-         return json(["total" => $count, "rows" => $list]);
 
-     }
 
-     public function apply() {
 
-         $request = $this->request;
 
-         $id = isset($request["id"]) ? $request["id"] : 0;
 
-         $info = TbcModel::where("id", $id)->find();
 
-         if ($this->request->isPost()) {
 
-             $response = new \stdClass();
 
-             $response->code = 500;
 
-             $data = $request->param();
 
-             $check = $this->dataCheck($data);
 
-             if ($check->code == 500) {
 
-                 return $check;
 
-             }
 
-             $talentInfo = \app\common\api\VerifyApi::getTalentInfoById($request["talentId"]);
 
-             if ($data["id"]) {
 
-                 unset($data["year"]);
 
-                 $data["updateUser"] = $this->user["uid"];
 
-                 $data["updateTime"] = date("Y-m-d H:i:s");
 
-                 TbcModel::update($data);
 
-                 $response->code = 200;
 
-                 $response->msg = "修改成功";
 
-                 return $response;
 
-             } else {
 
-                 $data["id"] = getStringId();
 
-                 $data["oldName"] = $talentInfo["name"];
 
-                 $data["oldNationality"] = $talentInfo["nationality"];
 
-                 $data["oldNation"] = $talentInfo["nation"];
 
-                 $data["oldPolitics"] = $talentInfo["politics"];
 
-                 $data["oldCardType"] = $talentInfo["card_type"];
 
-                 $data["oldIdCard"] = $talentInfo["card_number"];
 
-                 $data["oldBirthday"] = $talentInfo["birthday"];
 
-                 $data["oldEmail"] = $talentInfo["email"];
 
-                 $data["checkState"] = -1;
 
-                 $data["createUser"] = $this->user["uid"];
 
-                 $data["createTime"] = date("Y-m-d H:i:s");
 
-                 TbcModel::create($data);
 
-                 $user = $this->user;
 
-                 $log["id"] = getStringId();
 
-                 $log["active"] = 1;
 
-                 $log["state"] = 1;
 
-                 $log["step"] = 0;
 
-                 $log["stateChange"] = "";
 
-                 $log["type"] = ProjectState::BASICCHANGE;
 
-                 $log["mainId"] = $data["id"];
 
-                 $log["description"] = "添加人才基础信息变更申请";
 
-                 $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
 
-                 $log["createTime"] = date("Y-m-d H:i:s");
 
-                 TalentLog::create($log);
 
-                 $response->code = 200;
 
-                 $response->msg = "添加成功";
 
-                 $response->obj = $data;
 
-                 return $response;
 
-             }
 
-         }
 
-         $assigns = [];
 
-         if (!$info) {
 
-             $info["enterpriseId"] = $this->user["uid"];
 
-             $info["type"] = $this->user["type"];
 
-             $where = [];
 
-             $where[] = ["checkState", "<>", 3];
 
-             $changes = TbcModel::where($where)->select()->column("talentId");
 
-             unset($where);
 
-             $where[] = ["enterprise_id", "=", $this->user["uid"]];
 
-             $where[] = ["id", "not in", $changes];
 
-             $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
 
-             $list = \app\enterprise\model\Talent::where($where)->field("id,name")->select()->toArray();
 
-             $assigns["list"] = $list;
 
-         }
 
-         $assigns["type"] = $this->user["type"];
 
-         $assigns["row"] = $info;
 
-         return view("", $assigns);
 
-     }
 
-     public function view() {
 
-         $request = $this->request;
 
-         $id = isset($request["id"]) ? $request["id"] : 0;
 
-         $info = TbcModel::where("id", $id)->find();
 
-         return view("apply", ["row" => $info]);
 
-     }
 
-     public function submitToCheck() {
 
-         $response = new \stdClass();
 
-         $response->code = 500;
 
-         $id = $this->request["id"];
 
-         $info = TbcModel::where("id", $id)->find();
 
-         if (!$info) {
 
-             $response->msg = "提交审核失败,请先填写基础信息";
 
-             return $response;
 
-         }
 
-         if ($info["checkState"] != -1 && $info["checkState"] != 2) {
 
-             $response->msg = "不能重复提交审核";
 
-             return $response;
 
-         }
 
-         $check = $this->dataCheck($info);
 
-         if ($check->code == 500) {
 
-             return $check;
 
-         }
 
-         $where = [];
 
-         $where[] = ["type", "=", $info["type"]];
 
-         $where[] = ["project", "=", ProjectState::BASICCHANGE];
 
-         $where[] = ["active", "=", 1];
 
-         $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
 
-         foreach ($filetypes as $filetype) {
 
-             $sb = [];
 
-             $sb[] = "以下为必传附件:";
 
-             if ($filetype["must"] == 1) {
 
-                 $where = [];
 
-                 $where[] = ["mainId", "=", $id];
 
-                 $where[] = ["typeId", "=", $filetype["id"]];
 
-                 $count = Db::table("new_talent_file")->where($where)->count();
 
-                 if ($count == 0) {
 
-                     $sb[] = $filetype["name"] . ";";
 
-                 }
 
-             }
 
-         }
 
-         if (count($sb) > 1) {
 
-             $response->msg = implode("<br>", $sb);
 
-             return $response;
 
-         }
 
-         $data["id"] = $id;
 
-         if (\StrUtil::isEmpOrNull($info["firstSubmitTime"])) {
 
-             $data["firstSubmitTime"] = date("Y-m-d H:i:s");
 
-         }
 
-         $data["newSubmitTime"] = date("Y-m-d H:i:s");
 
-         $data["checkMsg"] = "";
 
-         $data["checkState"] = $info["checkState"] == 2 ? 9 : 1;
 
-         TbcModel::update($data);
 
-         $sb = [];
 
-         if ($info["checkState"] == -1) {
 
-             $sb[] = \app\common\state\MainState::getStateName(-2);
 
-         } else {
 
-             $sb[] = \app\common\state\MainState::getStateName(2);
 
-         }
 
-         if ($data["checkState"] == 1) {
 
-             $sb[] = \app\common\state\MainState::getStateName(1);
 
-         } else {
 
-             $sb[] = \app\common\state\MainState::getStateName(9);
 
-         }
 
-         $user = $this->user;
 
-         $log["id"] = getStringId();
 
-         $log["active"] = 1;
 
-         $log["state"] = 1;
 
-         $log["step"] = 0;
 
-         $log["stateChange"] = implode("->", $sb);
 
-         $log["type"] = ProjectState::BASICCHANGE;
 
-         $log["mainId"] = $id;
 
-         $log["description"] = "确认提交审核";
 
-         $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
 
-         $log["createTime"] = date("Y-m-d H:i:s");
 
-         TalentLog::create($log);
 
-         $response->code = 200;
 
-         $response->msg = "提交审核成功";
 
-         $response->obj = 1;
 
-         return $response;
 
-     }
 
-     public function delete() {
 
-         $response = new \stdClass();
 
-         $response->code = 500;
 
-         $info = TbcModel::where("id", $this->request["id"])->find();
 
-         if ($info["checkState"] != -1) {
 
-             $response->msg = "已提交审核,无法删除";
 
-             return $response;
 
-         }
 
-         $data["id"] = $info["id"];
 
-         $data["delete"] = 1;
 
-         $data["deleteTime"] = date("Y-m-d H:i:s");
 
-         TbcModel::update($data);
 
-         $response->code = 200;
 
-         $response->msg = "删除成功";
 
-         return $response;
 
-     }
 
-     private function dataCheck($data) {
 
-         $response = new \stdClass();
 
-         $response->code = 500;
 
-         if (\StrUtil::isEmpOrNull($data["newName"])) {
 
-             $response->msg = "现姓名不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newNationality"])) {
 
-             $response->msg = "现国籍不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newNation"])) {
 
-             $response->msg = "现民族不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newBirthday"])) {
 
-             $response->msg = "现出生日期不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newPolitics"])) {
 
-             $response->msg = "现政治面貌不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newCardType"])) {
 
-             $response->msg = "现证件类型不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newIdCard"])) {
 
-             $response->msg = "现证件号码不能为空";
 
-             return $response;
 
-         }
 
-         if (\StrUtil::isEmpOrNull($data["newEmail"])) {
 
-             $response->msg = "现电子邮箱不能为空";
 
-             return $response;
 
-         }        
 
-         if (!preg_match("/[\\w!#$%&'*+\/=?^_`{|}~-]+(?:\\.[\\w!#$%&'*+\/=?^_`{|}~-]+)*@(?:[\\w](?:[\\w-]*[\\w])?\\.)+[\\w](?:[\\w-]*[\\w])?/", $data["newEmail"])) {
 
-             $response->msg = "电子邮箱格式不正确";
 
-             return $response;
 
-         }
 
-         if ($data["newCardType"] == 1 && !\app\common\api\IdCardApi::isValid($data["newIdCard"])) {
 
-             $response->msg = "身份证号码不合法";
 
-             return $response;
 
-         }
 
-         if ($data["newCardType"] == 2 && !preg_match("/^[a-zA-Z0-9]{6,10}$/", $data["newIdCard"]) && !preg_match("/^([0-9]{8}|[0-9]{10})$/", $data["newIdCard"])) {
 
-             $response->msg = "通行证号码不合法";
 
-             return $response;
 
-         }
 
-         if ($data["newCardType"] == 3 && !preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $data["newIdCard"])) {
 
-             $response->msg = "护照格式不合法";
 
-             return $response;
 
-         }
 
-         $response->code = 200;
 
-         return $response;
 
-     }
 
- }
 
 
  |