TalentAllowanceApi.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <?php
  2. namespace app\common\api;
  3. use app\common\model\TalentAllowance as TaModel;
  4. use app\common\state\MainState;
  5. use think\facade\Db;
  6. use app\common\state\CommonConst;
  7. use app\common\state\AllowanceProjectEnum;
  8. use app\common\model\TalentAllowanceArrange;
  9. use app\common\model\AmountStandard as AsModel;
  10. use app\common\state\AllowanceStateEnum;
  11. /**
  12. * Description of TalentAllowanceApi
  13. *
  14. * @author sgq
  15. */
  16. class TalentAllowanceApi {
  17. public static function getList($params) {
  18. $user = session("user");
  19. $order = trim($params["order"]) ?: "desc";
  20. $offset = trim($params["offset"]) ?: 0;
  21. $limit = trim($params["limit"]) ?: 10;
  22. $where = [];
  23. $where[] = ["ta.delete", "=", 0];
  24. $where[] = ["ta.enterpriseId", "=", $user["uid"]];
  25. if ($_where = self::setTalentAllowanceInfo($params)) {
  26. $where = array_merge($where, $_where);
  27. }
  28. $whereRaw = "ta.id>0";
  29. if (\StrUtil::isNotEmpAndNull($params["checkState"])) {
  30. switch ($params["checkState"]) {
  31. case 1:
  32. $where[] = ["ta.checkState", "=", AllowanceStateEnum::SAVE];
  33. break;
  34. case 5:
  35. $where[] = ["ta.publicState", "<>", 5];
  36. $whereRaw = "ta.checkState=5 or ta.checkState >= 13";
  37. break;
  38. case 10:
  39. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT];
  40. break;
  41. case 30:
  42. $where[] = ["ta.checkState", "=", AllowanceStateEnum::REVIEW_PASS];
  43. $where[] = ["ta.publicState", "=", 5];
  44. break;
  45. case -1:
  46. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NOTPASS];
  47. break;
  48. }
  49. }
  50. $count = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->count();
  51. $list = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->field("ta.*")->limit($offset, $limit)->order("year {$order},ta.createTime {$order}")->select()->toArray();
  52. $levelList = DictApi::selectByParentCode("talent_arrange");
  53. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  54. $streetList = DictApi::selectByParentCode("street");
  55. $identifyConditionIds = array_filter(array_unique(array_column($list, "identifyCondition")));
  56. $whr[] = ["id", "in", $identifyConditionIds];
  57. $whr[] = ["type", "=", $user["type"]];
  58. $identifyConditionKvList = TalentConditionApi::getKvList($whr);
  59. foreach ($list as $key => $item) {
  60. $list[$key]["talentArrangeName"] = $levelList[$item["talentArrange"]];
  61. $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
  62. $list[$key]["addressName"] = $streetList[$item["address"]];
  63. $list[$key]["identifyConditionText"] = $identifyConditionKvList[$item["identifyCondition"]];
  64. }
  65. return ["total" => $count, "rows" => $list];
  66. }
  67. public static function getHospitalExamineList($params) {
  68. $user = session("user");
  69. $order = trim($params["order"]) ?: "desc";
  70. $offset = trim($params["offset"]) ?: 0;
  71. $limit = trim($params["limit"]) ?: 10;
  72. $where = [];
  73. $where[] = ["ta.delete", "=", 0];
  74. $where[] = ["ta.type", "=", 5];
  75. $where[] = ["e.medicalCommunityId", "=", $user["medicalCommunityId"]];
  76. $where[] = ["e.isGeneral", "=", 2];
  77. if ($_where = self::setTalentAllowanceInfo($params)) {
  78. $where = array_merge($where, $_where);
  79. }
  80. $whereRaw = "ta.id>0";
  81. if (\StrUtil::isNotEmpAndNull($params["checkState"])) {
  82. switch ($params["checkState"]) {
  83. case -1:
  84. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NOTPASS];
  85. break;
  86. case -2:
  87. $where[] = ["ta.checkState", "=", AllowanceStateEnum::SAVE];
  88. break;
  89. case 1:
  90. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NEED_GENERAL_CHECK];
  91. $whereRaw = "ta.highProcess is null or ta.highProcess < 1";
  92. break;
  93. case 2:
  94. $where[] = ["ta.checkState", "=", AllowanceStateEnum::GENERAL_REJECT];
  95. break;
  96. case 3:
  97. $where[] = ["ta.checkState", "=", AllowanceStateEnum::REVIEW_PASS];
  98. $where[] = ["ta.publicState", "=", 5];
  99. break;
  100. case 4:
  101. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT];
  102. break;
  103. case 5:
  104. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT_BRANCH];
  105. break;
  106. case 6:
  107. $where[] = ["ta.publicState", "<>", 5];
  108. $whereRaw = "ta.checkState=5 or ta.checkState >= 13";
  109. break;
  110. case 9:
  111. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NEED_GENERAL_CHECK];
  112. $whereRaw = "ta.highProcess is not null and ta.highProcess >= 1";
  113. break;
  114. }
  115. }
  116. $count = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->count();
  117. $list = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->field("ta.*")->limit($offset, $limit)->order("year {$order},ta.createTime {$order}")->select()->toArray();
  118. $levelList = DictApi::selectByParentCode("talent_arrange");
  119. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  120. $streetList = DictApi::selectByParentCode("street");
  121. $identifyConditionIds = array_filter(array_unique(array_column($list, "identifyCondition")));
  122. $whr[] = ["id", "in", $identifyConditionIds];
  123. $whr[] = ["type", "=", $user["type"]];
  124. $identifyConditionKvList = TalentConditionApi::getKvList($whr);
  125. foreach ($list as $key => $item) {
  126. $list[$key]["talentArrangeName"] = $levelList[$item["talentArrange"]];
  127. $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
  128. $list[$key]["addressName"] = $streetList[$item["address"]];
  129. $list[$key]["identifyConditionText"] = $identifyConditionKvList[$item["identifyCondition"]];
  130. }
  131. return ["total" => $count, "rows" => $list];
  132. }
  133. public static function setTalentAllowanceInfo($params) {
  134. $where = [];
  135. if (\StrUtil::isNotEmpAndNull($params["year"])) {
  136. $where[] = ["ta.year", "=", $params["year"]];
  137. }
  138. if (\StrUtil::isNotEmpAndNull($params["enterpriseName"])) {
  139. $where[] = ["ta.enterpriseName", "like", "%" . $params["enterpriseName"] . "%"];
  140. }
  141. if (\StrUtil::isNotEmpAndNull($params["name"])) {
  142. $where[] = ["ta.name", "like", "%" . $params["name"] . "%"];
  143. }
  144. if (\StrUtil::isNotEmpAndNull($params["talentType"])) {
  145. $where[] = ["ta.talentType", "=", $params["talentType"]];
  146. }
  147. if (\StrUtil::isNotEmpAndNull($params["talentArrange"])) {
  148. $where[] = ["ta.talentArrange", "=", $params["talentArrange"]];
  149. }
  150. if (\StrUtil::isNotEmpAndNull($params["identiryCondition"])) {
  151. $where[] = ["ta.identifyCondition", "=", $params["identifyCondition"]];
  152. }
  153. if (\StrUtil::isNotEmpAndNull($params["allowanceType"])) {
  154. $where[] = ["ta.allowanceType", "=", $params["allowanceType"]];
  155. }
  156. if (\StrUtil::isNotEmpAndNull($params["address"])) {
  157. $where[] = ["ta.address", "=", $params["address"]];
  158. }
  159. return $where;
  160. }
  161. public static function getInfoById($id) {
  162. return TaModel::findOrEmpty($id)->toArray();
  163. }
  164. public static function getApplyCountByIdCard($idCard) {
  165. $where = [];
  166. $where[] = ["idCard", "=", $idCard];
  167. $where[] = ["checkState", "<>", MainState::NOTPASS];
  168. $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
  169. $years = array_column($list, "year");
  170. return $years;
  171. }
  172. public static function getPassYearsByIdCard($idCard) {
  173. $where = [];
  174. $where[] = ["idCard", "=", $idCard];
  175. $where[] = ["checkState", "=", MainState::PASS];
  176. $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
  177. $passYears = array_column($list, "year");
  178. return $passYears;
  179. }
  180. public static function validateAllowanceType($id) {
  181. $info = ["id" => $id];
  182. $old = self::getInfoById($id);
  183. $info["type"] = $old["type"];
  184. $info["allowanceType"] = $old["allowanceType"];
  185. $enterpriseMap = \app\common\model\Enterprise::where("type", $old["type"])->column("name", "id");
  186. /* * 查询工作单位记录 */
  187. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  188. $detaiPdList = []; //用于判定类型
  189. $detailMonthList = []; //用于计算月份
  190. foreach ($initDetailList as $detail) {
  191. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  192. $projectMap = [];
  193. foreach ($projectList as $project) {
  194. $projectMap[$project["project"]] = $project;
  195. }
  196. $detail["list"] = $projectList;
  197. $detail["projectMap"] = $projectMap;
  198. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  199. /* * 筛选符合条件的人才标签 */
  200. $detaiPdList[] = $detail;
  201. $detailMonthList[] = $detail;
  202. }
  203. $monthMap = self::mergeMonth($detailMonthList);
  204. $monthAndDayMap = self::mergeMonthNeedDay($detailMonthList);
  205. $info["recommendAllowanceType"] = $old["allowanceType"];
  206. $info["recommendAllowanceMsg"] = [];
  207. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $id)->select()->toArray();
  208. $set = self::valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  209. $info["recommendAllowanceMsg"][] = "综合以上所有判断得到最终补贴类型为:";
  210. if ($info["recommendAllowanceType"] == 1) {
  211. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>工作津贴</span>;";
  212. $info["recommendAllowanceMsg"][] = "可享受月份为:";
  213. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $set) . "</span>;";
  214. }
  215. if ($info["recommendAllowanceType"] == 2)
  216. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>一次性交通补贴</span>;";
  217. if ($info["recommendAllowanceType"] == 3)
  218. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>不予兑现</span>;";
  219. usort($set, function($a, $b) {
  220. return (int) $a - (int) $b;
  221. });
  222. $info["recommendMonths"] = implode(",", $set);
  223. self::calculateAllowance($info, $set, $detailMonthList);
  224. return $info;
  225. }
  226. /**
  227. * 集成电路津补贴总校验
  228. * */
  229. private static function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  230. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  231. /* * 2.判定合同月份、工作月份、五险和个税是否满足重叠6个月要求* */
  232. $contractSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  233. $workdaySet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  234. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  235. $pensionSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  236. $unemploymentSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  237. $medicaSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  238. $taxSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  239. $str = "工作合同月份、考勤月份、工资发放月份";
  240. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  241. $str = "工作合同月份、考勤月份";
  242. $set = array_intersect($set, $contractSet);
  243. $set = array_intersect($set, $workdaySet);
  244. $checkSet = $set;
  245. $set = array_intersect($set, $pensionSet);
  246. $set = array_intersect($set, $taxSet);
  247. } else if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  248. $set = array_intersect($set, $contractSet);
  249. $set = array_intersect($set, $workdaySet);
  250. $set = array_intersect($set, $wageSet);
  251. $checkSet = $set;
  252. $set = array_intersect($set, $pensionSet);
  253. $set = array_intersect($set, $taxSet);
  254. } else {
  255. $set = array_intersect($set, $contractSet);
  256. $set = array_intersect($set, $workdaySet);
  257. $set = array_intersect($set, $wageSet);
  258. $checkSet = $set;
  259. $set = array_intersect($set, $pensionSet);
  260. $set = array_intersect($set, $unemploymentSet);
  261. $set = array_intersect($set, $medicaSet);
  262. $set = array_intersect($set, $taxSet);
  263. }
  264. usort($set, function($a, $b) {
  265. return (int) $a - (int) $b;
  266. });
  267. if ($info["recommendAllowanceType"] == 1) {
  268. if (count($checkSet) < 6) {
  269. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  270. $info["recommendAllowanceType"] = 3;
  271. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  272. } else {
  273. //检查连续缴纳月份是否满足6个月
  274. $count = 1;
  275. foreach ($checkSet as $s) {
  276. $currentVal = intval($s);
  277. $nextVal = $currentVal + 1;
  278. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  279. if (in_array($nextKey, $checkSet)) {
  280. $count++;
  281. if ($count >= 6) {
  282. break;
  283. }
  284. } else {
  285. $count = 1;
  286. }
  287. }
  288. if ($count < 6) {
  289. $info["recommendAllowanceType"] = 3;
  290. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足连续缴纳6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  291. }
  292. }
  293. }
  294. if ($info["recommendAllowanceType"] == 2) {
  295. //判断境内工作时间是否大于30天
  296. if ($info["allowanceType"] == 2) {
  297. $totalDays = 0;
  298. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  299. foreach ($workmonths as $days) {
  300. $totalDays += $days;
  301. }
  302. if ($totalDays < 30) {
  303. $info["recommendAllowanceType"] = 3;
  304. $info["recommendAllowanceMsg"][] = "全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  305. }
  306. } else {
  307. if (count($workdaySet) == 0) {
  308. $info["recommendAllowanceType"] = 3;
  309. $info["recommendAllowanceMsg"][] = "全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  310. } else {
  311. $info["recommendAllowanceType"] = 2;
  312. $info["recommendAllowanceMsg"][] = "*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  313. }
  314. }
  315. }
  316. return $set;
  317. }
  318. /**
  319. * 计算津补贴
  320. */
  321. private static function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  322. /* * 查询人才层次变更记录 */
  323. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  324. foreach ($arrangeList as &$arrange) {
  325. $where = [];
  326. $where[] = ["type", "=", $info["type"]];
  327. $where[] = ["allowanceType", "in", [1, 2]];
  328. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  329. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  330. foreach ($list as $amount) {
  331. if ($amount["allowanceType"] == 1) {
  332. $arrange["jobMoney"] = $amount["money"];
  333. }
  334. if ($amount["allowanceType"] == 2) {
  335. $arrange["jtMoney"] = $amount["money"];
  336. }
  337. }
  338. }unset($arrange);
  339. /* * * 容器 */
  340. $jobMoney = 0.00; //计算所得工作津贴
  341. $jtMoney = 0.00; //计算所得一次性交通补贴
  342. $recommendMonths = []; //推荐月份
  343. $talentArrange = null;
  344. /* * *********计算************* */
  345. $msgBulider = [];
  346. $identifyExpiredName = "人才证书有效期";
  347. if ($info["type"] == CommonConst::ENTERPRISE_JC) {
  348. $identifyExpiredName = "认定条件有效期";
  349. }
  350. switch ($info["recommendAllowanceType"]) {
  351. case 1:
  352. foreach ($arrangeList as &$arrange) {
  353. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  354. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  355. $levelList = array_intersect($levelList, $retainMonths);
  356. $total = round($arrange["jobMoney"] * count($levelList), 2);
  357. $jobMoney += $total;
  358. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  359. $recommendMonths = array_merge($recommendMonths, $levelList);
  360. usort($recommendMonths, function($a, $b) {
  361. return (int) $a - (int) $b;
  362. });
  363. $arrange["months"] = implode(",", $levelList);
  364. $arrange["count"] = count($levelList);
  365. $arrange["total"] = $total;
  366. } else {
  367. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  368. $arrange["count"] = 0;
  369. $arrange["total"] = 0.00;
  370. }
  371. }unset($arrange);
  372. $info["recommendMonths"] = implode(",", $recommendMonths);
  373. $info["recommendAllowanceMsg"][] = "通过与{$identifyExpiredName}取交集得到最终可享受月份:";
  374. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $recommendMonths) . "</span>;";
  375. $info["recommendAllowanceMsg"][] = "经过计算:兑现月份" . count($recommendMonths) . "个月,人才津贴为<span style='color:red;font-weight:bold;'>" . $jobMoney . "</span>;";
  376. $info["recommendMoney"] = $jobMoney;
  377. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  378. $updAllowance["id"] = $info["id"];
  379. $updAllowance["virtualAmount"] = $jobMoney;
  380. TaModel::update($updAllowance);
  381. break;
  382. case 2:
  383. foreach ($arrangeList as $arrange) {
  384. $jtMoney = $arrange["jtMoney"];
  385. $talentArrange = $arrange["talentArrange"];
  386. }
  387. $info["recommendMoney"] = $jtMoney;
  388. $info["recommendMonths"] = "";
  389. $info["recommendMoneyDesc"] = "一次性交通补贴";
  390. $info["workAllowanceMoney"] = 0.00;
  391. $info["developAllowanceMoney"] = 0.00;
  392. $info["recommendTalentArrange"] = $talentArrange;
  393. $updAllowance["id"] = $info["id"];
  394. $updAllowance["virtualAmount"] = $jtMoney;
  395. TaModel::update($updAllowance);
  396. break;
  397. case 3:
  398. $info["recommendMoney"] = 0.00;
  399. $info["recommendMonths"] = "";
  400. $info["recommendMoneyDesc"] = "不予兑现";
  401. $info["workAllowanceMoney"] = 0.00;
  402. $info["developAllowanceMoney"] = 0.00;
  403. break;
  404. }
  405. return $arrangeList;
  406. }
  407. /**
  408. * 判定是否交足6个月(集成电路)
  409. * @param set
  410. * @param info
  411. * @param name
  412. */
  413. private static function chkMonths($set, &$info, $name, $sort) {
  414. if ($name == "上年度工作月份") {
  415. if ($info["allowanceType"] == 2) {
  416. $tmp = [];
  417. foreach ($set as $s) {
  418. $_s = explode("=", $s);
  419. $month = $_s[0];
  420. $days = $_s[1];
  421. if ($days > 0) {
  422. $tmp[] = $month;
  423. }
  424. }
  425. $set = $tmp;
  426. }
  427. }
  428. $preCheckProjects = ["①", "②", "③"];
  429. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  430. $preCheckProjects = ["①", "②"];
  431. }
  432. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6) && in_array($sort, $preCheckProjects)) {
  433. $info["recommendAllowanceType"] = 3;
  434. $info["recommendAllowanceMsg"][] = $sort . $name . "不足6个月,无法享受工作津贴(×)";
  435. }
  436. return $set;
  437. }
  438. //合并所有项目的月份
  439. private static function mergeMonth($detailList) {
  440. $contractList = [];
  441. $taxList = [];
  442. $wagesList = [];
  443. $pensionList = [];
  444. $unemploymentList = [];
  445. $medicaList = [];
  446. $attendanceList = [];
  447. $workdayList = [];
  448. foreach ($detailList as $detail) {
  449. $projectMap = $detail["projectMap"];
  450. if ($detail["months"]) {
  451. $tmp = array_filter(explode(",", $detail["months"]));
  452. $contractList = array_merge($contractList, $tmp);
  453. }
  454. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  455. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  456. $taxList = array_merge($taxList, $tmp);
  457. }
  458. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  459. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  460. $wagesList = array_merge($wagesList, $tmp);
  461. }
  462. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  463. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  464. $pensionList = array_merge($pensionList, $tmp);
  465. }
  466. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  467. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  468. $unemploymentList = array_merge($unemploymentList, $tmp);
  469. }
  470. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  471. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  472. $medicaList = array_merge($medicaList, $tmp);
  473. }
  474. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  475. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  476. $attendanceList = array_merge($attendanceList, $tmp);
  477. }
  478. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  479. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  480. $workdayList = array_merge($workdayList, $tmp);
  481. }
  482. }
  483. $map = [
  484. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  485. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  486. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  487. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  488. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  489. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  490. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  491. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  492. ];
  493. return $map;
  494. }
  495. /**
  496. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  497. * */
  498. private static function mergeMonthNeedDay($detailList) {
  499. $attendMap = [];
  500. $workDayMap = [];
  501. foreach ($detailList as $detail) {
  502. $attendMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  503. $workDayMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  504. }
  505. $res = [
  506. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  507. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  508. ];
  509. return $res;
  510. }
  511. private static function getMergeMonthNeedDayMap($project, $map) {
  512. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  513. $monthAndDayList = array_filter(explode(",", $project["months"]));
  514. for ($i = 0; $i < count($monthAndDayList); $i++) {
  515. $obj = explode("=", $monthAndDayList[$i]);
  516. $month = $obj[0];
  517. $day = is_numeric($obj[1]) ? $obj[1] : 0;
  518. $count = $map[$month];
  519. if ($count == 0) {
  520. $map[$month] = $day;
  521. } else {
  522. $map[$month] = $day + $count;
  523. }
  524. }
  525. }
  526. return $map;
  527. }
  528. }