|
@@ -71,6 +71,10 @@ class TalentAllowance extends EnterpriseController {
|
|
|
return view("", ["year" => $batch, "type" => $this->user["type"], "row" => $info]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量提交申请
|
|
|
+ * @return Response
|
|
|
+ */
|
|
|
public function batchApply() {
|
|
|
$ids = $this->request["ids"];
|
|
|
$ids = array_filter(explode(",", $ids));
|
|
@@ -82,7 +86,80 @@ class TalentAllowance extends EnterpriseController {
|
|
|
}
|
|
|
|
|
|
for ($i = 0; $i < count($ids); $i++) {
|
|
|
- queue("app\job\TalentAllowance", ["type" => 1, "talentId" => $ids[$i], "enterprise" => $this->user, "year" => $batch, "allowanceType" => $allowanceType]);
|
|
|
+ queue("app\job\TalentAllowance", ["type" => 1, "method" => 1, "talentId" => $ids[$i], "enterprise" => $this->user, "year" => $batch, "allowanceType" => $allowanceType]);
|
|
|
+ }
|
|
|
+ return new Response(Response::SUCCESS, "已经成功添加到计划任务,请稍候查看申报列表进行确认");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量导入申请
|
|
|
+ * @return Response
|
|
|
+ */
|
|
|
+ public function batchImportApply() {
|
|
|
+ $maxFileSize = 10; //mb
|
|
|
+ $tmp = $this->request->file("file");
|
|
|
+
|
|
|
+ $batch = BatchApi::getValidBatch(ProjectState::JBT, $this->user["type"])["batch"];
|
|
|
+ if (!$batch) {
|
|
|
+ return new Response(Response::ERROR, "当前并无有效的申报批次进行中");
|
|
|
+ }
|
|
|
+ if (!$tmp) {
|
|
|
+ return new Response(Response::ERROR, "没有上传批量申请文档");
|
|
|
+ }
|
|
|
+ if (!isExcelFile($tmp->getMime())) {
|
|
|
+ return new Response(Response::ERROR, "只能识别Excel文档");
|
|
|
+ }
|
|
|
+ if (round($tmp->getSize() / 1024 / 1024, 2) > $maxFileSize) {
|
|
|
+ return new Response(Response::ERROR, "文档大小不能超过10MB");
|
|
|
+ }
|
|
|
+ $filepath = $tmp->getPathname();
|
|
|
+ $rows = getExcelDatas($filepath);
|
|
|
+ array_shift($rows); //去标题行
|
|
|
+ //检查excel文件有没有问题
|
|
|
+ $checkMonths = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
|
|
+ $titles = ["姓名", "身份证", "申请补贴类型", "个税缴纳月份", "工资发放月份", "考勤情况", "养老保险", "失业保险", "医疗保险"];
|
|
|
+ $allowanceTypes = ["工作津贴", "一次性交通补贴"];
|
|
|
+ $idCards = [];
|
|
|
+ foreach ($rows as $key => $row) {
|
|
|
+ $no = $key + 2;
|
|
|
+ $idCard = trim($row[1]);
|
|
|
+ $allowanceType = trim($row[2]);
|
|
|
+ if (!$idCard) {
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行身份证不能放空,请仔细检查内容完整后再重新提交", $no));
|
|
|
+ }
|
|
|
+ if (in_array($idCard, $idCards)) {
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行身份证存在重复,请请仔细检查内容无误后再重新提交", $no));
|
|
|
+ } else {
|
|
|
+ $idCards[] = $idCard;
|
|
|
+ }
|
|
|
+ if (!in_array($allowanceType, $allowanceTypes)) {
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行申请补贴类型错误,请仔细检查内容无误后再重新提交", $no));
|
|
|
+ }
|
|
|
+ if ($allowanceType == "工作津贴") {
|
|
|
+ for ($i = 3; $i < 9; $i++) {
|
|
|
+ $monthstr = str_replace([" ", ","], ",", trim($row[$i]));
|
|
|
+ $months = array_filter(explode(",", $monthstr));
|
|
|
+ if (!$months)
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行%s不能为空,请仔细检查内容完整后再重新提交", $no, $titles[$i]));
|
|
|
+ if (array_diff($months, $checkMonths))
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行%s错误,请查看模板文档对应列说明修改后再重新提交", $no, $titles[$i]));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $monthstr = str_replace([" ", ","], ",", trim($row[5]));
|
|
|
+ $monthstr = str_replace(":", ":", $monthstr);
|
|
|
+ $months = array_filter(explode(",", $monthstr));
|
|
|
+ if (!$months)
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行%s不能为空,请仔细检查内容完整后再重新提交", $no, $titles[5]));
|
|
|
+ foreach ($months as $m) {
|
|
|
+ list($a, $b) = explode(":", $m);
|
|
|
+ if (!in_array($a, $checkMonths) || !is_numeric($b) || $b > 31 || $b < 0)
|
|
|
+ return new Response(Response::ERROR, sprintf("第%d行%s错误,请查看模板文档对应列说明修改后再重新提交", $no, $titles[5]));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for ($i = 0; $i < count($rows); $i++) {
|
|
|
+ queue("app\job\TalentAllowance", ["type" => 1, "method" => 2, "data" => $rows[$i], "enterprise" => $this->user, "year" => $batch, "allowanceType" => trim($rows[$i][2]) == "工作津贴" ? 1 : 2]);
|
|
|
}
|
|
|
return new Response(Response::SUCCESS, "已经成功添加到计划任务,请稍候查看申报列表进行确认");
|
|
|
}
|