TalentAllowance.php 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087
  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\state\AllowanceTypeEnum;
  16. use app\common\model\AmountStandard as AsModel;
  17. use app\common\state\CommonConst;
  18. /**
  19. * Description of TalentAllowance
  20. *
  21. * @author sgq
  22. */
  23. class TalentAllowance extends AdminController {
  24. public function index() {
  25. $process = $this->request["process"];
  26. $type = $this->user["type"];
  27. $assigns = ["process" => $process, "type" => $type];
  28. if ($process == 4) {
  29. if ($type == CommonConst::ENTERPRISE_NORMAL) {
  30. $msgBody["typeName"] = "晋江市现代产业体系人才津补贴申报";
  31. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  32. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  33. $msgBody["phone"] = "0595-85633128";
  34. $msgBody["email"] = "jjrc85661234@163.com";
  35. }
  36. if ($type == CommonConst::ENTERPRISE_JC) {
  37. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  38. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  39. $msgBody["dep"] = "集成电路产业园区";
  40. $msgBody["phone"] = "0595-82250007、0595-82250001";
  41. $msgBody["email"] = "jjjcdr@163.com";
  42. }
  43. if ($type == CommonConst::ENTERPRISE_WJ) {
  44. $msgBody["typeName"] = "晋江市医疗卫生人才津补贴申报";
  45. $msgBody["address"] = "“健康晋江”微信公众号";
  46. $msgBody["dep"] = "晋江市卫生健康局";
  47. $msgBody["phone"] = "0595-85636159";
  48. $msgBody["email"] = "jjswjjrsk@163.com";
  49. }
  50. if ($type == CommonConst::ENTERPRISE_GJ) {
  51. $msgBody["typeName"] = "晋江市高等教育人才津补贴申报";
  52. $msgBody["address"] = "“泉州市高教发展中心”微信公众号";
  53. $msgBody["dep"] = "泉州市高教发展中心";
  54. $msgBody["phone"] = "0595-85002588";
  55. $msgBody["email"] = "jjsgjrc@126.com";
  56. }
  57. $assigns["message"] = $msgBody;
  58. }
  59. return view("", $assigns);
  60. }
  61. /**
  62. * 获取优秀人才津补贴列表
  63. */
  64. public function list() {
  65. $param = $this->request->param();
  66. $offset = $param["offset"] ?: 0;
  67. $limit = $param["limit"] ?: 10;
  68. $process = $param["process"];
  69. $where = [];
  70. $where[] = ["type", "=", $this->user["type"]];
  71. $where[] = ["delete", "=", 0];
  72. $order = "newSubmitTime desc";
  73. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  74. switch ($process) {
  75. case 1:
  76. $where[] = ["checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  77. break;
  78. case 2:
  79. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  80. break;
  81. case 3:
  82. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  83. break;
  84. case 4:
  85. if ($param["publicState"]) {
  86. $where[] = ["publicState", "=", $param["publicState"]];
  87. }
  88. $where[] = ["checkState", "in", [-1, 30]];
  89. break;
  90. }
  91. $count = TaModel::where($where)->count();
  92. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  93. $list = $this->translateChinese($list);
  94. return json(["rows" => $list, "total" => $count]);
  95. }
  96. /**
  97. * 审核页面
  98. * @return type
  99. */
  100. public function toCheckPage() {
  101. $id = $this->request["id"];
  102. $process = $this->request["process"];
  103. $obj = TalentAllowanceApi::getInfoById($id);
  104. $this->translateToChinese($obj);
  105. return view("info", ["row" => $obj, "process" => $process]);
  106. }
  107. /**
  108. * 查看详情
  109. * @return type
  110. */
  111. public function toSelectPage() {
  112. $id = $this->request["id"];
  113. $process = $this->request["process"];
  114. $obj = TalentAllowanceApi::getInfoById($id);
  115. $this->translateToChinese($obj);
  116. return view("select", ["row" => $obj, "process" => $process]);
  117. }
  118. /**
  119. * 审核保存
  120. */
  121. public function check() {
  122. $obj = $this->request->param();
  123. if (!$obj["checkState"]) {
  124. return new Response(Response::ERROR, "请选择审核状态");
  125. }
  126. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  127. if (!$oldObj) {
  128. return new Response(Response::ERROR, "审核对象不存在");
  129. }
  130. $newObj = [];
  131. $newObj["id"] = $obj["id"];
  132. $projectList = [];
  133. $fileList = [];
  134. if ($obj["process"] == 1) {
  135. if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
  136. $projectList = array_filter(explode(",", $obj["projects"]));
  137. $newObj["projects"] = implode(",", $projectList);
  138. }
  139. if (\StrUtil::isNotEmpAndNull($obj["files"])) {
  140. $fileList = array_filter(explode(",", $obj["files"]));
  141. $newObj["files"] = implode(",", $fileList);
  142. }
  143. //if (Const.RSJ.equals(checkCompany.getCode())) {
  144. $newObj["concats"] = $obj["concats"];
  145. $newObj["fields"] = $obj["fields"];
  146. //}
  147. }
  148. if ($obj["process"] == 3) {
  149. $newObj["toProcess"] = $obj["toProcess"];
  150. $newObj["toDep"] = $obj["toDep"];
  151. }
  152. TaModel::update($newObj);
  153. //添加日志
  154. TalentChecklog::create([
  155. 'id' => getStringId(),
  156. 'mainId' => $obj['id'],
  157. 'type' => intval(ProjectState::JBT),
  158. 'typeFileId' => null,
  159. 'active' => 2,
  160. 'state' => $obj["checkState"],
  161. 'step' => $obj["process"],
  162. 'stateChange' => null,
  163. 'description' => $obj["checkMsg"],
  164. 'createTime' => date("Y-m-d H:i:s", time()),
  165. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  166. ]);
  167. return new Response(Response::SUCCESS, "审核成功");
  168. }
  169. /**
  170. * 提交审核
  171. * @return Response
  172. */
  173. public function submitCheck() {
  174. $id = $this->request["id"];
  175. $process = $this->request["process"];
  176. $old = TalentAllowanceApi::getInfoById($id);
  177. if (!$old) {
  178. return new Response(Response::ERROR, "审核对象不存在");
  179. }
  180. $updCheck = [];
  181. $updCheck["id"] = $id;
  182. $updCheck["type"] = $old["type"];
  183. /* * 查询审核日志 */
  184. $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process);
  185. if (!$log) {
  186. return new Response(Response::ERROR, "请先审核后再提交");
  187. }
  188. $updCheck["checkMsg"] = $log["description"];
  189. /* * 判断到达的最高流程 */
  190. $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["process"];
  191. switch ($process) {
  192. case 1:
  193. switch ($log["state"]) {
  194. case 3:
  195. $updCheck["firstPassTime"] = $old["firstPassTime"];
  196. if (!$old["firstPassTime"]) {
  197. $updCheck["firstPassTime"] = date("Y-m-d H:i:s");
  198. }
  199. if (!$old["visitPassTime"]) {
  200. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  201. }
  202. $updCheck["submitTime"] = date("Y-m-d H:i:s");
  203. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  204. break;
  205. case 2:
  206. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT;
  207. break;
  208. case -2:
  209. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT_BRANCH;
  210. break;
  211. case -1:
  212. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  213. $updCheck["recommendAllowanceType"] = 3;
  214. $updCheck["recommendMoney"] = 0;
  215. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  216. break;
  217. default:
  218. return new Response(Response::ERROR, "未知的审核状态");
  219. }
  220. //添加日志
  221. TalentChecklog::create([
  222. 'id' => getStringId(),
  223. 'mainId' => $id,
  224. 'type' => intval(ProjectState::JBT),
  225. 'typeFileId' => null,
  226. 'active' => 1,
  227. 'state' => $log["state"],
  228. 'step' => $process,
  229. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  230. 'description' => $log["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 2:
  236. if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  237. return new Response(Response::ERROR, "不在审核范围内");
  238. }
  239. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  240. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  241. //添加日志
  242. TalentChecklog::create([
  243. 'id' => getStringId(),
  244. 'mainId' => $id,
  245. 'type' => intval(ProjectState::JBT),
  246. 'typeFileId' => null,
  247. 'active' => 1,
  248. 'state' => 3,
  249. 'step' => $process,
  250. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  251. 'description' => "走访核查提交审核",
  252. 'createTime' => date("Y-m-d H:i:s", time()),
  253. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  254. ]);
  255. break;
  256. case 3:
  257. switch ($log["state"]) {
  258. case 3:
  259. $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS;
  260. $updCheck["reviewPassTime"] = date("Y-m-d H:i:s");
  261. /* * * 在此处需要判断津补贴类型 */
  262. $arrangeList = $this->validateAllowanceType($updCheck);
  263. $taaModel = new TalentAllowanceArrange();
  264. $taaModel->saveAll($arrangeList);
  265. break;
  266. case 2:
  267. $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST;
  268. $updCheck["toProcess"] = null;
  269. $updCheck["toDep"] = "";
  270. break;
  271. case -1:
  272. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  273. $updCheck["recommendAllowanceType"] = 3;
  274. $updCheck["recommendMoney"] = 0;
  275. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  276. break;
  277. default:
  278. return new Response(Response::ERROR, "未知的审核状态");
  279. }
  280. //添加日志
  281. TalentChecklog::create([
  282. 'id' => getStringId(),
  283. 'mainId' => $id,
  284. 'type' => intval(ProjectState::JBT),
  285. 'typeFileId' => null,
  286. 'active' => 1,
  287. 'state' => $log["state"],
  288. 'step' => $process,
  289. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  290. 'description' => $log["description"],
  291. 'createTime' => date("Y-m-d H:i:s", time()),
  292. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  293. ]);
  294. break;
  295. }
  296. TalentChecklog::where("id", $log["id"])->delete();
  297. TaModel::update($updCheck);
  298. return new Response(Response::SUCCESS, "提交审核成功");
  299. }
  300. /**
  301. * 初审撤销
  302. * @return Response
  303. */
  304. public function cancleFirstCheck() {
  305. $obj = $this->request->param();
  306. $id = $obj["id"];
  307. $checkMsg = $obj["checkMsg"];
  308. if (!$id) {
  309. return new Response(Response::ERROR, "请选择需要撤销的对象");
  310. }
  311. $old = TalentAllowanceApi::getInfoById($id);
  312. if ($old["checkState"] != AllowanceStateEnum::NEED_REVIEW && $old["checkState"] != AllowanceStateEnum::NOTPASS) {
  313. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  314. }
  315. $data["id"] = $id;
  316. $data["checkMsg"] = $checkMsg;
  317. $data["checkState"] = AllowanceStateEnum::NEED_CHECK;
  318. //添加日志
  319. TalentChecklog::create([
  320. 'id' => getStringId(),
  321. 'mainId' => $id,
  322. 'type' => intval(ProjectState::JBT),
  323. 'typeFileId' => null,
  324. 'active' => 1,
  325. 'state' => 11, //撤销审核
  326. 'step' => 1,
  327. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  328. 'description' => "撤销原因:" . $checkMsg,
  329. 'createTime' => date("Y-m-d H:i:s", time()),
  330. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  331. ]);
  332. TaModel::update($data);
  333. return new Response(Response::SUCCESS, "撤销成功");
  334. }
  335. /**
  336. * 复核撤销
  337. * @return Response|\app\admin\controller\ResponseObj
  338. */
  339. public function reviewCancleCheck() {
  340. $obj = $this->request->param();
  341. $id = $obj["id"];
  342. $checkMsg = $obj["checkMsg"];
  343. if (!$id) {
  344. return new Response(Response::ERROR, "请选择需要撤销的对象");
  345. }
  346. $old = TalentAllowanceApi::getInfoById($id);
  347. if ($old["checkState"] != AllowanceStateEnum::REVIEW_PASS || $old["publicState"] != 1) {
  348. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  349. }
  350. $data["id"] = $id;
  351. $data["checkMsg"] = $checkMsg;
  352. $data["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  353. //添加日志
  354. TalentChecklog::create([
  355. 'id' => getStringId(),
  356. 'mainId' => $id,
  357. 'type' => intval(ProjectState::JBT),
  358. 'typeFileId' => null,
  359. 'active' => 1,
  360. 'state' => 11, //撤销审核
  361. 'step' => 3,
  362. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  363. 'description' => "撤销原因:" . $checkMsg,
  364. 'createTime' => date("Y-m-d H:i:s", time()),
  365. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  366. ]);
  367. TaModel::update($data);
  368. return new Response(Response::SUCCESS, "撤销成功");
  369. }
  370. /**
  371. * 查询需要导出的数据
  372. *
  373. */
  374. public function findTalentAllowanceByPage() {
  375. $param = $this->request->param();
  376. $where = [];
  377. $where[] = ["type", "=", $this->user["type"]];
  378. if ($param != null) {
  379. if (\StrUtil::isNotEmpAndNull($param["name"])) {
  380. $where[] = ["name", "like", "%" . $param["name"] . "%"];
  381. }
  382. if (\StrUtil::isNotEmpAndNull($param["idCard"])) {
  383. $where[] = ["idCard", "like", "%" . $param["idCard"] . "%"];
  384. }
  385. }
  386. $error = null;
  387. switch ($param["type"]) {
  388. case 1:
  389. case 2:
  390. $where[] = ["publicState", "=", 1];
  391. $where[] = ["checkState", "in", [-1, 30]];
  392. $error = "暂无可核查征信的数据";
  393. break;
  394. case 3:
  395. case 7:
  396. $where[] = ["publicState", "=", 2];
  397. $where[] = ["checkState", "in", [-1, 30]];
  398. $where[] = ["recommendAllowanceType", "=", 3];
  399. $error = "暂无可公示(不予兑现)的数据";
  400. break;
  401. case 4: //需要兑现
  402. case 8:
  403. $where[] = ["publicState", "=", 2];
  404. $where[] = ["checkState", "in", [30]];
  405. $where[] = ["recommendAllowanceType", "in", [1, 2]];
  406. $error = "暂无需要公示(兑现)的数据";
  407. break;
  408. case 5:
  409. $where[] = ["publicState", "=", 3];
  410. $where[] = ["checkState", "in", [-1, 30]];
  411. $error = "暂无可公示通过的数据";
  412. break;
  413. case 6:
  414. $where[] = ["publicState", "=", 4];
  415. $where[] = ["checkState", "in", [30]];
  416. $where[] = ["allowanceType", "in", [1, 2]];
  417. $error = "暂无可兑现的数据";
  418. break;
  419. }
  420. $list = TaModel::where($where)->select()->toArray();
  421. //查询企业信息
  422. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  423. foreach ($list as $key => $item) {
  424. $list[$key]["enterpriseName"] = $enterpriseMap[$item["enterpriseId"]];
  425. }
  426. $res = [
  427. "rows" => $list,
  428. "total" => count($list)
  429. ];
  430. return new Response(Response::SUCCESS, "", $res);
  431. }
  432. public function exportHczx() {
  433. $response = new \stdClass();
  434. $response->code = 500;
  435. $ids = $this->request->param("ids");
  436. $ids_arr = array_filter(explode(",", $ids));
  437. if (!$ids_arr) {
  438. $response->msg = "没有选择导出的名单";
  439. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  440. }
  441. $where = [];
  442. $where[] = ["id", "in", $ids_arr];
  443. $list = TaModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  444. if (!$list) {
  445. $response->msg = "暂无可核查征信的数据";
  446. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  447. }
  448. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  449. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  450. $cardTypeName = DictApi::selectByParentCode("card_type");
  451. $rows = [];
  452. for ($i = 0; $i < count($list); $i++) {
  453. $item = $list[$i];
  454. $row = [
  455. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["description"]
  456. ];
  457. $rows[] = $row;
  458. }
  459. $filename = "津补贴待核查征信名单导出";
  460. if ($rows) {
  461. export($columns, $rows, $filename);
  462. exit();
  463. } else {
  464. $response->msg = "没有选择导出的名单";
  465. return \StrUtil::back($response, "TalentTypeChange.callBack");
  466. }
  467. }
  468. /**
  469. * 核查征信驳回
  470. */
  471. public function hczxReject() {
  472. $param = $this->request->param();
  473. if (!$param) {
  474. return new Response(Response::ERROR, "系统错误,请联系管理员");
  475. }
  476. $old = TalentAllowanceApi::getInfoById($param["id"]);
  477. if ($old["publicState"] != 1) {
  478. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  479. }
  480. $data["id"] = $param["id"];
  481. $data["publicState"] = 2;
  482. $data["checkState"] = AllowanceStateEnum::NOTPASS;
  483. $data["recommendAllowanceType"] = 3;
  484. $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
  485. $data["recommendMonths"] = "";
  486. $data["recommendMoney"] = 0.00;
  487. $data["workAllowanceMoney"] = null;
  488. $data["developAllowanceMoney"] = null;
  489. //添加日志
  490. TalentChecklog::create([
  491. 'id' => getStringId(),
  492. 'mainId' => $param["id"],
  493. 'type' => intval(ProjectState::JBT),
  494. 'typeFileId' => null,
  495. 'active' => 1,
  496. 'state' => 2,
  497. 'step' => 4,
  498. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  499. 'description' => $param["outMsg"],
  500. 'createTime' => date("Y-m-d H:i:s", time()),
  501. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  502. ]);
  503. TaModel::update($data);
  504. return new Response(Response::SUCCESS, "核查征信成功");
  505. }
  506. /**
  507. * 核查征信批量通过
  508. */
  509. public function hczxPass() {
  510. $ids = $this->request["ids"];
  511. if (\StrUtil::isEmpOrNull($ids)) {
  512. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  513. }
  514. $where = [];
  515. $where[] = ["id", "in", $ids];
  516. $list = TaModel::where($where)->select()->toArray();
  517. $logList = [];
  518. $upds = [];
  519. foreach ($list as $obj) {
  520. $upds[] = [
  521. "id" => $obj["id"],
  522. "publicState" => 2,
  523. ];
  524. $logList[] = [
  525. "id" => getStringId(),
  526. "type" => ProjectState::JBT,
  527. "mainId" => $obj["id"],
  528. "active" => 1,
  529. "state" => 3,
  530. "step" => 4,
  531. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  532. "description" => "核查征信通过",
  533. "createTime" => date("Y-m-d H:i:s"),
  534. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  535. ];
  536. }
  537. $taModel = new TaModel();
  538. $taModel->saveAll($upds);
  539. Db::table("new_talent_checklog")->insertAll($logList);
  540. return new Response(Response::SUCCESS, "核查征信通过成功");
  541. }
  542. /**
  543. * 公示
  544. * */
  545. public function publicBatch() {
  546. $params = $this->request->param();
  547. $ids = $params["ids"];
  548. $ids = array_filter(explode(",", $ids));
  549. if (!$ids) {
  550. return new Response(Response::ERROR, "请至少选择一行数据");
  551. }
  552. $isMessage = $params["isMessage"] == 1 ? true : false;
  553. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  554. return new Response(Response::ERROR, "短信参数不能为空");
  555. }
  556. $where = [];
  557. $where[] = ["id", "in", $ids];
  558. $list = TaModel::where($where)->select()->toArray();
  559. Db::startTrans();
  560. try {
  561. $logList = [];
  562. $phones = [];
  563. foreach ($list as $info) {
  564. $data["id"] = $info["id"];
  565. $data["publicState"] = 3;
  566. Db::table("un_talent_allowance_info")->update($data);
  567. /* * 添加日志 */
  568. $logList[] = [
  569. "id" => getStringId(),
  570. "type" => ProjectState::JBT,
  571. "mainId" => $info["id"],
  572. "active" => 1,
  573. "state" => 3,
  574. "step" => 5,
  575. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  576. "description" => "批量公示",
  577. "createTime" => date("Y-m-d H:i:s"),
  578. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  579. ];
  580. $phones[] = $info["phone"];
  581. }
  582. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  583. Db::commit();
  584. if ($phones && $isMessage && $effect) {
  585. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  586. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  587. $phones = array_filter($phones);
  588. foreach ($phones as $phone) {
  589. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "津补贴-批量公示", "userType" => 3]);
  590. }
  591. }
  592. return new Response(Response::SUCCESS, "公示成功");
  593. } catch (\think\db\exception\DbException $e) {
  594. Db::rollback();
  595. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  596. }
  597. }
  598. /**
  599. * 跳转到公示再审核页面
  600. * */
  601. public function toSupplePage() {
  602. $id = $this->request["id"];
  603. $process = $this->request["process"];
  604. $obj = TalentAllowanceApi::getInfoById($id);
  605. $this->translateToChinese($obj);
  606. return view("public_check", ["row" => $obj, "process" => $process]);
  607. }
  608. /**
  609. * 公示再审核计算津补贴
  610. * */
  611. public function suppleCheckCalculate() {
  612. $id = $this->request["id"];
  613. try {
  614. $info = TalentAllowanceApi::getInfoById($id);
  615. $arrangeList = $this->validateAllowanceType($info);
  616. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  617. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  618. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  619. foreach ($detailList as &$detail) {
  620. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  621. if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
  622. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  623. }
  624. }
  625. $res = [
  626. "info" => $info,
  627. "detailList" => $detailList
  628. ];
  629. return new Response(Response::SUCCESS, "计算成功", $res);
  630. } catch (\think\Exception $e) {
  631. return new Response(Response::ERROR, "系统异常,请联系管理员");
  632. }
  633. }
  634. /**
  635. * 公示后审核
  636. */
  637. public function afterCheck() {
  638. $param = $this->request->param();
  639. if (!$param["id"]) {
  640. return new Response(Response::ERROR, "系统错误,请联系管理员");
  641. }
  642. $old = TalentAllowanceApi::getInfoById($param["id"]);
  643. if ($old["publicState"] != 3) {
  644. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  645. }
  646. try {
  647. $arrangeList = null;
  648. $desc = "审核意见:" . $param["checkMsg"] . ";\n";
  649. $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
  650. $data["id"] = $param["id"];
  651. if ($param["checkState"] == -1) {
  652. $data["checkState"] = -1;
  653. $data["checkMsg"] = $param["checkMsg"];
  654. $data["allowanceType"] = 3;
  655. $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
  656. $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
  657. } else if ($param["checkState"] == 3) {
  658. if ($param["zxState"] == 1) {
  659. $typeName = "";
  660. $old["recommendAllowanceMsg"] = "";
  661. if ($param["source"] == 1) { //遵循系统结果
  662. $arrangeList = $this->validateAllowanceType($old);
  663. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  664. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
  665. } else if ($param["source"] == 2) {
  666. $detailIds = array_column($param["details"], "id");
  667. $where = [];
  668. $where[] = ["id", "in", $detailIds];
  669. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  670. $set = [];
  671. if ($params["resAllowanceType"] == 1) {
  672. $monthsMap = [];
  673. for ($i = 0; $i < count($param["details"]); $i++) {
  674. $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
  675. }
  676. foreach ($detailList as &$detail) {
  677. $months = $monthdsMap[$detail["id"]];
  678. if (\StrUtil::isNotEmpAndNull($months)) {
  679. $detail["months"] = $months;
  680. $set = array_merge($set, explode(",", $months));
  681. }
  682. }unset($detail);
  683. }
  684. $set = array_filter($set);
  685. usort($set, function($a, $b) {
  686. return (int) $a - (int) $b;
  687. });
  688. $old["recommendAllowanceType"] = $param["resAllowanceType"];
  689. $old["recommendMonths"] = implode(",", $set);
  690. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  691. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
  692. $arrangeList = $this->calculateAllowance($old, $set, $detailList);
  693. }
  694. $desc .= "判定结果:" . $typeName;
  695. $data["checkState"] = 30;
  696. $data["outMsg"] = "";
  697. $data["allowanceType"] = $old["recommendAllowanceType"];
  698. $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
  699. $data["months"] = $old["recommendMonths"];
  700. $data["money"] = $old["recommendMoney"];
  701. $data["moneyDesc"] = $old["recommendMoneyDesc"];
  702. $data["jtTalentArrange"] = $old["recommendTalentArrange"];
  703. $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
  704. $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
  705. } else {
  706. $data["checkState"] = -1;
  707. $data["outMsg"] = $param["zxMsg"];
  708. $data["allowanceType"] = 3;
  709. $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
  710. }
  711. }
  712. if ($param["allowanceType"] == 3) {
  713. $data["months"] = "";
  714. $data["money"] = 0;
  715. $data["moneyDesc"] = "";
  716. $data["jtTalentArrange"] = "";
  717. $data["workAllowanceMoney"] = null;
  718. $data["developAllowanceMoney"] = null;
  719. }
  720. $data["isPublicCheck"] = 1;
  721. $data["publicState"] = 4;
  722. //添加日志
  723. TalentChecklog::create([
  724. 'id' => getStringId(),
  725. 'mainId' => $old['id'],
  726. 'type' => intval(ProjectState::JBT),
  727. 'typeFileId' => null,
  728. 'active' => 1,
  729. 'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
  730. 'step' => 6,
  731. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  732. 'description' => $desc,
  733. 'createTime' => date("Y-m-d H:i:s", time()),
  734. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  735. ]);
  736. TaModel::update($data);
  737. if ($arrangeList != null) {
  738. $taaModel = new TalentAllowanceArrange();
  739. $taaModel->saveAll($arrangeList);
  740. }
  741. return new Response(Response::SUCCESS, "审核成功");
  742. } catch (\think\Exception $e) {
  743. return new Response(Response::ERROR, "系统异常,请联系管理员");
  744. }
  745. }
  746. /**
  747. * 批量公示通过
  748. */
  749. public function publicPass() {
  750. $ids = $this->request["ids"];
  751. $ids = explode(",", $ids);
  752. if (!$ids) {
  753. return new Response(Response::ERROR, "请至少选择一行数据");
  754. }
  755. $where = [];
  756. $where[] = ["id", "in", $ids];
  757. $list = TaModel::where($where)->select()->toArray();
  758. $logList = [];
  759. try {
  760. Db::startTrans();
  761. for ($i = 0; $i < count($list); $i++) {
  762. $obj = $list[$i];
  763. $upd["id"] = $obj["id"];
  764. $upd["publicState"] = 4;
  765. $upd["allowanceType"] = $obj["recommendAllowanceType"];
  766. $upd["allowanceMsg"] = $obj["recommendAllowanceMsg"];
  767. if ($upd["allowanceType"] == 1) {
  768. $upd["months"] = $obj["recommendMonths"];
  769. $upd["money"] = $obj["recommendMoney"];
  770. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  771. } else if ($upd["allowanceType"] == 2) {
  772. $upd["months"] = "";
  773. $upd["jtTalentArrange"] = $obj["recommendTalentArrange"];
  774. $upd["money"] = $obj["recommendMoney"];
  775. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  776. $upd["workAllowanceMoney"] = null;
  777. $upd["developAllowanceMoney"] = null;
  778. } else {
  779. $upd["months"] = "";
  780. $upd["money"] = 0.00;
  781. $upd["workAllowanceMoney"] = null;
  782. $upd["developAllowanceMoney"] = null;
  783. }
  784. Db::table("un_talent_allowance_info")->update($upd);
  785. //添加日志
  786. $stateChange = null;
  787. $desc = null;
  788. if ($obj["checkState"] == AllowanceStateEnum::NOTPASS) {
  789. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-danger'>审核不通过</span>";
  790. $desc = "审核不通过";
  791. } else {
  792. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  793. $desc = "批量公示";
  794. }
  795. $logList[] = [
  796. "id" => getStringId(),
  797. "type" => ProjectState::JBT,
  798. "mainId" => $obj["id"],
  799. "active" => 1,
  800. "state" => 3,
  801. "step" => 6,
  802. "stateChange" => $stateChange,
  803. "description" => $desc,
  804. "createTime" => date("Y-m-d H:i:s"),
  805. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  806. ];
  807. }
  808. Db::table("new_talent_checklog")->insertAll($logList);
  809. Db::commit();
  810. return new Response(Response::SUCCESS, "批量公示通过成功");
  811. } catch (\think\db\exception\DbException $e) {
  812. Db::rollback();
  813. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  814. }
  815. }
  816. /**
  817. * 兑现
  818. */
  819. public function cash() {
  820. $ids = $this->request["ids"];
  821. $ids = array_filter(explode(",", $ids));
  822. if (!$ids) {
  823. return new Response(Response::ERROR, "请至少选择一行数据");
  824. }
  825. $where = [];
  826. $where[] = ["id", "in", $ids];
  827. $list = TaModel::where($where)->select()->toArray();
  828. //添加日志
  829. $logList = [];
  830. try {
  831. Db::startTrans();
  832. for ($i = 0; $i < count($list); $i++) {
  833. $obj = $list[$i];
  834. $upd["id"] = $obj["id"];
  835. $upd["publicState"] = 5;
  836. Db::table("un_talent_allowance_info")->update($upd);
  837. $logList[] = [
  838. "id" => getStringId(),
  839. "type" => ProjectState::JBT,
  840. "mainId" => $obj["id"],
  841. "active" => 1,
  842. "state" => 3,
  843. "step" => 50,
  844. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  845. "description" => "批量兑现",
  846. "createTime" => date("Y-m-d H:i:s"),
  847. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  848. ];
  849. }
  850. Db::table("new_talent_checklog")->insertAll($logList);
  851. Db::commit();
  852. return new Response(Response::SUCCESS, "批量兑现成功");
  853. } catch (\think\db\exception\DbException $e) {
  854. Db::rollback();
  855. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  856. }
  857. }
  858. /**
  859. * 公示预览(不予兑现)
  860. */
  861. public function exportPublicNotCash() {
  862. $response = new \stdClass();
  863. $response->code = 500;
  864. //获取字典表人才层次+
  865. $levelMap = DictApi::selectByParentCode("talent_arrange");
  866. $streetMap = DictApi::selectByParentCode("street");
  867. //查询企业信息
  868. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  869. //查询所有
  870. $where = [];
  871. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  872. $list = TaModel::where($where)->select()->toArray();
  873. $rows = [];
  874. for ($i = 0; $i < count($list); $i++) {
  875. $item = $list[$i];
  876. $rows[] = [
  877. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  878. ];
  879. }
  880. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  881. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  882. if ($rows) {
  883. export($columns, $rows, $filename);
  884. exit();
  885. } else {
  886. $response->msg = "没有选择导出的名单";
  887. return \StrUtil::back($response, "TalentTypeChange.callBack");
  888. }
  889. }
  890. /**
  891. * 导出公示名单(需要兑现)
  892. */
  893. public function exportPublic() {
  894. //获取字典表人才层次+
  895. $levelMap = DictApi::selectByParentCode("talent_arrange");
  896. $streetMap = DictApi::selectByParentCode("street");
  897. //查询企业信息
  898. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  899. /* * 查询需要公示的数据 */
  900. $where = [];
  901. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  902. $list = TaModel::where($where)->select()->toArray();
  903. /* * 查询相关的津补贴人才层次 */
  904. $where = [];
  905. $where[] = ["mainId", "in", explode(",", $this->request["ids"])];
  906. $arrangeList = TalentAllowanceArrange::where($where)->select()->toArray();
  907. foreach ($arrangeList as &$arrange) {
  908. $arrange["talentArrangeName"] = $levelMap[$arrange["talentArrange"]];
  909. }unset($arrange);
  910. /* Map<String,List<TalentAllowanceArrange>> arrangeMap = arrangeList.stream().collect(Collectors.groupingBy(TalentAllowanceArrange::getMainId));
  911. Integer sheetSize = 0;
  912. for(TalentAllowanceInfo info:allList){
  913. info.setEnterpriseName(enterpriseMap.get(info.getEnterpriseId()));
  914. info.setAddressName(streetMap.get(info.getAddress()));
  915. info.setTalentArrangeName(levelMap.get(info.getTalentArrange()));
  916. if(info.getRecommendAllowanceType() == 1){
  917. info.setArrangeList(arrangeMap.get(info.getId()));
  918. sheetSize = sheetSize + info.getArrangeList().size();
  919. }else if(info.getRecommendAllowanceType() == 1){
  920. sheetSize++;
  921. }
  922. } */
  923. $filename = CommonConst::getTypeName($this->user["type"]) . $list[0]["year"] . "年度津补贴拟发放对象名单";
  924. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "津补贴享受月份数", "每月享受津贴标准(元)", $list[0]["year"] . "年度累计应享受津补贴金额(元)", "备注"];
  925. }
  926. /**
  927. * 导出基本信息
  928. */
  929. public function exportBasicInfo() {
  930. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  931. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  932. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  933. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  934. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  935. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  936. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  937. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  938. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  939. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  940. $obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
  941. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  942. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  943. $obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
  944. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  945. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  946. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  947. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  948. $obj["type"] = $this->user["type"];
  949. $where = [];
  950. $where[] = ["ta.delete", "=", 0];
  951. $where[] = ["ta.type", "=", $this->user["type"]];
  952. $this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
  953. switch ($obj["process"]) {
  954. case 1:
  955. $where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  956. break;
  957. case 2:
  958. $where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
  959. break;
  960. case 3:
  961. $where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
  962. break;
  963. case 4:
  964. if ($obj["publicState"]) {
  965. $where[] = ["publicState", "=", $param["publicState"]];
  966. }
  967. $where[] = ["ta.checkState", "in", [-1, 30]];
  968. break;
  969. }
  970. $projects = [
  971. AllowanceProjectEnum::PROJECT_TAX,
  972. AllowanceProjectEnum::PROJECT_WAGES,
  973. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  974. AllowanceProjectEnum::PROJECT_SB_PENSION,
  975. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  976. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  977. ];
  978. $months = [];
  979. for ($m = 1; $m <= 12; $m++) {
  980. $months[] = $m . "月";
  981. }
  982. $columns = [["年度", [1, 2]], ["所属镇街", [1, 2]], ["姓名", [1, 2]], ["性别", [1, 2]], ["证件号码", [1, 2]], ["人才层次", [1, 2]], ["认定条件", [1, 2]], ["认定条件取得时间", [1, 2]], ["认定条件名称", [1, 2]], ["公布入选月份", [1, 2]], ["拟认定津补贴类型", [1, 2]], ["拟兑现月份", [1, 2]], ["拟兑现金额", [1, 2]], ["拟兑现金额说明", [1, 2]], ["津补贴类型", [1, 2]], ["兑现月份", [1, 2]], ["兑现金额", [1, 2]], ["金额说明", [1, 2]], ["审核状态", [1, 2]], ["缴纳单位", [1, 2]]];
  983. $infoCols = count($columns);
  984. for ($i = 0; $i < count($projects); $i++) {
  985. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  986. }
  987. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  988. ->field("ta.id,ta.year,ta.enterpriseId as curEnterpriseId,ta.address,ta.name,ta.sex,ta.idCard,ta.talentArrange,ta.identifyCondition,ta.identifyGetTime,ta.identifyConditionName,ta.identifyMonth,ta.recommendAllowanceType,ta.recommendMonths,ta.recommendMoney,ta.recommendMoneyDesc,ta.allowanceType,ta.months,ta.money,ta.moneyDesc,ta.checkState,ta.publicState,pro.project,pro.months as pre_months,con.enterpriseId,con.startTime,con.endTime,con.entryTime,con.quitTime,con.isQuit")
  989. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  990. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  991. ->where($where)
  992. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  993. ->select()->toArray();
  994. $tmpList = [];
  995. $levelMap = DictApi::selectByParentCode("talent_arrange");
  996. $streetMap = DictApi::selectByParentCode("street");
  997. $where = [];
  998. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  999. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1000. $where = [];
  1001. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  1002. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  1003. foreach ($list as $item) {
  1004. //组装数据
  1005. if (!$tmpList[$item["id"]]) {
  1006. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  1007. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  1008. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
  1009. $item["recommendMoneyDesc"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  1010. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
  1011. }
  1012. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  1013. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  1014. "startTime" => $item["startTime"],
  1015. "endTime" => $item["endTime"],
  1016. "entryTime" => $item["entryTime"],
  1017. "isQuit" => $item["isQuit"]
  1018. ];
  1019. }
  1020. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  1021. }
  1022. $rows = [];
  1023. $colorset = [];
  1024. foreach ($tmpList as $id => $item) {
  1025. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  1026. $row = $item["info"];
  1027. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  1028. for ($i = 0; $i < count($projects); $i++) {
  1029. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  1030. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1031. for ($m = 1; $m <= 12; $m++) {
  1032. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1033. if (in_array($_month, $months)) {
  1034. $row[] = "✔";
  1035. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1036. } else {
  1037. $row[] = "";
  1038. }
  1039. }
  1040. } else {
  1041. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1042. $_months = [];
  1043. foreach ($months as $month) {
  1044. $kv = explode("=", $month);
  1045. $_months[$kv[0]] = $kv[1];
  1046. }
  1047. for ($m = 1; $m <= 12; $m++) {
  1048. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1049. $days = $_months[$_month];
  1050. if ($days && $days > 0) {
  1051. $row[] = $days . "天";
  1052. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1053. } else {
  1054. $row[] = "";
  1055. }
  1056. }
  1057. }
  1058. }
  1059. $rows[] = $row;
  1060. }
  1061. }
  1062. $cols = $infoCols + count($projects) * 12 - 1;
  1063. $settings = [
  1064. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  1065. "height" => [18],
  1066. "freeze" => "D3",
  1067. "color" => $colorset
  1068. ];
  1069. for ($i = 0; $i < count($projects) * 12; $i++) {
  1070. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  1071. }
  1072. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  1073. export($columns, $rows, "津补贴申报名单", $settings);
  1074. }
  1075. private function validateAllowanceType(&$info) {
  1076. $old = TalentAllowanceApi::getInfoById($info["id"]);
  1077. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1078. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1079. /* * 查询工作单位记录 */
  1080. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  1081. $detaiPdList = []; //用于判定类型
  1082. $detailMonthList = []; //用于计算月份
  1083. $recommendAllowanceMsg = [];
  1084. foreach ($initDetailList as $detail) {
  1085. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  1086. $projectMap = [];
  1087. foreach ($projectList as $project) {
  1088. $projectMap[$project["project"]] = $project;
  1089. }
  1090. $detail["list"] = $projectList;
  1091. $detail["projectMap"] = $projectMap;
  1092. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1093. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  1094. /* * 筛选符合条件的人才标签 */
  1095. $detaiPdList[] = $detail;
  1096. $detailMonthList[] = $detail;
  1097. }
  1098. /* * 集成电路优秀人才 */
  1099. //if ($this->user["type"] == 2) {
  1100. /* * 获取各个项目的综合月份 */
  1101. $monthMap = $this->mergeMonth($detailMonthList);
  1102. $monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList);
  1103. $info["recommendAllowanceType"] = 1;
  1104. $info["recommendAllowanceMsg"] = "";
  1105. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $info["id"])->select()->toArray();
  1106. $set = $this->valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  1107. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n综合以上所有判断得到最终补贴类型为:";
  1108. if ($info["recommendAllowanceType"] == 1) {
  1109. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "工作津贴;可享受月份为:" . implode(",", $set) . "\n";
  1110. }
  1111. if ($info["recommendAllowanceType"] == 2)
  1112. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "一次性交通补贴;";
  1113. if ($info["recommendAllowanceType"] == 3)
  1114. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "不予兑现;";
  1115. usort($set, function($a, $b) {
  1116. return (int) $a - (int) $b;
  1117. });
  1118. //}
  1119. $info["recommendMonths"] = implode(",", $set);
  1120. $arrangeList = $this->calculateAllowance($info, $set, $detailMonthList);
  1121. return $arrangeList;
  1122. }
  1123. /**
  1124. * 集成电路津补贴总校验
  1125. * */
  1126. private function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  1127. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  1128. /* * 2.判定工作月份、五险和个税是否满足重叠6个月要求* */
  1129. $contractSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  1130. $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  1131. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  1132. $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  1133. $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  1134. $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  1135. $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  1136. $str = "工作合同月份、考勤月份、工资发放月份";
  1137. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  1138. $str = "工作合同月份、考勤月份";
  1139. $set = array_intersect($set, $contractSet);
  1140. $set = array_intersect($set, $workdaySet);
  1141. $checkSet = $set;
  1142. $set = array_intersect($set, $pensionSet);
  1143. $set = array_intersect($set, $taxSet);
  1144. } else if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  1145. $set = array_intersect($set, $contractSet);
  1146. $set = array_intersect($set, $workdaySet);
  1147. $set = array_intersect($set, $wageSet);
  1148. $checkSet = $set;
  1149. $set = array_intersect($set, $pensionSet);
  1150. $set = array_intersect($set, $taxSet);
  1151. } else {
  1152. $set = array_intersect($set, $contractSet);
  1153. $set = array_intersect($set, $workdaySet);
  1154. $set = array_intersect($set, $wageSet);
  1155. $checkSet = $set;
  1156. $set = array_intersect($set, $pensionSet);
  1157. $set = array_intersect($set, $unemploymentSet);
  1158. $set = array_intersect($set, $medicaSet);
  1159. $set = array_intersect($set, $taxSet);
  1160. }
  1161. usort($set, function($a, $b) {
  1162. return (int) $a - (int) $b;
  1163. });
  1164. if ($info["recommendAllowanceType"] == 1) {
  1165. if (count($checkSet) < 6) {
  1166. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  1167. $info["recommendAllowanceType"] = 2;
  1168. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度{$str}交集月份不满足6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1169. } else {
  1170. //检查连续缴纳月份是否满足6个月
  1171. $count = 1;
  1172. foreach ($checkSet as $s) {
  1173. $currentVal = intval($s);
  1174. $nextVal = $currentVal + 1;
  1175. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1176. if (in_array($nextKey, $checkSet)) {
  1177. $count++;
  1178. if ($count >= 6) {
  1179. break;
  1180. }
  1181. } else {
  1182. $count = 1;
  1183. }
  1184. }
  1185. if ($count < 6) {
  1186. $info["recommendAllowanceType"] = 2;
  1187. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度{$str}不满足连续缴纳6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1188. }
  1189. }
  1190. }
  1191. if ($info["recommendAllowanceType"] == 2) {
  1192. //判断境内工作时间是否大于30天
  1193. if ($info["allowanceType"] == 2) {
  1194. $totalDays = 0;
  1195. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  1196. foreach ($workmonths as $days) {
  1197. $totalDays += $days;
  1198. }
  1199. if ($totalDays < 30) {
  1200. $info["recommendAllowanceType"] = 3;
  1201. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  1202. }
  1203. } else {
  1204. if (count($workdaySet) == 0) {
  1205. $info["recommendAllowanceType"] = 3;
  1206. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  1207. } else {
  1208. $info["recommendAllowanceType"] = 2;
  1209. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  1210. }
  1211. }
  1212. }
  1213. return $set;
  1214. }
  1215. /**
  1216. * 计算津补贴
  1217. */
  1218. private function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  1219. /* * 查询人才层次变更记录 */
  1220. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  1221. foreach ($arrangeList as &$arrange) {
  1222. $where = [];
  1223. $where[] = ["type", "=", $this->user["type"]];
  1224. $where[] = ["allowanceType", "in", [1, 2]];
  1225. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  1226. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  1227. foreach ($list as $amount) {
  1228. if ($amount["allowanceType"] == 1) {
  1229. $arrange["jobMoney"] = $amount["money"];
  1230. }
  1231. if ($amount["allowanceType"] == 2) {
  1232. $arrange["jtMoney"] = $amount["money"];
  1233. }
  1234. }
  1235. }unset($arrange);
  1236. /* * * 容器 */
  1237. $jobMoney = 0.00; //计算所得工作津贴
  1238. $jtMoney = 0.00; //计算所得一次性交通补贴
  1239. $recommendMonths = []; //推荐月份
  1240. $talentArrange = null;
  1241. /* * *********计算************* */
  1242. $msgBulider = [];
  1243. $identifyExpiredName = "人才证书有效期";
  1244. if ($info["type"] == CommonConst::ENTERPRISE_JC) {
  1245. $identifyExpiredName = "认定条件有效期";
  1246. }
  1247. switch ($info["recommendAllowanceType"]) {
  1248. case 1:
  1249. foreach ($arrangeList as &$arrange) {
  1250. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  1251. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  1252. $levelList = array_intersect($levelList, $retainMonths);
  1253. $total = round($arrange["jobMoney"] * count($levelList), 2);
  1254. $jobMoney += $total;
  1255. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  1256. $recommendMonths = array_merge($recommendMonths, $levelList);
  1257. usort($recommendMonths, function($a, $b) {
  1258. return (int) $a - (int) $b;
  1259. });
  1260. $arrange["months"] = implode(",", $levelList);
  1261. $arrange["count"] = count($levelList);
  1262. $arrange["total"] = $total;
  1263. } else {
  1264. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  1265. $arrange["count"] = 0;
  1266. $arrange["total"] = 0.00;
  1267. }
  1268. }unset($arrange);
  1269. $info["recommendMonths"] = implode(",", $recommendMonths);
  1270. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "通过与{$identifyExpiredName}取交集得到最终可享受月份:" . implode(",", $recommendMonths) . "\n经过计算:人才津贴为" . $jobMoney . ";";
  1271. $info["recommendMoney"] = $jobMoney;
  1272. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  1273. break;
  1274. case 2:
  1275. foreach ($arrangeList as $arrange) {
  1276. $jtMoney = $arrange["jtMoney"];
  1277. $talentArrange = $arrange["talentArrange"];
  1278. }
  1279. $info["recommendMoney"] = $jtMoney;
  1280. $info["recommendMonths"] = "";
  1281. $info["recommendMoneyDesc"] = "一次性交通补贴";
  1282. $info["workAllowanceMoney"] = 0.00;
  1283. $info["developAllowanceMoney"] = 0.00;
  1284. $info["recommendTalentArrange"] = $talentArrange;
  1285. break;
  1286. case 3:
  1287. $info["recommendMoney"] = 0.00;
  1288. $info["recommendMonths"] = "";
  1289. $info["recommendMoneyDesc"] = "不予兑现";
  1290. $info["workAllowanceMoney"] = 0.00;
  1291. $info["developAllowanceMoney"] = 0.00;
  1292. break;
  1293. }
  1294. return $arrangeList;
  1295. }
  1296. /**
  1297. * 判定是否交足6个月(集成电路)
  1298. * @param set
  1299. * @param info
  1300. * @param name
  1301. */
  1302. private function chkMonths($set, &$info, $name, $sort) {
  1303. if ($name == "上年度工作月份") {
  1304. if ($info["allowanceType"] == 2) {
  1305. $tmp = [];
  1306. foreach ($set as $s) {
  1307. $_s = explode("=", $s);
  1308. $month = $_s[0];
  1309. $days = $_s[1];
  1310. if ($days > 0) {
  1311. $tmp[] = $month;
  1312. }
  1313. }
  1314. $set = $tmp;
  1315. }
  1316. }
  1317. $preCheckProjects = ["①", "②", "③"];
  1318. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  1319. $preCheckProjects = ["①", "②"];
  1320. }
  1321. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6) && in_array($sort, $preCheckProjects)) {
  1322. $info["recommendAllowanceType"] = 2;
  1323. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)";
  1324. }
  1325. return $set;
  1326. }
  1327. //合并所有项目的月份
  1328. private function mergeMonth($detailList) {
  1329. $contractList = [];
  1330. $taxList = [];
  1331. $wagesList = [];
  1332. $pensionList = [];
  1333. $unemploymentList = [];
  1334. $medicaList = [];
  1335. $attendanceList = [];
  1336. $workdayList = [];
  1337. foreach ($detailList as $detail) {
  1338. $projectMap = $detail["projectMap"];
  1339. if ($detail["months"]) {
  1340. $tmp = array_filter(explode(",", $detail["months"]));
  1341. $contractList = array_merge($contractList, $tmp);
  1342. }
  1343. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  1344. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  1345. $taxList = array_merge($taxList, $tmp);
  1346. }
  1347. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  1348. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  1349. $wagesList = array_merge($wagesList, $tmp);
  1350. }
  1351. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  1352. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  1353. $pensionList = array_merge($pensionList, $tmp);
  1354. }
  1355. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  1356. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  1357. $unemploymentList = array_merge($unemploymentList, $tmp);
  1358. }
  1359. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  1360. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  1361. $medicaList = array_merge($medicaList, $tmp);
  1362. }
  1363. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  1364. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  1365. $attendanceList = array_merge($attendanceList, $tmp);
  1366. }
  1367. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  1368. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  1369. $workdayList = array_merge($workdayList, $tmp);
  1370. }
  1371. }
  1372. $map = [
  1373. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  1374. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  1375. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  1376. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  1377. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  1378. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  1379. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  1380. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  1381. ];
  1382. return $map;
  1383. }
  1384. /**
  1385. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  1386. * */
  1387. private function mergeMonthNeedDay($detailList) {
  1388. $attendMap = [];
  1389. $workDayMap = [];
  1390. foreach ($detailList as $detail) {
  1391. $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  1392. $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  1393. }
  1394. $res = [
  1395. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  1396. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  1397. ];
  1398. return $res;
  1399. }
  1400. private function getMergeMonthNeedDayMap($project, $map) {
  1401. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  1402. $monthAndDayList = array_filter(explode(",", $project["months"]));
  1403. for ($i = 0; $i < count($monthAndDayList); $i++) {
  1404. $obj = explode("=", $monthAndDayList[$i]);
  1405. $month = $obj[0];
  1406. $day = is_numeric($obj[1]) ? $obj[1] : 0;
  1407. $count = $map[$month];
  1408. if ($count == 0) {
  1409. $map[$month] = $day;
  1410. } else {
  1411. $map[$month] = $day + $count;
  1412. }
  1413. }
  1414. }
  1415. return $map;
  1416. }
  1417. /**
  1418. * 校验是否在审核范围内
  1419. */
  1420. public function validateIsCheck() {
  1421. $id = $this->request["id"];
  1422. $type = $this->request["type"];
  1423. $process = $this->request["process"];
  1424. $info = null;
  1425. switch ($type) {
  1426. case 1: //编辑合同
  1427. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  1428. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1429. break;
  1430. case 2: //编辑项目
  1431. $project = \app\common\model\TalentAllowanceProject::find($id);
  1432. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  1433. break;
  1434. case 3:
  1435. $info = TalentAllowanceApi::getInfoById($id);
  1436. break;
  1437. }
  1438. if (!$info) {
  1439. return new Response(Response::ERROR, "校验不通过,无法操作");
  1440. }
  1441. $where = [];
  1442. $where[] = ["mainId", "=", $info["id"]];
  1443. $where[] = ["step", "=", $process];
  1444. $where[] = ["active", "=", 2];
  1445. $log = null;
  1446. switch ($process) {
  1447. case 1:
  1448. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  1449. return new Response(Response::ERROR, "不在审核范围内");
  1450. }
  1451. //$where[] = ["companyId","=",$this->user["companyId"]];
  1452. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1453. break;
  1454. case 2:
  1455. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  1456. return new Response(Response::ERROR, "不在审核范围内");
  1457. }
  1458. break;
  1459. case 3:
  1460. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  1461. return new Response(Response::ERROR, "不在审核范围内");
  1462. }
  1463. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1464. break;
  1465. }
  1466. if ($log != null) {
  1467. $info["checkState"] = $log["state"];
  1468. $info["checkMsg"] = $log["description"];
  1469. } else {
  1470. $info["checkState"] = null;
  1471. $info["checkMsg"] = "";
  1472. }
  1473. $res = [];
  1474. $res["info"] = $info;
  1475. if ($type == 3) {
  1476. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1477. $where = [];
  1478. $where[] = ["mainId", "=", $id];
  1479. $where[] = ["isLock", "=", 1];
  1480. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1481. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1482. $detailMap = array_reduce($detailList, function ($result, $item) {
  1483. $key = $item["id"];
  1484. $result[$key] = $item;
  1485. return $result;
  1486. }, []);
  1487. foreach ($detailList as &$detail) {
  1488. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1489. }unset($detail);
  1490. foreach ($projectList as &$project) {
  1491. $detail = $detailMap[$project["baseId"]];
  1492. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1493. }
  1494. $where = [];
  1495. $where[] = ["type", "=", $info["type"]];
  1496. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1497. $where[] = ["active", "=", 1];
  1498. $where[] = ["delete", "=", 0];
  1499. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1500. $res["files"] = $filetypes;
  1501. $res["projects"] = $projectList;
  1502. $res["concats"] = $detailList;
  1503. }
  1504. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  1505. }
  1506. /**
  1507. * 初始化可修改的项目/附件/合同
  1508. * */
  1509. public function findFieldsAndFiles() {
  1510. $id = $this->request["id"];
  1511. if (\StrUtil::isEmpOrNull($id)) {
  1512. return new Response(Response::ERROR, "请选择需要修改的对象");
  1513. }
  1514. $info = TalentAllowanceApi::getInfoById($id);
  1515. if (!$info) {
  1516. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1517. }
  1518. if ($info["checkState"] != AllowanceStateEnum::FIRST_REJECT) {
  1519. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1520. }
  1521. $res = [];
  1522. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1523. $where = [];
  1524. $where[] = ["mainId", "=", $id];
  1525. $where[] = ["isLock", "=", 1];
  1526. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1527. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1528. foreach ($detailList as &$detail) {
  1529. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1530. }unset($detail);
  1531. foreach ($projectList as &$project) {
  1532. $detail = $detailMap[$project["baseId"]];
  1533. $project["projectName"] = sprintf("%s(%s)", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]]);
  1534. }unset($project);
  1535. $where = [];
  1536. $where[] = ["type", "=", $info["type"]];
  1537. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1538. $where[] = ["active", "=", 1];
  1539. $where[] = ["delete", "=", 0];
  1540. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1541. $res["files"] = $filetypes;
  1542. $res["projects"] = $projectList;
  1543. $res["concats"] = $detailList;
  1544. $res["info"] = $info;
  1545. return new Response(Response::SUCCESS, "", $res);
  1546. }
  1547. /**
  1548. * 修改驳回项目/附件/合同
  1549. * */
  1550. public function updateFieldsAndFiles() {
  1551. $data = $this->request->param();
  1552. if (!$data["id"]) {
  1553. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1554. }
  1555. TaModel::update($data);
  1556. return new Response(Response::SUCCESS, "修改成功");
  1557. }
  1558. /**
  1559. * 修改项目
  1560. */
  1561. public function editProject() {
  1562. $param = $this->request->param();
  1563. if (!$param["id"]) {
  1564. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1565. }
  1566. $detail = \app\common\model\TalentAllowanceProject::find($param["id"]);
  1567. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1568. \app\common\model\TalentAllowanceProject::update($param);
  1569. //添加日志
  1570. TalentChecklog::create([
  1571. 'id' => getStringId(),
  1572. 'mainId' => $info['id'],
  1573. 'type' => intval(ProjectState::JBT),
  1574. 'typeFileId' => $param["id"],
  1575. 'active' => 1,
  1576. 'state' => null,
  1577. 'step' => $param["process"],
  1578. 'stateChange' => null,
  1579. 'description' => "修改项目名:" . AllowanceProjectEnum::getProjectName($detail["project"]) . "的值为:" . $param["months"] . ";备注为:" . $param["description"],
  1580. 'createTime' => date("Y-m-d H:i:s", time()),
  1581. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1582. ]);
  1583. return new Response(Response::SUCCESS, "修改成功");
  1584. }
  1585. /**
  1586. * 查询工作单位
  1587. */
  1588. public function findAllowanceContractDetail() {
  1589. $mainId = $this->request["mainId"];
  1590. $offset = $this->request["offset"] ?: 0;
  1591. $limit = $this->request["limit"] ?: 1000;
  1592. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  1593. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  1594. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  1595. foreach ($list as &$row) {
  1596. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  1597. }unset($row);
  1598. return json(["rows" => $list, "total" => $count]);
  1599. }
  1600. /**
  1601. * 查询核查项目情况
  1602. */
  1603. public function findAllowanceProject() {
  1604. $mainId = $this->request["mainId"];
  1605. $baseId = $this->request["baseId"];
  1606. $offset = $this->request["offset"] ?: 0;
  1607. $limit = $this->request["limit"] ?: 1000;
  1608. $where = [];
  1609. $where[] = ["mainId", "=", $mainId];
  1610. $where[] = ["baseId", "=", $baseId];
  1611. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  1612. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  1613. $info = TalentAllowanceApi::getInfoById($mainId);
  1614. foreach ($list as &$project) {
  1615. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  1616. if ($info["checkState"] == 1) {
  1617. $project["isEdit"] = in_array($project["project"], [
  1618. //AllowanceProjectEnum::PROJECT_CONTRACT,
  1619. AllowanceProjectEnum::PROJECT_TAX,
  1620. AllowanceProjectEnum::PROJECT_WAGES,
  1621. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1622. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1623. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1624. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1625. //AllowanceProjectEnum::PROJECT_WORKDAY
  1626. ]) ? 1 : 2;
  1627. } else if ($info["checkState"] == 10 || $info["checkState"] == 8) {
  1628. $projects = explode(",", $info["projects"]);
  1629. if (in_array($project["id"], $projects)) {
  1630. $project["isEdit"] = 1;
  1631. } else {
  1632. $project["isEdit"] = 2;
  1633. }
  1634. } else {
  1635. $project["isEdit"] = 2;
  1636. }
  1637. }unset($project);
  1638. return json(["rows" => $list, "total" => $count]);
  1639. }
  1640. /**
  1641. * 查询人才层次变更记录
  1642. */
  1643. public function findAllowanceArrange() {
  1644. $mainId = $this->request["mainId"];
  1645. $offset = $this->request["offset"] ?: 0;
  1646. $limit = $this->request["limit"] ?: 1000;
  1647. $where = [];
  1648. $where[] = ["mainId", "=", $mainId];
  1649. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  1650. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  1651. foreach ($list as &$arrange) {
  1652. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  1653. $arrange["identifyConditionText"] = $condition["name"];
  1654. $arrange["talentArrangeName"] = CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  1655. }unset($arrange);
  1656. return json(["rows" => $list, "total" => $count]);
  1657. }
  1658. /**
  1659. * 试算
  1660. * @param type $id
  1661. * @return type
  1662. */
  1663. public function calculator($id) {
  1664. $cal = TalentAllowanceApi::validateAllowanceType($id);
  1665. return json($cal);
  1666. }
  1667. private function setTalentAllowanceInfo($where, $query, $process) {
  1668. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1669. $where[] = ["year", "=", $query["year"]];
  1670. }
  1671. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1672. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1673. }
  1674. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1675. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1676. }
  1677. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1678. $where[] = ["talentType", "=", $query["talentType"]];
  1679. }
  1680. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1681. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1682. }
  1683. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1684. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  1685. }
  1686. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1687. $where[] = ["address", "=", $query["address"]];
  1688. }
  1689. if ($query["allowanceType"]) {
  1690. $where[] = ["allowanceType", "=", $query["allowanceType"]];
  1691. }
  1692. if ($query["recommendAllowanceType"]) {
  1693. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1694. }
  1695. if ($query["publicState"]) {
  1696. $where[] = ["publicState", "=", $query["publicState"]];
  1697. }
  1698. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1699. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  1700. }
  1701. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1702. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  1703. }
  1704. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1705. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  1706. }
  1707. if ($process == 4) {
  1708. if ($query["isSupple"]) {
  1709. $where[] = ["isSupple", "=", $query["isSupple"]];
  1710. }
  1711. if ($query["isPublicCheck"]) {
  1712. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  1713. }
  1714. }
  1715. if ($query["checkState"]) {
  1716. if ($query["checkState"] == -1) {
  1717. $where[] = ["checkState", "=", $query["checkState"]];
  1718. } else {
  1719. if ($process == 1) {
  1720. switch ($query["checkState"]) {
  1721. case 0: //保存未提交
  1722. $where[] = ["checkState", "=", 1];
  1723. break;
  1724. case 1:
  1725. $where[] = ["checkState", "=", 5];
  1726. break;
  1727. case 2: //驳回
  1728. $where[] = ["checkState", "=", 10];
  1729. break;
  1730. case 3: //通过
  1731. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  1732. break;
  1733. case 4: //重新提交
  1734. $where[] = ["checkState", "=", 5];
  1735. $where[] = ["highProcess", ">=", $process];
  1736. break;
  1737. case 5: //上级驳回
  1738. $where[] = ["checkState", "=", 13];
  1739. break;
  1740. }
  1741. }
  1742. if ($process == 2) {
  1743. switch ($query["checkState"]) {
  1744. case 1:
  1745. $where[] = ["checkState", "=", 15];
  1746. break;
  1747. case 2: //驳回
  1748. $where[] = ["checkState", "in", [1, 5, 10]];
  1749. $where[] = ["highProcess", ">=", $process];
  1750. break;
  1751. case 3: //通过
  1752. $where[] = ["checkState", "in", [20, 30]];
  1753. break;
  1754. case 9: //重新提交
  1755. $where[] = ["checkState", "=", 15];
  1756. $where[] = ["highProcess", ">=", $process];
  1757. break;
  1758. case 4: //上级驳回
  1759. $where[] = ["checkState", "=", 25];
  1760. break;
  1761. case -1:
  1762. $where[] = ["checkState", "=", -1];
  1763. break;
  1764. }
  1765. }
  1766. if ($process == 3) {
  1767. switch ($query["checkState"]) {
  1768. case -1:
  1769. $where[] = ["checkState", "=", -1];
  1770. break;
  1771. case 1:
  1772. $where[] = ["checkState", "=", 20];
  1773. break;
  1774. case 2: //驳回
  1775. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  1776. $where[] = ["highProcess", ">=", $process];
  1777. break;
  1778. case 3: //通过
  1779. $where[] = ["checkState", "=", 30];
  1780. break;
  1781. case 9: //重新提交
  1782. $where[] = ["checkState", "=", 20];
  1783. $where[] = ["highProcess", ">=", $process];
  1784. break;
  1785. case 4: //上级驳回
  1786. $where[] = ["checkState", "=", 35];
  1787. break;
  1788. }
  1789. }
  1790. if ($process == 4) {
  1791. switch ($query["checkState"]) {
  1792. case -1:
  1793. $where[] = ["checkState", "=", -1];
  1794. break;
  1795. case 3: //通过
  1796. $where[] = ["checkState", "=", 30];
  1797. break;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. return $where;
  1803. }
  1804. private function setTalentAllowanceInfoForExport(&$where, $query, $process) {
  1805. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1806. $where[] = ["ta.year", "=", $query["year"]];
  1807. }
  1808. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1809. $where[] = ["ta.enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1810. }
  1811. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1812. $where[] = ["ta.name", "like", "%" . $query["name"] . "%"];
  1813. }
  1814. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1815. $where[] = ["ta.talentType", "=", $query["talentType"]];
  1816. }
  1817. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1818. $where[] = ["ta.talentArrange", "=", $query["talentArrange"]];
  1819. }
  1820. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1821. $where[] = ["ta.identifyCondition", "=", $query["identifyCondition"]];
  1822. }
  1823. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1824. $where[] = ["ta.address", "=", $query["address"]];
  1825. }
  1826. if (\StrUtil::isNotEmpAndNull($query["allowanceType"])) {
  1827. $where[] = ["ta.allowanceType", "=", $query["allowanceType"]];
  1828. }
  1829. if (\StrUtil::isNotEmpAndNull($query["recommendAllowanceType"])) {
  1830. $where[] = ["ta.recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1831. }
  1832. if (\StrUtil::isNotEmpAndNull($query["publicState"])) {
  1833. $where[] = ["ta.publicState", "=", $query["publicState"]];
  1834. }
  1835. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1836. $where[] = ["ta.introductionMode", "=", $query["introductionMode"]];
  1837. }
  1838. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1839. $where[] = ["ta.firstInJJTime", ">=", $query["firstJJStartTime"]];
  1840. }
  1841. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1842. $where[] = ["ta.firstInJJTime", "<=", $query["firstJJEndTime"]];
  1843. }
  1844. if ($process == 4) {
  1845. if ($query["isSupple"]) {
  1846. $where[] = ["ta.isSupple", "=", $query["isSupple"]];
  1847. }
  1848. if ($query["isPublicCheck"]) {
  1849. $where[] = ["ta.isPublicCheck", "=", $query["isPublicCheck"]];
  1850. }
  1851. }
  1852. if ($query["checkState"]) {
  1853. if ($query["checkState"] == -1) {
  1854. $where[] = ["ta.checkState", "=", $query["checkState"]];
  1855. } else {
  1856. if ($process == 1) {
  1857. switch ($query["checkState"]) {
  1858. case 0: //保存未提交
  1859. $where[] = ["ta.checkState", "=", 1];
  1860. break;
  1861. case 1:
  1862. $where[] = ["ta.checkState", "=", 5];
  1863. break;
  1864. case 2: //驳回
  1865. $where[] = ["ta.checkState", "=", 10];
  1866. break;
  1867. case 3: //通过
  1868. $where[] = ["ta.checkState", "in", [15, 20, 30, 25]];
  1869. break;
  1870. case 4: //重新提交
  1871. $where[] = ["ta.checkState", "=", 5];
  1872. $where[] = ["ta.highProcess", ">=", $process];
  1873. break;
  1874. case 5: //上级驳回
  1875. $where[] = ["ta.checkState", "=", 13];
  1876. break;
  1877. }
  1878. }
  1879. if ($process == 2) {
  1880. switch ($query["checkState"]) {
  1881. case 1:
  1882. $where[] = ["ta.checkState", "=", 15];
  1883. break;
  1884. case 2: //驳回
  1885. $where[] = ["ta.checkState", "in", [1, 5, 10]];
  1886. $where[] = ["ta.highProcess", ">=", $process];
  1887. break;
  1888. case 3: //通过
  1889. $where[] = ["ta.checkState", "in", [20, 30]];
  1890. break;
  1891. case 9: //重新提交
  1892. $where[] = ["ta.checkState", "=", 15];
  1893. $where[] = ["ta.highProcess", ">=", $process];
  1894. break;
  1895. case 4: //上级驳回
  1896. $where[] = ["ta.checkState", "=", 25];
  1897. break;
  1898. case -1:
  1899. $where[] = ["ta.checkState", "=", -1];
  1900. break;
  1901. }
  1902. }
  1903. if ($process == 3) {
  1904. switch ($query["checkState"]) {
  1905. case -1:
  1906. $where[] = ["ta.checkState", "=", -1];
  1907. break;
  1908. case 1:
  1909. $where[] = ["ta.checkState", "=", 20];
  1910. break;
  1911. case 2: //驳回
  1912. $where[] = ["ta.checkState", "in", [1, 5, 10, 15, 25]];
  1913. $where[] = ["ta.highProcess", ">=", $process];
  1914. break;
  1915. case 3: //通过
  1916. $where[] = ["ta.checkState", "=", 30];
  1917. break;
  1918. case 9: //重新提交
  1919. $where[] = ["ta.checkState", "=", 20];
  1920. $where[] = ["ta.highProcess", ">=", $process];
  1921. break;
  1922. case 4: //上级驳回
  1923. $where[] = ["ta.checkState", "=", 35];
  1924. break;
  1925. }
  1926. }
  1927. if ($process == 4) {
  1928. switch ($query["checkState"]) {
  1929. case -1:
  1930. $where[] = ["ta.checkState", "=", -1];
  1931. break;
  1932. case 3: //通过
  1933. $where[] = ["ta.checkState", "=", 30];
  1934. break;
  1935. }
  1936. }
  1937. }
  1938. }
  1939. }
  1940. private function translateToChinese(&$obj) {
  1941. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1942. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1943. }
  1944. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1945. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1946. }
  1947. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1948. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1949. }
  1950. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1951. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1952. }
  1953. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1954. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1955. }
  1956. }
  1957. private function translateChinese($list) {
  1958. //获取字典表
  1959. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1960. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1961. $streetMap = DictApi::selectByParentCode("street");
  1962. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1963. $modeMap = DictApi::selectByParentCode("import_way");
  1964. $where = [];
  1965. $where[] = ["type", "=", $this->user["type"]];
  1966. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1967. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1968. foreach ($list as &$info) {
  1969. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  1970. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1971. }
  1972. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1973. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  1974. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  1975. }
  1976. $info["addressName"] = $streetMap[$info["address"]];
  1977. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  1978. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  1979. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1980. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  1981. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  1982. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recommendAllowanceType"]);
  1983. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  1984. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  1985. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  1986. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  1987. }unset($info);
  1988. return $list;
  1989. }
  1990. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  1991. switch ($checkState) {
  1992. case 1:
  1993. return "待提交";
  1994. case 5:
  1995. case 13:
  1996. case 15:
  1997. case 20:
  1998. case 25:
  1999. case 35:
  2000. return "审核中";
  2001. case 10:
  2002. return "已驳回";
  2003. case - 1:
  2004. if ($publicState >= 3) {
  2005. return "审核不通过";
  2006. } else {
  2007. return "审核中";
  2008. }
  2009. break;
  2010. case 30:
  2011. if ($publicState == 1) {
  2012. return "待核查征信";
  2013. } else if ($publicState == 2) {
  2014. return "待公示";
  2015. } else if ($publicState == 3) {
  2016. return "公示中";
  2017. } else if ($publicState == 4) {
  2018. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  2019. } else if ($publicState == 5) {
  2020. return "已兑现";
  2021. }
  2022. default:
  2023. return "未知状态";
  2024. }
  2025. }
  2026. }