TalentAllowance.php 96 KB

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