1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132 |
- <?php
- namespace app\common\controller;
- use app\BaseController;
- use app\common\api\EnterpriseApi;
- use app\common\middleware\Auth;
- use app\common\model\TalentChecklog;
- use app\common\validate\Enterprise;
- use think\exception\ValidateException;
- use think\facade\Db;
- use app\enterprise\api\TalentApi;
- use app\common\api\TalentLogApi;
- use app\common\api\DictApi;
- use app\common\model\CurrentcyFileType;
- use app\common\model\TalentCommonFile;
- use app\common\api\UploadApi;
- use app\common\api\TalentConditionApi;
- use app\common\api\CompanyApi;
- use app\common\api\TalentState;
- use app\common\state\ProjectState;
- use app\common\state\IntegralState;
- /**
- * 需要权限的公共方法放这
- * Description of Tool
- *
- * @author sgq
- */
- class Api extends BaseController {
- protected $middleware = [Auth::class];
- protected $user;
- public function __construct(\think\App $app) {
- parent::__construct($app);
- $this->user = session("user");
- }
- public function findIdentifyConditionByLevel() {
- $params = $this->request->param();
- $id = $params["id"];
- $type = $this->user["type"];
- $showAll = $params["showAll"] == 1 ? true : false;
- if ($id) {
- $talentInfo = TalentApi::getOne($id);
- $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
- $type = $enterprise["type"];
- }
- $list = TalentConditionApi::getList($params["level"], $type, $params["cat"], $showAll);
- return json($list, 200);
- }
- public function getTalentCondtionUploadFile() {
- $param = $this->request->param();
- $id = $param["mainId"];
- $order = $param["order"];
- $project = $param["project"];
- $type = $param["type"];
- $talent_condition = $param["talent_condition"];
- $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
- if (!$condition_info["bindFileTypes"])
- return json(["rows" => null]);
- $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
- $whr[] = ["active", "=", 1];
- $whr[] = ["delete", "=", 0];
- $rows = Db::table("new_common_filetype")->where($whr)->order("sn " . $order)->select()->toArray();
- if ($id) {
- foreach ($rows as $key => $row) {
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["typeId", "=", $row["id"]];
- $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
- foreach ($files as &$file) {
- $file["ext"] = pathinfo($file["url"])["extension"];
- $file["url"] = getStoragePath($file["url"]);
- }
- $rows[$key]["files"] = $files;
- }
- }
- return json(["rows" => $rows, "info" => $condition_info]);
- }
- public function getCheckLog() {
- $userType = session("user")["usertype"];
- $params = $this->request->param();
- $mainId = $params["mainId"];
- $enterpriseId = $params["enterpriseId"];
- $category = $params["category"];
- $type = $params["type"];
- $list = [];
- switch ($type) {
- case 1:
- $talentInfo = TalentApi::getOne($mainId);
- $talent_condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
- case 2:
- case 3:
- case 4:
- case 6:
- case 7:
- case 8:
- case 9:
- case 19:
- case 20:
- $list = TalentLogApi::getList($type, $mainId);
- break;
- case 10:
- if ($enterpriseId) {
- $where[] = ["mainId", "=", $enterpriseId];
- $ids = \app\enterprise\model\EnterpriseRecord::where($where)->column("id");
- $ids[] = $enterpriseId;
- $where = [];
- $where[] = ["type", "=", $type];
- $where[] = ["active", "=", 1];
- $where[] = ["mainId", "in", $ids];
- $list = TalentChecklog::where($where)->order("createTime desc")->select();
- } else {
- $list = TalentLogApi::getList($type, $mainId);
- }
- break;
- }
- $new_list = [];
- foreach ($list as $key => $item) {
- if (($item["createUser"] == "系统" || $item["updateUser"] == "系统") && $userType != 1)//非管理员用户不显示系统自动生成或修改的日志
- continue;
- $new_item["description"] = $item["description"];
- switch ($item['type']) {
- case 2:
- case 3:
- case 4:
- case 6:
- case 7:
- case 8:
- case 9:
- case 19:
- $new_item["stateName"] = \app\common\state\LivingAllowanceState::getStateName($item["state"]);
- $new_item["stepName"] = \app\common\state\LivingAllowanceState::getStepName($item["step"]);
- $new_item["stateChange"] = $item["stateChange"];
- break;
- case 20:
- $new_item["stepName"] = IntegralState::getLogStepName($item["state"]);
- $new_item["stateName"] = IntegralState::getLogStateName($item["state"], $item["last_state"]);
- if ($item["last_state"] && $item["new_state"]) {
- $new_item["stateChange"] = sprintf("%s -> %s", IntegralState::getLogChangeName($item["last_state"]), IntegralState::getLogChangeName($item["new_state"], $item["last_state"]));
- } else {
- $new_item["stateChange"] = "";
- }
- break;
- case 10:
- if ($item["category"] == "enterprise_change") {
- switch ($item['step']) {
- case 100:
- $new_item["stepName"] = "<span class='label'>用户操作</span>";
- break;
- case 101:
- $new_item["stepName"] = "<span class='label label-primary'>审核</span>";
- break;
- case 102:
- $new_item["stepName"] = "<span class='label label-danger'>设置冻结</span>";
- break;
- case 103:
- $new_item["stepName"] = "<span class='label label-info'>重置密码</span>";
- break;
- }
- if ($category == "close_account") {
- $new_item["stateName"] = \app\common\state\MainState::getStateName($item['state']);
- } else {
- switch ($item['state']) {
- case 1:
- if ($item["stateChange"]) {
- $new_item["stateName"] = "<span class='label label-success'>待提交</span>";
- } else {
- $item['stateChange'] = "修改密码";
- }
- break;
- case 2:
- $new_item["stateName"] = "<span class='label label-success'>待审核</span>";
- break;
- case 3:
- $new_item["stateName"] = "<span class='label label-danger'>审核驳回</span>";
- break;
- case 4:
- $new_item["stateName"] = "<span class='label label-primary'>审核通过</span>";
- break;
- case 5:
- $new_item["stateName"] = "<span class='label label-warm'>重新提交</span>";
- break;
- case 6:
- $new_item["stateName"] = "<span class='label label-danger'>初审驳回</span>";
- break;
- case 7:
- $new_item["stateName"] = "<span class='label label-primary'>初审通过</span>";
- break;
- }
- }
- $new_item["stateChange"] = $item['stateChange'];
- } else {
- switch ($item['step']) {
- case 100:
- $new_item["stepName"] = "<span class='label'>用户操作</span>";
- break;
- case 101:
- $new_item["stepName"] = "<span class='label label-primary'>注册审核</span>";
- break;
- case 102:
- $new_item["stepName"] = "<span class='label label-danger'>设置冻结</span>";
- break;
- case 103:
- $new_item["stepName"] = "<span class='label label-info'>重置密码</span>";
- break;
- }
- switch ($item['state']) {
- case 1:
- $new_item["stateName"] = "<span class='label label-success'>待审核</span>";
- break;
- case 2:
- $new_item["stateName"] = "<span class='label label-danger'>审核驳回</span>";
- break;
- case 3:
- $new_item["stateName"] = "<span class='label label-primary'>审核通过</span>";
- break;
- case 4:
- $new_item["stateName"] = "<span class='label label-primary'>重新提交</span>";
- break;
- case 5:
- $new_item["stateName"] = "<span class='label label-danger'>初审驳回</span>";
- break;
- case 6:
- $new_item["stateName"] = "<span class='label label-primary'>初审通过</span>";
- break;
- default:
- break;
- }
- $new_item["stateChange"] = $item['stateChange'];
- }
- break;
- case 1:
- if ($item["step"] && $item["step"] != 3) {
- $new_item["stepName"] = \app\common\state\LivingAllowanceState::getStepName($item["step"]);
- } else {
- $new_item["stepName"] = DictApi::getCheckLogStepName($item["state"], $item["step"]);
- }
- if (in_array($item["state"], [TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
- $new_item["stateName"] = '<span class="label label-danger">审核不通过</span>';
- } else if (in_array($item["state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
- if ($item["step"] == 3) {
- if ($item["new_state"] == TalentState::SCND_SUBMIT) {
- $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
- } else if ($item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
- $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
- } else {
- $new_item["stateName"] = '<span class="label label-success">待审核</span>';
- }
- if ($item["active"] === 0 && !in_array($item["companyId"], explode(",", $talent_condition["companyIds"]))) {
- $new_item["stateName"] = '<span class="label">已废弃</span>';
- }
- } else {
- $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
- }
- } else if (in_array($item["state"], [TalentState::BASE_REJECT, TalentState::BASE_REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT])) {
- $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
- } else if (in_array($item["state"], [TalentState::ZX_PASS, TalentState::ANNOUNCED, TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS, TalentState::CERTIFICATED])) {
- $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
- } else if (in_array($item["state"], [TalentState::FST_SAVE, TalentState::SCND_SAVE])) {
- $new_item["stateName"] = '<span class="label">保存未提交</span>';
- } else if (in_array($item["state"], [TalentState::REVERIFY_CANCEL])) {
- $new_item["stateName"] = '<span class="label label-primary">撤销审核</span>';
- } else if (!$item["state"]) {
- if ($item["typeFileId"]) {
- $new_item["stateName"] = '<span class="label">添加附件</span>';
- }
- } else {
- if (($item["last_state"] == TalentState::BASE_REJECT && $item["state"] == TalentState::FST_SUBMIT) || ($item["last_state"] == TalentState::FST_VERIFY_REJECT && $item["state"] == TalentState::SCND_SUBMIT)) {
- $new_item["stateName"] = '<span class="label label-success">待审核(重新提交)</span>';
- } else {
- $new_item["stateName"] = '<span class="label label-success">待审核</span>';
- }
- }
- if ($item["step"] == 3) {
- $company = CompanyApi::getOne($item["companyId"]);
- if ($item["active"] == 0) {
- $new_item["description"] = "等待部门审核";
- $new_item["stateChange"] = str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"]));
- } else {
- $new_item["stateChange"] = sprintf("%s -> %s", str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"])), DictApi::getTalentInfoStateName($item["new_state"], $item["step"]));
- }
- } else {
- if ($item["last_state"] && $item["new_state"]) {
- $new_item["stateChange"] = sprintf("%s -> %s", DictApi::getTalentInfoStateName($item["last_state"], $list[$key + 1]["step"]), DictApi::getTalentInfoStateName($item["new_state"], $list[$key - 1]["step"], $item["last_state"]));
- } else {
- $new_item["stateChange"] = $item["stateChange"] ?: "";
- }
- }
- break;
- }
- $new_item["createUser"] = $item["updateUser"] && strpos($item["updateUser"], "企业用户") === false ? $item["updateUser"] : $item["createUser"]; //$item["updateUser"] ?: $item["createUser"];
- if ($new_item["createUser"] != "用户") {
- list($name, $company) = explode("(", $new_item["createUser"]);
- $where = [];
- $where[] = ["name", "=", $name];
- $user = \app\admin\model\User::where($where)->find();
- if ($user) {
- $new_item["createUser"] = implode("(", [$user["account"], $company]);
- }
- }
- $new_item["createTime"] = $item["updateTime"] ?: $item["createTime"];
- $new_list[] = $new_item;
- }
- if ($type == ProjectState::TALENT) {
- if ($talentInfo["oldId"]) {
- $where = [];
- $where[] = ["mainId", "=", $talentInfo["oldId"]];
- $where[] = ["type", "=", ProjectState::TALENT];
- $before_list = Db::table("un_talent_checklog")->where($where)->order("createTime desc")->select();
- foreach ($before_list as $before_item) {
- $new_list[] = [
- "stepName" => DictApi::getOldStepNameByStep($before_item["step"]),
- "stateName" => DictApi::getOldStateNameByState($before_item["state"]),
- "stateChange" => $before_item["stateChange"],
- "description" => $before_item["description"],
- "createUser" => $before_item["createUser"],
- "createTime" => $before_item["createTime"]
- ];
- }
- }
- }
- if ($type == ProjectState::LEVELCHANGE) {
- $where = [];
- $where[] = ["mainId", "=", $mainId];
- $where[] = ["type", "=", ProjectState::LEVELCHANGE];
- $before_list = Db::table("un_talent_checklog")->where($where)->order("createTime desc")->select();
- foreach ($before_list as $before_item) {
- $new_list[] = [
- "stepName" => DictApi::getOldStepNameByStep($before_item["step"]),
- "stateName" => DictApi::getOldStateNameByState($before_item["state"]),
- "stateChange" => $before_item["stateChange"],
- "description" => $before_item["description"],
- "createUser" => $before_item["createUser"],
- "createTime" => $before_item["createTime"]
- ];
- }
- }
- return json(["rows" => $new_list]);
- }
- public function getJbtCheckLog() {
- $obj = $this->request->param();
- $where = [];
- if ($obj["type"] != null) {
- $where[] = ["type", "=", $obj["type"]];
- }if (\StrUtil::isNotEmpAndNull($obj["mainId"])) {
- $where[] = ["mainId", "=", $obj["mainId"]];
- }
- if (\StrUtil::isNotEmpAndNull($obj["typeFileId"])) {
- $where[] = ["typeFileId", "=", $obj["typeFileId"]];
- } else {
- $where[] = ["typeFileId", "EXP", Db::raw("is null")];
- }
- if ($obj["active"] != null) {
- $where[] = ["active", "=", $obj["active"]];
- }
- $list = TalentChecklog::where($where)->select()->order("createTime desc")->toArray();
- foreach ($list as &$log) {
- $log["stateName"] = \app\common\state\AllowanceStateEnum::getStateName($log["state"]);
- $log["stepName"] = \app\common\state\AllowanceStepEnum::getStepName($log["step"]);
- }unset($log);
- $res = [
- "rows" => $list,
- "total" => count($list)
- ];
- return json($res);
- }
- public function findCommonFileType() {
- $param = $this->request->param();
- $id = $param["mainId"];
- $source = $param["source"];
- $order = $param["order"];
- $project = $param["project"];
- $type = $param["type"];
- $checkState = $param["checkState"];
- $isMix = $param["isMix"] ?: 0;
- $talent_condition = $param["talent_condition"];
- $token = $param["pageToken"];
- $where[] = ["project", "=", $project];
- $where[] = ["active", "=", 1];
- $where[] = ["delete", "=", 0];
- $where[] = ["type", "=", $type];
- switch ($project) {
- case 2:
- $where[] = ["isConditionFile", "in", [0, $param["allowanceType"]]];
- break;
- case 1:
- case 8:
- //if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, 0, TalentState::FST_SAVE, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS]) && $isMix != 1) {
- //$where[] = ["step", "=", 1]; //只查找人才第一步所需文件
- //} else {
- $where[] = ["isConditionFile", "<>", 1]; //排除人才条件上传文件
- //}
- if (($talent_condition && in_array($source, [3, 4, 5])) || $type == \app\common\state\CommonConst::ENTERPRISE_WJ || $type == \app\common\state\CommonConst::ENTERPRISE_GJ) {
- $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
- if ($condition_info["bindFileTypes"]) {
- $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
- }
- }
- break;
- case 20:
- //积分申报的附件需要特殊处理
- $newList = [];
- $_where = $where;
- $_where[] = ["isConditionFile", "=", 1];
- $fileTypes = Db::table("new_common_filetype")->where($_where)->order("must asc")->order("sn " . $order)->select()->toArray();
- foreach ($fileTypes as $k => $ft) {
- $_whr = [];
- if ($id) {
- $_whr[] = ["mainId", "=", $id];
- } else {
- $_whr[] = ["description", "=", $token];
- }
- $_whr[] = ["relationId", "=", 0];
- $_whr[] = ["typeId", "=", $ft["id"]];
- $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
- foreach ($files as $n => $file) {
- $files[$n]["ext"] = pathinfo($file["url"])["extension"];
- $files[$n]["url"] = getStoragePath($file["url"]);
- }
- $fileTypes[$k]["files"] = $files;
- }
- $newList[] = [
- "id" => 0,
- "name" => "公共附件",
- "fileTypes" => $fileTypes
- ];
- $itemIds = $param["itemId"];
- $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
- if ($itemIds) {
- foreach ($itemIds as $key => $item_id) {
- $integral_item = json_decode($redis->hGet("IntegralItem", $item_id), true);
- if ($integral_item["fileTypeId"]) {
- $typeIds = array_filter(explode(",", $integral_item["fileTypeId"]));
- $whr = $where;
- $whr[] = ["id", "in", $typeIds];
- $whr[] = ["isConditionFile", "=", 0];
- $fileTypes = Db::table("new_common_filetype")->where($whr)->order("must asc")->order("sn " . $order)->select()->toArray();
- foreach ($fileTypes as $k => $ft) {
- $_whr = [];
- if ($id) {
- $_whr[] = ["mainId", "=", $id];
- } else {
- $_whr[] = ["description", "=", $token];
- }
- $_whr[] = ["relationId", "=", $item_id];
- $_whr[] = ["typeId", "=", $ft["id"]];
- $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
- foreach ($files as $n => $file) {
- $files[$n]["ext"] = pathinfo($file["url"])["extension"];
- $files[$n]["url"] = getStoragePath($file["url"]);
- }
- $fileTypes[$k]["files"] = $files;
- }
- $newList[] = [
- "id" => $integral_item["id"],
- "name" => $integral_item["name"],
- "fileTypes" => $fileTypes
- ];
- }
- }
- }
- return json(["rows" => $newList]);
- break;
- }
- if ($whr) {
- $rows = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("must asc")->order("sn " . $order)->select()->toArray();
- } else {
- $rows = Db::table("new_common_filetype")->where($where)->order("must asc")->order("sn " . $order)->select()->toArray();
- }
- if ($id) {
- foreach ($rows as $key => $row) {
- $where = [];
- $where[] = ["mainId", "=", $id];
- $where[] = ["typeId", "=", $row["id"]];
- $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
- foreach ($files as &$file) {
- $file["ext"] = pathinfo($file["url"])["extension"];
- $file["url"] = getStoragePath($file["url"]);
- }
- $rows[$key]["files"] = $files;
- }
- }
- $old_types = [];
- if ($project == ProjectState::LEVELCHANGE) {
- $where = [];
- $where[] = ["type", "=", $type];
- $where[] = ["project", "=", $project];
- $where[] = ["active", "=", 1];
- //$old_types = Db::table("un_common_filetype")->where($where)->order("must")->order("sn")->select()->toArray();
- }
- if ($old_types) {
- $rows = array_merge($rows, $old_types);
- }
- return json(["rows" => $rows, "old_types" => $old_types]);
- }
- public function listTalentFile() {
- $param = $this->request->param();
- $mainId = $param["mainId"];
- $typeId = $param["fileTypeId"];
- $where = [["mainId", "=", $mainId], ["typeId", "=", $typeId]];
- $list = Db::table("new_talent_file")->where($where)->select()->toArray();
- $_where = [["mainId", "=", $mainId], ["fileTypeId", "=", $typeId]];
- $old_list = Db::table("un_talent_file")->where($_where)->select()->toArray();
- if ($old_list) {
- $list = array_merge($list, $old_list);
- }
- foreach ($list as $key => $item) {
- $list[$key]["ext"] = pathinfo($item["url"])["extension"];
- $list[$key]["url"] = getStoragePath($item["url"]);
- }
- return json($list);
- }
- public function listNonPredefinedFiles() {
- $param = $this->request->param();
- $memo = $param["batch"];
- $fileTag = $param["fileTag"];
- $where = [["fileTag", "=", $fileTag], ["memo", "=", $memo]];
- $list = Db::table("new_non_predefined_file")->where($where)->select()->toArray();
- foreach ($list as $key => $item) {
- $list[$key]["ext"] = pathinfo($item["url"])["extension"];
- $list[$key]["url"] = getStoragePath($item["url"]);
- }
- return json(["rows" => $list]);
- }
- public function listTalentAllowanceCommonFile() {
- $param = $this->request->param();
- $id = $param["id"];
- $info = \app\common\api\TalentAllowanceApi::getInfoById($id);
- $list = [];
- if ($info) {
- $where = [["batch", "=", $info["year"]], ["enterpriseId", "=", $info["enterpriseId"]]];
- $list = Db::table("un_talent_allowance_common_file")->where($where)->select()->toArray();
- foreach ($list as $key => $item) {
- $list[$key]["ext"] = pathinfo($item["url"])["extension"];
- $list[$key]["url"] = getStoragePath($item["url"]);
- }
- }
- return json(["rows" => $list]);
- }
- public function addTalentFile() {
- $backName = $this->request->param("backName");
- $fileId = $this->request->param("fileId");
- $mainId = $this->request->param("mainId");
- $fileTypeId = $this->request->param("fileTypeId");
- $relationId = $this->request->param("relationId");
- $pageToken = $this->request->param("pageToken");
- $index = $this->request->param("index");
- $type = $this->request->param("type");
- $upload = new \app\common\api\UploadApi();
- $file = $this->request->file("fileUrl");
- $isFileEditable = false;
- switch ($type) {
- case ProjectState::INTEGRAL:
- $isFileEditable = \app\common\api\IntegralRecordApi::checkIsEditable($mainId);
- break;
- default:
- $isFileEditable = TalentApi::checkIsEditable($mainId);
- break;
- }
- if (!$isFileEditable) {
- $res = ["msg" => "当前状态不能修改附件", "obj" => $index];
- echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
- exit();
- }
- $mime = $file->getMime();
- switch ($mime) {
- case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"://xlsx
- case "application/pdf"://pdf
- case "application/vnd.ms-excel"://xls
- $filestd = $upload->uploadOne($file, "file", "talent_files");
- break;
- case "image/jpg":
- case "image/jpeg":
- case "image/png":
- case "image/gif":
- $filestd = $upload->uploadOne($file, "image", "talent_files");
- break;
- default:
- $res = ["msg" => "不支持的附件类型", "obj" => $index];
- echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
- exit();
- break;
- }
- $change = false;
- if ($fileId) {
- if (!$this->chkIsFileOwner($mainId, $type)) {
- $res = ["msg" => "删除失败", "obj" => $index];
- echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
- exit();
- }
- $old = Db::table("new_talent_file")->findOrEmpty($fileId);
- $old_filepath = "storage/" . $old["url"];
- if (file_exists($old_filepath))
- unlink($old_filepath);
- $data["id"] = $fileId;
- $change = true;
- }
- $data["mainId"] = $mainId;
- $data["relationId"] = $relationId;
- $data["description"] = $pageToken;
- $data["type"] = $type;
- $data["typeId"] = $fileTypeId;
- $data["orignName"] = $file->getOriginalName();
- $data["url"] = $filestd->filepath;
- $data["sn"] = $index;
- $data["createTime"] = date("Y-m-d H:i:s");
- if ($fileId) {
- Db::table("new_talent_file")->save($data);
- } else {
- $fileId = Db::table("new_talent_file")->insertGetId($data);
- }
- $ext = pathinfo($filestd->filepath)["extension"];
- TalentLogApi::write($type, $mainId, 0, sprintf("%s附件,附件名为:%s", $change ? "修改" : "添加", $data["orignName"]), 1, $fileTypeId, $fileId);
- $res = ["code" => 200, "msg" => "上传附件成功", "obj" => $index, "ext" => $ext, "info" => getStoragePath($filestd->filepath), "typeId" => $fileTypeId, "id" => $fileId, "orignName" => $data["orignName"]];
- echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
- }
- public function deleteFile() {
- $param = $this->request->param();
- $where = [["id", "=", $param["id"]]];
- $file = Db::table("new_talent_file")->where($where)->findOrEmpty();
- if (!TalentApi::checkIsEditable($file["mainId"]))
- return json(["msg" => "当前状态不能删除或者文件已删除,请刷新重试。"]);
- if ($this->chkIsFileOwner($file["mainId"], $file["type"])) {
- if (!empty($file["url"])) {
- $filepath = "storage/" . $file["url"];
- if (file_exists($filepath)) {
- unlink($filepath);
- }
- }
- Db::table("new_talent_file")->delete($file["id"]);
- TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
- return json(["code" => 200, "msg" => "删除成功"]);
- }
- return json(["msg" => "不能删除"]);
- }
- public function deleteTalentCommonFile() {
- $param = $this->request->param();
- $where = [["id", "=", $param["id"]]];
- $file = Db::table("new_talent_common_file")->where($where)->findOrEmpty();
- $filepath = "storage/" . $file["url"];
- if (file_exists($filepath)) {
- unlink($filepath);
- }
- Db::table("new_talent_common_file")->delete($file["id"]);
- //TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
- return json(["code" => 200, "msg" => "删除成功"]);
- return json(["msg" => "不能删除"]);
- }
- public function deleteNonPredefinedFile() {
- $param = $this->request->param();
- $where = [["id", "=", $param["id"]]];
- $file = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
- $filepath = "storage/" . $file["url"];
- if (file_exists($filepath) && $file["url"]) {
- @unlink($filepath);
- }
- Db::table("new_non_predefined_file")->delete($file["id"]);
- return json(["code" => 200, "msg" => "删除成功"]);
- }
- /**
- * 下载文件
- */
- public function downloadFile() {
- $param = $this->request->param();
- $type = $param["type"];
- $id = $param["id"];
- $where = [];
- $where[] = ["id", "=", $id];
- $url = "";
- switch ($type) {
- case 1:
- case 8:
- case 19:
- $fileinfo = Db::table("new_talent_file")->where($where)->findOrEmpty();
- $filename = $fileinfo["orignName"];
- $url = $fileinfo["url"];
- break;
- case 2:
- $fileinfo = Db::table("new_talent_common_file")->where($where)->findOrEmpty();
- $filename = $fileinfo["orignName"];
- $url = $fileinfo["url"];
- break;
- case 3:
- $fileinfo = Db::table("new_currency_filetype")->where($where)->findOrEmpty();
- $filename = $fileinfo["templateUrl"];
- $url = $fileinfo["templateUrl"];
- break;
- case 4:
- $fileinfo = Db::table("sys_common_file")->where($where)->findOrEmpty();
- $filename = $fileinfo["orignName"];
- $url = $fileinfo["url"];
- break;
- case 5:
- $fileinfo = Db::table("new_common_filetype")->where($where)->findOrEmpty();
- $filename = $fileinfo["templateUrl"];
- $url = $fileinfo["templateUrl"];
- break;
- case 6://预定义外的文件类型下载
- $fileinfo = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
- $filename = $fileinfo["originalName"];
- $url = $fileinfo["url"];
- break;
- }
- $filepath = "storage/" . $url; // 下载文件名
- if (!file_exists($filepath)) {
- header('HTTP/1.1 404 NOT FOUND');
- } else {
- $file = fopen($filepath, "rb");
- Header("Content-type: application/octet-stream");
- Header("Accept-Ranges: bytes");
- Header("Accept-Length: " . filesize($filepath));
- Header("Content-Disposition: attachment; filename=" . $filename);
- echo fread($file, filesize($filepath));
- fclose($file);
- exit();
- }
- }
- /**
- * 打包下载人才申请附件
- */
- public function downloadZip() {
- $table = "new_talent_file";
- $param = $this->request->param();
- $type = $param["type"];
- $id = $param["id"];
- $where = [];
- switch ($type) {
- case ProjectState::TALENT:
- $where[] = ["type", "=", $type];
- $talent_info = \app\enterprise\model\Talent::findOrEmpty($id);
- $enterprise_info = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
- $zip_filename = sprintf("%s(%s)人才申报材料.zip", $talent_info["name"], $enterprise_info["name"]);
- break;
- case ProjectState::QUIT:
- $table = "new_talent_common_file";
- $info = \app\common\model\TalentQuit::findOrEmpty($id);
- $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
- $zip_filename = sprintf("%s(%s)离职材料.zip", $info["talentName"], $enterprise_info["name"]);
- break;
- case ProjectState::WORKCHANGE:
- $table = "new_talent_common_file";
- $info = \app\common\model\TalentWorkUnitChange::findOrEmpty($id);
- $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
- $zip_filename = sprintf("%s(%s)工作单位变更材料.zip", $info["talentName"], $enterprise_info["name"]);
- break;
- case ProjectState::LEVELCHANGE:
- $info = \app\enterprise\model\TalentTypeChange::findOrEmpty($id);
- $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
- $zip_filename = sprintf("%s(%s)人才层次变更材料.zip", $info["talentName"], $enterprise_info["name"]);
- break;
- case ProjectState::INTEGRAL:
- $where[] = ["type", "=", $type];
- $record = \app\common\api\IntegralRecordApi::getOne($id);
- $zip_filename = sprintf("%s(%s)积分申报材料.zip", $record["name"], $record["enterprise"]["name"]);
- break;
- case 109:
- $table = "un_enterpriseclose_record";
- $record = \app\common\model\EnterpriseCloseAccount::where("id", $id)->find();
- $zip_filename = sprintf("%s(%s)注销申请材料.zip", $record["name"], $record["username"]);
- $files = json_decode($record["files"], true);
- break;
- }
- $where[] = ["mainId", "=", $id];
- if (!$files)
- $files = Db::table($table)->where($where)->select()->toArray();
- if (!$files) {
- //die("没有附件不能打包下载");
- echo "<script>parent.layer.alert('没有附件不能打包下载');window.history.go(-1);</script>";
- }
- $tmp_path = "storage/temp/";
- $tmp_file_path = $tmp_path . $zip_filename;
- if (!file_exists($tmp_path)) {
- mkdir($tmp_path);
- }
- $zip = new \ZipArchive();
- if (!$zip->open($tmp_file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
- header('HTTP/1.1 404 NOT FOUND');
- }
- foreach ($files as $file) {
- if (is_array($file)) {
- $filepath = "storage/" . $file["url"];
- $fileTypeInfo = Db::table("new_common_filetype")->where("id", $file["typeId"])->find();
- $filename = $fileTypeInfo["name"] . "/" . $file["orignName"];
- $zip->addFile($filepath, $filename);
- } else {
- $filepath = "storage/" . $file;
- $filename = basename($filepath);
- $zip->addFile($filepath, $filename);
- }
- }
- $zip->close();
- if (file_exists($tmp_file_path)) {
- header("Cache-Control: public");
- header("Content-Description: File Transfer");
- header('Content-disposition: attachment; filename=' . $zip_filename); //文件名
- header("Content-Type: application/octet-stream;charset=utf-8"); //zip格式的
- header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
- header('Content-Length: ' . filesize($tmp_file_path)); //告诉浏览器,文件大小
- @readfile($tmp_file_path);
- }
- //删除临时文件
- @unlink($tmp_file_path);
- }
- private function chkIsFileOwner($mainId, $type) {
- if (!$mainId)
- return true;
- switch ($type) {
- case ProjectState::TALENT:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $talent_info = Db::table("new_talent_info")->findOrEmpty($mainId);
- if ($user_id == $talent_info["enterprise_id"])
- return true;
- }
- break;
- case ProjectState::JBT:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $talent_info = \app\common\model\TalentAllowance::findOrEmpty($mainId);
- if ($user_id == $talent_info["enterpriseId"])
- return true;
- }
- break;
- case ProjectState::EDUCATION:
- if ($this->user["usertype"] == 3) {
- $user_id = $this->user["uid"];
- $talent_info = \app\common\model\EducationSchool::findOrEmpty($mainId);
- if ($user_id == $talent_info["personId"])
- return true;
- }
- break;
- case ProjectState::LEVELCHANGE:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $talent_info = \app\enterprise\model\TalentTypeChange::findOrEmpty($mainId);
- if ($user_id == $talent_info["enterpriseId"])
- return true;
- }
- break;
- case ProjectState::LIVINGALLOWANCE:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $record = Db::table("md_living_allowance_info")->findOrEmpty($mainId);
- if ($user_id == $record["enterpriseId"])
- return true;
- }
- break;
- case ProjectState::INTEGRAL:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $record = Db::table("new_integral_record")->findOrEmpty($mainId);
- if ($user_id == $record["enterprise_id"])
- return true;
- }
- break;
- case ProjectState::BASICCHANGE:
- if ($this->user["usertype"] == 2) {
- $user_id = $this->user["uid"];
- $record = Db::table("un_talent_basic_change")->findOrEmpty($mainId);
- if ($user_id == $record["enterpriseId"])
- return true;
- }
- break;
- }
- return false;
- }
- public function getCompanyKvs() {
- $companys = \app\common\model\Company::field("name,id")->select();
- return json($companys);
- }
- public function getEnterpriseKvs() {
- $where[] = ["type", "=", $this->user["type"]];
- $enterprises = \app\common\model\Enterprise::field("name,id")->where($where)->select();
- return json($enterprises);
- }
- public function getLayerCatsByLayer() {
- $lv = $this->request->param("level");
- return json(DictApi::getLayerCatsByLayer($lv));
- }
- /**
- * 通过人才类别查找人才认定第二步骤支持的所有文件类型
- * 默认人才认定第二步骤,当前只有人才认定分了两步,所以此方法目前默认参数高度匹配人才认定第二阶段附件的查找
- */
- public function getConditionFileTypesByType() {
- $params = $this->request->param();
- $type = $params["type"]; //人才类型不默认,需要传
- $declare_type = $params["project"] ?: 1; //默认人才认定
- $active = $params["active"] ?: 1; //默认查找启用的附件
- $where[] = ["type", "=", $type];
- $where[] = ["project", "=", $declare_type];
- $where[] = ["active", "=", $active];
- $where[] = ["delete", "=", 0];
- $where[] = ["isConditionFile", "=", 1];
- $list = Db::table("new_common_filetype")->where($where)->order("sn " . $order)->select()->toArray();
- return json($list);
- }
- public function listCurrencyFileType() {
- $where = [
- 'type' => $this->request['type'],
- 'active' => 1
- ];
- $rows = CurrentcyFileType::where($where)->select();
- return json(["rows" => $rows, 'total' => count($rows)]);
- }
- public function listTalentCommonFile() {
- $where = [];
- if (\StrUtil::isNotEmpAndNull($this->request['mainId'])) {
- $where[] = ['mainId', '=', $this->request['mainId']];
- }
- if (\StrUtil::isNotEmpAndNull($this->request['typeId'])) {
- $where[] = ['typeId', '=', $this->request['typeId']];
- }
- $res = TalentCommonFile::where($where)->order('sn')->select();
- if ($res) {
- foreach ($res as $k => &$v) {
- $v["ext"] = pathinfo($v["url"])["extension"];
- $v['url'] = getStoragePath($v['url']);
- }
- }
- return json($res);
- }
- public function addTalentCommonFile() {
- $backName = \StrUtil::getRequestDecodeParam($this->request, 'backName');
- $id = \StrUtil::getRequestDecodeParam($this->request, "fileId");
- $mainId = \StrUtil::getRequestDecodeParam($this->request, "mainId");
- $typeId = \StrUtil::getRequestDecodeParam($this->request, "typeId");
- $index = \StrUtil::getRequestDecodeParam($this->request, "index");
- if ($backName == "EpChangeEdit.callBack") {
- $type = 1;
- $error = "文件格式不正确,只能上传图片";
- } else {
- $type = 4;
- $error = "文件格式不正确,只能上传pdf和图片";
- }
- $uploadapi = new UploadApi();
- $file_check_res = $uploadapi->uploadOne($this->request->file('fileUrl'), 'system');
- if ($file_check_res->code == 500) {
- $file_check_res->obj = $index;
- return \StrUtil::back($file_check_res, $backName);
- }
- $file_data = [
- 'id' => getStringId(),
- 'mainId' => $mainId,
- 'typeId' => $typeId,
- 'orignName' => $this->request->file('fileUrl')->getOriginalName(),
- 'url' => $file_check_res->filepath
- ];
- if (\StrUtil::isEmpOrNull($id)) {
- $tc = TalentCommonFile::where('mainId', $mainId)->where('typeId', $typeId)->order('sn', 'desc')->findOrEmpty();
- if ($tc) {
- $file_data['sn'] = $tc['sn'] + 1;
- } else {
- $file_data['sn'] = 1;
- }
- $file_data['createTime'] = date("Y-m-d H:i:s");
- TalentCommonFile::create($file_data);
- $response_object = new \StdClass();
- $response_object->code = 200;
- $response_object->msg = "附件上传成功!";
- $response_object->obj = $index;
- return \StrUtil::back($response_object, $backName);
- } else {
- $tf = TalentCommonFile::findOrEmpty($id);
- $tf->originalName = $file_data['orignName'];
- $tf->updateTime = date("Y-m-d H:i:s");
- $tf->url = $file_check_res->filepath;
- $tf->save();
- $response_object = new \StdClass();
- $response_object->code = 200;
- $response_object->msg = "附件修改成功!";
- $response_object->obj = $index;
- return \StrUtil::back($response_object, $backName);
- }
- }
- public function changePwd() {
- $password = \StrUtil::getRequestDecodeParam($this->request, 'password');
- $newPassword = \StrUtil::getRequestDecodeParam($this->request, 'newPassword');
- //数据校验(原密码与新密码不能为空)
- if (\StrUtil::isEmpOrNull($password)) {
- return json(['code' => 500, 'msg' => "请填写原密码!"]);
- }
- if (\StrUtil::isEmpOrNull($newPassword)) {
- return json(['code' => 500, 'msg' => "请填写新密码!"]);
- }
- try {
- validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
- $ep = EnterpriseApi::getOne(session("user")['uid']);
- if (!$ep) {
- return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
- }
- if ($ep->password != hash('md5', $password)) {
- return json(['code' => 500, 'msg' => "旧密码不正确!"]);
- }
- $ep->password = hash('md5', $newPassword);
- $ep->updateUser = session("user")['uid'];
- $ep->updateTime = date("Y-m-d H:i:s");
- $ep->save();
- TalentChecklog::create([
- 'id' => getStringId(),
- 'category' => 'enterprise_change',
- 'mainId' => $ep->id,
- 'type' => 10,
- 'typeFileId' => null,
- 'active' => 1,
- 'state' => 1,
- 'step' => 100,
- 'stateChange' => null,
- 'description' => '用户修改密码',
- 'createTime' => date("Y-m-d H:i:s", time()),
- 'createUser' => '用户'
- ]);
- return json(['code' => 200, 'msg' => "修改成功!"]);
- } catch (ValidateException $e) {
- $error = $e->getError();
- return json(['code' => 500, 'msg' => array_pop($error)]);
- }
- }
- function getIntegralRecordByIdCard() {
- $cardType = $this->request->param("cardType");
- $cardNumber = $this->request->param("cardNumber");
- $tips = \app\common\api\IntegralRecordApi::getIntegralRecordByIdCard($cardType, $cardNumber);
- return json(["tips" => $tips]);
- }
- function getIntegralProjectsByType() {
- $projectType = $this->request->param("projectType") ?: 0;
- if (session("user")["usertype"] == 2) {
- $where[] = ["type", "=", 2];
- } else {
- $type = $this->request->param("type") ?: 0;
- $where[] = ["type", "=", $type];
- }
- $where[] = ["projectType", "=", $projectType];
- $where[] = ["active", "=", 1];
- $list = \app\common\api\IntegralProjectApi::getAll($where);
- return json($list);
- }
- public function getIntegralItemsByProject() {
- $projectId = $this->request->param("projectId") ?: 0;
- $where[] = ["projectId", "=", $projectId];
- $where[] = ["active", "=", 1];
- $list = \app\common\api\IntegralItemApi::getAll($where);
- return json($list);
- }
- public function calIntegral() {
- $params = $this->request->param();
- $enterpriseId = $params["enterpriseId"];
- $cardType = $params["cardType"];
- $cardNumber = $params["cardNumber"];
- $itemId = $params["itemId"];
- $amount = $params["amount"];
- if (session("user")["usertype"] == 2) {
- //企业端只能通过企业自身id来查询积分
- $enterpriseId = session("user")["uid"];
- }
- return json(\app\common\api\IntegralRecordApi::calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount));
- }
- public function imgViewer() {
- $img = urldecode($this->request["picShow"]);
- return view("", ["img" => $img]);
- }
- public function gotoFileShow() {
- return view("admin@talent/filesShow");
- }
- public function getJbtFiletypesExceptCommon() {
- $type = $this->user["type"];
- $where[] = ["type", "=", $type];
- $where[] = ["project", "=", 2];
- $where[] = ["isConditionFile", "in", [1, 2]];
- $fileTypes = \app\common\api\FileTypeApi::getAll($where);
- foreach ($fileTypes as &$ft) {
- $ft["name"] = sprintf("%s(%s)", $ft["name"], \app\common\state\AllowanceTypeEnum::getTypeName($ft["isConditionFile"]));
- }
- return json($fileTypes);
- }
- public function getEnterpriseData() {
-
- }
- }
|