TalentAllowance.php 110 KB

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