TalentAllowanceApi.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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", "like", $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["backWork"] = $old["backWork"];
  185. $info["allowanceType"] = $old["allowanceType"];
  186. $info["otherEnjoyedMoney"] = $old["otherEnjoyedMoney"];
  187. $info["otherEnjoyedDescription"] = $old["otherEnjoyedDescription"];
  188. $enterpriseMap = \app\common\model\Enterprise::where("type", $old["type"])->column("name", "id");
  189. /* * 查询工作单位记录 */
  190. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  191. $detaiPdList = []; //用于判定类型
  192. $detailMonthList = []; //用于计算月份
  193. foreach ($initDetailList as $detail) {
  194. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  195. $projectMap = [];
  196. foreach ($projectList as $project) {
  197. $projectMap[$project["project"]] = $project;
  198. }
  199. $detail["list"] = $projectList;
  200. $detail["projectMap"] = $projectMap;
  201. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  202. /* * 筛选符合条件的人才标签 */
  203. $detaiPdList[] = $detail;
  204. $detailMonthList[] = $detail;
  205. }
  206. $monthMap = self::mergeMonth($detailMonthList);
  207. $monthAndDayMap = self::mergeMonthNeedDay($detailMonthList);
  208. $info["recommendAllowanceType"] = $old["allowanceType"];
  209. $info["recommendAllowanceMsg"] = [];
  210. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $id)->select()->toArray();
  211. $set = self::valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  212. $info["recommendAllowanceMsg"][] = "综合以上所有判断得到最终补贴类型为:";
  213. if ($info["recommendAllowanceType"] == 1) {
  214. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>工作津贴</span>;";
  215. $info["recommendAllowanceMsg"][] = "可享受月份为:";
  216. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $set) . "</span>;";
  217. }
  218. if ($info["recommendAllowanceType"] == 2)
  219. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>一次性交通补贴</span>;";
  220. if ($info["recommendAllowanceType"] == 3)
  221. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>不予兑现</span>;";
  222. usort($set, function($a, $b) {
  223. return (int) $a - (int) $b;
  224. });
  225. $info["recommendMonths"] = implode(",", $set);
  226. self::calculateAllowance($info, $set, $detailMonthList);
  227. return $info;
  228. }
  229. /**
  230. * 集成电路津补贴总校验
  231. * */
  232. private static function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  233. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  234. /* * 2.判定合同月份、工作月份、五险和个税是否满足重叠6个月要求* */
  235. $contractSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  236. $workdaySet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  237. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  238. $pensionSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  239. $unemploymentSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  240. $medicaSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  241. $taxSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  242. $str = "工作合同月份、考勤月份、工资发放月份";
  243. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  244. $str = "工作合同月份、考勤月份";
  245. $set = array_intersect($set, $contractSet);
  246. $set = array_intersect($set, $workdaySet);
  247. $checkSet = $set;
  248. //$set = array_intersect($set, $pensionSet);
  249. //$set = array_intersect($set, $taxSet);
  250. } else if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  251. if ($info["backWork"] == 1) {
  252. $str = "工资发放月份、个税缴交月份";
  253. $set = array_intersect($set, $wageSet);
  254. $set = array_intersect($set, $taxSet);
  255. $checkSet = $set;
  256. //$set = array_intersect($set, $contractSet);
  257. //$set = array_intersect($set, $pensionSet);
  258. //$set = array_intersect($set, $workdaySet);
  259. } else {
  260. $str = "养老保险缴交月份、工资发放月份、个税缴交月份";
  261. $set = array_intersect($set, $pensionSet);
  262. $set = array_intersect($set, $wageSet);
  263. $set = array_intersect($set, $taxSet);
  264. $checkSet = $set;
  265. //$set = array_intersect($set, $contractSet);
  266. //$set = array_intersect($set, $workdaySet);
  267. }
  268. } else {
  269. $set = array_intersect($set, $contractSet);
  270. $set = array_intersect($set, $workdaySet);
  271. $set = array_intersect($set, $wageSet);
  272. $checkSet = $set;
  273. $set = array_intersect($set, $pensionSet);
  274. $set = array_intersect($set, $unemploymentSet);
  275. $set = array_intersect($set, $medicaSet);
  276. $set = array_intersect($set, $taxSet);
  277. }
  278. usort($set, function($a, $b) {
  279. return (int) $a - (int) $b;
  280. });
  281. if ($info["recommendAllowanceType"] == 1) {
  282. if (count($checkSet) < 6) {
  283. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  284. $info["recommendAllowanceType"] = 3;
  285. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  286. } else {
  287. //检查连续缴纳月份是否满足6个月
  288. $count = 1;
  289. foreach ($checkSet as $s) {
  290. $currentVal = intval($s);
  291. $nextVal = $currentVal + 1;
  292. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  293. if (in_array($nextKey, $checkSet)) {
  294. $count++;
  295. if ($count >= 6) {
  296. break;
  297. }
  298. } else {
  299. $count = 1;
  300. }
  301. }
  302. if ($count < 6) {
  303. $info["recommendAllowanceType"] = 3;
  304. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足连续缴纳6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  305. }
  306. }
  307. }
  308. if ($info["recommendAllowanceType"] == 2) {
  309. //判断境内工作时间是否大于30天
  310. if ($info["allowanceType"] == 2) {
  311. $totalDays = 0;
  312. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  313. foreach ($workmonths as $days) {
  314. $totalDays += $days;
  315. }
  316. if ($totalDays < 30) {
  317. $info["recommendAllowanceType"] = 3;
  318. $info["recommendAllowanceMsg"][] = "全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  319. }
  320. } else {
  321. if (count($workdaySet) == 0) {
  322. $info["recommendAllowanceType"] = 3;
  323. $info["recommendAllowanceMsg"][] = "全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  324. } else {
  325. $info["recommendAllowanceType"] = 2;
  326. $info["recommendAllowanceMsg"][] = "*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  327. }
  328. }
  329. }
  330. return $set;
  331. }
  332. /**
  333. * 计算津补贴
  334. */
  335. private static function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  336. /* * 查询人才层次变更记录 */
  337. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  338. foreach ($arrangeList as &$arrange) {
  339. $where = [];
  340. $where[] = ["type", "=", $info["type"]];
  341. $where[] = ["allowanceType", "in", [1, 2]];
  342. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  343. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  344. foreach ($list as $amount) {
  345. if ($amount["allowanceType"] == 1) {
  346. $arrange["jobMoney"] = $amount["money"];
  347. }
  348. if ($amount["allowanceType"] == 2) {
  349. $arrange["jtMoney"] = $amount["money"];
  350. }
  351. }
  352. }unset($arrange);
  353. /* * * 容器 */
  354. $jobMoney = 0.00; //计算所得工作津贴
  355. $jtMoney = 0.00; //计算所得一次性交通补贴
  356. $recommendMonths = []; //推荐月份
  357. $talentArrange = null;
  358. /* * *********计算************* */
  359. $msgBulider = [];
  360. $identifyExpiredName = "人才证书有效期";
  361. if ($info["type"] == CommonConst::ENTERPRISE_JC) {
  362. $identifyExpiredName = "认定条件有效期";
  363. }
  364. switch ($info["recommendAllowanceType"]) {
  365. case 1:
  366. foreach ($arrangeList as &$arrange) {
  367. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  368. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  369. $levelList = array_intersect($levelList, $retainMonths);
  370. $total = round($arrange["jobMoney"] * count($levelList), 2);
  371. $jobMoney += $total;
  372. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  373. $recommendMonths = array_merge($recommendMonths, $levelList);
  374. usort($recommendMonths, function($a, $b) {
  375. return (int) $a - (int) $b;
  376. });
  377. $arrange["months"] = implode(",", $levelList);
  378. $arrange["count"] = count($levelList);
  379. $arrange["total"] = $total;
  380. } else {
  381. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  382. $arrange["count"] = 0;
  383. $arrange["total"] = 0.00;
  384. }
  385. }unset($arrange);
  386. $info["recommendMonths"] = implode(",", $recommendMonths);
  387. $info["recommendAllowanceMsg"][] = "通过与{$identifyExpiredName}取交集得到最终可享受月份:";
  388. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $recommendMonths) . "</span>;";
  389. $info["recommendAllowanceMsg"][] = "经过计算:兑现月份" . count($recommendMonths) . "个月,人才津贴为<span style='color:red;font-weight:bold;'>" . $jobMoney . "</span>;";
  390. $finnalMoney = $jobMoney;
  391. if ($info["otherEnjoyedMoney"] > 0) {
  392. $finnalMoney = number_format($jobMoney - $info["otherEnjoyedMoney"], 2);
  393. $info["recommendAllowanceMsg"][] = "扣除其它已享受补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为<span style='color:red;font-weight:bold;'>" . number_format($jobMoney - $info["otherEnjoyedMoney"], 2) . "</span>;";
  394. }
  395. $info["finnalMoney"] = $finnalMoney;
  396. $info["recommendMoney"] = $jobMoney;
  397. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  398. $updAllowance["id"] = $info["id"];
  399. $updAllowance["virtualAmount"] = $jobMoney;
  400. TaModel::update($updAllowance);
  401. break;
  402. case 2:
  403. foreach ($arrangeList as $arrange) {
  404. $jtMoney = $arrange["jtMoney"];
  405. $talentArrange = $arrange["talentArrange"];
  406. }
  407. $info["recommendMoney"] = $jtMoney;
  408. $info["recommendMonths"] = "";
  409. $info["recommendMoneyDesc"] = "一次性交通补贴";
  410. $info["workAllowanceMoney"] = 0.00;
  411. $info["developAllowanceMoney"] = 0.00;
  412. $info["recommendTalentArrange"] = $talentArrange;
  413. $updAllowance["id"] = $info["id"];
  414. $updAllowance["virtualAmount"] = $jtMoney;
  415. $finnalMoney = $jtMoney;
  416. if ($info["otherEnjoyedMoney"] > 0) {
  417. $finnalMoney = number_format($jobMoney - $info["otherEnjoyedMoney"], 2);
  418. $info["recommendAllowanceMsg"][] = "扣除其它已享受补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为<span style='color:red;font-weight:bold;'>" . number_format($jtMoney - $info["otherEnjoyedMoney"], 2) . "</span>;";
  419. }
  420. $info["finnalMoney"] = $finnalMoney;
  421. TaModel::update($updAllowance);
  422. break;
  423. case 3:
  424. $info["recommendMoney"] = 0.00;
  425. $info["recommendMonths"] = "";
  426. $info["recommendMoneyDesc"] = "不予兑现";
  427. $info["workAllowanceMoney"] = 0.00;
  428. $info["developAllowanceMoney"] = 0.00;
  429. break;
  430. }
  431. return $arrangeList;
  432. }
  433. /**
  434. * 判定是否交足6个月(集成电路)
  435. * @param set
  436. * @param info
  437. * @param name
  438. */
  439. private static function chkMonths($set, &$info, $name, $sort) {
  440. if ($name == "上年度工作月份") {
  441. if ($info["allowanceType"] == 2) {
  442. $tmp = [];
  443. foreach ($set as $s) {
  444. $_s = explode("=", $s);
  445. $month = $_s[0];
  446. $days = $_s[1];
  447. if ($days > 0) {
  448. $tmp[] = $month;
  449. }
  450. }
  451. $set = $tmp;
  452. }
  453. }
  454. $preCheckProjects = ["①", "②", "③"];
  455. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  456. $preCheckProjects = ["①", "②"];
  457. }
  458. if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  459. if ($info["backWork"] == 1) {
  460. $preCheckProjects = ["③", "⑦"];
  461. } else {
  462. $preCheckProjects = ["③", "④", "⑦"];
  463. }
  464. }
  465. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6) && in_array($sort, $preCheckProjects)) {
  466. $info["recommendAllowanceType"] = 3;
  467. $info["recommendAllowanceMsg"][] = $sort . $name . "不足6个月,无法享受工作津贴(×)";
  468. }
  469. return $set;
  470. }
  471. //合并所有项目的月份
  472. private static function mergeMonth($detailList) {
  473. $contractList = [];
  474. $taxList = [];
  475. $wagesList = [];
  476. $pensionList = [];
  477. $unemploymentList = [];
  478. $medicaList = [];
  479. $attendanceList = [];
  480. $workdayList = [];
  481. foreach ($detailList as $detail) {
  482. $projectMap = $detail["projectMap"];
  483. if ($detail["months"]) {
  484. $tmp = array_filter(explode(",", $detail["months"]));
  485. $contractList = array_merge($contractList, $tmp);
  486. }
  487. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  488. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  489. $taxList = array_merge($taxList, $tmp);
  490. }
  491. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  492. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  493. $wagesList = array_merge($wagesList, $tmp);
  494. }
  495. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  496. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  497. $pensionList = array_merge($pensionList, $tmp);
  498. }
  499. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  500. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  501. $unemploymentList = array_merge($unemploymentList, $tmp);
  502. }
  503. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  504. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  505. $medicaList = array_merge($medicaList, $tmp);
  506. }
  507. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  508. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  509. $attendanceList = array_merge($attendanceList, $tmp);
  510. }
  511. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  512. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  513. $workdayList = array_merge($workdayList, $tmp);
  514. }
  515. }
  516. $map = [
  517. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  518. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  519. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  520. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  521. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  522. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  523. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  524. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  525. ];
  526. return $map;
  527. }
  528. /**
  529. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  530. * */
  531. private static function mergeMonthNeedDay($detailList) {
  532. $attendMap = [];
  533. $workDayMap = [];
  534. foreach ($detailList as $detail) {
  535. $attendMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  536. $workDayMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  537. }
  538. $res = [
  539. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  540. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  541. ];
  542. return $res;
  543. }
  544. private static function getMergeMonthNeedDayMap($project, $map) {
  545. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  546. $monthAndDayList = array_filter(explode(",", $project["months"]));
  547. for ($i = 0; $i < count($monthAndDayList); $i++) {
  548. $obj = explode("=", $monthAndDayList[$i]);
  549. $month = $obj[0];
  550. $day = is_numeric($obj[1]) ? $obj[1] : 0;
  551. $count = $map[$month];
  552. if ($count == 0) {
  553. $map[$month] = $day;
  554. } else {
  555. $map[$month] = $day + $count;
  556. }
  557. }
  558. }
  559. return $map;
  560. }
  561. }