TalentAllowance.php 107 KB

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