TalentAllowance.php 103 KB

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