TalentAllowance.php 105 KB

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