TalentAllowance.php 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628
  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 publicBatch() {
  525. $params = $this->request->param();
  526. $ids = $params["ids"];
  527. $ids = array_filter(explode(",", $ids));
  528. if (!$ids) {
  529. return new Response(Response::ERROR, "请至少选择一行数据");
  530. }
  531. $isMessage = $params["isMessage"] == 1 ? true : false;
  532. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  533. return new Response(Response::ERROR, "短信参数不能为空");
  534. }
  535. $where = [];
  536. $where[] = ["id", "in", $ids];
  537. $list = TaModel::where($where)->select()->toArray();
  538. Db::startTrans();
  539. try {
  540. $logList = [];
  541. $phones = [];
  542. foreach ($list as $info) {
  543. $data["id"] = $info["id"];
  544. $data["publicState"] = 3;
  545. Db::table("un_talent_allowance_info")->update($data);
  546. /* * 添加日志 */
  547. $logList[] = [
  548. "id" => getStringId(),
  549. "type" => ProjectState::JBT,
  550. "mainId" => $info["id"],
  551. "active" => 1,
  552. "state" => 3,
  553. "step" => 5,
  554. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  555. "description" => "批量公示",
  556. "createTime" => date("Y-m-d H:i:s"),
  557. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  558. ];
  559. $phones[] = $info["phone"];
  560. }
  561. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  562. Db::commit();
  563. if ($phones && $isMessage && $effect) {
  564. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  565. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  566. $phones = array_filter($phones);
  567. foreach ($phones as $phone) {
  568. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "津补贴-批量公示", "userType" => 3]);
  569. }
  570. }
  571. return new Response(Response::SUCCESS, "公示成功");
  572. } catch (\think\db\exception\DbException $e) {
  573. Db::rollback();
  574. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  575. }
  576. }
  577. /**
  578. * 跳转到公示再审核页面
  579. * */
  580. public function toSupplePage() {
  581. $id = $this->request["id"];
  582. $process = $this->request["process"];
  583. $obj = TalentAllowanceApi::getInfoById($id);
  584. $this->translateToChinese($obj);
  585. return view("public_check", ["row" => $obj, "process" => $process]);
  586. }
  587. /**
  588. * 公示再审核计算津补贴
  589. * */
  590. public function suppleCheckCalculate() {
  591. $id = $this->request["id"];
  592. try {
  593. $info = TalentAllowanceApi::getInfoById($id);
  594. $arrangeList = $this->validateAllowanceType($info);
  595. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  596. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  597. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  598. foreach ($detailList as &$detail) {
  599. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  600. if (\StrUtil::isNotEmpAndNull($detal["talentType"])) {
  601. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  602. }
  603. }
  604. $res = [
  605. "info" => $info,
  606. "detailList" => $detailList
  607. ];
  608. return new Response(Response::SUCCESS, "计算成功", $res);
  609. } catch (\think\Exception $e) {
  610. return new Response(Response::ERROR, "系统异常,请联系管理员");
  611. }
  612. }
  613. /**
  614. * 公示后审核
  615. */
  616. public function afterCheck() {
  617. $param = $this->request->param();
  618. if (!$param["id"]) {
  619. return new Response(Response::ERROR, "系统错误,请联系管理员");
  620. }
  621. $old = TalentAllowanceApi::getInfoById($param["id"]);
  622. if ($old["publicState"] != 3) {
  623. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  624. }
  625. try {
  626. $arrangeList = null;
  627. $desc = "审核意见:" . $param["checkMsg"] . ";\n";
  628. $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
  629. $data["id"] = $param["id"];
  630. if ($param["checkState"] == -1) {
  631. $data["checkState"] = -1;
  632. $data["checkMsg"] = $param["checkMsg"];
  633. $data["allowanceType"] = 3;
  634. $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
  635. $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
  636. } else if ($param["checkState"] == 3) {
  637. if ($param["zxState"] == 1) {
  638. $typeName = "";
  639. $old["recommendAllowanceMsg"] = "";
  640. if ($param["source"] == 1) { //遵循系统结果
  641. $arrangeList = $this->validateAllowanceType($old);
  642. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  643. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
  644. } else if ($param["source"] == 2) {
  645. $detailIds = array_column($param["details"], "id");
  646. $where = [];
  647. $where[] = ["id", "in", $detailIds];
  648. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  649. $set = [];
  650. if ($params["resAllowanceType"] == 1) {
  651. $monthsMap = [];
  652. for ($i = 0; $i < count($param["details"]); $i++) {
  653. $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
  654. }
  655. foreach ($detailList as &$detail) {
  656. $months = $monthdsMap[$detail["id"]];
  657. if (\StrUtil::isNotEmpAndNull($months)) {
  658. $detail["months"] = $months;
  659. $set = array_merge($set, explode(",", $months));
  660. }
  661. }unset($detail);
  662. }
  663. $set = array_filter($set);
  664. usort($set, function($a, $b) {
  665. return (int) $a - (int) $b;
  666. });
  667. $old["recommendAllowanceType"] = $param["resAllowanceType"];
  668. $old["recommendMonths"] = implode(",", $set);
  669. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  670. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
  671. $arrangeList = $this->calculateAllowance($old, $set, $detailList);
  672. }
  673. $desc .= "判定结果:" . $typeName;
  674. $data["checkState"] = 30;
  675. $data["outMsg"] = "";
  676. $data["allowanceType"] = $old["recommendAllowanceType"];
  677. $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
  678. $data["months"] = $old["recommendMonths"];
  679. $data["money"] = $old["recommendMoney"];
  680. $data["moneyDesc"] = $old["recommendMoneyDesc"];
  681. $data["jtTalentArrange"] = $old["recommendTalentArrange"];
  682. $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
  683. $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
  684. } else {
  685. $data["checkState"] = -1;
  686. $data["outMsg"] = $param["zxMsg"];
  687. $data["allowanceType"] = 3;
  688. $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
  689. }
  690. }
  691. if ($param["allowanceType"] == 3) {
  692. $data["months"] = "";
  693. $data["money"] = 0;
  694. $data["moneyDesc"] = "";
  695. $data["jtTalentArrange"] = "";
  696. $data["workAllowanceMoney"] = null;
  697. $data["developAllowanceMoney"] = null;
  698. }
  699. $data["isPublicCheck"] = 1;
  700. $data["publicState"] = 4;
  701. //添加日志
  702. TalentChecklog::create([
  703. 'id' => getStringId(),
  704. 'mainId' => $old['id'],
  705. 'type' => intval(ProjectState::JBT),
  706. 'typeFileId' => null,
  707. 'active' => 1,
  708. 'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
  709. 'step' => 6,
  710. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  711. 'description' => $desc,
  712. 'createTime' => date("Y-m-d H:i:s", time()),
  713. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  714. ]);
  715. TaModel::update($data);
  716. if ($arrangeList != null) {
  717. $taaModel = new TalentAllowanceArrange();
  718. $taaModel->saveAll($arrangeList);
  719. }
  720. return new Response(Response::SUCCESS, "审核成功");
  721. } catch (\think\Exception $e) {
  722. return new Response(Response::ERROR, "系统异常,请联系管理员");
  723. }
  724. }
  725. /**
  726. * 批量公示通过
  727. */
  728. public function publicPass() {
  729. $ids = $this->request["ids"];
  730. $ids = explode(",", $ids);
  731. if (!$ids) {
  732. return new Response(Response::ERROR, "请至少选择一行数据");
  733. }
  734. $where = [];
  735. $where[] = ["id", "in"];
  736. $list = TaModel::where($where)->select()->toArray();
  737. $logList = [];
  738. try {
  739. Db::startTrans();
  740. for ($i = 0; $i < count($list); $i++) {
  741. $obj = $list[$i];
  742. $upd["id"] = $obj["id"];
  743. $upd["publicState"] = 4;
  744. $upd["allowanceType"] = $obj["recommendAllowanceType"];
  745. $upd["allowanceMsg"] = $obj["recommendAllowanceMsg"];
  746. if ($upd["allowanceType"] == 1) {
  747. $upd["months"] = $obj["recommendMonths"];
  748. $upd["money"] = $obj["recommendMoney"];
  749. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  750. } else if ($upd["allowanceType"] == 2) {
  751. $upd["months"] = "";
  752. $upd["jtTalentArrange"] = $obj["recommendTalentArrange"];
  753. $upd["money"] = $obj["recommendMoney"];
  754. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  755. $upd["workAllowanceMoney"] = null;
  756. $upd["developAllowanceMoney"] = null;
  757. } else {
  758. $upd["months"] = "";
  759. $upd["money"] = 0.00;
  760. $upd["workAllowanceMoney"] = null;
  761. $upd["developAllowanceMoney"] = null;
  762. }
  763. Db::table("un_talent_allowance_info")->update($upd);
  764. //添加日志
  765. $stateChange = null;
  766. $desc = null;
  767. if ($obj["checkState"] == AllowanceStateEnum::NOTPASS) {
  768. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-danger'>审核不通过</span>";
  769. $desc = "审核不通过";
  770. } else {
  771. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  772. $desc = "批量公示";
  773. }
  774. $logList[] = [
  775. "id" => getStringId(),
  776. "type" => ProjectState::JBT,
  777. "mainId" => $obj["id"],
  778. "active" => 1,
  779. "state" => 3,
  780. "step" => 6,
  781. "stateChange" => $stateChange,
  782. "description" => $desc,
  783. "createTime" => date("Y-m-d H:i:s"),
  784. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  785. ];
  786. }
  787. Db::table("new_talent_checklog")->insertAll($logList);
  788. Db::commit();
  789. return new Response(Response::SUCCESS, "批量公示通过成功");
  790. } catch (\think\db\exception\DbException $e) {
  791. Db::rollback();
  792. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  793. }
  794. }
  795. /**
  796. * 兑现
  797. */
  798. public function cash() {
  799. $ids = $this->request["ids"];
  800. $ids = array_filter(explode(",", $ids));
  801. if (!$ids) {
  802. return new Response(Response::ERROR, "请至少选择一行数据");
  803. }
  804. $where = [];
  805. $where[] = ["id", "in", $ids];
  806. $list = TaModel::where($where)->select()->toArray();
  807. //添加日志
  808. $logList = [];
  809. try {
  810. Db::startTrans();
  811. for ($i = 0; $i < count($list); $i++) {
  812. $obj = $list[$i];
  813. $upd["id"] = $obj["id"];
  814. $upd["publicState"] = 5;
  815. Db::table("un_talent_allowance_info")->update($upd);
  816. $logList[] = [
  817. "id" => getStringId(),
  818. "type" => ProjectState::JBT,
  819. "mainId" => $obj["id"],
  820. "active" => 1,
  821. "state" => 3,
  822. "step" => 50,
  823. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  824. "description" => "批量兑现",
  825. "createTime" => date("Y-m-d H:i:s"),
  826. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  827. ];
  828. }
  829. Db::table("new_talent_checklog")->insertAll($logList);
  830. Db::commit();
  831. return new Response(Response::SUCCESS, "批量兑现成功");
  832. } catch (\think\db\exception\DbException $e) {
  833. Db::rollback();
  834. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  835. }
  836. }
  837. /**
  838. * 公示预览(不予兑现)
  839. */
  840. public function exportPublicNotCash() {
  841. $response = new \stdClass();
  842. $response->code = 500;
  843. //获取字典表人才层次+
  844. $levelMap = DictApi::selectByParentCode("talent_arrange");
  845. $streetMap = DictApi::selectByParentCode("street");
  846. //查询企业信息
  847. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  848. //查询所有
  849. $where = [];
  850. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  851. $list = TaModel::where($where)->select()->toArray();
  852. $rows = [];
  853. for ($i = 0; $i < count($list); $i++) {
  854. $item = $list[$i];
  855. $rows[] = [
  856. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  857. ];
  858. }
  859. $filename = ($this->user["type"] == 1 ? "晋江市优秀人才" : "晋江市集成电路人才") . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  860. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  861. if ($rows) {
  862. export($columns, $rows, $filename);
  863. exit();
  864. } else {
  865. $response->msg = "没有选择导出的名单";
  866. return \StrUtil::back($response, "TalentTypeChange.callBack");
  867. }
  868. }
  869. /**
  870. * 导出公示名单(需要兑现)
  871. */
  872. public function exportPublic() {
  873. //获取字典表人才层次+
  874. $levelMap = DictApi::selectByParentCode("talent_arrange");
  875. $streetMap = DictApi::selectByParentCode("street");
  876. //查询企业信息
  877. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  878. /* * 查询需要公示的数据 */
  879. $where = [];
  880. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  881. $list = TaModel::where($where)->select()->toArray();
  882. /* * 查询相关的津补贴人才层次 */
  883. $where = [];
  884. $where[] = ["mainId", "in", explode(",", $this->request["ids"])];
  885. $arrangeList = TalentAllowanceArrange::where($where)->select()->toArray();
  886. foreach ($arrangeList as &$arrange) {
  887. $arrange["talentArrangeName"] = $levelMap[$arrange["talentArrange"]];
  888. }unset($arrange);
  889. /* Map<String,List<TalentAllowanceArrange>> arrangeMap = arrangeList.stream().collect(Collectors.groupingBy(TalentAllowanceArrange::getMainId));
  890. Integer sheetSize = 0;
  891. for(TalentAllowanceInfo info:allList){
  892. info.setEnterpriseName(enterpriseMap.get(info.getEnterpriseId()));
  893. info.setAddressName(streetMap.get(info.getAddress()));
  894. info.setTalentArrangeName(levelMap.get(info.getTalentArrange()));
  895. if(info.getRecommendAllowanceType() == 1){
  896. info.setArrangeList(arrangeMap.get(info.getId()));
  897. sheetSize = sheetSize + info.getArrangeList().size();
  898. }else if(info.getRecommendAllowanceType() == 1){
  899. sheetSize++;
  900. }
  901. } */
  902. $filename = ($this->user["type"] == 1 ? "晋江市优秀人才" : "晋江市集成电路人才") . $list[0]["year"] . "年度津补贴拟发放对象名单";
  903. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "津补贴享受月份数", "每月享受津贴标准(元)", $list[0]["year"] . "年度累计应享受津补贴金额(元)", "备注"];
  904. }
  905. /**
  906. * 导出基本信息
  907. */
  908. public function exportBasicInfo() {
  909. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  910. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  911. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  912. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  913. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  914. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  915. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  916. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  917. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  918. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  919. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  920. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  921. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  922. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  923. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  924. $obj["type"] = $this->user["type"];
  925. $list = [];
  926. switch ($obj["process"]) {
  927. case 1:
  928. break;
  929. case 2:
  930. break;
  931. case 3:
  932. break;
  933. case 4:
  934. break;
  935. }
  936. }
  937. private function validateAllowanceType(&$info) {
  938. $old = TalentAllowanceApi::getInfoById($info["id"]);
  939. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  940. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  941. /* * 查询工作单位记录 */
  942. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  943. $detaiPdList = []; //用于判定类型
  944. $detailMonthList = []; //用于计算月份
  945. $recommendAllowanceMsg = [];
  946. foreach ($initDetailList as $detail) {
  947. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  948. $projectMap = [];
  949. foreach ($projectList as $project) {
  950. $projectMap[$project["project"]] = $project;
  951. }
  952. $detail["list"] = $projectList;
  953. $detail["projectMap"] = $projectMap;
  954. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  955. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  956. /* * 筛选符合条件的人才标签 */
  957. $detaiPdList[] = $detail;
  958. $detailMonthList[] = $detail;
  959. }
  960. /* * 集成电路优秀人才 */
  961. if ($this->user["type"] == 2) {
  962. /* * 获取各个项目的综合月份 */
  963. $monthMap = $this->mergeMonth($detailMonthList);
  964. $monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList);
  965. $info["recommendAllowanceType"] = 1;
  966. $info["recommendAllowanceMsg"] = "";
  967. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $info["id"])->select()->toArray();
  968. $set = $this->valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  969. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n综合以上所有判断得到最终补贴类型为:";
  970. if ($info["recommendAllowanceType"] == 1) {
  971. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "工作津贴;可享受月份为:" . implode(",", $set) . "\n";
  972. }
  973. if ($info["recommendAllowanceType"] == 2)
  974. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "一次性交通补贴;";
  975. if ($info["recommendAllowanceType"] == 3)
  976. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "不予兑现;";
  977. usort($set, function($a, $b) {
  978. return (int) $a - (int) $b;
  979. });
  980. }
  981. $info["recommendMonths"] = implode(",", $set);
  982. $arrangeList = $this->calculateAllowance($info, $set, $detailMonthList);
  983. return $arrangeList;
  984. }
  985. /**
  986. * 集成电路津补贴总校验
  987. * */
  988. private function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  989. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  990. /* * 2.判定工作月份、五险和个税是否满足重叠6个月要求* */
  991. $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "①");
  992. $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "②");
  993. $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "③");
  994. $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "④");
  995. $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑤");
  996. $set = array_intersect($set, $workdaySet);
  997. $set = array_intersect($set, $pensionSet);
  998. $set = array_intersect($set, $unemploymentSet);
  999. $set = array_intersect($set, $medicaSet);
  1000. $set = array_intersect($set, $taxSet);
  1001. usort($set, function($a, $b) {
  1002. return (int) $a - (int) $b;
  1003. });
  1004. if ($info["recommendAllowanceType"] == 1) {
  1005. if (count($set) < 6) {
  1006. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  1007. $info["recommendAllowanceType"] == 2;
  1008. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n社会保险、个税、上年度工作月份交集月份不满足6个月(" . implode(",", $set) . "),无法享受工作津贴(×)";
  1009. } else {
  1010. //检查连续缴纳月份是否满足6个月
  1011. $count = 1;
  1012. foreach ($set as $s) {
  1013. $currentVal = intval($s);
  1014. $nextVal = $currentVal + 1;
  1015. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1016. if (in_array($nextKey, $set)) {
  1017. $count++;
  1018. if ($count >= 6) {
  1019. break;
  1020. }
  1021. } else {
  1022. $count = 1;
  1023. }
  1024. }
  1025. if ($count < 6) {
  1026. $info["recommendAllowanceType"] == 2;
  1027. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n社会保险、个税、上年度工作月份交集月份不满足连续缴纳6个月(" . implode(",", $set) . "),无法享受工作津贴(×)";
  1028. }
  1029. }
  1030. }
  1031. if ($info["recommendAllowanceType"] == 2) {
  1032. //判断境内工作时间是否大于30天
  1033. $totalDays = 0;
  1034. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  1035. foreach ($workmonths as $days) {
  1036. $totalDays += $days;
  1037. }
  1038. if ($totalDays < 30) {
  1039. $info["recommendAllowanceType"] == 3;
  1040. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  1041. }
  1042. }
  1043. return $set;
  1044. }
  1045. /**
  1046. * 计算津补贴
  1047. */
  1048. private function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  1049. /* * 查询人才层次变更记录 */
  1050. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  1051. foreach ($arrangeList as &$arrange) {
  1052. $where = [];
  1053. $where[] = ["type", "=", $this->user["type"]];
  1054. $where[] = ["allowanceType", "in", [1, 2]];
  1055. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  1056. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  1057. foreach ($list as $amount) {
  1058. if ($amount["allowanceType"] == 1) {
  1059. $arrange["jobMoney"] = $amount["money"];
  1060. }
  1061. if ($amount["allowanceType"] == 2) {
  1062. $arrange["jtMoney"] = $amount["money"];
  1063. }
  1064. }
  1065. }unset($arrange);
  1066. /* * * 容器 */
  1067. $jobMoney = 0.00; //计算所得工作津贴
  1068. $jtMoney = 0.00; //计算所得一次性交通补贴
  1069. $recommendMonths = []; //推荐月份
  1070. $talentArrange = null;
  1071. /* * *********计算************* */
  1072. $msgBulider = [];
  1073. switch ($info["recommendAllowanceType"]) {
  1074. case 1:
  1075. foreach ($arrangeList as &$arrange) {
  1076. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  1077. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  1078. $levelList = array_intersect($levelList, $retainMonths);
  1079. $total = round($arrange["jobMoney"] * count($levelList), 2);
  1080. $jobMoney += $total;
  1081. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  1082. $recommendMonths = array_merge($recommendMonths, $levelList);
  1083. usort($recommendMonths, function($a, $b) {
  1084. return (int) $a - (int) $b;
  1085. });
  1086. $arrange["months"] = implode(",", $levelList);
  1087. $arrange["count"] = count($levelList);
  1088. $arrange["total"] = $total;
  1089. } else {
  1090. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  1091. $arrange["count"] = 0;
  1092. $arrange["total"] = 0.00;
  1093. }
  1094. }unset($arrange);
  1095. $info["recommendMonths"] = implode(",", $recommendMonths);
  1096. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "通过与人才证书有效期取交集得到最终可享受月份:" . implode(",", $recommendMonths) . "\n经过计算:人才津贴为" . $jobMoney . ";";
  1097. $info["recommendMoney"] = $jobMoney;
  1098. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  1099. break;
  1100. case 2:
  1101. foreach ($arrangeList as $arrange) {
  1102. $jtMoney = $arrange["jtMoney"];
  1103. $talentArrange = $arrange["talentArrange"];
  1104. }
  1105. $info["recommendMoney"] = $jtMoney;
  1106. $info["recommendMonths"] = "";
  1107. $info["recommendMoneyDesc"] = "一次性交通补贴";
  1108. $info["workAllowanceMoney"] = 0.00;
  1109. $info["developAllowanceMoney"] = 0.00;
  1110. $info["recommendTalentArrange"] = $talentArrange;
  1111. break;
  1112. case 3:
  1113. $info["recommendMoney"] = 0.00;
  1114. $info["recommendMonths"] = "";
  1115. $info["recommendMoneyDesc"] = "不予兑现";
  1116. $info["workAllowanceMoney"] = 0.00;
  1117. $info["developAllowanceMoney"] = 0.00;
  1118. break;
  1119. }
  1120. return $arrangeList;
  1121. }
  1122. /**
  1123. * 判定是否交足6个月(集成电路)
  1124. * @param set
  1125. * @param info
  1126. * @param name
  1127. */
  1128. private function chkMonths($set, &$info, $name, $sort) {
  1129. if ($name == "上年度工作月份") {
  1130. $tmp = [];
  1131. foreach ($set as $s) {
  1132. $_s = explode("=", $s);
  1133. $month = $_s[0];
  1134. $days = $_s[1];
  1135. if ($days > 0) {
  1136. $tmp[] = $month;
  1137. }
  1138. }
  1139. $set = $tmp;
  1140. }
  1141. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6)) {
  1142. $info["recommendAllowanceType"] = 2;
  1143. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)";
  1144. }
  1145. return $set;
  1146. }
  1147. //合并所有项目的月份
  1148. private function mergeMonth($detailList) {
  1149. $taxList = [];
  1150. $wagesList = [];
  1151. $pensionList = [];
  1152. $unemploymentList = [];
  1153. $medicaList = [];
  1154. $attendanceList = [];
  1155. $workdayList = [];
  1156. foreach ($detailList as $detail) {
  1157. $projectMap = $detail["projectMap"];
  1158. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  1159. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  1160. $taxList = array_merge($taxList, $tmp);
  1161. }
  1162. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  1163. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  1164. $wagesList = array_merge($wagesList, $tmp);
  1165. }
  1166. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  1167. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  1168. $pensionList = array_merge($pensionList, $tmp);
  1169. }
  1170. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  1171. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  1172. $unemploymentList = array_merge($unemploymentList, $tmp);
  1173. }
  1174. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  1175. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  1176. $medicaList = array_merge($medicaList, $tmp);
  1177. }
  1178. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  1179. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  1180. $attendanceList = array_merge($attendanceList, $tmp);
  1181. }
  1182. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  1183. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  1184. $workdayList = array_merge($workdayList, $tmp);
  1185. }
  1186. }
  1187. $map = [
  1188. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  1189. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  1190. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  1191. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  1192. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  1193. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  1194. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  1195. ];
  1196. return $map;
  1197. }
  1198. /**
  1199. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  1200. * */
  1201. private function mergeMonthNeedDay($detailList) {
  1202. $attendMap = [];
  1203. $workDayMap = [];
  1204. foreach ($detailList as $detail) {
  1205. $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  1206. $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  1207. }
  1208. $res = [
  1209. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  1210. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  1211. ];
  1212. return $res;
  1213. }
  1214. private function getMergeMonthNeedDayMap($project, $map) {
  1215. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  1216. $monthAndDayList = array_filter(explode(",", $project["months"]));
  1217. for ($i = 0; $i < count($monthAndDayList); $i++) {
  1218. $obj = explode("=", $monthAndDayList[$i]);
  1219. $month = $obj[0];
  1220. $day = $obj[1];
  1221. $count = $map[$month];
  1222. if ($count == 0) {
  1223. $map[$month] = $day;
  1224. } else {
  1225. $map[$month] = $day + $count;
  1226. }
  1227. }
  1228. }
  1229. return $map;
  1230. }
  1231. /**
  1232. * 校验是否在审核范围内
  1233. */
  1234. public function validateIsCheck() {
  1235. $id = $this->request["id"];
  1236. $type = $this->request["type"];
  1237. $process = $this->request["process"];
  1238. $info = null;
  1239. switch ($type) {
  1240. case 1: //编辑合同
  1241. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  1242. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1243. break;
  1244. case 2: //编辑项目
  1245. $project = \app\common\model\TalentAllowanceProject::find($id);
  1246. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  1247. break;
  1248. case 3:
  1249. $info = TalentAllowanceApi::getInfoById($id);
  1250. break;
  1251. }
  1252. if (!$info) {
  1253. return new Response(Response::ERROR, "校验不通过,无法操作");
  1254. }
  1255. $where = [];
  1256. $where[] = ["mainId", "=", $info["id"]];
  1257. $where[] = ["step", "=", $process];
  1258. $where[] = ["active", "=", 2];
  1259. $log = null;
  1260. switch ($process) {
  1261. case 1:
  1262. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  1263. return new Response(Response::ERROR, "不在审核范围内");
  1264. }
  1265. //$where[] = ["companyId","=",$this->user["companyId"]];
  1266. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1267. break;
  1268. case 2:
  1269. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  1270. return new Response(Response::ERROR, "不在审核范围内");
  1271. }
  1272. break;
  1273. case 3:
  1274. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  1275. return new Response(Response::ERROR, "不在审核范围内");
  1276. }
  1277. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1278. break;
  1279. }
  1280. if ($log != null) {
  1281. $info["checkState"] = $log["state"];
  1282. $info["checkMsg"] = $log["description"];
  1283. } else {
  1284. $info["checkState"] = null;
  1285. $info["checkMsg"] = "";
  1286. }
  1287. $res = [];
  1288. $res["info"] = $info;
  1289. if ($type == 3) {
  1290. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1291. $where = [];
  1292. $where[] = ["mainId", "=", $id];
  1293. $where[] = ["isLock", "=", 1];
  1294. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1295. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1296. $detailMap = array_reduce($detailList, function ($result, $item) {
  1297. $key = $item["id"];
  1298. $result[$key] = $item;
  1299. return $result;
  1300. }, []);
  1301. foreach ($detailList as &$detail) {
  1302. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1303. }unset($detail);
  1304. foreach ($projectList as &$project) {
  1305. $detail = $detailMap[$project["baseId"]];
  1306. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1307. }
  1308. $where = [];
  1309. $where[] = ["type", "=", $info["type"]];
  1310. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1311. $where[] = ["active", "=", 1];
  1312. $where[] = ["delete", "=", 0];
  1313. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1314. $res["files"] = $filetypes;
  1315. $res["projects"] = $projectList;
  1316. $res["concats"] = $detailList;
  1317. }
  1318. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  1319. }
  1320. /**
  1321. * 查询工作单位
  1322. */
  1323. public function findAllowanceContractDetail() {
  1324. $mainId = $this->request["mainId"];
  1325. $offset = $this->request["offset"] ?: 0;
  1326. $limit = $this->request["limit"] ?: 1000;
  1327. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  1328. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  1329. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  1330. foreach ($list as &$row) {
  1331. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  1332. }unset($row);
  1333. return json(["rows" => $list, "total" => $count]);
  1334. }
  1335. /**
  1336. * 查询核查项目情况
  1337. */
  1338. public function findAllowanceProject() {
  1339. $mainId = $this->request["mainId"];
  1340. $baseId = $this->request["baseId"];
  1341. $offset = $this->request["offset"] ?: 0;
  1342. $limit = $this->request["limit"] ?: 1000;
  1343. $where = [];
  1344. $where[] = ["mainId", "=", $mainId];
  1345. $where[] = ["baseId", "=", $baseId];
  1346. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  1347. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  1348. $info = TalentAllowanceApi::getInfoById($mainId);
  1349. foreach ($list as &$project) {
  1350. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  1351. if ($info["checkState"] == 1) {
  1352. $project["isEdit"] = in_array($project["project"], [
  1353. //AllowanceProjectEnum::PROJECT_CONTRACT,
  1354. AllowanceProjectEnum::PROJECT_TAX,
  1355. AllowanceProjectEnum::PROJECT_WAGES,
  1356. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1357. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1358. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1359. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1360. //AllowanceProjectEnum::PROJECT_WORKDAY
  1361. ]) ? 1 : 2;
  1362. } else if ($info["checkState"] == 10) {
  1363. $projects = explode(",", $info["projects"]);
  1364. if (in_array($project["id"], $projects)) {
  1365. $project["isEdit"] = 1;
  1366. } else {
  1367. $project["isEdit"] = 2;
  1368. }
  1369. } else {
  1370. $project["isEdit"] = 2;
  1371. }
  1372. }unset($project);
  1373. return json(["rows" => $list, "total" => $count]);
  1374. }
  1375. /**
  1376. * 查询人才层次变更记录
  1377. */
  1378. public function findAllowanceArrange() {
  1379. $mainId = $this->request["mainId"];
  1380. $offset = $this->request["offset"] ?: 0;
  1381. $limit = $this->request["limit"] ?: 1000;
  1382. $where = [];
  1383. $where[] = ["mainId", "=", $mainId];
  1384. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  1385. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  1386. foreach ($list as &$arrange) {
  1387. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  1388. $arrange["identifyConditionText"] = $condition["name"];
  1389. $arrange["talentArrangeName"] = \app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  1390. }unset($arrange);
  1391. return json(["rows" => $list, "total" => $count]);
  1392. }
  1393. private function setTalentAllowanceInfo($where, $query, $process) {
  1394. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1395. $where[] = ["year", "=", $query["year"]];
  1396. }
  1397. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1398. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1399. }
  1400. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1401. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1402. }
  1403. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1404. $where[] = ["talentType", "=", $query["talentType"]];
  1405. }
  1406. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1407. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1408. }
  1409. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1410. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  1411. }
  1412. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1413. $where[] = ["address", "=", $query["address"]];
  1414. }
  1415. if ($query["recommendAllowanceType"]) {
  1416. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1417. }
  1418. if ($query["publicState"]) {
  1419. $where[] = ["publicState", "=", $query["publicState"]];
  1420. }
  1421. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1422. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  1423. }
  1424. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1425. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  1426. }
  1427. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1428. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  1429. }
  1430. if ($process == 4) {
  1431. if ($query["isSupple"]) {
  1432. $where[] = ["isSupple", "=", $query["isSupple"]];
  1433. }
  1434. if ($query["isPublicCheck"]) {
  1435. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  1436. }
  1437. }
  1438. if ($query["checkState"]) {
  1439. if ($query["checkState"] == -1) {
  1440. $where[] = ["checkState", "=", $query["checkState"]];
  1441. } else {
  1442. if ($process == 1) {
  1443. switch ($query["checkState"]) {
  1444. case 0: //保存未提交
  1445. $where[] = ["checkState", "=", 1];
  1446. break;
  1447. case 1:
  1448. $where[] = ["checkState", "=", 5];
  1449. break;
  1450. case 2: //驳回
  1451. $where[] = ["checkState", "=", 10];
  1452. break;
  1453. case 3: //通过
  1454. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  1455. break;
  1456. case 4: //重新提交
  1457. $where[] = ["checkState", "=", 5];
  1458. $where[] = ["highProcess", ">=", $process];
  1459. break;
  1460. case 5: //上级驳回
  1461. $where[] = ["checkState", "=", 13];
  1462. break;
  1463. }
  1464. }
  1465. if ($process == 2) {
  1466. switch ($query["checkState"]) {
  1467. case 1:
  1468. $where[] = ["checkState", "=", 15];
  1469. break;
  1470. case 2: //驳回
  1471. $where[] = ["checkState", "in", [1, 5, 10]];
  1472. $where[] = ["highProcess", ">=", $process];
  1473. break;
  1474. case 3: //通过
  1475. $where[] = ["checkState", "in", [20, 30]];
  1476. break;
  1477. case 9: //重新提交
  1478. $where[] = ["checkState", "=", 15];
  1479. $where[] = ["highProcess", ">=", $process];
  1480. break;
  1481. case 4: //上级驳回
  1482. $where[] = ["checkState", "=", 25];
  1483. break;
  1484. case -1:
  1485. $where[] = ["checkState", "=", -1];
  1486. break;
  1487. }
  1488. }
  1489. if ($process == 3) {
  1490. switch ($query["checkState"]) {
  1491. case -1:
  1492. $where[] = ["checkState", "=", -1];
  1493. break;
  1494. case 1:
  1495. $where[] = ["checkState", "=", 20];
  1496. break;
  1497. case 2: //驳回
  1498. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  1499. $where[] = ["highProcess", ">=", $process];
  1500. break;
  1501. case 3: //通过
  1502. $where[] = ["checkState", "=", 30];
  1503. break;
  1504. case 9: //重新提交
  1505. $where[] = ["checkState", "=", 20];
  1506. $where[] = ["highProcess", ">=", $process];
  1507. break;
  1508. case 4: //上级驳回
  1509. $where[] = ["checkState", "=", 35];
  1510. break;
  1511. }
  1512. }
  1513. if ($process == 4) {
  1514. switch ($query["checkState"]) {
  1515. case -1:
  1516. $where[] = ["checkState", "=", -1];
  1517. break;
  1518. case 3: //通过
  1519. $where[] = ["checkState", "=", 30];
  1520. break;
  1521. }
  1522. }
  1523. }
  1524. }
  1525. return $where;
  1526. }
  1527. private function translateToChinese(&$obj) {
  1528. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1529. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1530. }
  1531. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1532. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1533. }
  1534. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1535. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1536. }
  1537. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1538. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1539. }
  1540. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1541. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1542. }
  1543. }
  1544. private function translateChinese($list) {
  1545. //获取字典表
  1546. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1547. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1548. $streetMap = DictApi::selectByParentCode("street");
  1549. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1550. $modeMap = DictApi::selectByParentCode("import_way");
  1551. $where = [];
  1552. $where[] = ["type", "=", $this->user["type"]];
  1553. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1554. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1555. foreach ($list as &$info) {
  1556. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  1557. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1558. }
  1559. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1560. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  1561. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  1562. }
  1563. $info["addressName"] = $streetMap[$info["address"]];
  1564. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  1565. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  1566. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1567. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  1568. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  1569. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  1570. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  1571. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  1572. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  1573. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  1574. }unset($info);
  1575. return $list;
  1576. }
  1577. }