TalentAllowance.php 47 KB

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