TalentAllowance.php 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047
  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. $contractSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  1125. $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  1126. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  1127. $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  1128. $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  1129. $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  1130. $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  1131. $set = array_intersect($set, $contractSet);
  1132. $set = array_intersect($set, $workdaySet);
  1133. $set = array_intersect($set, $wageSet);
  1134. $checkSet = $set;
  1135. $set = array_intersect($set, $pensionSet);
  1136. $set = array_intersect($set, $unemploymentSet);
  1137. $set = array_intersect($set, $medicaSet);
  1138. $set = array_intersect($set, $taxSet);
  1139. usort($set, function($a, $b) {
  1140. return (int) $a - (int) $b;
  1141. });
  1142. if ($info["recommendAllowanceType"] == 1) {
  1143. if (count($checkSet) < 6) {
  1144. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  1145. $info["recommendAllowanceType"] = 2;
  1146. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度工作合同月份、考勤月份、工资发放月份交集月份不满足6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1147. } else {
  1148. //检查连续缴纳月份是否满足6个月
  1149. $count = 1;
  1150. foreach ($checkSet as $s) {
  1151. $currentVal = intval($s);
  1152. $nextVal = $currentVal + 1;
  1153. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1154. if (in_array($nextKey, $checkSet)) {
  1155. $count++;
  1156. if ($count >= 6) {
  1157. break;
  1158. }
  1159. } else {
  1160. $count = 1;
  1161. }
  1162. }
  1163. if ($count < 6) {
  1164. $info["recommendAllowanceType"] = 2;
  1165. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度工作合同月份、考勤月份、工资发放月份不满足连续缴纳6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1166. }
  1167. }
  1168. }
  1169. if ($info["recommendAllowanceType"] == 2) {
  1170. //判断境内工作时间是否大于30天
  1171. if ($info["allowanceType"] == 2) {
  1172. $totalDays = 0;
  1173. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  1174. foreach ($workmonths as $days) {
  1175. $totalDays += $days;
  1176. }
  1177. if ($totalDays < 30) {
  1178. $info["recommendAllowanceType"] = 3;
  1179. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  1180. }
  1181. } else {
  1182. if (count($workdaySet) == 0) {
  1183. $info["recommendAllowanceType"] = 3;
  1184. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  1185. } else {
  1186. $info["recommendAllowanceType"] = 2;
  1187. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  1188. }
  1189. }
  1190. }
  1191. return $set;
  1192. }
  1193. /**
  1194. * 计算津补贴
  1195. */
  1196. private function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  1197. /* * 查询人才层次变更记录 */
  1198. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  1199. foreach ($arrangeList as &$arrange) {
  1200. $where = [];
  1201. $where[] = ["type", "=", $this->user["type"]];
  1202. $where[] = ["allowanceType", "in", [1, 2]];
  1203. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  1204. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  1205. foreach ($list as $amount) {
  1206. if ($amount["allowanceType"] == 1) {
  1207. $arrange["jobMoney"] = $amount["money"];
  1208. }
  1209. if ($amount["allowanceType"] == 2) {
  1210. $arrange["jtMoney"] = $amount["money"];
  1211. }
  1212. }
  1213. }unset($arrange);
  1214. /* * * 容器 */
  1215. $jobMoney = 0.00; //计算所得工作津贴
  1216. $jtMoney = 0.00; //计算所得一次性交通补贴
  1217. $recommendMonths = []; //推荐月份
  1218. $talentArrange = null;
  1219. /* * *********计算************* */
  1220. $msgBulider = [];
  1221. switch ($info["recommendAllowanceType"]) {
  1222. case 1:
  1223. foreach ($arrangeList as &$arrange) {
  1224. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  1225. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  1226. $levelList = array_intersect($levelList, $retainMonths);
  1227. $total = round($arrange["jobMoney"] * count($levelList), 2);
  1228. $jobMoney += $total;
  1229. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  1230. $recommendMonths = array_merge($recommendMonths, $levelList);
  1231. usort($recommendMonths, function($a, $b) {
  1232. return (int) $a - (int) $b;
  1233. });
  1234. $arrange["months"] = implode(",", $levelList);
  1235. $arrange["count"] = count($levelList);
  1236. $arrange["total"] = $total;
  1237. } else {
  1238. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  1239. $arrange["count"] = 0;
  1240. $arrange["total"] = 0.00;
  1241. }
  1242. }unset($arrange);
  1243. $info["recommendMonths"] = implode(",", $recommendMonths);
  1244. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "通过与人才证书有效期取交集得到最终可享受月份:" . implode(",", $recommendMonths) . "\n经过计算:人才津贴为" . $jobMoney . ";";
  1245. $info["recommendMoney"] = $jobMoney;
  1246. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  1247. break;
  1248. case 2:
  1249. foreach ($arrangeList as $arrange) {
  1250. $jtMoney = $arrange["jtMoney"];
  1251. $talentArrange = $arrange["talentArrange"];
  1252. }
  1253. $info["recommendMoney"] = $jtMoney;
  1254. $info["recommendMonths"] = "";
  1255. $info["recommendMoneyDesc"] = "一次性交通补贴";
  1256. $info["workAllowanceMoney"] = 0.00;
  1257. $info["developAllowanceMoney"] = 0.00;
  1258. $info["recommendTalentArrange"] = $talentArrange;
  1259. break;
  1260. case 3:
  1261. $info["recommendMoney"] = 0.00;
  1262. $info["recommendMonths"] = "";
  1263. $info["recommendMoneyDesc"] = "不予兑现";
  1264. $info["workAllowanceMoney"] = 0.00;
  1265. $info["developAllowanceMoney"] = 0.00;
  1266. break;
  1267. }
  1268. return $arrangeList;
  1269. }
  1270. /**
  1271. * 判定是否交足6个月(集成电路)
  1272. * @param set
  1273. * @param info
  1274. * @param name
  1275. */
  1276. private function chkMonths($set, &$info, $name, $sort) {
  1277. if ($name == "上年度工作月份") {
  1278. if ($info["allowanceType"] == 2) {
  1279. $tmp = [];
  1280. foreach ($set as $s) {
  1281. $_s = explode("=", $s);
  1282. $month = $_s[0];
  1283. $days = $_s[1];
  1284. if ($days > 0) {
  1285. $tmp[] = $month;
  1286. }
  1287. }
  1288. $set = $tmp;
  1289. }
  1290. }
  1291. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6)) {
  1292. $info["recommendAllowanceType"] = 2;
  1293. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)";
  1294. }
  1295. return $set;
  1296. }
  1297. //合并所有项目的月份
  1298. private function mergeMonth($detailList) {
  1299. $contractList = [];
  1300. $taxList = [];
  1301. $wagesList = [];
  1302. $pensionList = [];
  1303. $unemploymentList = [];
  1304. $medicaList = [];
  1305. $attendanceList = [];
  1306. $workdayList = [];
  1307. foreach ($detailList as $detail) {
  1308. $projectMap = $detail["projectMap"];
  1309. if ($detail["months"]) {
  1310. $tmp = array_filter(explode(",", $detail["months"]));
  1311. $contractList = array_merge($contractList, $tmp);
  1312. }
  1313. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  1314. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  1315. $taxList = array_merge($taxList, $tmp);
  1316. }
  1317. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  1318. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  1319. $wagesList = array_merge($wagesList, $tmp);
  1320. }
  1321. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  1322. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  1323. $pensionList = array_merge($pensionList, $tmp);
  1324. }
  1325. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  1326. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  1327. $unemploymentList = array_merge($unemploymentList, $tmp);
  1328. }
  1329. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  1330. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  1331. $medicaList = array_merge($medicaList, $tmp);
  1332. }
  1333. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  1334. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  1335. $attendanceList = array_merge($attendanceList, $tmp);
  1336. }
  1337. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  1338. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  1339. $workdayList = array_merge($workdayList, $tmp);
  1340. }
  1341. }
  1342. $map = [
  1343. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  1344. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  1345. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  1346. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  1347. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  1348. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  1349. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  1350. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  1351. ];
  1352. return $map;
  1353. }
  1354. /**
  1355. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  1356. * */
  1357. private function mergeMonthNeedDay($detailList) {
  1358. $attendMap = [];
  1359. $workDayMap = [];
  1360. foreach ($detailList as $detail) {
  1361. $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  1362. $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  1363. }
  1364. $res = [
  1365. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  1366. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  1367. ];
  1368. return $res;
  1369. }
  1370. private function getMergeMonthNeedDayMap($project, $map) {
  1371. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  1372. $monthAndDayList = array_filter(explode(",", $project["months"]));
  1373. for ($i = 0; $i < count($monthAndDayList); $i++) {
  1374. $obj = explode("=", $monthAndDayList[$i]);
  1375. $month = $obj[0];
  1376. $day = $obj[1];
  1377. $count = $map[$month];
  1378. if ($count == 0) {
  1379. $map[$month] = $day;
  1380. } else {
  1381. $map[$month] = $day + $count;
  1382. }
  1383. }
  1384. }
  1385. return $map;
  1386. }
  1387. /**
  1388. * 校验是否在审核范围内
  1389. */
  1390. public function validateIsCheck() {
  1391. $id = $this->request["id"];
  1392. $type = $this->request["type"];
  1393. $process = $this->request["process"];
  1394. $info = null;
  1395. switch ($type) {
  1396. case 1: //编辑合同
  1397. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  1398. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1399. break;
  1400. case 2: //编辑项目
  1401. $project = \app\common\model\TalentAllowanceProject::find($id);
  1402. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  1403. break;
  1404. case 3:
  1405. $info = TalentAllowanceApi::getInfoById($id);
  1406. break;
  1407. }
  1408. if (!$info) {
  1409. return new Response(Response::ERROR, "校验不通过,无法操作");
  1410. }
  1411. $where = [];
  1412. $where[] = ["mainId", "=", $info["id"]];
  1413. $where[] = ["step", "=", $process];
  1414. $where[] = ["active", "=", 2];
  1415. $log = null;
  1416. switch ($process) {
  1417. case 1:
  1418. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  1419. return new Response(Response::ERROR, "不在审核范围内");
  1420. }
  1421. //$where[] = ["companyId","=",$this->user["companyId"]];
  1422. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1423. break;
  1424. case 2:
  1425. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  1426. return new Response(Response::ERROR, "不在审核范围内");
  1427. }
  1428. break;
  1429. case 3:
  1430. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  1431. return new Response(Response::ERROR, "不在审核范围内");
  1432. }
  1433. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1434. break;
  1435. }
  1436. if ($log != null) {
  1437. $info["checkState"] = $log["state"];
  1438. $info["checkMsg"] = $log["description"];
  1439. } else {
  1440. $info["checkState"] = null;
  1441. $info["checkMsg"] = "";
  1442. }
  1443. $res = [];
  1444. $res["info"] = $info;
  1445. if ($type == 3) {
  1446. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1447. $where = [];
  1448. $where[] = ["mainId", "=", $id];
  1449. $where[] = ["isLock", "=", 1];
  1450. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1451. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1452. $detailMap = array_reduce($detailList, function ($result, $item) {
  1453. $key = $item["id"];
  1454. $result[$key] = $item;
  1455. return $result;
  1456. }, []);
  1457. foreach ($detailList as &$detail) {
  1458. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1459. }unset($detail);
  1460. foreach ($projectList as &$project) {
  1461. $detail = $detailMap[$project["baseId"]];
  1462. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1463. }
  1464. $where = [];
  1465. $where[] = ["type", "=", $info["type"]];
  1466. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1467. $where[] = ["active", "=", 1];
  1468. $where[] = ["delete", "=", 0];
  1469. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1470. $res["files"] = $filetypes;
  1471. $res["projects"] = $projectList;
  1472. $res["concats"] = $detailList;
  1473. }
  1474. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  1475. }
  1476. /**
  1477. * 初始化可修改的项目/附件/合同
  1478. * */
  1479. public function findFieldsAndFiles() {
  1480. $id = $this->request["id"];
  1481. if (\StrUtil::isEmpOrNull($id)) {
  1482. return new Response(Response::ERROR, "请选择需要修改的对象");
  1483. }
  1484. $info = TalentAllowanceApi::getInfoById($id);
  1485. if (!$info) {
  1486. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1487. }
  1488. if ($info["checkState"] != AllowanceStateEnum::FIRST_REJECT) {
  1489. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1490. }
  1491. $res = [];
  1492. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1493. $where = [];
  1494. $where[] = ["mainId", "=", $id];
  1495. $where[] = ["isLock", "=", 1];
  1496. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1497. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1498. foreach ($detailList as &$detail) {
  1499. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1500. }unset($detail);
  1501. foreach ($projectList as &$project) {
  1502. $detail = $detailMap[$project["baseId"]];
  1503. $project["projectName"] = sprintf("%s(%s)", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]]);
  1504. }unset($project);
  1505. $where = [];
  1506. $where[] = ["type", "=", $info["type"]];
  1507. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1508. $where[] = ["active", "=", 1];
  1509. $where[] = ["delete", "=", 0];
  1510. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1511. $res["files"] = $filetypes;
  1512. $res["projects"] = $projectList;
  1513. $res["concats"] = $detailList;
  1514. $res["info"] = $info;
  1515. return new Response(Response::SUCCESS, "", $res);
  1516. }
  1517. /**
  1518. * 修改驳回项目/附件/合同
  1519. * */
  1520. public function updateFieldsAndFiles() {
  1521. $data = $this->request->param();
  1522. if (!$data["id"]) {
  1523. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1524. }
  1525. TaModel::update($data);
  1526. return new Response(Response::SUCCESS, "修改成功");
  1527. }
  1528. /**
  1529. * 修改项目
  1530. */
  1531. public function editProject() {
  1532. $param = $this->request->param();
  1533. if (!$param["id"]) {
  1534. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1535. }
  1536. $detail = \app\common\model\TalentAllowanceProject::find($param["id"]);
  1537. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1538. \app\common\model\TalentAllowanceProject::update($param);
  1539. //添加日志
  1540. TalentChecklog::create([
  1541. 'id' => getStringId(),
  1542. 'mainId' => $info['id'],
  1543. 'type' => intval(ProjectState::JBT),
  1544. 'typeFileId' => $param["id"],
  1545. 'active' => 1,
  1546. 'state' => null,
  1547. 'step' => $param["process"],
  1548. 'stateChange' => null,
  1549. 'description' => "修改项目名:" . AllowanceProjectEnum::getProjectName($detail["project"]) . "的值为:" . $param["months"] . ";备注为:" . $param["description"],
  1550. 'createTime' => date("Y-m-d H:i:s", time()),
  1551. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1552. ]);
  1553. return new Response(Response::SUCCESS, "修改成功");
  1554. }
  1555. /**
  1556. * 查询工作单位
  1557. */
  1558. public function findAllowanceContractDetail() {
  1559. $mainId = $this->request["mainId"];
  1560. $offset = $this->request["offset"] ?: 0;
  1561. $limit = $this->request["limit"] ?: 1000;
  1562. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  1563. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  1564. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  1565. foreach ($list as &$row) {
  1566. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  1567. }unset($row);
  1568. return json(["rows" => $list, "total" => $count]);
  1569. }
  1570. /**
  1571. * 查询核查项目情况
  1572. */
  1573. public function findAllowanceProject() {
  1574. $mainId = $this->request["mainId"];
  1575. $baseId = $this->request["baseId"];
  1576. $offset = $this->request["offset"] ?: 0;
  1577. $limit = $this->request["limit"] ?: 1000;
  1578. $where = [];
  1579. $where[] = ["mainId", "=", $mainId];
  1580. $where[] = ["baseId", "=", $baseId];
  1581. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  1582. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  1583. $info = TalentAllowanceApi::getInfoById($mainId);
  1584. foreach ($list as &$project) {
  1585. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  1586. if ($info["checkState"] == 1) {
  1587. $project["isEdit"] = in_array($project["project"], [
  1588. //AllowanceProjectEnum::PROJECT_CONTRACT,
  1589. AllowanceProjectEnum::PROJECT_TAX,
  1590. AllowanceProjectEnum::PROJECT_WAGES,
  1591. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1592. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1593. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1594. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1595. //AllowanceProjectEnum::PROJECT_WORKDAY
  1596. ]) ? 1 : 2;
  1597. } else if ($info["checkState"] == 10) {
  1598. $projects = explode(",", $info["projects"]);
  1599. if (in_array($project["id"], $projects)) {
  1600. $project["isEdit"] = 1;
  1601. } else {
  1602. $project["isEdit"] = 2;
  1603. }
  1604. } else {
  1605. $project["isEdit"] = 2;
  1606. }
  1607. }unset($project);
  1608. return json(["rows" => $list, "total" => $count]);
  1609. }
  1610. /**
  1611. * 查询人才层次变更记录
  1612. */
  1613. public function findAllowanceArrange() {
  1614. $mainId = $this->request["mainId"];
  1615. $offset = $this->request["offset"] ?: 0;
  1616. $limit = $this->request["limit"] ?: 1000;
  1617. $where = [];
  1618. $where[] = ["mainId", "=", $mainId];
  1619. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  1620. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  1621. foreach ($list as &$arrange) {
  1622. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  1623. $arrange["identifyConditionText"] = $condition["name"];
  1624. $arrange["talentArrangeName"] = CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  1625. }unset($arrange);
  1626. return json(["rows" => $list, "total" => $count]);
  1627. }
  1628. private function setTalentAllowanceInfo($where, $query, $process) {
  1629. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1630. $where[] = ["year", "=", $query["year"]];
  1631. }
  1632. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1633. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1634. }
  1635. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1636. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1637. }
  1638. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1639. $where[] = ["talentType", "=", $query["talentType"]];
  1640. }
  1641. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1642. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1643. }
  1644. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1645. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  1646. }
  1647. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1648. $where[] = ["address", "=", $query["address"]];
  1649. }
  1650. if ($query["allowanceType"]) {
  1651. $where[] = ["allowanceType", "=", $query["allowanceType"]];
  1652. }
  1653. if ($query["recommendAllowanceType"]) {
  1654. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1655. }
  1656. if ($query["publicState"]) {
  1657. $where[] = ["publicState", "=", $query["publicState"]];
  1658. }
  1659. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1660. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  1661. }
  1662. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1663. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  1664. }
  1665. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1666. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  1667. }
  1668. if ($process == 4) {
  1669. if ($query["isSupple"]) {
  1670. $where[] = ["isSupple", "=", $query["isSupple"]];
  1671. }
  1672. if ($query["isPublicCheck"]) {
  1673. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  1674. }
  1675. }
  1676. if ($query["checkState"]) {
  1677. if ($query["checkState"] == -1) {
  1678. $where[] = ["checkState", "=", $query["checkState"]];
  1679. } else {
  1680. if ($process == 1) {
  1681. switch ($query["checkState"]) {
  1682. case 0: //保存未提交
  1683. $where[] = ["checkState", "=", 1];
  1684. break;
  1685. case 1:
  1686. $where[] = ["checkState", "=", 5];
  1687. break;
  1688. case 2: //驳回
  1689. $where[] = ["checkState", "=", 10];
  1690. break;
  1691. case 3: //通过
  1692. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  1693. break;
  1694. case 4: //重新提交
  1695. $where[] = ["checkState", "=", 5];
  1696. $where[] = ["highProcess", ">=", $process];
  1697. break;
  1698. case 5: //上级驳回
  1699. $where[] = ["checkState", "=", 13];
  1700. break;
  1701. }
  1702. }
  1703. if ($process == 2) {
  1704. switch ($query["checkState"]) {
  1705. case 1:
  1706. $where[] = ["checkState", "=", 15];
  1707. break;
  1708. case 2: //驳回
  1709. $where[] = ["checkState", "in", [1, 5, 10]];
  1710. $where[] = ["highProcess", ">=", $process];
  1711. break;
  1712. case 3: //通过
  1713. $where[] = ["checkState", "in", [20, 30]];
  1714. break;
  1715. case 9: //重新提交
  1716. $where[] = ["checkState", "=", 15];
  1717. $where[] = ["highProcess", ">=", $process];
  1718. break;
  1719. case 4: //上级驳回
  1720. $where[] = ["checkState", "=", 25];
  1721. break;
  1722. case -1:
  1723. $where[] = ["checkState", "=", -1];
  1724. break;
  1725. }
  1726. }
  1727. if ($process == 3) {
  1728. switch ($query["checkState"]) {
  1729. case -1:
  1730. $where[] = ["checkState", "=", -1];
  1731. break;
  1732. case 1:
  1733. $where[] = ["checkState", "=", 20];
  1734. break;
  1735. case 2: //驳回
  1736. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  1737. $where[] = ["highProcess", ">=", $process];
  1738. break;
  1739. case 3: //通过
  1740. $where[] = ["checkState", "=", 30];
  1741. break;
  1742. case 9: //重新提交
  1743. $where[] = ["checkState", "=", 20];
  1744. $where[] = ["highProcess", ">=", $process];
  1745. break;
  1746. case 4: //上级驳回
  1747. $where[] = ["checkState", "=", 35];
  1748. break;
  1749. }
  1750. }
  1751. if ($process == 4) {
  1752. switch ($query["checkState"]) {
  1753. case -1:
  1754. $where[] = ["checkState", "=", -1];
  1755. break;
  1756. case 3: //通过
  1757. $where[] = ["checkState", "=", 30];
  1758. break;
  1759. }
  1760. }
  1761. }
  1762. }
  1763. return $where;
  1764. }
  1765. private function setTalentAllowanceInfoForExport(&$where, $query, $process) {
  1766. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1767. $where[] = ["ta.year", "=", $query["year"]];
  1768. }
  1769. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1770. $where[] = ["ta.enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1771. }
  1772. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1773. $where[] = ["ta.name", "like", "%" . $query["name"] . "%"];
  1774. }
  1775. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1776. $where[] = ["ta.talentType", "=", $query["talentType"]];
  1777. }
  1778. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1779. $where[] = ["ta.talentArrange", "=", $query["talentArrange"]];
  1780. }
  1781. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1782. $where[] = ["ta.identifyCondition", "=", $query["identifyCondition"]];
  1783. }
  1784. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1785. $where[] = ["ta.address", "=", $query["address"]];
  1786. }
  1787. if (\StrUtil::isNotEmpAndNull($query["allowanceType"])) {
  1788. $where[] = ["ta.allowanceType", "=", $query["allowanceType"]];
  1789. }
  1790. if (\StrUtil::isNotEmpAndNull($query["recommendAllowanceType"])) {
  1791. $where[] = ["ta.recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1792. }
  1793. if (\StrUtil::isNotEmpAndNull($query["publicState"])) {
  1794. $where[] = ["ta.publicState", "=", $query["publicState"]];
  1795. }
  1796. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1797. $where[] = ["ta.introductionMode", "=", $query["introductionMode"]];
  1798. }
  1799. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1800. $where[] = ["ta.firstInJJTime", ">=", $query["firstJJStartTime"]];
  1801. }
  1802. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1803. $where[] = ["ta.firstInJJTime", "<=", $query["firstJJEndTime"]];
  1804. }
  1805. if ($process == 4) {
  1806. if ($query["isSupple"]) {
  1807. $where[] = ["ta.isSupple", "=", $query["isSupple"]];
  1808. }
  1809. if ($query["isPublicCheck"]) {
  1810. $where[] = ["ta.isPublicCheck", "=", $query["isPublicCheck"]];
  1811. }
  1812. }
  1813. if ($query["checkState"]) {
  1814. if ($query["checkState"] == -1) {
  1815. $where[] = ["ta.checkState", "=", $query["checkState"]];
  1816. } else {
  1817. if ($process == 1) {
  1818. switch ($query["checkState"]) {
  1819. case 0: //保存未提交
  1820. $where[] = ["ta.checkState", "=", 1];
  1821. break;
  1822. case 1:
  1823. $where[] = ["ta.checkState", "=", 5];
  1824. break;
  1825. case 2: //驳回
  1826. $where[] = ["ta.checkState", "=", 10];
  1827. break;
  1828. case 3: //通过
  1829. $where[] = ["ta.checkState", "in", [15, 20, 30, 25]];
  1830. break;
  1831. case 4: //重新提交
  1832. $where[] = ["ta.checkState", "=", 5];
  1833. $where[] = ["ta.highProcess", ">=", $process];
  1834. break;
  1835. case 5: //上级驳回
  1836. $where[] = ["ta.checkState", "=", 13];
  1837. break;
  1838. }
  1839. }
  1840. if ($process == 2) {
  1841. switch ($query["checkState"]) {
  1842. case 1:
  1843. $where[] = ["ta.checkState", "=", 15];
  1844. break;
  1845. case 2: //驳回
  1846. $where[] = ["ta.checkState", "in", [1, 5, 10]];
  1847. $where[] = ["ta.highProcess", ">=", $process];
  1848. break;
  1849. case 3: //通过
  1850. $where[] = ["ta.checkState", "in", [20, 30]];
  1851. break;
  1852. case 9: //重新提交
  1853. $where[] = ["ta.checkState", "=", 15];
  1854. $where[] = ["ta.highProcess", ">=", $process];
  1855. break;
  1856. case 4: //上级驳回
  1857. $where[] = ["ta.checkState", "=", 25];
  1858. break;
  1859. case -1:
  1860. $where[] = ["ta.checkState", "=", -1];
  1861. break;
  1862. }
  1863. }
  1864. if ($process == 3) {
  1865. switch ($query["checkState"]) {
  1866. case -1:
  1867. $where[] = ["ta.checkState", "=", -1];
  1868. break;
  1869. case 1:
  1870. $where[] = ["ta.checkState", "=", 20];
  1871. break;
  1872. case 2: //驳回
  1873. $where[] = ["ta.checkState", "in", [1, 5, 10, 15, 25]];
  1874. $where[] = ["ta.highProcess", ">=", $process];
  1875. break;
  1876. case 3: //通过
  1877. $where[] = ["ta.checkState", "=", 30];
  1878. break;
  1879. case 9: //重新提交
  1880. $where[] = ["ta.checkState", "=", 20];
  1881. $where[] = ["ta.highProcess", ">=", $process];
  1882. break;
  1883. case 4: //上级驳回
  1884. $where[] = ["ta.checkState", "=", 35];
  1885. break;
  1886. }
  1887. }
  1888. if ($process == 4) {
  1889. switch ($query["checkState"]) {
  1890. case -1:
  1891. $where[] = ["ta.checkState", "=", -1];
  1892. break;
  1893. case 3: //通过
  1894. $where[] = ["ta.checkState", "=", 30];
  1895. break;
  1896. }
  1897. }
  1898. }
  1899. }
  1900. }
  1901. private function translateToChinese(&$obj) {
  1902. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1903. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1904. }
  1905. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1906. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1907. }
  1908. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1909. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1910. }
  1911. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1912. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1913. }
  1914. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1915. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1916. }
  1917. }
  1918. private function translateChinese($list) {
  1919. //获取字典表
  1920. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1921. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1922. $streetMap = DictApi::selectByParentCode("street");
  1923. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1924. $modeMap = DictApi::selectByParentCode("import_way");
  1925. $where = [];
  1926. $where[] = ["type", "=", $this->user["type"]];
  1927. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1928. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1929. foreach ($list as &$info) {
  1930. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  1931. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1932. }
  1933. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1934. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  1935. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  1936. }
  1937. $info["addressName"] = $streetMap[$info["address"]];
  1938. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  1939. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  1940. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1941. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  1942. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  1943. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recomendAllowanceType"]);
  1944. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  1945. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  1946. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  1947. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  1948. }unset($info);
  1949. return $list;
  1950. }
  1951. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  1952. switch ($checkState) {
  1953. case 1:
  1954. return "待提交";
  1955. case 5:
  1956. case 13:
  1957. case 15:
  1958. case 20:
  1959. case 25:
  1960. case 35:
  1961. return "审核中";
  1962. case 10:
  1963. return "已驳回";
  1964. case - 1:
  1965. if ($publicState >= 3) {
  1966. return "审核不通过";
  1967. } else {
  1968. return "审核中";
  1969. }
  1970. break;
  1971. case 30:
  1972. if ($publicState == 1) {
  1973. return "待核查征信";
  1974. } else if ($publicState == 2) {
  1975. return "待公示";
  1976. } else if ($publicState == 3) {
  1977. return "公示中";
  1978. } else if ($publicState == 4) {
  1979. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  1980. } else if ($publicState == 5) {
  1981. return "已兑现";
  1982. }
  1983. default:
  1984. return "未知状态";
  1985. }
  1986. }
  1987. }