TalentAllowance.php 109 KB

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