TalentAllowance.php 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. use app\common\api\Response;
  6. use app\common\api\DictApi;
  7. use app\common\api\TalentAllowanceApi;
  8. use app\common\api\TalentLogApi;
  9. use app\common\model\TalentAllowance as TaModel;
  10. use app\common\model\TalentChecklog;
  11. use app\common\model\TalentAllowanceArrange;
  12. use app\common\state\ProjectState;
  13. use app\common\state\AllowanceStateEnum;
  14. use app\common\state\AllowanceProjectEnum;
  15. use app\common\model\AmountStandard as AsModel;
  16. /**
  17. * Description of TalentAllowance
  18. *
  19. * @author sgq
  20. */
  21. class TalentAllowance extends AdminController {
  22. public function index() {
  23. $process = $this->request["process"];
  24. $type = $this->user["type"];
  25. $assigns = ["process" => $process, "type" => $type];
  26. if ($process == 4) {
  27. if ($type == 1) {
  28. $msgBody["typeName"] = "晋江市优秀人才津补贴申报";
  29. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  30. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  31. $msgBody["phone"] = "0595-85633128";
  32. $msgBody["email"] = "jjrc85661234@163.com";
  33. }
  34. if ($type == 2) {
  35. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  36. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  37. $msgBody["dep"] = "集成电路产业园区";
  38. $msgBody["phone"] = "0595-82250007、0595-82250001";
  39. $msgBody["email"] = "jjjcdr@163.com";
  40. }
  41. $assigns["message"] = $msgBody;
  42. }
  43. return view("", $assigns);
  44. }
  45. /**
  46. * 获取优秀人才津补贴列表
  47. */
  48. public function list() {
  49. $param = $this->request->param();
  50. $offset = $param["offset"] ?: 0;
  51. $limit = $param["limit"] ?: 10;
  52. $process = $param["process"];
  53. $where = [];
  54. $where[] = ["type", "=", $this->user["type"]];
  55. $order = "newSubmitTime desc";
  56. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  57. switch ($process) {
  58. case 1:
  59. $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  60. break;
  61. case 2:
  62. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  63. break;
  64. case 3:
  65. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  66. break;
  67. case 4:
  68. if ($param["publicState"]) {
  69. $where[] = ["publicState", "=", $param["publicState"]];
  70. }
  71. $where[] = ["checkState", "in", [-1, 30]];
  72. break;
  73. }
  74. $count = TaModel::where($where)->count();
  75. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  76. $list = $this->translateChinese($list);
  77. return json(["rows" => $list, "total" => $count]);
  78. }
  79. /**
  80. * 审核页面
  81. * @return type
  82. */
  83. public function toCheckPage() {
  84. $id = $this->request["id"];
  85. $process = $this->request["process"];
  86. $obj = TalentAllowanceApi::getInfoById($id);
  87. $this->translateToChinese($obj);
  88. return view("info", ["row" => $obj, "process" => $process]);
  89. }
  90. /**
  91. * 查看详情
  92. * @return type
  93. */
  94. public function toSelectPage() {
  95. $id = $this->request["id"];
  96. $process = $this->request["process"];
  97. $obj = TalentAllowanceApi::getInfoById($id);
  98. $this->translateToChinese($obj);
  99. return view("select", ["row" => $obj, "process" => $process]);
  100. }
  101. /**
  102. * 审核保存
  103. */
  104. public function check() {
  105. $obj = $this->request->param();
  106. if (!$obj["checkState"]) {
  107. return new Response(Response::ERROR, "请选择审核状态");
  108. }
  109. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  110. if (!$oldObj) {
  111. return new Response(Response::ERROR, "审核对象不存在");
  112. }
  113. $newObj = [];
  114. $newObj["id"] = $obj["id"];
  115. $projectList = [];
  116. $fileList = [];
  117. if ($obj["process"] == 1) {
  118. if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
  119. $projectList = array_filter(explode(",", $obj["projects"]));
  120. $newObj["projects"] = implode(",", $projectList);
  121. }
  122. if (\StrUtil::isNotEmpAndNull($obj["files"])) {
  123. $fileList = array_filter(explode(",", $obj["files"]));
  124. $newObj["files"] = implode(",", $fileList);
  125. }
  126. //if (Const.RSJ.equals(checkCompany.getCode())) {
  127. $newObj["concats"] = $obj["concats"];
  128. $newObj["fields"] = $obj["fields"];
  129. //}
  130. }
  131. if ($obj["process"] == 3) {
  132. $newObj["toProcess"] = $obj["toProcess"];
  133. $newObj["toDep"] = $obj["toDep"];
  134. }
  135. TaModel::update($newObj);
  136. //添加日志
  137. TalentChecklog::create([
  138. 'id' => getStringId(),
  139. 'mainId' => $obj['id'],
  140. 'type' => intval(ProjectState::JBT),
  141. 'typeFileId' => null,
  142. 'active' => 2,
  143. 'state' => $obj["checkState"],
  144. 'step' => $obj["process"],
  145. 'stateChange' => null,
  146. 'description' => $obj["checkMsg"],
  147. 'createTime' => date("Y-m-d H:i:s", time()),
  148. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  149. ]);
  150. return new Response(Response::SUCCESS, "审核成功");
  151. }
  152. /**
  153. * 提交审核
  154. * @return Response
  155. */
  156. public function submitCheck() {
  157. $id = $this->request["id"];
  158. $process = $this->request["process"];
  159. $old = TalentAllowanceApi::getInfoById($id);
  160. if (!$old) {
  161. return new Response(Response::ERROR, "审核对象不存在");
  162. }
  163. $updCheck = [];
  164. $updCheck["id"] = $id;
  165. /* * 查询审核日志 */
  166. $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process);
  167. if (!$log) {
  168. return new Response(Response::ERROR, "请先审核后再提交");
  169. }
  170. $updCheck["checkMsg"] = $log["description"];
  171. /* * 判断到达的最高流程 */
  172. $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["process"];
  173. switch ($process) {
  174. case 1:
  175. switch ($log["state"]) {
  176. case 3:
  177. $updCheck["firstPassTime"] = $old["firstPassTime"];
  178. if (!$old["firstPassTime"]) {
  179. $updCheck["firstPassTime"] = date("Y-m-d H:i:s");
  180. }
  181. if (!$old["visitPassTime"]) {
  182. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  183. }
  184. $updCheck["submitTime"] = date("Y-m-d H:i:s");
  185. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  186. break;
  187. case 2:
  188. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT;
  189. break;
  190. case -1:
  191. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  192. $updCheck["recommendAllowanceType"] = 3;
  193. $updCheck["recommendMoney"] = 0;
  194. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  195. break;
  196. default:
  197. return new Response(Response::ERROR, "未知的审核状态");
  198. }
  199. //添加日志
  200. TalentChecklog::create([
  201. 'id' => getStringId(),
  202. 'mainId' => $id,
  203. 'type' => intval(ProjectState::JBT),
  204. 'typeFileId' => null,
  205. 'active' => 1,
  206. 'state' => $log["state"],
  207. 'step' => $process,
  208. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  209. 'description' => $log["description"],
  210. 'createTime' => date("Y-m-d H:i:s", time()),
  211. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  212. ]);
  213. break;
  214. case 2:
  215. if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  216. return new Response(Response::ERROR, "不在审核范围内");
  217. }
  218. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  219. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  220. //添加日志
  221. TalentChecklog::create([
  222. 'id' => getStringId(),
  223. 'mainId' => $id,
  224. 'type' => intval(ProjectState::JBT),
  225. 'typeFileId' => null,
  226. 'active' => 1,
  227. 'state' => 3,
  228. 'step' => $process,
  229. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  230. 'description' => "走访核查提交审核",
  231. 'createTime' => date("Y-m-d H:i:s", time()),
  232. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  233. ]);
  234. break;
  235. case 3:
  236. switch ($log["state"]) {
  237. case 3:
  238. $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS;
  239. $updCheck["reviewPassTime"] = date("Y-m-d H:i:s");
  240. /* * * 在此处需要判断津补贴类型 */
  241. $arrangeList = $this->validateAllowanceType($updCheck);
  242. $taaModel = new TalentAllowanceArrange();
  243. $taaModel->saveAll($arrangeList);
  244. break;
  245. case 2:
  246. $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST;
  247. $updCheck["toProcess"] = null;
  248. $updCheck["toDep"] = "";
  249. break;
  250. case -1:
  251. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  252. $updCheck["recommendAllowanceType"] = 3;
  253. $updCheck["recommendMoney"] = 0;
  254. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  255. break;
  256. default:
  257. return new Response(Response::ERROR, "未知的审核状态");
  258. }
  259. //添加日志
  260. TalentChecklog::create([
  261. 'id' => getStringId(),
  262. 'mainId' => $id,
  263. 'type' => intval(ProjectState::JBT),
  264. 'typeFileId' => null,
  265. 'active' => 1,
  266. 'state' => $log["state"],
  267. 'step' => $process,
  268. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  269. 'description' => $log["description"],
  270. 'createTime' => date("Y-m-d H:i:s", time()),
  271. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  272. ]);
  273. break;
  274. }
  275. TalentChecklog::where("id", $log["id"])->delete();
  276. TaModel::update($updCheck);
  277. return new Response(Response::SUCCESS, "提交审核成功");
  278. }
  279. /**
  280. * 初审撤销
  281. * @return Response
  282. */
  283. public function cancleFirstCheck() {
  284. $obj = $this->request->param();
  285. $id = $obj["id"];
  286. $checkMsg = $obj["checkMsg"];
  287. if (!$id) {
  288. return new Response(Response::ERROR, "请选择需要撤销的对象");
  289. }
  290. $old = TalentAllowanceApi::getInfoById($id);
  291. if ($old["checkState"] != AllowanceStateEnum::NEED_REVIEW && $old["checkState"] != AllowanceStateEnum::NOTPASS) {
  292. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  293. }
  294. $data["id"] = $id;
  295. $data["checkMsg"] = $checkMsg;
  296. $data["checkState"] = AllowanceStateEnum::NEED_CHECK;
  297. //添加日志
  298. TalentChecklog::create([
  299. 'id' => getStringId(),
  300. 'mainId' => $id,
  301. 'type' => intval(ProjectState::JBT),
  302. 'typeFileId' => null,
  303. 'active' => 1,
  304. 'state' => 11, //撤销审核
  305. 'step' => 1,
  306. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  307. 'description' => "撤销原因:" . $checkMsg,
  308. 'createTime' => date("Y-m-d H:i:s", time()),
  309. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  310. ]);
  311. TaModel::update($data);
  312. return new Response(Response::SUCCESS, "撤销成功");
  313. }
  314. /**
  315. * 复核撤销
  316. * @return Response|\app\admin\controller\ResponseObj
  317. */
  318. public function reviewCancleCheck() {
  319. $obj = $this->request->param();
  320. $id = $obj["id"];
  321. $checkMsg = $obj["checkMsg"];
  322. if (!$id) {
  323. return new Response(Response::ERROR, "请选择需要撤销的对象");
  324. }
  325. $old = TalentAllowanceApi::getInfoById($id);
  326. if ($old["checkState"] != AllowanceStateEnum::REVIEW_PASS || $old["publicState"] != 1) {
  327. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  328. }
  329. $data["id"] = $id;
  330. $data["checkMsg"] = $checkMsg;
  331. $data["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  332. //添加日志
  333. TalentChecklog::create([
  334. 'id' => getStringId(),
  335. 'mainId' => $id,
  336. 'type' => intval(ProjectState::JBT),
  337. 'typeFileId' => null,
  338. 'active' => 1,
  339. 'state' => 11, //撤销审核
  340. 'step' => 3,
  341. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  342. 'description' => "撤销原因:" . $checkMsg,
  343. 'createTime' => date("Y-m-d H:i:s", time()),
  344. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  345. ]);
  346. TaModel::update($data);
  347. return new Response(Response::SUCCESS, "撤销成功");
  348. }
  349. /**
  350. * 查询需要导出的数据
  351. *
  352. */
  353. public function findTalentAllowanceByPage() {
  354. $param = $this->request->param();
  355. $where = [];
  356. $where[] = ["type", "=", $this->user["type"]];
  357. if ($param != null) {
  358. if (\StrUtil::isNotEmpAndNull($param["name"])) {
  359. $where[] = ["name", "like", "%" . $param["name"] . "%"];
  360. }
  361. if (\StrUtil::isNotEmpAndNull($param["idCard"])) {
  362. $where[] = ["idCard", "like", "%" . $param["idCard"] . "%"];
  363. }
  364. }
  365. $error = null;
  366. switch ($param["type"]) {
  367. case 1:
  368. case 2:
  369. $where[] = ["publicState", "=", 1];
  370. $where[] = ["checkState", "in", [-1, 30]];
  371. $error = "暂无可核查征信的数据";
  372. break;
  373. case 3:
  374. case 7:
  375. $where[] = ["publicState", "=", 2];
  376. $where[] = ["checkState", "in", [-1, 30]];
  377. $where[] = ["recommendAllowanceType", "=", 3];
  378. $error = "暂无可公示(不予兑现)的数据";
  379. break;
  380. case 4: //需要兑现
  381. case 8:
  382. $where[] = ["publicState", "=", 2];
  383. $where[] = ["checkState", "in", [30]];
  384. $where[] = ["recommendAllowanceType", "in", [1, 2]];
  385. $error = "暂无需要公示(兑现)的数据";
  386. break;
  387. case 5:
  388. $where[] = ["publicState", "=", 3];
  389. $where[] = ["checkState", "in", [-1, 30]];
  390. $error = "暂无可公示通过的数据";
  391. break;
  392. case 6:
  393. $where[] = ["publicState", "=", 4];
  394. $where[] = ["checkState", "in", [30]];
  395. $where[] = ["allowanceType", "in", [1, 2]];
  396. $error = "暂无可兑现的数据";
  397. break;
  398. }
  399. $list = TaModel::where($where)->select()->toArray();
  400. //查询企业信息
  401. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  402. foreach ($list as $key => $item) {
  403. $list[$key]["enterpriseName"] = $enterpriseMap[$item["enterpriseId"]];
  404. }
  405. $res = [
  406. "rows" => $list,
  407. "total" => count($list)
  408. ];
  409. return new Response(Response::SUCCESS, "", $res);
  410. }
  411. public function exportHczx() {
  412. $response = new \stdClass();
  413. $response->code = 500;
  414. $ids = $this->request->param("ids");
  415. $ids_arr = array_filter(explode(",", $ids));
  416. if (!$ids_arr) {
  417. $response->msg = "没有选择导出的名单";
  418. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  419. }
  420. $where = [];
  421. $where[] = ["id", "in", $ids_arr];
  422. $list = TaModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  423. if (!$list) {
  424. $response->msg = "暂无可核查征信的数据";
  425. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  426. }
  427. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  428. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  429. $cardTypeName = DictApi::selectByParentCode("card_type");
  430. $rows = [];
  431. for ($i = 0; $i < count($list); $i++) {
  432. $item = $list[$i];
  433. $row = [
  434. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["description"]
  435. ];
  436. $rows[] = $row;
  437. }
  438. $filename = "津补贴待核查征信名单导出";
  439. if ($rows) {
  440. export($columns, $rows, $filename);
  441. exit();
  442. } else {
  443. $response->msg = "没有选择导出的名单";
  444. return \StrUtil::back($response, "TalentTypeChange.callBack");
  445. }
  446. }
  447. /**
  448. * 核查征信驳回
  449. */
  450. public function hczxReject() {
  451. $param = $this->request->param();
  452. if (!$param) {
  453. return new Response(Response::ERROR, "系统错误,请联系管理员");
  454. }
  455. $old = TalentAllowanceApi::getInfoById($param["id"]);
  456. if ($old["publicState"] != 1) {
  457. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  458. }
  459. $data["id"] = $param["id"];
  460. $data["publicState"] = 2;
  461. $data["checkState"] = AllowanceStateEnum::NOTPASS;
  462. $data["recommendAllowanceType"] = 3;
  463. $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
  464. $data["recommendMonths"] = "";
  465. $data["recommendMoney"] = 0.00;
  466. $data["workAllowanceMoney"] = null;
  467. $data["developAllowanceMoney"] = null;
  468. //添加日志
  469. TalentChecklog::create([
  470. 'id' => getStringId(),
  471. 'mainId' => $param["id"],
  472. 'type' => intval(ProjectState::JBT),
  473. 'typeFileId' => null,
  474. 'active' => 1,
  475. 'state' => 2,
  476. 'step' => 4,
  477. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  478. 'description' => $param["outMsg"],
  479. 'createTime' => date("Y-m-d H:i:s", time()),
  480. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  481. ]);
  482. TaModel::update($data);
  483. return new Response(Response::SUCCESS, "核查征信成功");
  484. }
  485. /**
  486. * 核查征信批量通过
  487. */
  488. public function hczxPass() {
  489. $ids = $this->request["ids"];
  490. if (\StrUtil::isEmpOrNull($ids)) {
  491. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  492. }
  493. $where = [];
  494. $where[] = ["id", "in", $ids];
  495. $list = TaModel::where($where)->select()->toArray();
  496. $logList = [];
  497. $upds = [];
  498. foreach ($list as $obj) {
  499. $upds[] = [
  500. "id" => $obj["id"],
  501. "publicState" => 2,
  502. ];
  503. $logList[] = [
  504. "id" => getStringId(),
  505. "type" => ProjectState::JBT,
  506. "mainId" => $obj["id"],
  507. "active" => 1,
  508. "state" => 3,
  509. "step" => 4,
  510. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  511. "description" => "核查征信通过",
  512. "createTime" => date("Y-m-d H:i:s"),
  513. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  514. ];
  515. }
  516. $taModel = new TaModel();
  517. $taModel->saveAll($upds);
  518. Db::table("new_talent_checklog")->insertAll($logList);
  519. return new Response(Response::SUCCESS, "核查征信通过成功");
  520. }
  521. /**
  522. * 公示预览(不予兑现)
  523. */
  524. public function exportPublicNotCash() {
  525. $response = new \stdClass();
  526. $response->code = 500;
  527. //获取字典表人才层次+
  528. $levelMap = DictApi::selectByParentCode("talent_arrange");
  529. $streetMap = DictApi::selectByParentCode("street");
  530. //查询企业信息
  531. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  532. //查询所有
  533. $where = [];
  534. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  535. $list = TaModel::where($where)->select()->toArray();
  536. $rows = [];
  537. for ($i = 0; $i < count($list); $i++) {
  538. $item = $list[$i];
  539. $rows[] = [
  540. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  541. ];
  542. }
  543. $filename = ($this->user["type"] == 1 ? "晋江市优秀人才" : "晋江市集成电路人才") . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  544. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  545. if ($rows) {
  546. export($columns, $rows, $filename);
  547. exit();
  548. } else {
  549. $response->msg = "没有选择导出的名单";
  550. return \StrUtil::back($response, "TalentTypeChange.callBack");
  551. }
  552. }
  553. private function validateAllowanceType(&$info) {
  554. $old = TalentAllowanceApi::getInfoById($info["id"]);
  555. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  556. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  557. /* * 查询工作单位记录 */
  558. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  559. $detaiPdList = []; //用于判定类型
  560. $detailMonthList = []; //用于计算月份
  561. $recommendAllowanceMsg = [];
  562. foreach ($initDetailList as $detail) {
  563. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  564. $projectMap = [];
  565. foreach ($projectList as $project) {
  566. $projectMap[$project["project"]] = $project;
  567. }
  568. $detail["list"] = $projectList;
  569. $detail["projectMap"] = $projectMap;
  570. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  571. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  572. /* * 筛选符合条件的人才标签 */
  573. $detaiPdList[] = $detail;
  574. $detailMonthList[] = $detail;
  575. }
  576. /* * 集成电路优秀人才 */
  577. if ($this->user["type"] == 2) {
  578. /* * 获取各个项目的综合月份 */
  579. $monthMap = $this->mergeMonth($detailMonthList);
  580. $monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList);
  581. $info["recommendAllowanceType"] = 1;
  582. $info["recommendAllowanceMsg"] = "";
  583. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $info["id"])->select()->toArray();
  584. $set = $this->valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  585. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n综合以上所有判断得到最终补贴类型为:";
  586. if ($info["recommendAllowanceType"] == 1) {
  587. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "工作津贴;可享受月份为:" . implode(",", $set) . "\n";
  588. }
  589. if ($info["recommendAllowanceType"] == 2)
  590. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "一次性交通补贴;";
  591. if ($info["recommendAllowanceType"] == 3)
  592. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "不予兑现;";
  593. usort($set, function($a, $b) {
  594. return (int) $a - (int) $b;
  595. });
  596. }
  597. $info["recommendMonths"] = implode(",", $set);
  598. $arrangeList = $this->calculateAllowance($info, $set, $detailMonthList);
  599. return $arrangeList;
  600. }
  601. /**
  602. * 集成电路津补贴总校验
  603. * */
  604. private function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  605. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  606. /* * 2.判定工作月份、五险和个税是否满足重叠6个月要求* */
  607. $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WORKDAY], $info, "上年度工作月份", "①");
  608. $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "②");
  609. $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "③");
  610. $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "④");
  611. $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑤");
  612. $set = array_intersect($set, $workdaySet);
  613. $set = array_intersect($set, $pensionSet);
  614. $set = array_intersect($set, $unemploymentSet);
  615. $set = array_intersect($set, $medicaSet);
  616. $set = array_intersect($set, $taxSet);
  617. usort($set, function($a, $b) {
  618. return (int) $a - (int) $b;
  619. });
  620. if ($info["recommendAllowanceType"] == 1) {
  621. if (count($set) < 6) {
  622. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  623. $info["recommendAllowanceType"] == 2;
  624. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n社会保险、个税、上年度工作月份交集月份不满足6个月(" . implode(",", $set) . "),无法享受工作津贴(×)";
  625. } else {
  626. //检查连续缴纳月份是否满足6个月
  627. $count = 1;
  628. foreach ($set as $s) {
  629. $currentVal = intval($s);
  630. $nextVal = $currentVal + 1;
  631. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  632. if (in_array($nextKey, $set)) {
  633. $count++;
  634. if ($count >= 6) {
  635. break;
  636. }
  637. } else {
  638. $count = 1;
  639. }
  640. }
  641. if ($count < 6) {
  642. $info["recommendAllowanceType"] == 2;
  643. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n社会保险、个税、上年度工作月份交集月份不满足连续缴纳6个月(" . implode(",", $set) . "),无法享受工作津贴(×)";
  644. }
  645. }
  646. }
  647. if ($info["recommendAllowanceType"] == 2) {
  648. //判断境内工作时间是否大于30天
  649. $totalDays = 0;
  650. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_WORKDAY];
  651. foreach ($workmonths as $days) {
  652. $totalDays += $days;
  653. }
  654. if ($totalDays < 30) {
  655. $info["recommendAllowanceType"] == 3;
  656. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  657. }
  658. }
  659. return $set;
  660. }
  661. /**
  662. * 计算津补贴
  663. */
  664. private function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  665. /* * 查询人才层次变更记录 */
  666. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  667. foreach ($arrangeList as &$arrange) {
  668. $where = [];
  669. $where[] = ["type", "=", $this->user["type"]];
  670. $where[] = ["allowanceType", "in", [1, 2]];
  671. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  672. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  673. foreach ($list as $amount) {
  674. if ($amount["allowanceType"] == 1) {
  675. $arrange["jobMoney"] = $amount["money"];
  676. }
  677. if ($amount["allowanceType"] == 2) {
  678. $arrange["jtMoney"] = $amount["money"];
  679. }
  680. }
  681. }unset($arrange);
  682. /* * * 容器 */
  683. $jobMoney = 0.00; //计算所得工作津贴
  684. $jtMoney = 0.00; //计算所得一次性交通补贴
  685. $recommendMonths = []; //推荐月份
  686. $talentArrange = null;
  687. /* * *********计算************* */
  688. $msgBulider = [];
  689. switch ($info["recommendAllowanceType"]) {
  690. case 1:
  691. foreach ($arrangeList as &$arrange) {
  692. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  693. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  694. $levelList = array_intersect($levelList, $retainMonths);
  695. $total = round($arrange["jobMoney"] * count($levelList), 2);
  696. $jobMoney += $total;
  697. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  698. $recommendMonths = array_merge($recommendMonths, $levelList);
  699. usort($recommendMonths, function($a, $b) {
  700. return (int) $a - (int) $b;
  701. });
  702. $arrange["months"] = implode(",", $levelList);
  703. $arrange["count"] = count($levelList);
  704. $arrange["total"] = $total;
  705. } else {
  706. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  707. $arrange["count"] = 0;
  708. $arrange["total"] = 0.00;
  709. }
  710. }unset($arrange);
  711. $info["recommendMonths"] = implode(",", $recommendMonths);
  712. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "通过与人才证书有效期取交集得到最终可享受月份:" . implode(",", $recommendMonths) . "\n经过计算:人才津贴为" . $jobMoney . ";";
  713. $info["recommendMoney"] = $jobMoney;
  714. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  715. break;
  716. case 2:
  717. foreach ($arrangeList as $arrange) {
  718. $jtMoney = $arrange["jtMoney"];
  719. $talentArrange = $arrange["talentArrange"];
  720. }
  721. $info["recommendMoney"] = $jtMoney;
  722. $info["recommendMonths"] = "";
  723. $info["recommendMoneyDesc"] = "一次性交通补贴";
  724. $info["workAllowanceMoney"] = 0.00;
  725. $info["developAllowanceMoney"] = 0.00;
  726. $info["recommendTalentArrange"] = $talentArrange;
  727. break;
  728. case 3:
  729. $info["recommendMoney"] = 0.00;
  730. $info["recommendMonths"] = "";
  731. $info["recommendMoneyDesc"] = "不予兑现";
  732. $info["workAllowanceMoney"] = 0.00;
  733. $info["developAllowanceMoney"] = 0.00;
  734. break;
  735. }
  736. return $arrangeList;
  737. }
  738. /**
  739. * 判定是否交足6个月(集成电路)
  740. * @param set
  741. * @param info
  742. * @param name
  743. */
  744. private function chkMonths($set, &$info, $name, $sort) {
  745. if ($name == "上年度工作月份") {
  746. $tmp = [];
  747. foreach ($set as $s) {
  748. $_s = explode("=", $s);
  749. $month = $_s[0];
  750. $days = $_s[1];
  751. if ($days > 0) {
  752. $tmp[] = $month;
  753. }
  754. }
  755. $set = $tmp;
  756. }
  757. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6)) {
  758. $info["recommendAllowanceType"] = 2;
  759. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)";
  760. }
  761. return $set;
  762. }
  763. //合并所有项目的月份
  764. private function mergeMonth($detailList) {
  765. $taxList = [];
  766. $wagesList = [];
  767. $pensionList = [];
  768. $unemploymentList = [];
  769. $medicaList = [];
  770. $attendanceList = [];
  771. $workdayList = [];
  772. foreach ($detailList as $detail) {
  773. $projectMap = $detail["projectMap"];
  774. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  775. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  776. $taxList = array_merge($taxList, $tmp);
  777. }
  778. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  779. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  780. $wagesList = array_merge($wagesList, $tmp);
  781. }
  782. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  783. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  784. $pensionList = array_merge($pensionList, $tmp);
  785. }
  786. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  787. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  788. $unemploymentList = array_merge($unemploymentList, $tmp);
  789. }
  790. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  791. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  792. $medicaList = array_merge($medicaList, $tmp);
  793. }
  794. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  795. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  796. $attendanceList = array_merge($attendanceList, $tmp);
  797. }
  798. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  799. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  800. $workdayList = array_merge($workdayList, $tmp);
  801. }
  802. }
  803. $map = [
  804. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  805. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  806. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  807. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  808. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  809. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  810. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  811. ];
  812. return $map;
  813. }
  814. /**
  815. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  816. * */
  817. private function mergeMonthNeedDay($detailList) {
  818. $attendMap = [];
  819. $workDayMap = [];
  820. foreach ($detailList as $detail) {
  821. $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  822. $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  823. }
  824. $res = [
  825. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  826. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  827. ];
  828. return $res;
  829. }
  830. private function getMergeMonthNeedDayMap($project, $map) {
  831. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  832. $monthAndDayList = array_filter(explode(",", $project["months"]));
  833. for ($i = 0; $i < count($monthAndDayList); $i++) {
  834. $obj = explode("=", $monthAndDayList[$i]);
  835. $month = $obj[0];
  836. $day = $obj[1];
  837. $count = $map[$month];
  838. if ($count == 0) {
  839. $map[$month] = $day;
  840. } else {
  841. $map[$month] = $day + $count;
  842. }
  843. }
  844. }
  845. return $map;
  846. }
  847. /**
  848. * 校验是否在审核范围内
  849. */
  850. public function validateIsCheck() {
  851. $id = $this->request["id"];
  852. $type = $this->request["type"];
  853. $process = $this->request["process"];
  854. $info = null;
  855. switch ($type) {
  856. case 1: //编辑合同
  857. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  858. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  859. break;
  860. case 2: //编辑项目
  861. $project = \app\common\model\TalentAllowanceProject::find($id);
  862. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  863. break;
  864. case 3:
  865. $info = TalentAllowanceApi::getInfoById($id);
  866. break;
  867. }
  868. if (!$info) {
  869. return new Response(Response::ERROR, "校验不通过,无法操作");
  870. }
  871. $where = [];
  872. $where[] = ["mainId", "=", $info["id"]];
  873. $where[] = ["step", "=", $process];
  874. $where[] = ["active", "=", 2];
  875. $log = null;
  876. switch ($process) {
  877. case 1:
  878. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  879. return new Response(Response::ERROR, "不在审核范围内");
  880. }
  881. //$where[] = ["companyId","=",$this->user["companyId"]];
  882. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  883. break;
  884. case 2:
  885. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  886. return new Response(Response::ERROR, "不在审核范围内");
  887. }
  888. break;
  889. case 3:
  890. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  891. return new Response(Response::ERROR, "不在审核范围内");
  892. }
  893. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  894. break;
  895. }
  896. if ($log != null) {
  897. $info["checkState"] = $log["state"];
  898. $info["checkMsg"] = $log["description"];
  899. } else {
  900. $info["checkState"] = null;
  901. $info["checkMsg"] = "";
  902. }
  903. $res = [];
  904. $res["info"] = $info;
  905. if ($type == 3) {
  906. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  907. $where = [];
  908. $where[] = ["mainId", "=", $id];
  909. $where[] = ["isLock", "=", 1];
  910. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  911. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  912. $detailMap = array_reduce($detailList, function ($result, $item) {
  913. $key = $item["id"];
  914. $result[$key] = $item;
  915. return $result;
  916. }, []);
  917. foreach ($detailList as &$detail) {
  918. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  919. }unset($detail);
  920. foreach ($projectList as &$project) {
  921. $detail = $detailMap[$project["baseId"]];
  922. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  923. }
  924. $where = [];
  925. $where[] = ["type", "=", $info["type"]];
  926. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  927. $where[] = ["active", "=", 1];
  928. $where[] = ["delete", "=", 0];
  929. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  930. $res["files"] = $filetypes;
  931. $res["projects"] = $projectList;
  932. $res["concats"] = $detailList;
  933. }
  934. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  935. }
  936. /**
  937. * 查询工作单位
  938. */
  939. public function findAllowanceContractDetail() {
  940. $mainId = $this->request["mainId"];
  941. $offset = $this->request["offset"] ?: 0;
  942. $limit = $this->request["limit"] ?: 1000;
  943. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  944. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  945. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  946. foreach ($list as &$row) {
  947. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  948. }unset($row);
  949. return json(["rows" => $list, "total" => $count]);
  950. }
  951. /**
  952. * 查询核查项目情况
  953. */
  954. public function findAllowanceProject() {
  955. $mainId = $this->request["mainId"];
  956. $baseId = $this->request["baseId"];
  957. $offset = $this->request["offset"] ?: 0;
  958. $limit = $this->request["limit"] ?: 1000;
  959. $where = [];
  960. $where[] = ["mainId", "=", $mainId];
  961. $where[] = ["baseId", "=", $baseId];
  962. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  963. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  964. $info = TalentAllowanceApi::getInfoById($mainId);
  965. foreach ($list as &$project) {
  966. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  967. if ($info["checkState"] == 1) {
  968. $project["isEdit"] = in_array($project["project"], [
  969. AllowanceProjectEnum::PROJECT_CONTRACT,
  970. AllowanceProjectEnum::PROJECT_TAX,
  971. AllowanceProjectEnum::PROJECT_WAGES,
  972. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  973. AllowanceProjectEnum::PROJECT_SB_PENSION,
  974. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  975. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  976. AllowanceProjectEnum::PROJECT_WORKDAY
  977. ]) ? 1 : 2;
  978. } else if ($info["checkState"] == 10) {
  979. $projects = explode(",", $info["projects"]);
  980. if (in_array($project["id"], $projects)) {
  981. $project["isEdit"] = 1;
  982. } else {
  983. $project["isEdit"] = 2;
  984. }
  985. } else {
  986. $project["isEdit"] = 2;
  987. }
  988. }unset($project);
  989. return json(["rows" => $list, "total" => $count]);
  990. }
  991. /**
  992. * 查询人才层次变更记录
  993. */
  994. public function findAllowanceArrange() {
  995. $mainId = $this->request["mainId"];
  996. $offset = $this->request["offset"] ?: 0;
  997. $limit = $this->request["limit"] ?: 1000;
  998. $where = [];
  999. $where[] = ["mainId", "=", $mainId];
  1000. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  1001. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  1002. foreach ($list as &$arrange) {
  1003. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  1004. $arrange["identifyConditionText"] = $condition["name"];
  1005. $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  1006. }unset($arrange);
  1007. return json(["rows" => $list, "total" => $count]);
  1008. }
  1009. private function setTalentAllowanceInfo($where, $query, $process) {
  1010. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1011. $where[] = ["year", "=", $query["year"]];
  1012. }
  1013. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1014. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1015. }
  1016. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1017. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1018. }
  1019. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1020. $where[] = ["talentType", "=", $query["talentType"]];
  1021. }
  1022. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1023. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1024. }
  1025. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1026. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  1027. }
  1028. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1029. $where[] = ["address", "=", $query["address"]];
  1030. }
  1031. if ($query["recommendAllowanceType"]) {
  1032. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1033. }
  1034. if ($query["publicState"]) {
  1035. $where[] = ["publicState", "=", $query["publicState"]];
  1036. }
  1037. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1038. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  1039. }
  1040. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1041. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  1042. }
  1043. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1044. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  1045. }
  1046. if ($process == 4) {
  1047. if ($query["isSupple"]) {
  1048. $where[] = ["isSupple", "=", $query["isSupple"]];
  1049. }
  1050. if ($query["isPublicCheck"]) {
  1051. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  1052. }
  1053. }
  1054. if ($query["checkState"]) {
  1055. if ($query["checkState"] == -1) {
  1056. $where[] = ["checkState", "=", $query["checkState"]];
  1057. } else {
  1058. if ($process == 1) {
  1059. switch ($query["checkState"]) {
  1060. case 0: //保存未提交
  1061. $where[] = ["checkState", "=", 1];
  1062. break;
  1063. case 1:
  1064. $where[] = ["checkState", "=", 5];
  1065. break;
  1066. case 2: //驳回
  1067. $where[] = ["checkState", "=", 10];
  1068. break;
  1069. case 3: //通过
  1070. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  1071. break;
  1072. case 4: //重新提交
  1073. $where[] = ["checkState", "=", 5];
  1074. $where[] = ["highProcess", ">=", $process];
  1075. break;
  1076. case 5: //上级驳回
  1077. $where[] = ["checkState", "=", 13];
  1078. break;
  1079. }
  1080. }
  1081. if ($process == 2) {
  1082. switch ($query["checkState"]) {
  1083. case 1:
  1084. $where[] = ["checkState", "=", 15];
  1085. break;
  1086. case 2: //驳回
  1087. $where[] = ["checkState", "in", [1, 5, 10]];
  1088. $where[] = ["highProcess", ">=", $process];
  1089. break;
  1090. case 3: //通过
  1091. $where[] = ["checkState", "in", [20, 30]];
  1092. break;
  1093. case 9: //重新提交
  1094. $where[] = ["checkState", "=", 15];
  1095. $where[] = ["highProcess", ">=", $process];
  1096. break;
  1097. case 4: //上级驳回
  1098. $where[] = ["checkState", "=", 25];
  1099. break;
  1100. case -1:
  1101. $where[] = ["checkState", "=", -1];
  1102. break;
  1103. }
  1104. }
  1105. if ($process == 3) {
  1106. switch ($query["checkState"]) {
  1107. case -1:
  1108. $where[] = ["checkState", "=", -1];
  1109. break;
  1110. case 1:
  1111. $where[] = ["checkState", "=", 20];
  1112. break;
  1113. case 2: //驳回
  1114. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  1115. $where[] = ["highProcess", ">=", $process];
  1116. break;
  1117. case 3: //通过
  1118. $where[] = ["checkState", "=", 30];
  1119. break;
  1120. case 9: //重新提交
  1121. $where[] = ["checkState", "=", 20];
  1122. $where[] = ["highProcess", ">=", $process];
  1123. break;
  1124. case 4: //上级驳回
  1125. $where[] = ["checkState", "=", 35];
  1126. break;
  1127. }
  1128. }
  1129. if ($process == 4) {
  1130. switch ($query["checkState"]) {
  1131. case -1:
  1132. $where[] = ["checkState", "=", -1];
  1133. break;
  1134. case 3: //通过
  1135. $where[] = ["checkState", "=", 30];
  1136. break;
  1137. }
  1138. }
  1139. }
  1140. }
  1141. return $where;
  1142. }
  1143. private function translateToChinese(&$obj) {
  1144. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1145. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1146. }
  1147. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1148. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1149. }
  1150. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1151. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1152. }
  1153. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1154. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1155. }
  1156. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1157. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1158. }
  1159. }
  1160. private function translateChinese($list) {
  1161. //获取字典表
  1162. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1163. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1164. $streetMap = DictApi::selectByParentCode("street");
  1165. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1166. $modeMap = DictApi::selectByParentCode("import_way");
  1167. $where = [];
  1168. $where[] = ["type", "=", $this->user["type"]];
  1169. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1170. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1171. foreach ($list as &$info) {
  1172. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  1173. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1174. }
  1175. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1176. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  1177. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  1178. }
  1179. $info["addressName"] = $streetMap[$info["address"]];
  1180. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  1181. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  1182. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1183. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  1184. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  1185. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  1186. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  1187. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  1188. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  1189. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  1190. }unset($info);
  1191. return $list;
  1192. }
  1193. }