TalentAllowance.php 101 KB

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