TalentAllowance.php 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace app\enterprise\controller;
  8. use app\enterprise\common\EnterpriseController;
  9. use app\common\state\CommonConst;
  10. use app\common\api\BatchApi;
  11. use app\common\api\TalentAllowanceApi;
  12. use app\common\state\ProjectState;
  13. use app\common\api\DictApi;
  14. use app\common\state\MainState;
  15. use app\common\model\TalentAllowance as TaModel;
  16. use app\common\state\AllowanceProjectEnum;
  17. use app\common\model\TalentChecklog;
  18. use think\facade\Db;
  19. use app\common\api\Response;
  20. use app\common\api\UploadApi;
  21. use app\enterprise\model\TalentTypeChange;
  22. use app\common\state\AllowanceTypeEnum;
  23. /**
  24. * Description of TalentAllowance
  25. *
  26. * @author sgq
  27. */
  28. class TalentAllowance extends EnterpriseController {
  29. public function index() {
  30. $tpl = "";
  31. switch ($this->user["type"]) {
  32. case CommonConst::ENTERPRISE_WJ:
  33. case CommonConst::ENTERPRISE_GJ:
  34. case CommonConst::ENTERPRISE_JC:
  35. $tpl = "indexIC";
  36. break;
  37. }
  38. return view($tpl, ['type' => $this->user["type"]]);
  39. }
  40. public function list() {
  41. $res = TalentAllowanceApi::getList($this->request);
  42. return json($res);
  43. }
  44. /**
  45. * 申请
  46. */
  47. public function apply(\think\Request $request) {
  48. $param = $request->param();
  49. $id = isset($param["id"]) ? $param["id"] : 0;
  50. $info = null;
  51. if ($id) {
  52. $info = TalentAllowanceApi::getInfoById($id);
  53. $this->translateToChinese($info);
  54. }
  55. if ($request->isPost()) {
  56. return $this->save($info, $request);
  57. }
  58. $batch = $info["year"] ?: BatchApi::getValidBatch(ProjectState::JBT, $this->user["type"])["batch"];
  59. return view("", ["year" => $batch, "type" => $this->user["type"], "row" => $info]);
  60. }
  61. public function batchApply() {
  62. $ids = $this->request["ids"];
  63. $ids = array_filter(explode(",", $ids));
  64. $allowanceType = $this->request["allowanceType"];
  65. $batch = BatchApi::getValidBatch(ProjectState::JBT, $this->user["type"])["batch"];
  66. if (!$batch) {
  67. return new Response(Response::ERROR, "当前并无有效的申报批次进行中");
  68. }
  69. for ($i = 0; $i < count($ids); $i++) {
  70. queue("app\job\TalentAllowance", ["type" => 1, "talentId" => $ids[$i], "enterprise" => $this->user, "year" => $batch, "allowanceType" => $allowanceType]);
  71. }
  72. return new Response(Response::SUCCESS, "已经成功添加到计划任务,请稍候查看申报列表进行确认");
  73. }
  74. private function save($talentAllowance, \think\Request $request) {
  75. $response = new \stdClass();
  76. $response->code = 500;
  77. $param = $request->param();
  78. if (!$param) {
  79. $response->msg = "请填写信息后在提交";
  80. return $response;
  81. }
  82. if (\StrUtil::isEmpOrNull($param["talentId"])) {
  83. $response->msg = "请选择申报对象";
  84. return $response;
  85. }
  86. if (!$param["id"]) {
  87. $where = [];
  88. $where[] = ["year", "=", $param["year"]];
  89. $where[] = ["idCard", "=", $param["idCard"]];
  90. $where[] = ["checkState", "not in", [MainState::NOTPASS, MainState::PASS]];
  91. $exists = TaModel::where($where)->find();
  92. if ($exists) {
  93. $response->msg = "当前申请对象在当前批次中存在申请中的记录,请等待申请结束后再操作";
  94. return $response;
  95. }
  96. $user = $this->user;
  97. $ti = \app\common\api\VerifyApi::getTalentInfoById($param["talentId"]);
  98. $data = [
  99. "talentId" => $param["talentId"],
  100. "enterpriseId" => $ti["enterprise_id"],
  101. "enterpriseName" => $user["name"],
  102. "year" => $param["year"],
  103. "source" => $ti["source"],
  104. "qzgccrcActiveTime" => $ti["certificateExpireTime"],
  105. "talentType" => $ti["enterpriseTag"],
  106. "address" => $ti["street"],
  107. "name" => $ti["name"],
  108. "sex" => $ti["sex"],
  109. "cardType" => $ti["card_type"],
  110. "idCard" => $ti["card_number"],
  111. "firstInJJTime" => $ti["fst_work_time"],
  112. "entryTime" => $ti["cur_entry_time"],
  113. "post" => $ti["position"],
  114. "phone" => $ti["phone"],
  115. "talentArrange" => $ti["talent_arrange"],
  116. "identifyCondition" => $ti["talent_condition"],
  117. "identifyGetTime" => $ti["identifyGetTime"],
  118. "identifyOutTime" => $ti["identifyExpireTime"],
  119. "identifyConditionName" => $ti["identifyConditionName"],
  120. "identifyMonth" => $ti["identifyMonth"],
  121. "bank" => $ti["bank"],
  122. "bankNetwork" => $ti["bank_branch_name"],
  123. "bankAccount" => $ti["bank_account"],
  124. "bankNumber" => $ti["bank_number"],
  125. "checkState" => 1,
  126. "type" => $user["type"],
  127. "provinceCode" => $ti["province"],
  128. "provinceName" => \app\common\api\LocationApi::getNameByCode($ti["province"]),
  129. "cityCode" => $ti["city"],
  130. "cityName" => \app\common\api\LocationApi::getNameByCode($ti["city"]),
  131. "countyCode" => $ti["county"],
  132. "countyName" => \app\common\api\LocationApi::getNameByCode($ti["county"]),
  133. "isSupple" => 2,
  134. "createTime" => date("Y-m-d H:i:s"),
  135. "createUser" => $user["uid"],
  136. "id" => getStringId(),
  137. "wage" => $param["wage"],
  138. "allowanceType" => $param["allowanceType"]
  139. ];
  140. /* * 1.获取上一年度的人才层次 */
  141. $arrangeList = $this->getLastYearTalentType($data, $ti);
  142. if (!$arrangeList) {
  143. $response->msg = "上一年度暂无有效的人才层次";
  144. return $response;
  145. }
  146. /* * 2.获取上一年度所在单位* */
  147. $contractDetailList = $this->getConcatList($ti, $data, $param["year"]); //保存上一年度的工作单位
  148. if (!$contractDetailList) {
  149. $response->msg = "申报失败,原因为:申报年度不存在有效的工作单位";
  150. return $response;
  151. }
  152. TaModel::insert($data);
  153. \app\common\model\TalentAllowancecontractDetail::insertAll($contractDetailList);
  154. /**
  155. * 4.添加津补贴核查项目
  156. */
  157. //核查项目详情表
  158. $this->createAllowanceProject($data, $contractDetailList);
  159. \app\common\model\TalentAllowanceArrange::insertAll($arrangeList);
  160. //添加日志
  161. TalentChecklog::create([
  162. 'id' => getStringId(),
  163. 'mainId' => $data['id'],
  164. 'type' => intval(ProjectState::JBT),
  165. 'typeFileId' => null,
  166. 'active' => 1,
  167. 'state' => 1,
  168. 'step' => 0,
  169. 'stateChange' => "保存未提交",
  170. 'description' => "添加津补贴申报",
  171. 'createTime' => date("Y-m-d H:i:s", time()),
  172. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  173. ]);
  174. $response->msg = "保存成功";
  175. $response->code = 200;
  176. $response->obj = $data;
  177. return $response;
  178. } else {
  179. TaModel::update($param);
  180. $response->msg = "修改成功";
  181. $response->code = 200;
  182. return $response;
  183. }
  184. }
  185. public function getInfoByIdAndYear($id, $year) {
  186. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  187. $data = [
  188. "talentId" => $id,
  189. "year" => $year,
  190. "idCard" => $ti["card_number"],
  191. "id" => getStringId()
  192. ];
  193. /* * 1.获取上一年度的人才层次 */
  194. $arrangeList = $this->getLastYearTalentType($data, $ti);
  195. if (!$arrangeList) {
  196. return new Response(Response::ERROR, "该人员上一年度暂无有效的人才层次");
  197. }
  198. /* * 2.获取上一年度所在单位* */
  199. $contractDetailList = $this->getConcatList($ti, $data, $year); //保存上一年度的工作单位
  200. if (!$contractDetailList) {
  201. return new Response(Response::ERROR, "该人员申报年度不存在有效的工作单位");
  202. }
  203. return new Response(Response::SUCCESS, "", $ti);
  204. }
  205. /**
  206. * 删除优秀人才津补贴
  207. */
  208. public function delete() {
  209. $id = $this->request["id"];
  210. $response = new \stdClass();
  211. $response->code = 500;
  212. $info = TalentAllowanceApi::getInfoById($id);
  213. if ($info["checkState"] != 1) {
  214. $response->msg = "删除失败!此数据已提交审核,无法删除!";
  215. return $response;
  216. }
  217. Db::startTrans();
  218. try {
  219. //删除核查项目表
  220. Db::table("un_talent_allowance_project")->where("mainId", $id)->delete();
  221. //删除合同情况表
  222. Db::table("un_talent_allowancecontract_detail")->where("mainId", $id)->delete();
  223. //删除人才层次变更表
  224. Db::table("un_talent_allowance_arrange")->where("mainId", $id)->delete();
  225. //删除日志
  226. $where[] = ["mainId", "=", $id];
  227. $where[] = ["type", "=", ProjectState::JBT];
  228. Db::table("new_talent_checklog")->where($where)->delete();
  229. //删除主表
  230. Db::table("un_talent_allowance_info")->delete($id);
  231. Db::commit();
  232. $response->code = 200;
  233. $response->msg = "删除成功";
  234. return $response;
  235. } catch (think\db\exception\DbException $e) {
  236. Db::rollback();
  237. $response->msg = $e->getMessage();
  238. return $response;
  239. }
  240. }
  241. public function detail(\think\Request $request) {
  242. $param = $request->param();
  243. $id = $param["id"];
  244. $info = TalentAllowanceApi::getInfoById($id);
  245. $this->translateToChinese($info);
  246. return view("", ["row" => $info]);
  247. }
  248. private function translateToChinese(&$obj) {
  249. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  250. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  251. }
  252. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  253. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  254. }
  255. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  256. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  257. }
  258. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  259. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  260. }
  261. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  262. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  263. }
  264. }
  265. /* * 获取上一年度的人才层次变更信息 */
  266. private function getLastYearTalentType($info, $talentInfo) {
  267. $arrangeList = [];
  268. /* * * 添加人才层次记录 */
  269. $where = [];
  270. $where[] = ["idCard", "=", $info["idCard"]];
  271. $where[] = ["checkState", "=", MainState::PASS];
  272. $where[] = ["isPublic", ">=", 5];
  273. $where[] = ["oldIdentifyMonth", "<=", $info["year"] . "-12-31"];
  274. $typeList = TalentTypeChange::where($where)->field("oldTalentArrange,oldIdentifyCondition,oldIdentifyGetTime,oldIdentifyOutTime,oldIdentifyMonth,oldCertificateStartTime,oldCertificateOutTime,newIdentifyMonth")->order("createTime desc")->select()->toArray();
  275. $typeList[] = [
  276. "oldTalentArrange" => $talentInfo["talent_arrange"],
  277. "oldIdentifyCondition" => $talentInfo["talent_condition"],
  278. "oldIdentifyGetTime" => $talentInfo["identifyGetTime"],
  279. "oldIdentifyOutTime" => $talentInfo["identifyExpireTime"],
  280. "oldIdentifyMonth" => $talentInfo["identifyMonth"],
  281. "oldCertificateStartTime" => $talentInfo["certificateGetTime"],
  282. "oldCertificateOutTime" => $talentInfo["certificateExpireTime"],
  283. "newIdentifyMonth" => $info["year"] . "-12-31"
  284. ];
  285. $totalMonth = \DateUtil::getMonthBetweenDates($info["year"] . "-01-01", $info["year"] . "-12-31");
  286. /* * 获取上一年度有效的人才层次 */
  287. usort($typeList, function($a, $b) {
  288. return (int) $b["oldTalentArrange"] - (int) $a["oldTalentArrange"];
  289. });
  290. $commonMonth = [];
  291. foreach ($typeList as $talentTypeChange) {
  292. $startTime = $talentTypeChange["oldIdentifyMonth"];
  293. $endTime = $talentTypeChange["newIdentifyMonth"];
  294. $monthList = \DateUtil::getMonthBetweenDatesNotBegin($startTime, $endTime);
  295. if ($monthList) {
  296. $monthList = array_intersect($monthList, $totalMonth);
  297. }
  298. if ($monthList) {
  299. $months = implode(",", $monthList);
  300. $monthList = array_filter($monthList, function($value) use ($commonMonth) {
  301. return !in_array($value, $commonMonth);
  302. });
  303. $commonMonth = array_filter(array_merge($commonMonth, $monthList));
  304. if (count($monthList) > 0) {
  305. $arrange = [
  306. "id" => getStringId(),
  307. "mainId" => $info["id"],
  308. "talentArrange" => $talentTypeChange["oldTalentArrange"],
  309. "identifyCondition" => $talentTypeChange["oldIdentifyCondition"],
  310. "startTime" => $startTime,
  311. "endTime" => $endTime,
  312. "prepareMonths" => null,
  313. "description" => "申报年度有效月份:" . $months,
  314. "identifyConditionName" => $talentTypeChange["oldIdentifyConditionName"],
  315. "identifyConditionGetTime" => $talentTypeChange["oldIdentifyGetTime"],
  316. ];
  317. $sb = '';
  318. foreach ($monthList as $month) {
  319. $sb .= substr($month, 5, 2) . ",";
  320. }
  321. $arrange["prepareMonths"] = rtrim($sb, ",");
  322. $arrangeList[] = $arrange;
  323. }
  324. }
  325. }
  326. return $arrangeList;
  327. }
  328. /**
  329. * @param
  330. * @returns void
  331. * @author Liu
  332. * @date 2020/4/26
  333. * @description 获取上一年度所在单位
  334. * */
  335. private function getConcatList($talentInfo, $info, $year) {
  336. $totalMonth = \DateUtil::getMonthBetweenDates($year . "-01-01", $year . "-12-31");
  337. /** 添加申报人才上一年度工作单位记录 */
  338. $where = [];
  339. $where[] = ["idCard", "=", $talentInfo["card_number"]];
  340. $where[] = ["checkState", "=", 3];
  341. $quitList = \app\common\model\TalentQuit::where($where)->field("enterpriseId,enterpriseName,talentType,identifyGetTime,starttime,endtime,entryTime,quitTime,post")->select()->toArray();
  342. /* * * 将最新的人才数据转为工作变更记录(为了统一处理) */
  343. if ($talentInfo["active"] == 1) {
  344. $labor_contract_rangetime = explode(" - ", $talentInfo["labor_contract_rangetime"]);
  345. $starttime = $labor_contract_rangetime[0];
  346. $endtime = $labor_contract_rangetime[1];
  347. $quitList[] = [
  348. "enterpriseId" => $talentInfo["enterprise_id"],
  349. "enterpriseName" => $talentInfo["enterpriseName"],
  350. "talentType" => $talentInfo["enterpriseTag"],
  351. "identifyGetTime" => $talentInfo["identifyGetTime"],
  352. "starttime" => $starttime,
  353. "endtime" => $endtime,
  354. "entryTime" => $talentInfo["cur_entry_time"],
  355. "quitTime" => null,
  356. "post" => $talentInfo["position"]
  357. ];
  358. }
  359. $list = [];
  360. foreach ($quitList as $quit) {
  361. $monthList = \DateUtil::getMonthBetweenDates($quit["entryTime"], \StrUtil::isEmpOrNull($quit["quitTime"]) ? $year . "-12-31" : $quit["quitTime"]);
  362. $monthList = array_intersect($monthList, $totalMonth);
  363. if ($monthList) {
  364. $sb = '';
  365. foreach ($monthList as $month) {
  366. $sb .= substr($month, 5, 2) . ",";
  367. }
  368. $list[] = [
  369. "id" => getStringId(),
  370. "mainId" => $info["id"],
  371. "enterpriseId" => $quit["enterpriseId"],
  372. "talentType" => $quit["talentType"],
  373. "startTime" => $quit["starttime"],
  374. "endTime" => $quit["endtime"],
  375. "entryTime" => $quit["entryTime"],
  376. "quitTime" => \StrUtil::isEmpOrNull($quit["quitTime"]) ? $year . "-12-31" : $quit["quitTime"],
  377. "letterTime" => $quit["letterTime"],
  378. "gygb" => $quit["gygb"],
  379. "identifyGetTime" => $quit["identifyGetTime"],
  380. "isQuit" => \StrUtil::isEmpOrNull($quit["quitTime"]) ? 2 : 1,
  381. "post" => $quit["post"],
  382. "months" => rtrim($sb, ",")
  383. ];
  384. }
  385. }
  386. return $list;
  387. }
  388. private function createAllowanceProject($info, $contractList) {
  389. $count = 0;
  390. foreach ($contractList as $detail) {
  391. $count++;
  392. $projects = [
  393. //AllowanceProjectEnum::PROJECT_CONTRACT,
  394. AllowanceProjectEnum::PROJECT_TAX,
  395. AllowanceProjectEnum::PROJECT_WAGES,
  396. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  397. AllowanceProjectEnum::PROJECT_SB_PENSION,
  398. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  399. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  400. //AllowanceProjectEnum::PROJECT_WORKDAY,
  401. ];
  402. $list = [];
  403. foreach ($projects as $project) {
  404. $months = "";
  405. if ($count == count($contractList) && $info["allowanceType"] == AllowanceTypeEnum::JBT_TALENT)
  406. $months = "01,02,03,04,05,06,07,08,09,10,11,12";
  407. $list[] = [
  408. "mainId" => $info["id"],
  409. "baseId" => $detail["id"],
  410. "enterpriseId" => $detail["enterpriseId"],
  411. "project" => $project,
  412. "months" => $months,
  413. "isLock" => 1,
  414. "createTime" => date("Y-m-d H:i:s")
  415. ];
  416. }
  417. \app\common\model\TalentAllowanceProject::insertAll($list);
  418. }
  419. }
  420. /**
  421. * 查询工作单位
  422. */
  423. public function findAllowanceContractDetail() {
  424. $mainId = $this->request["mainId"];
  425. $offset = $this->request["offset"] ?: 0;
  426. $limit = $this->request["limit"] ?: 1000;
  427. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  428. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  429. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  430. foreach ($list as &$row) {
  431. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  432. }unset($row);
  433. return json(["rows" => $list, "total" => $count]);
  434. }
  435. /**
  436. * 查询核查项目情况
  437. */
  438. public function findAllowanceProject() {
  439. $mainId = $this->request["mainId"];
  440. $baseId = $this->request["baseId"];
  441. $offset = $this->request["offset"] ?: 0;
  442. $limit = $this->request["limit"] ?: 1000;
  443. $where = [];
  444. $where[] = ["mainId", "=", $mainId];
  445. $where[] = ["baseId", "=", $baseId];
  446. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  447. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  448. $info = TalentAllowanceApi::getInfoById($mainId);
  449. foreach ($list as &$project) {
  450. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  451. if ($info["checkState"] == 1) {
  452. $project["isEdit"] = in_array($project["project"], [
  453. //AllowanceProjectEnum::PROJECT_CONTRACT,
  454. AllowanceProjectEnum::PROJECT_TAX,
  455. AllowanceProjectEnum::PROJECT_WAGES,
  456. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  457. AllowanceProjectEnum::PROJECT_SB_PENSION,
  458. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  459. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  460. //AllowanceProjectEnum::PROJECT_WORKDAY
  461. ]) ? 1 : 2;
  462. } else if ($info["checkState"] == 10) {
  463. $projects = explode(",", $info["projects"]);
  464. if (in_array($project["id"], $projects)) {
  465. $project["isEdit"] = 1;
  466. } else {
  467. $project["isEdit"] = 2;
  468. }
  469. } else {
  470. $project["isEdit"] = 2;
  471. }
  472. }unset($project);
  473. return json(["rows" => $list, "total" => $count]);
  474. }
  475. /**
  476. * 查询人才层次变更记录
  477. */
  478. public function findAllowanceArrange() {
  479. $mainId = $this->request["mainId"];
  480. $offset = $this->request["offset"] ?: 0;
  481. $limit = $this->request["limit"] ?: 1000;
  482. $where = [];
  483. $where[] = ["mainId", "=", $mainId];
  484. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  485. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  486. foreach ($list as &$arrange) {
  487. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  488. $arrange["identifyConditionText"] = $condition["name"];
  489. $arrange["talentArrangeName"] = app\common\state\CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  490. }unset($arrange);
  491. return json(["rows" => $list, "total" => $count]);
  492. }
  493. /**
  494. * 修改合同起止时间
  495. */
  496. public function editContract() {
  497. $response = new \stdClass();
  498. $response->code = 500;
  499. $param = $this->request->param();
  500. if (!$param["id"]) {
  501. $response->msg = "系统错误,请联系管理员";
  502. return $response;
  503. }
  504. $detail = \app\common\model\TalentAllowancecontractDetail::find($param["id"]);
  505. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  506. if (\StrUtil::isEmpOrNull($param["startTime"])) {
  507. $response->msg = "请选择合同起始时间";
  508. return $response;
  509. }
  510. if (\StrUtil::isEmpOrNull($param["endTime"])) {
  511. $response->msg = "请选择合同截止时间";
  512. return $response;
  513. }
  514. \app\common\model\TalentAllowancecontractDetail::update($param);
  515. //添加日志
  516. TalentChecklog::create([
  517. 'id' => getStringId(),
  518. 'mainId' => $info['id'],
  519. 'type' => intval(ProjectState::JBT),
  520. 'typeFileId' => $param["id"],
  521. 'active' => 1,
  522. 'state' => null,
  523. 'step' => 0,
  524. 'stateChange' => null,
  525. 'description' => "修改工作单位合同时间为:" . $param["startTime"] . "至" . $param["endTime"],
  526. 'createTime' => date("Y-m-d H:i:s", time()),
  527. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  528. ]);
  529. $response->msg = "修改成功";
  530. $response->code = 200;
  531. return $response;
  532. }
  533. /**
  534. * 修改项目
  535. */
  536. public function editProject() {
  537. $response = new \stdClass();
  538. $response->code = 500;
  539. $param = $this->request->param();
  540. if (!$param["id"]) {
  541. $response->msg = "系统错误,请联系管理员";
  542. return $response;
  543. }
  544. $detail = \app\common\model\TalentAllowanceProject::find($param["id"]);
  545. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  546. \app\common\model\TalentAllowanceProject::update($param);
  547. //添加日志
  548. TalentChecklog::create([
  549. 'id' => getStringId(),
  550. 'mainId' => $info['id'],
  551. 'type' => intval(ProjectState::JBT),
  552. 'typeFileId' => $param["id"],
  553. 'active' => 1,
  554. 'state' => null,
  555. 'step' => 0,
  556. 'stateChange' => null,
  557. 'description' => "修改项目名:" . AllowanceProjectEnum::getProjectName($detail["project"]) . "的值为:" . $param["months"] . ";备注为:" . $param["description"],
  558. 'createTime' => date("Y-m-d H:i:s", time()),
  559. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  560. ]);
  561. $response->msg = "修改成功";
  562. $response->code = 200;
  563. return $response;
  564. }
  565. /**
  566. * 判断是否可以修改
  567. */
  568. public function validateIsEdit() {
  569. $id = $this->request["id"];
  570. $type = $this->request["type"];
  571. $info = null;
  572. if ($type == 1) { //编辑合同
  573. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  574. } else if ($type == 2) { //编辑项目
  575. $detail = \app\common\model\TalentAllowanceProject::find($id);
  576. }
  577. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  578. if ($info["checkState"] != 1 && $info["checkState"] != 10) {
  579. if ($info["checkState"] == -1) {
  580. return new Response(Response::ERROR, "您的申报审核不通过,无法操作");
  581. } else if ($info["checkState"] == 30) {
  582. return new Response(Response::ERROR, "您的申报已审核通过,无法操作");
  583. } else {
  584. return new Response(Response::ERROR, "您的申报正在审核中,请耐心等待");
  585. }
  586. }
  587. return new Response(Response::SUCCESS, "");
  588. }
  589. /**
  590. * 提交审核
  591. */
  592. public function submitToCheck() {
  593. $data = $this->request->param();
  594. $response = new \stdClass();
  595. $response->code = 500;
  596. if (!$data || !$data["id"]) {
  597. $response->msg = "提交审核失败,请先填写基础信息";
  598. return $response;
  599. }
  600. $old = TalentAllowanceApi::getInfoById($data["id"]);
  601. $batch = BatchApi::checkBatchValid(["type" => ProjectState::JBT, "year" => $old["year"], "first_submit_time" => $old["firstSubmitTime"]], $this->user["type"]);
  602. if ($batch["code"] != 200) {
  603. $response->msg = $batch["msg"];
  604. return $response;
  605. }
  606. if ($old["checkState"] != 1 && $old["checkState"] != 10) {
  607. $response->msg = "不能重复提交审核";
  608. return $response;
  609. }
  610. if (!$old["allowanceType"]) {
  611. $response->msg = "没有明确津贴类型";
  612. return $response;
  613. }
  614. //因为工作津贴和交通补贴两者的考勤分别记录的是月份和天数,如果没有手动修改值会导致数据不对口,如修改类型却未修改考勤记录,则手动改为空。
  615. $where = [];
  616. $where[] = ["project", "=", AllowanceProjectEnum::PROJECT_ATTENDANCE];
  617. $where[] = ["mainId", "=", $data["id"]];
  618. $attendanceList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  619. if ($old["allowanceType"] == AllowanceTypeEnum::JBT_JT) {
  620. //因为天数保存格式为 月份=天数 如 01=31,02=20,03=15,月份保存格式为01,02,03,所以可以从有没有=号判断是否有进行考勤的修改保存操作
  621. foreach ($attendanceList as $a) {
  622. //$a["months"]有值但是没有包含=号则一般可认为是类型修改为交通补贴而未修改考勤,此时的months字段数据是错误的,修改为空。
  623. if ($a["months"] && strpos($a["months"], "=") === false) {
  624. $_updProject["id"] = $a["id"];
  625. $_updProject["months"] = "";
  626. \app\common\model\TalentAllowanceProject::update($_updProject);
  627. }
  628. }
  629. } else {
  630. foreach ($attendanceList as $a) {
  631. //$a["months"]有值但是包含了=号则一般可认为是类型修改为工作津贴而未修改考勤,此时的months字段数据是错误的,修改为空。
  632. if ($a["months"] && strpos($a["months"], "=") !== false) {
  633. $_updProject["id"] = $a["id"];
  634. $_updProject["months"] = "";
  635. \app\common\model\TalentAllowanceProject::update($_updProject);
  636. }
  637. }
  638. }
  639. $where = [];
  640. $where[] = ["type", "=", $old["type"]];
  641. $where[] = ["project", "=", ProjectState::JBT];
  642. $where[] = ["isConditionFile", "in", [0, $old["allowanceType"]]];
  643. $where[] = ["active", "=", 1];
  644. $where[] = ["delete", "=", 0];
  645. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  646. $sb = [];
  647. $sb[] = "以下为必传附件:";
  648. foreach ($filetypes as $filetype) {
  649. if ($filetype["must"] == 1) {
  650. $where = [];
  651. $where[] = ["mainId", "=", $data["id"]];
  652. $where[] = ["typeId", "=", $filetype["id"]];
  653. $count = Db::table("new_talent_file")->where($where)->count();
  654. if ($count == 0) {
  655. $sb[] = $filetype["name"] . ";";
  656. }
  657. }
  658. }
  659. if (count($sb) > 1) {
  660. $response->msg = implode("<br>", $sb);
  661. return $response;
  662. }
  663. /**
  664. * 初步判断合同是否满两年
  665. */
  666. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $old["id"])->select()->toArray();
  667. foreach ($detailList as $detail) {
  668. if (\StrUtil::isEmpOrNull($detail["startTime"]) || \StrUtil::isEmpOrNull($detail["endTime"])) {
  669. $response->msg = "合同起止时间不能为空";
  670. return $response;
  671. }
  672. }
  673. foreach ($detailList as $detail) {
  674. $contractEndTime = strtotime($detail["endTime"]);
  675. $contractStartTimeAdd2Years = strtotime("+2 years -1 day {$detail['startTime']}");
  676. $where = [];
  677. $where[] = ["mainId", "=", $data["id"]];
  678. $where[] = ["baseId", "=", $detail["id"]];
  679. $where[] = ["project", "=", AllowanceProjectEnum::PROJECT_CONTRACT];
  680. $updProject["months"] = $contractEndTime >= $contractStartTimeAdd2Years ? "是" : "否";
  681. \app\common\model\TalentAllowanceProject::where($where)->update($updProject);
  682. }
  683. $data["checkMsg"] = "";
  684. $data["checkState"] = 5;
  685. $data["files"] = "";
  686. $data["projects"] = "";
  687. $data["concats"] = "";
  688. $data["fields"] = "";
  689. $data["toDep"] = "";
  690. $data["process"] = null;
  691. if (!$old["firstSubmitTime"]) {
  692. $data["firstSubmitTime"] = date("Y-m-d H:i:s");
  693. }
  694. $data["newSubmitTime"] = date("Y-m-d H:i:s");
  695. TaModel::update($data);
  696. //添加日志
  697. TalentChecklog::create([
  698. 'id' => getStringId(),
  699. 'mainId' => $data['id'],
  700. 'type' => intval(ProjectState::JBT),
  701. 'typeFileId' => null,
  702. 'active' => 1,
  703. 'state' => 1,
  704. 'step' => 0,
  705. 'stateChange' => sprintf("%s->%s", MainState::getStateDesc(1), MainState::getStateDesc(7)),
  706. 'description' => "确认提交审核",
  707. 'createTime' => date("Y-m-d H:i:s", time()),
  708. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  709. ]);
  710. $response->msg = "提交审核成功";
  711. $response->code = 200;
  712. $response->obj = 5;
  713. return $response;
  714. }
  715. public function updateSuppleState() {
  716. $id = $this->request["id"];
  717. $response = new \stdClass();
  718. $response->code = 500;
  719. if (\StrUtil::isEmpOrNull($id)) {
  720. $response->msg = "系统错误,请联系管理员";
  721. return $response;
  722. }
  723. $data["id"] = $id;
  724. $data["isSupple"] = 1;
  725. TaModel::update($data);
  726. $response->msg = "状态更新成功";
  727. $response->code = 200;
  728. return $response;
  729. }
  730. public function uploadCommonFile() {
  731. $batchId = $this->request["batch"];
  732. if (!$batchId) {
  733. return json(new Response(Response::ERROR, "没有提交批次信息,无法按批次归档,上传被中止"));
  734. }
  735. $batchInfo = BatchApi::getOne($batchId);
  736. if (!$batchInfo) {
  737. return json(new Response(Response::ERROR, "批次信息不存在,无法按批次归档,上传被中止"));
  738. }
  739. if (!$this->request->file()) {
  740. return json(new Response(Response::ERROR, "没有上传任何材料"));
  741. }
  742. $file = $this->request->file("file");
  743. $upload = new UploadApi();
  744. $result = $upload->uploadOne($file, "system", "talent/TalentAllowanceCommonFile");
  745. if ($result->code != 200) {
  746. return json(new Response(Response::ERROR, $result->msg));
  747. }
  748. $data["id"] = getStringId();
  749. $data["enterpriseId"] = $this->user["uid"];
  750. $data["batchId"] = $batchId;
  751. $data["batch"] = $batchInfo["batch"];
  752. $data["url"] = $result->filepath;
  753. $data["originalName"] = $file->getOriginalName();
  754. $data["createTime"] = date("Y-m-d H:i:s");
  755. $data["createUser"] = $this->user["uid"];
  756. $res = Db::table("un_talent_allowance_common_file")->insert($data);
  757. return json(new Response(Response::SUCCESS, "上传成功"));
  758. }
  759. public function listCommonFile() {
  760. $param = $this->request->param();
  761. $batchId = $param["batch"];
  762. $where = [["batchId", "=", $batchId], ["enterpriseId", "=", $this->user["uid"]]];
  763. $list = Db::table("un_talent_allowance_common_file")->where($where)->select()->toArray();
  764. foreach ($list as $key => $item) {
  765. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  766. $list[$key]["url"] = getStoragePath($item["url"]);
  767. }
  768. return json(["rows" => $list]);
  769. }
  770. public function deleteCommonFile() {
  771. $id = $this->request["id"];
  772. $where = [];
  773. $where[] = ["id", "=", $id];
  774. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  775. $file = Db::table("un_talent_allowance_common_file")->where($where)->find();
  776. if (!$file) {
  777. return json(new Response(Response::ERROR, "不存在的文件,删除失败"));
  778. }
  779. if (Db::table("un_talent_allowance_common_file")->where($where)->delete()) {
  780. if (!empty($file["url"])) {
  781. $filepath = "storage/" . $file["url"];
  782. if (file_exists($filepath)) {
  783. unlink($filepath);
  784. }
  785. }
  786. return json(new Response(Response::SUCCESS, "删除成功"));
  787. }
  788. }
  789. public function findTalentAllowance() {
  790. $res = [];
  791. $batch = BatchApi::getValidBatch(ProjectState::JBT, $this->user["type"]);
  792. $year = $batch["batch"];
  793. if ($year) {
  794. $ids = null;
  795. //根据申报年度查询当前企业已申报的人才
  796. $where = [];
  797. $where[] = ["year", "=", $year];
  798. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  799. $talentAllowances = TaModel::where($where)->select()->toArray();
  800. $ids = array_unique(array_column($talentAllowances, "talentId"));
  801. $whr = [];
  802. $whr[] = ["ti.checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  803. $whr[] = ["ti.enterprise_id", "=", $this->user["uid"]];
  804. $whr[] = ["e.type", "=", $this->user["type"]];
  805. $whr[] = ["ti.id", "not in", $ids];
  806. $list = \app\enterprise\model\Talent::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.id,ti.name,ti.card_number as idCard,ti.cur_entry_time")->where($whr)->select()->toArray();
  807. foreach ($list as $info) {
  808. if (strtotime($year . "-12-31") >= strtotime($info["identifyMonth"])) {
  809. $res[] = $info;
  810. } else {
  811. $whereTypeChange = [];
  812. $whereTypeChange[] = ["idCard", "=", $info["idCard"]];
  813. $whereTypeChange[] = ["checkState", "=", MainState::PASS];
  814. $whereTypeChange[] = ["isPublic", "=", 6];
  815. $typeChanges = TalentTypeChange::where($whereTypeChange)->select()->toArray();
  816. foreach ($typeChanges as $typeChange) {
  817. if (strtotime($year . "-12-31") >= strtotime($typeChange["oldIdentifyMonth"])) {
  818. $res[] = $info;
  819. break;
  820. }
  821. }
  822. }
  823. }
  824. }
  825. return new Response(Response::SUCCESS, "", ["rows" => $res, "total" => count($res)]);
  826. }
  827. public function export() {
  828. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  829. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  830. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  831. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  832. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  833. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  834. $where = [];
  835. $where[] = ["ta.enterpriseId", "=", $this->user["uid"]];
  836. if (\StrUtil::isNotEmpAndNull($obj["year"])) {
  837. $where[] = ["ta.year", "like", "%" . $obj["year"] . "%"];
  838. }
  839. if (\StrUtil::isNotEmpAndNull($obj["name"])) {
  840. $where[] = ["ta.name", "like", "%" . $obj["name"] . "%"];
  841. }
  842. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  843. $where[] = ["ta.talentArrange", "=", $obj["talentArrange"]];
  844. }
  845. if (\StrUtil::isNotEmpAndNull($obj["allowanceType"])) {
  846. $where[] = ["ta.allowanceType", "=", $obj["allowanceType"]];
  847. }
  848. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  849. $where[] = ["ta.address", "=", $obj["address"]];
  850. }
  851. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  852. $where[] = ["ta.identifyCondition", "=", $obj["identifyCondition"]];
  853. }
  854. $projects = [
  855. AllowanceProjectEnum::PROJECT_TAX,
  856. AllowanceProjectEnum::PROJECT_WAGES,
  857. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  858. AllowanceProjectEnum::PROJECT_SB_PENSION,
  859. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  860. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  861. ];
  862. $months = [];
  863. for ($m = 1; $m <= 12; $m++) {
  864. $months[] = $m . "月";
  865. }
  866. $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]]];
  867. $infoCols = count($columns);
  868. for ($i = 0; $i < count($projects); $i++) {
  869. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  870. }
  871. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  872. ->field("ta.id,ta.year,ta.enterpriseId as curEnterpriseId,ta.address,ta.name,ta.sex,ta.idCard,ta.talentArrange,ta.identifyCondition,ta.identifyGetTime,ta.identifyConditionName,ta.identifyMonth,ta.allowanceType,ta.months,ta.money,ta.moneyDesc,ta.checkState,ta.publicState,pro.project,pro.months as pre_months,con.enterpriseId,con.startTime,con.endTime,con.entryTime,con.quitTime,con.isQuit")
  873. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  874. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  875. ->where($where)
  876. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  877. ->select()->toArray();
  878. $tmpList = [];
  879. $levelMap = DictApi::selectByParentCode("talent_arrange");
  880. $streetMap = DictApi::selectByParentCode("street");
  881. $where = [];
  882. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  883. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  884. $where = [];
  885. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  886. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  887. foreach ($list as $item) {
  888. //组装数据
  889. if (!$tmpList[$item["id"]]) {
  890. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  891. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  892. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  893. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
  894. }
  895. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  896. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  897. "startTime" => $item["startTime"],
  898. "endTime" => $item["endTime"],
  899. "entryTime" => $item["entryTime"],
  900. "isQuit" => $item["isQuit"]
  901. ];
  902. }
  903. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  904. }
  905. $rows = [];
  906. $colorset = [];
  907. foreach ($tmpList as $id => $item) {
  908. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  909. $row = $item["info"];
  910. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  911. for ($i = 0; $i < count($projects); $i++) {
  912. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  913. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  914. for ($m = 1; $m <= 12; $m++) {
  915. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  916. if (in_array($_month, $months)) {
  917. $row[] = "✔";
  918. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  919. } else {
  920. $row[] = "";
  921. }
  922. }
  923. } else {
  924. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  925. $_months = [];
  926. foreach ($months as $month) {
  927. $kv = explode("=", $month);
  928. $_months[$kv[0]] = $kv[1];
  929. }
  930. for ($m = 1; $m <= 12; $m++) {
  931. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  932. $days = $_months[$_month];
  933. if ($days && $days > 0) {
  934. $row[] = $days . "天";
  935. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  936. } else {
  937. $row[] = "";
  938. }
  939. }
  940. }
  941. }
  942. $rows[] = $row;
  943. }
  944. }
  945. $cols = $infoCols + count($projects) * 12 - 1;
  946. $settings = [
  947. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  948. "height" => [18],
  949. "freeze" => "D3",
  950. "color" => $colorset
  951. ];
  952. for ($i = 0; $i < count($projects) * 12; $i++) {
  953. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  954. }
  955. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  956. export($columns, $rows, "津补贴申报名单", $settings);
  957. }
  958. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  959. switch ($checkState) {
  960. case 1:
  961. return "待提交";
  962. case 5:
  963. case 13:
  964. case 15:
  965. case 20:
  966. case 25:
  967. case 35:
  968. return "审核中";
  969. case 10:
  970. return "已驳回";
  971. case - 1:
  972. if ($publicState >= 3) {
  973. return "审核不通过";
  974. } else {
  975. return "审核中";
  976. }
  977. break;
  978. case 30:
  979. if ($publicState == 1) {
  980. return "待核查征信";
  981. } else if ($publicState == 2) {
  982. return "待公示";
  983. } else if ($publicState == 3) {
  984. return "公示中";
  985. } else if ($publicState == 4) {
  986. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  987. } else if ($publicState == 5) {
  988. return "已兑现";
  989. }
  990. default:
  991. return "未知状态";
  992. }
  993. }
  994. }