TalentAllowance.php 47 KB

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