TalentAllowanceApi.php 23 KB

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