TalentAllowance.php 20 KB

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