TalentAllowance.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\Response;
  5. use app\common\model\TalentAllowance as TaModel;
  6. use think\facade\Db;
  7. use app\common\api\DictApi;
  8. use app\common\state\AllowanceStateEnum;
  9. use app\common\state\AllowanceProjectEnum;
  10. use app\common\api\TalentAllowanceApi;
  11. use app\common\model\TalentChecklog;
  12. use app\common\state\ProjectState;
  13. /**
  14. * Description of TalentAllowance
  15. *
  16. * @author sgq
  17. */
  18. class TalentAllowance extends AdminController {
  19. public function index() {
  20. $process = $this->request["process"];
  21. $type = $this->user["type"];
  22. $assigns = ["process" => $process, "type" => $type];
  23. if ($process == 4) {
  24. if ($type == 1) {
  25. $msgBody["typeName"] = "晋江市优秀人才津补贴申报";
  26. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  27. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  28. $msgBody["phone"] = "0595-85633128";
  29. $msgBody["email"] = "jjrc85661234@163.com";
  30. }
  31. if ($type == 2) {
  32. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  33. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  34. $msgBody["dep"] = "集成电路产业园区";
  35. $msgBody["phone"] = "0595-82250007、0595-82250001";
  36. $msgBody["email"] = "jjjcdr@163.com";
  37. }
  38. $assigns["message"] = $msgBody;
  39. }
  40. return view("", $assigns);
  41. }
  42. /**
  43. * 获取优秀人才津补贴列表
  44. */
  45. public function list() {
  46. $param = $this->request->param();
  47. $offset = $param["offset"] ?: 0;
  48. $limit = $param["limit"] ?: 10;
  49. $process = $param["process"];
  50. $where = [];
  51. $where[] = ["type", "=", $this->user["type"]];
  52. $order = "newSubmitTime desc";
  53. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  54. switch ($process) {
  55. case 1:
  56. $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  57. break;
  58. case 2:
  59. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  60. break;
  61. case 3:
  62. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  63. break;
  64. case 4:
  65. if ($param["publicState"]) {
  66. $where[] = ["publicState", "=", $param["publicState"]];
  67. }
  68. $where[] = ["checkState", "in", [-1, 30]];
  69. break;
  70. }
  71. $count = TaModel::where($where)->count();
  72. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  73. $list = $this->translateChinese($list);
  74. return json(["rows" => $list, "total" => $count]);
  75. }
  76. public function toCheckPage() {
  77. $id = $this->request["id"];
  78. $process = $this->request["process"];
  79. $obj = TalentAllowanceApi::getInfoById($id);
  80. $this->translateToChinese($obj);
  81. return view("info", ["row" => $obj, "process" => $process]);
  82. }
  83. /**
  84. * 审核
  85. */
  86. public function check() {
  87. $obj = $this->request->param();
  88. if (!$obj["checkState"]) {
  89. return new Response(Response::ERROR, "请选择审核状态");
  90. }
  91. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  92. if (!$oldObj) {
  93. return new Response(Response::ERROR, "不存在的申请记录");
  94. }
  95. $newObj = [];
  96. $newObj["id"] = $obj["id"];
  97. $projectList = [];
  98. $fileList = [];
  99. if ($obj["process"] == 1) {
  100. if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
  101. $projectList = array_filter(explode(",", $obj["projects"]));
  102. $newObj["projects"] = implode(",", $projectList);
  103. }
  104. if (\StrUtil::isNotEmpAndNull($obj["files"])) {
  105. $fileList = array_filter(explode(",", $obj["files"]));
  106. $newObj["files"] = implode(",", $fileList);
  107. }
  108. //if (Const.RSJ.equals(checkCompany.getCode())) {
  109. $newObj["concats"] = $obj["concats"];
  110. $newObj["fields"] = $obj["fields"];
  111. //}
  112. }
  113. if ($obj["process"] == 3) {
  114. $newObj["toProcess"] = $obj["toProcess"];
  115. $newObj["toDep"] = $obj["toDep"];
  116. }
  117. TaModel::update($newObj);
  118. //添加日志
  119. TalentChecklog::create([
  120. 'id' => getStringId(),
  121. 'mainId' => $obj['id'],
  122. 'type' => intval(ProjectState::JBT),
  123. 'typeFileId' => null,
  124. 'active' => 2,
  125. 'state' => $obj["checkState"],
  126. 'step' => $obj["process"],
  127. 'stateChange' => null,
  128. 'description' => $obj["checkMsg"],
  129. 'createTime' => date("Y-m-d H:i:s", time()),
  130. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  131. ]);
  132. return new Response(Response::SUCCESS, "审核成功");
  133. }
  134. /**
  135. * 校验是否在审核范围内
  136. */
  137. public function validateIsCheck() {
  138. $id = $this->request["id"];
  139. $type = $this->request["type"];
  140. $process = $this->request["process"];
  141. $info = null;
  142. switch ($type) {
  143. case 1: //编辑合同
  144. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  145. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  146. break;
  147. case 2: //编辑项目
  148. $project = \app\common\model\TalentAllowanceProject::find($id);
  149. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  150. break;
  151. case 3:
  152. $info = TalentAllowanceApi::getInfoById($id);
  153. break;
  154. }
  155. if (!$info) {
  156. return new Response(Response::ERROR, "校验不通过,无法操作");
  157. }
  158. $where = [];
  159. $where[] = ["mainId", "=", $info["id"]];
  160. $where[] = ["step", "=", $process];
  161. $where[] = ["active", "=", 2];
  162. $log = null;
  163. switch ($process) {
  164. case 1:
  165. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  166. return new Response(Response::ERROR, "不在审核范围内");
  167. }
  168. //$where[] = ["companyId","=",$this->user["companyId"]];
  169. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  170. break;
  171. case 2:
  172. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  173. return new Response(Response::ERROR, "不在审核范围内");
  174. }
  175. break;
  176. case 3:
  177. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  178. return new Response(Response::ERROR, "不在审核范围内");
  179. }
  180. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  181. break;
  182. }
  183. if ($log != null) {
  184. $info["checkState"] = $log["state"];
  185. $info["checkMsg"] = $log["description"];
  186. } else {
  187. $info["checkState"] = null;
  188. $info["checkMsg"] = "";
  189. }
  190. $res = [];
  191. $res["info"] = $info;
  192. if ($type == 3) {
  193. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  194. $where = [];
  195. $where[] = ["mainId", "=", $id];
  196. $where[] = ["isLock", "=", 1];
  197. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  198. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  199. $detailMap = array_reduce($detailList, function ($result, $item) {
  200. $key = $item["id"];
  201. $result[$key] = $item;
  202. return $result;
  203. }, []);
  204. foreach ($detailList as &$detail) {
  205. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  206. }unset($detail);
  207. foreach ($projectList as &$project) {
  208. $detail = $detailMap[$project["baseId"]];
  209. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  210. }
  211. $where = [];
  212. $where[] = ["type", "=", $info["type"]];
  213. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  214. $where[] = ["active", "=", 1];
  215. $where[] = ["delete", "=", 0];
  216. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  217. $res["files"] = $filetypes;
  218. $res["projects"] = $projectList;
  219. $res["concats"] = $detailList;
  220. }
  221. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  222. }
  223. /**
  224. * 查询工作单位
  225. */
  226. public function findAllowanceContractDetail() {
  227. $mainId = $this->request["mainId"];
  228. $offset = $this->request["offset"] ?: 0;
  229. $limit = $this->request["limit"] ?: 1000;
  230. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  231. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  232. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  233. foreach ($list as &$row) {
  234. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  235. }unset($row);
  236. return json(["rows" => $list, "total" => $count]);
  237. }
  238. /**
  239. * 查询核查项目情况
  240. */
  241. public function findAllowanceProject() {
  242. $mainId = $this->request["mainId"];
  243. $baseId = $this->request["baseId"];
  244. $offset = $this->request["offset"] ?: 0;
  245. $limit = $this->request["limit"] ?: 1000;
  246. $where = [];
  247. $where[] = ["mainId", "=", $mainId];
  248. $where[] = ["baseId", "=", $baseId];
  249. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  250. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  251. $info = TalentAllowanceApi::getInfoById($mainId);
  252. foreach ($list as &$project) {
  253. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  254. if ($info["checkState"] == 1) {
  255. $project["isEdit"] = in_array($project["project"], [
  256. AllowanceProjectEnum::PROJECT_CONTRACT,
  257. AllowanceProjectEnum::PROJECT_TAX,
  258. AllowanceProjectEnum::PROJECT_WAGES,
  259. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  260. AllowanceProjectEnum::PROJECT_SB_PENSION,
  261. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  262. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  263. AllowanceProjectEnum::PROJECT_WORKDAY
  264. ]) ? 1 : 2;
  265. } else if ($info["checkState"] == 10) {
  266. $projects = explode(",", $info["projects"]);
  267. if (in_array($project["id"], $projects)) {
  268. $project["isEdit"] = 1;
  269. } else {
  270. $project["isEdit"] = 2;
  271. }
  272. } else {
  273. $project["isEdit"] = 2;
  274. }
  275. }unset($project);
  276. return json(["rows" => $list, "total" => $count]);
  277. }
  278. /**
  279. * 查询人才层次变更记录
  280. */
  281. public function findAllowanceArrange() {
  282. $mainId = $this->request["mainId"];
  283. $offset = $this->request["offset"] ?: 0;
  284. $limit = $this->request["limit"] ?: 1000;
  285. $where = [];
  286. $where[] = ["mainId", "=", $mainId];
  287. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  288. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  289. foreach ($list as &$arrange) {
  290. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  291. $arrange["identifyConditionText"] = $condition["name"];
  292. $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  293. }unset($arrange);
  294. return json(["rows" => $list, "total" => $count]);
  295. }
  296. private function setTalentAllowanceInfo($where, $query, $process) {
  297. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  298. $where[] = ["year", "=", $query["year"]];
  299. }
  300. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  301. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  302. }
  303. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  304. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  305. }
  306. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  307. $where[] = ["talentType", "=", $query["talentType"]];
  308. }
  309. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  310. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  311. }
  312. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  313. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  314. }
  315. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  316. $where[] = ["address", "=", $query["address"]];
  317. }
  318. if ($query["recommendAllowanceType"]) {
  319. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  320. }
  321. if ($query["publicState"]) {
  322. $where[] = ["publicState", "=", $query["publicState"]];
  323. }
  324. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  325. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  326. }
  327. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  328. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  329. }
  330. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  331. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  332. }
  333. if ($process == 4) {
  334. if ($query["isSupple"]) {
  335. $where[] = ["isSupple", "=", $query["isSupple"]];
  336. }
  337. if ($query["isPublicCheck"]) {
  338. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  339. }
  340. }
  341. if ($query["checkState"]) {
  342. if ($query["checkState"] == -1) {
  343. $where[] = ["checkState", "=", $query["checkState"]];
  344. } else {
  345. if ($process == 1) {
  346. switch ($query["checkState"]) {
  347. case 0: //保存未提交
  348. $where[] = ["checkState", "=", 1];
  349. break;
  350. case 1:
  351. $where[] = ["checkState", "=", 5];
  352. break;
  353. case 2: //驳回
  354. $where[] = ["checkState", "=", 10];
  355. break;
  356. case 3: //通过
  357. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  358. break;
  359. case 4: //重新提交
  360. $where[] = ["checkState", "=", 5];
  361. $where[] = ["highProcess", ">=", $process];
  362. break;
  363. case 5: //上级驳回
  364. $where[] = ["checkState", "=", 13];
  365. break;
  366. }
  367. }
  368. if ($process == 2) {
  369. switch ($query["checkState"]) {
  370. case 1:
  371. $where[] = ["checkState", "=", 15];
  372. break;
  373. case 2: //驳回
  374. $where[] = ["checkState", "in", [1, 5, 10]];
  375. $where[] = ["highProcess", ">=", $process];
  376. break;
  377. case 3: //通过
  378. $where[] = ["checkState", "in", [20, 30]];
  379. break;
  380. case 9: //重新提交
  381. $where[] = ["checkState", "=", 15];
  382. $where[] = ["highProcess", ">=", $process];
  383. break;
  384. case 4: //上级驳回
  385. $where[] = ["checkState", "=", 25];
  386. break;
  387. case -1:
  388. $where[] = ["checkState", "=", -1];
  389. break;
  390. }
  391. }
  392. if ($process == 3) {
  393. switch ($query["checkState"]) {
  394. case -1:
  395. $where[] = ["checkState", "=", -1];
  396. break;
  397. case 1:
  398. $where[] = ["checkState", "=", 20];
  399. break;
  400. case 2: //驳回
  401. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  402. $where[] = ["highProcess", ">=", $process];
  403. break;
  404. case 3: //通过
  405. $where[] = ["checkState", "=", 30];
  406. break;
  407. case 9: //重新提交
  408. $where[] = ["checkState", "=", 20];
  409. $where[] = ["highProcess", ">=", $process];
  410. break;
  411. case 4: //上级驳回
  412. $where[] = ["checkState", "=", 35];
  413. break;
  414. }
  415. }
  416. if ($process == 4) {
  417. switch ($query["checkState"]) {
  418. case -1:
  419. $where[] = ["checkState", "=", -1];
  420. break;
  421. case 3: //通过
  422. $where[] = ["checkState", "=", 30];
  423. break;
  424. }
  425. }
  426. }
  427. }
  428. return $where;
  429. }
  430. private function translateToChinese(&$obj) {
  431. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  432. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  433. }
  434. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  435. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  436. }
  437. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  438. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  439. }
  440. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  441. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  442. }
  443. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  444. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  445. }
  446. }
  447. private function translateChinese($list) {
  448. //获取字典表
  449. $levelMap = DictApi::selectByParentCode("talent_arrange");
  450. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  451. $streetMap = DictApi::selectByParentCode("street");
  452. $cardTypeMap = DictApi::selectByParentCode("card_type");
  453. $modeMap = DictApi::selectByParentCode("import_way");
  454. $where = [];
  455. $where[] = ["type", "=", $this->user["type"]];
  456. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  457. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  458. foreach ($list as &$info) {
  459. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  460. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  461. }
  462. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  463. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  464. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  465. }
  466. $info["addressName"] = $streetMap[$info["address"]];
  467. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  468. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  469. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  470. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  471. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  472. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  473. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  474. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  475. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  476. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  477. }unset($info);
  478. return $list;
  479. }
  480. }