| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 | 
							- <?php
 
- namespace app\admin\controller;
 
- use app\admin\common\AdminController;
 
- use app\common\model\TalentQuit as TqModel;
 
- use app\common\api\DictApi;
 
- use app\common\state\MainState;
 
- use app\common\model\TalentLog;
 
- use app\common\state\ProjectState;
 
- use think\facade\Db;
 
- /**
 
-  * Description of TalentQuit
 
-  *
 
-  * @author sgq
 
-  */
 
- class TalentQuit extends AdminController {
 
-     public function index() {
 
-         return view("", ["type" => $this->user["type"]]);
 
-     }
 
-     public function list() {
 
-         $params = $this->request->param();
 
-         $offset = $params["offset"] ?: 0;
 
-         $order = $params["order"] ?: "desc";
 
-         $limit = $params["limit"] ?: 10;
 
-         $where = $this->setTalentQuit($params);
 
-         $where[] = ["type", "=", $this->user["type"]];
 
-         //获取字典表人才层次
 
-         $levelMap = DictApi::selectByParentCode("talent_arrange");
 
-         $typeMap = DictApi::selectByParentCode("enterprise_tag");
 
-         $count = TqModel::where($where)->count();
 
-         $list = TqModel::where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
 
-         foreach ($list as $key => $item) {
 
-             $list[$key]["talentArrangeName"] = $levelMap[$item["talentArrange"]];
 
-             $list[$key]["talentTypeName"] = $typeMap[$item["talentType"]];
 
-         }
 
-         return json(["rows" => $list, "total" => $count]);
 
-     }
 
-     public function check() {
 
-         $id = $this->request["id"];
 
-         $info = TqModel::where("id", $id)->find();
 
-         $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talentArrange"]];
 
-         if (\StrUtil::isNotEmpAndNull($info["talentType"])) {
 
-             $info["talentTypeName"] = DictApi::selectByParentCode("enterprise_tag")[$info["talentType"]];
 
-         }
 
-         return view("check", ["type" => $this->user["type"], "row" => $info]);
 
-     }
 
-     public function submitToCheck() {
 
-         $responseObj = new \stdClass();
 
-         $responseObj->code = 500;
 
-         $id = $this->request["id"];
 
-         $checkState = $this->request["checkState"];
 
-         $checkMsg = $this->request["checkMsg"];
 
-         $info = TqModel::where("id", $id)->find();
 
-         if (!$info) {
 
-             $responseObj->msg = "系统错误,请联系管理员";
 
-             return $responseObj;
 
-         }
 
-         if (!$checkState) {
 
-             $responseObj->msg = "请选择审核状态";
 
-             return $responseObj;
 
-         }
 
-         Db::startTrans();
 
-         try {
 
-             //添加日志
 
-             $user = $this->user;
 
-             $log["id"] = getStringId();
 
-             $log["active"] = 1;
 
-             $log["state"] = $checkState;
 
-             $log["step"] = 11;
 
-             $log["stateChange"] = MainState::getStateDesc($info["checkState"]) . "->" . MainState::getStateDesc($checkState);
 
-             $log["type"] = ProjectState::QUIT;
 
-             $log["mainId"] = $id;
 
-             $log["description"] = $checkMsg;
 
-             $log["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
 
-             $log["createTime"] = date("Y-m-d H:i:s");
 
-             $updTalentQuit["id"] = $id;
 
-             $updTalentQuit["checkState"] = $checkState;
 
-             $updTalentQuit["checkMsg"] = $checkMsg;
 
-             if ($checkState == 3) {
 
-                 //修改人才库信息
 
-                 $upd["id"] = $info["talentId"];
 
-                 $upd["active"] = 2;
 
-                 $upd["cur_quit_time"] = $info["quitTime"];
 
-                 Db::table("new_talent_info")->save($upd);
 
-                 $talentLog["id"] = getStringId();
 
-                 $talentLog["active"] = 1;
 
-                 $talentLog["step"] = 22;
 
-                 $talentLog["type"] = ProjectState::TALENT;
 
-                 $talentLog["mainId"] = $info["talentId"];
 
-                 $talentLog["description"] = "离职变更通过,同步到人才库";
 
-                 $talentLog["createUser"] = $user ? sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]) : "系统";
 
-                 $talentLog["createTime"] = date("Y-m-d H:i:s");
 
-                 Db::table("new_talent_checklog")->insert($talentLog);
 
-                 $updTalentQuit["passTime"] = date("Y-m-d H:i:s");
 
-             }
 
-             Db::table("new_talent_checklog")->insert($log);
 
-             Db::table("un_talent_quit")->save($updTalentQuit);
 
-             $responseObj->code = 200;
 
-             $responseObj->msg = "审核成功";
 
-             Db::commit();
 
-             return $responseObj;
 
-         } catch (\think\db\exception\DbException $e) {
 
-             $responseObj->msg = $e->getMessage();
 
-             Db::rollback();
 
-             return $responseObj;
 
-         }
 
-     }
 
-     private function setTalentQuit($talentQuitInfo) {
 
-         $where = [];
 
-         if (\StrUtil::isNotEmpAndNull($talentQuitInfo["talentName"])) {
 
-             $where[] = ["talentName", "=", $talentQuitInfo["talentName"]];
 
-         }
 
-         if (\StrUtil::isNotEmpAndNull($talentQuitInfo["idCard"])) {
 
-             $where[] = ["idCard", "=", $talentQuitInfo["IdCard"]];
 
-         }
 
-         if (\StrUtil::isNotEmpAndNull($talentQuitInfo["enterpriseName"])) {
 
-             $where[] = ["enterpriseName", "=", $talentQuitInfo["enterpriseName"]];
 
-         }
 
-         if (\StrUtil::isNotEmpAndNull($talentQuitInfo["talentArrange"])) {
 
-             $where[] = ["talentArrange", "=", $talentQuitInfo["talentArrange"]];
 
-         }
 
-         if ($talentQuitInfo["checkState"] != null) {
 
-             $where[] = ["checkState", "=", $talentQuitInfo["checkState"]];
 
-         }
 
-         return $where;
 
-     }
 
- }
 
 
  |