123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- <?php
- namespace app\admin\controller;
- use app\admin\common\AdminController;
- use app\common\model\TalentBankChange as TbcModel;
- 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 TalentBankChange
- *
- * @author sgq
- */
- class TalentBankChange 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->setTalentBank($params);
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["delete", "=", 0];
- //获取字典表人才层次
- $levelMap = DictApi::selectByParentCode("talent_arrange");
- $count = TbcModel::where($where)->count();
- $list = TbcModel::where($where)->limit($offset, $limit)->order("createTime {$order}")->select()->toArray();
- foreach ($list as $key => $item) {
- $list[$key]["talentArrangeName"] = $levelMap[$item["talentArrange"]];
- }
- return json(["rows" => $list, "total" => $count]);
- }
- public function check() {
- $id = $this->request["id"];
- $info = TbcModel::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"]];
- }
- //查看是否有上传旧附件
- $_where = [["mainId", "=", $id]];
- $old_list = Db::table("un_talent_common_file")->where($_where)->find();
- $showOldFile = 0;
- if ($old_list) {
- $showOldFile = 1;
- }
- return view("check", ["type" => $this->user["type"], "row" => $info, "showOldFile" => $showOldFile]);
- }
- public function submitToCheck() {
- $responseObj = new \stdClass();
- $responseObj->code = 500;
- $id = $this->request["id"];
- $checkState = $this->request["checkState"];
- $checkMsg = $this->request["checkMsg"];
- $info = TbcModel::where("id", $id)->find();
- if (!$info) {
- $responseObj->msg = "系统错误,请联系管理员";
- return $responseObj;
- }
- if (strlen($info["talentId"]) == 19) {
- //旧系统申请兼容处理
- unset($where);
- $where[] = ["enterprise_id", "=", $info["enterpriseId"]];
- $where[] = ["card_number", "=", $info["idCard"]];
- $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
- $where[] = ["active", "=", 1];
- $where[] = ["delete", "=", 0];
- $ti = \app\enterprise\model\Talent::where($where)->order("createTime desc")->find();
- if (!$ti) {
- $responseObj->msg = "未匹配到人才数据";
- return $responseObj;
- }
- $info["talentId"] = $ti["id"];
- }
- 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::getStateName($info["checkState"]) . "->" . MainState::getStateName($checkState);
- $log["type"] = ProjectState::BANKCHANGE;
- $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");
- $updTalentBank["id"] = $id;
- $updTalentBank["checkState"] = $checkState;
- $updTalentBank["checkMsg"] = $checkMsg;
- if ($checkState == 3) {
- //修改人才库信息
- $upd["id"] = $info["talentId"];
- $upd["bank"] = $info["newBankName"];
- $upd["bank_number"] = $info["newBankNumber"];
- $upd["bank_branch_name"] = $info["newBankNerPoint"];
- $upd["bank_account"] = $info["newBankAccount"];
- Db::table("new_talent_info")->save($upd);
- //修改津补贴
- $updAllowance["bank"] = $info["newBankName"];
- $updAllowance["bankNumber"] = $info["newBankNumber"];
- $updAllowance["bankNetwork"] = $info["newBankNerPoint"];
- $updAllowance["bankAccount"] = $info["newBankAccount"];
- $where = [];
- $where[] = ["talentId", "=", $info["talentId"]];
- $where[] = ["publicState", "<=", 3];
- Db::table("un_talent_allowance_info")->where($where)->save($updAllowance);
- //修改购房补贴
- $updHousepurchase["bank"] = $info["newBankName"];
- $updHousepurchase["bankNumber"] = $info["newBankNumber"];
- $updHousepurchase["bankNetwork"] = $info["newBankNerPoint"];
- $updHousepurchase["bankAccount"] = $info["newBankAccount"];
- $where = [];
- $where[] = ["talentId", "=", $info["talentId"]];
- $where[] = ["publicState", "<=", 2];
- Db::table("un_housepurchase")->where($where)->save($updHousepurchase);
- $talentLog["id"] = getStringId();
- $talentLog["active"] = 1;
- $talentLog["step"] = 23;
- $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);
- $updTalentBank["passTime"] = date("Y-m-d H:i:s");
- }
- Db::table("new_talent_checklog")->insert($log);
- Db::table("un_talent_bank_change")->save($updTalentBank);
- $responseObj->code = 200;
- $responseObj->msg = "审核成功";
- Db::commit();
- return $responseObj;
- } catch (\think\db\exception\DbException $e) {
- $responseObj->msg = $e->getMessage();
- Db::rollback();
- return $responseObj;
- }
- }
- public function export() {
- $request = $this->request;
- $data["talentName"] = \StrUtil::getRequestDecodeParam($request, "talentName");
- $data["idCard"] = \StrUtil::getRequestDecodeParam($request, "idCard");
- $data["oldBankName"] = \StrUtil::getRequestDecodeParam($request, "oldBankName");
- $data["oldBankAccount"] = \StrUtil::getRequestDecodeParam($request, "oldBankAccount");
- $data["newBankName"] = \StrUtil::getRequestDecodeParam($request, "newBankName");
- $data["newBankAccount"] = \StrUtil::getRequestDecodeParam($request, "newBankAccount");
- $data["checkState"] = \StrUtil::getRequestDecodeParam($request, "checkState");
- $where = $this->setTalentBank($data);
- $where[] = ["type", "=", $this->user["type"]];
- $where[] = ["delete", "=", 0];
- $list = TbcModel::where($where)->select()->toArray();
- $levelMap = DictApi::selectByParentCode("talent_arrange");
- $title = ["姓名", "证件号码", "工作单位", "人才层次", "原开户银行", "原开户银行网点", "原银行账号", "原银行行号",
- "现开户银行", "现开户银行网点", "现银行账号", "现银行行号", "审核状态", "审核意见", "审核通过时间"];
- $keys = ["talentName", "idCard", "enterpriseName", "talentArrangeName", "oldBankName", "oldBankNerPoint", "oldBankAccount", "oldBankNumber",
- "newBankName", "newBankNerPoint", "newBankAccount", "newBankNumber", "checkStateName", "checkMsg", "passTime"];
- $rows = [];
- foreach ($list as &$item) {
- $item["talentArrangeName"] = $levelMap[$item["talentArrange"]];
- switch ($item["checkState"]) {
- case -1:
- $item["checkStateName"] = "待提交";
- break;
- case 1:
- $item["checkStateName"] = "待审核";
- break;
- case 2:
- $item["checkStateName"] = "审核驳回";
- break;
- case 3:
- $item["checkStateName"] = "已通过";
- break;
- case 9:
- $item["checkStateName"] = "重新提交";
- break;
- }
- $row = [];
- for ($i = 0; $i < count($keys); $i++) {
- $row[] = $item[$keys[$i]];
- }
- $rows[] = $row;
- }unset($item);
- if (!$rows) {
- return json(["msg" => "没有可导出的内容"]);
- }
- $fileName = "银行卡变更列表";
- export($title, $rows, $fileName);
- }
- private function setTalentBank($data) {
- $where = [];
- if (\StrUtil::isNotEmpAndNull($data["talentName"])) {
- $where[] = ["talentName", "=", $data["talentName"]];
- }
- if (\StrUtil::isNotEmpAndNull($data["idCard"])) {
- $where[] = ["idCard", "=", $data["IdCard"]];
- }
- if (\StrUtil::isNotEmpAndNull($data["oldBankName"])) {
- $where[] = ["oldBankName", "=", $data["oldBankName"]];
- }
- if (\StrUtil::isNotEmpAndNull($data["newBankName"])) {
- $where[] = ["newBankName", "=", $data["newBankName"]];
- }
- if (\StrUtil::isNotEmpAndNull($data["oldBankAccount"])) {
- $where[] = ["oldBankAccount", "=", $data["oldBankAccount"]];
- }
- if (\StrUtil::isNotEmpAndNull($data["newBankAccount"])) {
- $where[] = ["newBankAccount", "=", $data["newBankAccount"]];
- }
- if ($data["checkState"] != null) {
- $where[] = ["checkState", "=", $data["checkState"]];
- }
- return $where;
- }
- }
|