Bläddra i källkod

生活补贴++到公示

sugangqiang 1 år sedan
förälder
incheckning
7e7a6a42fd

+ 392 - 6
app/admin/controller/LivingAllowance.php

@@ -130,7 +130,7 @@ class LivingAllowance extends AdminController {
             case 3:
                 if ($oldInfo["checkState"] != LaState::LA_NEED_THIRD) {
                     $responseObj->msg = "该申报不在审核范围内,无法审核";
-                } else if ($oldInfo["reditStatus"] == 1) {
+                } else if ($oldInfo["creditStatus"] == 1) {
                     $responseObj->msg = "当前申报数据未导入核查数据,无法审核";
                 } else {
                     $responseObj->code = 200;
@@ -249,19 +249,21 @@ class LivingAllowance extends AdminController {
                 }
                 $oldState = $obj["checkState"];
                 $newState = LaState::LA_NOTPASS;
-                $updates[] = [
+                $update = [
                     "id" => $obj["id"],
                     "checkState" => $newState,
                     "checkMsg" => $msg
                 ];
+                $updates[] = $update;
+                Db::table("md_living_allowance_info")->save($update);
                 $newLog["id"] = getStringId();
                 $newLog["type"] = ProjectState::LIVINGALLOWANCE;
                 $newLog["mainId"] = $obj["id"];
-                $newLog["active"] = 2;
+                $newLog["active"] = 1;
                 $newLog["state"] = $newState;
                 $newLog["step"] = 70; //审核不通过
                 $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($newState);
-                $newLog["description"] = $msg;
+                $newLog["description"] = "原因:" . $msg;
                 $newLog["createTime"] = date("Y-m-d H:i:s");
                 $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
 
@@ -275,7 +277,6 @@ class LivingAllowance extends AdminController {
                 $responseObj->msg = "没有待审核项";
                 return json($responseObj);
             }
-            Db::table("md_living_allowance_info")->saveAll($updates);
             Db::table("new_talent_checklog")->insertAll($newLogs);
             Db::commit();
             $responseObj->code = 200;
@@ -415,6 +416,292 @@ class LivingAllowance extends AdminController {
         }
     }
 
+    /**
+     * 查询需要处理的数据
+     */
+    public function selectNeedCheckData() {
+        $response = new \stdClass();
+        $response->code = 500;
+        $user = $this->user;
+
+        $type = $this->request->param("type");
+        $id = $this->request->param("id");
+        $name = \StrUtil::getRequestDecodeParam($this->request, "name");
+        $sex = $this->request->param("sex");
+        $checkState = $this->request->param("checkState");
+
+        if (!in_array($user["type"], [1, 2])) {
+            $response->msg = "当前账号类型没有操作权限";
+            return json($response);
+        }
+        $where = [];
+        $where[] = ["type", "=", $user["type"]];
+        if ($name) {
+            $where[] = ["name", "like", "%" . $name . "%"];
+        }
+        if ($sex) {
+            $where[] = ["sex", "=", $sex];
+        }
+        if ($checkState) {
+            $where[] = ["checkState", "=", $checkState];
+        }
+        switch ($type) {
+            case 1:
+                $where[] = ["isPublic", "=", 1];
+                $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
+                break;
+            case 2:
+                $where[] = ["isPublic", "=", 1];
+                $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
+                break;
+            case 3:             //公示
+            case 7:             //公示预览
+                $where[] = ["isPublic", "=", 2];
+                $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
+                break;
+            case 4:
+                $where[] = ["isPublic", "=", 3];
+                $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
+                break;
+            case 6:
+                $where[] = ["isPublic", "=", 4];
+                $where[] = ["checkState", "=", LaState::LA_PASS];
+                break;
+        }
+        $list = Db::table("md_living_allowance_info")->field("id,idCard,name,enterpriseName,checkState")->where($where)->select()->toArray();
+        $response->obj = ["rows" => $list, "total" => count($list)];
+        $response->code = 200;
+        return json($response);
+    }
+
+    /**
+     * 导出核查征信名单
+     * @auth {{/talentInfo/exportHczx}}
+     */
+    public function exportHczx() {
+        $response = new \stdClass();
+        $response->code = 500;
+        $user = $this->user;
+        if (!in_array($user["type"], [1, 2])) {
+            $response->msg = "当前账号类型没有操作权限";
+            return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
+        }
+        $where = [];
+        $ids = array_filter(explode(",", $this->request->param("ids")));
+        $where[] = ["id", "in", $ids];
+        $list = LaModel::where($where)->select()->toArray();
+
+        $nationalitys = DictApi::selectByParentCode("nationality"); //查询国籍字典表
+        if (!$list) {
+            $response->msg = "暂无可核查征信的数据";
+            return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
+        }
+        $title = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
+        $exportList = [];
+        for ($i = 0; $i < count($list); $i++) {
+            $tmp = $list[$i];
+            $exportList[] = [
+                $i + 1, $tmp["name"], $nationalitys[$tmp["nationality"]], $tmp["idCard"], $tmp["enterpriseName"], $tmp["outMsg"], $tmp["actualSocialSecurity"], $tmp["actualTax"], $tmp["actualBusinessRegistration"]
+            ];
+        }
+        $fileName = "硕博人才生活补贴核查征信名单导出";
+        export($title, $exportList, $fileName);
+    }
+
+    /**
+     * 导入征信核查结果
+     * @auth {{/talentInfo/importProject}}
+     */
+    public function importProject(\think\Request $request) {
+        $response = new \stdClass();
+        $response->code = 500;
+        if (!$request->file()) {
+            $response->msg = "没有导入文件";
+            return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+        }
+        $file = $request->file("file");
+        if (!isExcelFile($file->getMime())) {
+            $response->msg = "不是正确的Excel文件";
+            return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+        }
+
+        $path = $file->getRealPath();
+        $rows = getExcelDatas($path);
+        $titleRow = array_shift($rows); //去标题        
+        $titles = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
+        Db::startTrans();
+        try {
+            for ($i = 0; $i < count($titles); $i++) {
+                if ($titles[$i] != $titleRow[$i]) {
+                    $response->msg = "模板错误";
+                    return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+                }
+            }
+            $total = count($rows);
+            if ($total == 0) {
+                $response->msg = "没有数据";
+                return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+            }
+            //------------行数据校验------------------------------------------------------//
+            $idCards = [];
+            $sbf = [];
+            for ($i = 0; $i < $total; $i++) {
+                $row = $rows[$i];
+                $name = trim($row[1]);
+                $idCard = trim($row[3]);
+                $creditStatus = trim($row[5]);
+                $socialSecurity = trim($row[6]);
+                $personalTax = trim($row[7]);
+                $businessRegistration = trim($row[8]);
+                if (\StrUtil::isEmpOrNull($name)) {
+                    $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
+                }
+                if (\StrUtil::isEmpOrNull($idCard)) {
+                    $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
+                }
+                if (\StrUtil::isEmpOrNull($creditStatus) || !in_array($creditStatus, ["无", "在逃人员", "失信被执行人", "意识形态存在问题"])) {
+                    $sbf[] = sprintf("第 %d 行征信格式错误,请根据核查情况填写[ 无 | 在逃人员 | 失信被执行人 | 意识形态存在问题 ]", $i + 1);
+                }
+                //如2022-01,2022-02,2022-03,2022-04
+                $datesRegexp = "/^[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1}(?:,[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1})*$/";
+                if ($socialSecurity && !preg_match($datesRegexp, $socialSecurity)) {
+                    $sbf[] = sprintf("第 %d 行社保核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
+                }
+                if ($personalTax && !preg_match($datesRegexp, $personalTax)) {
+                    $sbf[] = sprintf("第 %d 行个税核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
+                }
+                if ($businessRegistration && !preg_match($datesRegexp, $businessRegistration)) {
+                    $sbf[] = sprintf("第 %d 行工商注册情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
+                }
+                $idCards[] = $idCard;
+            }
+            if ($sbf) {//如果校验 通不过
+                $resultStr = implode("<br>", $sbf);
+                if (mb_strlen($resultStr) > 200) {
+                    $resultStr = mb_substr($resultStr, 0, 200) . "...";
+                }
+                $response->msg = $resultStr;
+                return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+            }
+            $where = [];
+            $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
+            $where[] = ["isPublic", "=", 1];
+            $where[] = ["idCard", "in", $idCards];
+            $list = Db::table("md_living_allowance_info")->where($where)->column("*", "idCard");
+            for ($i = 0; $i < $total; $i++) {
+                $row = $rows[$i];
+                $idCard = trim($row[3]);
+                $outMsg = trim($row[5]);
+                $sbDetail = trim($row[6]);
+                $taxDetail = trim($row[7]);
+                $gsRegistDetail = trim($row[8]);
+                $info = $list[$idCard];
+                if ($info) {
+                    $info["outMsg"] = $outMsg;
+                    $info["actualSocialSecurity"] = $sbDetail;
+                    $info["actualTax"] = $taxDetail;
+                    $info["actualBusinessRegistration"] = $gsRegistDetail;
+                    $info = $this->vailIsCash($info);
+                    $info["creditStatus"] = $outMsg != "无" ? 3 : 2;
+                    Db::table("md_living_allowance_info")->save($info);
+                }
+            }
+
+            $response->code = 200;
+            $response->msg = "导入成功";
+            Db::commit();
+            return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+        } catch (\Exception $e) {
+            Db::rollback();
+            $response->msg = "导入失败,系统错误:" . $e->getMessage();
+            return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
+        }
+    }
+
+    /**
+     * 公示
+     */
+    public function publicBatch() {
+        $response = new \stdClass();
+        $response->code = 200;
+
+        //查询需要公示的数据(勾选)
+        $request = $this->request;
+        $batch = \StrUtil::getRequestDecodeParam($request, "batch");
+        $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
+        $where = [];
+        $where[] = ["id", "in", $ids];
+        $list = LaModel::where($where)->select()->toArray();
+        $recordList = [];
+        $sb = [];
+        $newLogs = [];
+        //MessageRecord sendRecord = new MessageRecord(null, 2, 2, null, null, null, SmsProperties . CHECK_PUBLIC);
+        //sendRecord . setId(IdWorker . getIdStr());
+        Db::startTrans();
+        try {
+            for ($i = 0; $i < count($list); $i++) {
+                $obj = $list[$i];
+                $obj["publicBatch"] = $batch;
+                $obj["isPublic"] = 3;
+                Db::table("md_living_allowance_info")->save($obj);
+                //添加日志
+                $newLog["id"] = getStringId();
+                $newLog["type"] = ProjectState::LIVINGALLOWANCE;
+                $newLog["mainId"] = $obj["id"];
+                $newLog["active"] = 1;
+                $newLog["state"] = 3;
+                $newLog["step"] = 5;
+                $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
+                $newLog["createTime"] = date("Y-m-d H:i:s");
+                $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
+
+                $newLogs[] = $newLog;
+                //sb . append(obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";");
+                /*                 * 短信参数 */
+                //String param = obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";";
+                //sb . append(param);
+                //MessageRecord record = new MessageRecord(null, 2, 2, obj . getName(), obj . getPhone(), param . substring(0, param . length() - 1), SmsProperties . CHECK_PUBLIC);
+                //record . setState(1);
+                //record . setBizId(sendRecord . getId());
+                //record . setSendingDate(DateUtil . getTime());
+                //record . setCreateTime(DateUtil . getTime());
+                //recordList . add(record);
+            }
+            /* if (isMessage != null && isMessage == 1) {
+              if (list.size() > 1000) {
+              return new ResponseObj(ResponseObj . FAILD, "需要发送短信时公示量不能超过1000个");
+              }
+              //发送短信
+              Map map = new HashMap();
+              map . put("account", smsProperties . getAccount());
+              map . put("password", smsProperties . getPassword());
+              map . put("msg", sendRecord . getTemplateCode());
+              map . put("params", sb . substring(0, sb . length() - 1));
+              map . put("report", "true");
+              map . put("uid", sendRecord . getId());
+              String sendUrl = smsProperties . getBaseUrl() + "variable/json";
+              JSONObject js = (JSONObject) JSONObject . toJSON(map);
+              String res = HttpUtil . sendSmsByPost(sendUrl, js . toString());
+              JSONObject jsonObject = JSONObject . parseObject(res);
+              String code = jsonObject . getString("code");
+              String errorMsg = jsonObject . getString("errorMsg");
+              if (!"0" . equals(code)) {
+              return new ResponseObj(ResponseObj . FAILD, "短信发送失败,原因为:" + errorMsg);
+              }
+              this . messageRecordService . insertBatch(recordList);
+              } */
+            Db::table("new_talent_checklog")->insertAll($newLogs);
+            Db::commit();
+            $response->msg = "公示成功";
+            $response->code = 200;
+            return json($response);
+        } catch (\Exception $e) {
+            Db::rollback();
+            $response->msg = $e->getMessage();
+            return json($response);
+        }
+    }
+
     /**
      * 计算兑现额度
      * @param type $oldInfo
@@ -439,7 +726,7 @@ class LivingAllowance extends AdminController {
         $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
         $where[] = ["checkState", "=", 30];
         $where[] = ["publicState", ">=", 4];
-        $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty();
+        $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
         if ($talentAllowanceInfo) {
             $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
             if (round($balanceMoney, 2) == round(0, 2)) {
@@ -456,4 +743,103 @@ class LivingAllowance extends AdminController {
         return $return;
     }
 
+    /**
+     * 判断申报人是否满足兑现条件
+     */
+    private function vailIsCash($old) {
+        /*         * 对申报人的信息进行校验是否满足补贴条件:
+         * 第一年:合同需要在3年以上、缴纳社保3个月及以上
+         * 第二、三年:社保和个税均在9个月以上
+         * */
+        if ($old["outMsg"] != "无") {
+            $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
+            $old["recommendIsPay"] = -1;
+            $old["recommendAmount"] = 0;
+            return $old;
+        }
+        $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
+        if ($old["introductionMethod"] == 2) {
+            $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
+            $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
+            $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
+            if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
+                $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
+                $old["recommendIsPay"] = -1;
+                $old["recommendAmount"] = 0;
+                return $old;
+            }
+            $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
+        }
+        if ($old["applyCount"] == 1) {
+            $endTime = strtotime($old["endTime"]);
+            $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
+            if ($endTime < $after3YearsTime) {
+                $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
+                $old["recommendIsPay"] = -1;
+                $old["recommendAmount"] = 0;
+                return $old;
+            }
+            if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
+                $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
+                $old["recommendIsPay"] = -1;
+                $old["recommendAmount"] = 0;
+                return $old;
+            }
+            $old["recommendIsPay"] = 1;
+            $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
+            $_old = $this->calculateAmount($old);
+            $old = array_merge($old, $_old);
+        } else {
+            if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
+                $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
+                $old["recommendIsPay"] = -1;
+                $old["recommendAmount"] = 0;
+                return $old;
+            }
+            if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
+                $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
+                $old["recommendIsPay"] = -1;
+                $old["recommendAmount"] = 0;
+                return $old;
+            }
+            $old["recommendIsPay"] = 1;
+            $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
+            $_old = $this->calculateAmount($old);
+            $old = array_merge($old, $_old);
+        }
+        return $old;
+    }
+
+    /**
+     * 计算月份数
+     * @param type $dates
+     * @return type
+     */
+    private function countByDates($dates) {
+        $dateArr = explode(",", $dates);
+        $count = 0;
+        for ($i = 0; $i < count($dateArr); $i++) {
+            $date = $dateArr[$i];
+            if ($date) {
+                if (strpos($date, "-") !== false) {
+                    $cDateArr = explode("-", $date);
+                    $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
+                    $month1 = date("n", strtotime($cDateArr[0] . "01"));
+                    $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
+                    $month2 = date("n", strtotime($cDateArr[1] . "01"));
+                    // 方法返回为相差月份                    
+                    $date1 = date_create($_date1);
+                    $date2 = date_create($_date2);
+                    $diff = date_diff($date1, $date2);
+                    if ($diff->invert != 1) {
+                        $count += $diff->y * 12 + ($month2 - $month1) + 1;
+                    }
+                } else {
+                    $count++;
+                }
+            }
+        }
+        return $count;
+    }
+
 }

+ 1 - 1
app/admin/view/living_allowance/index.html

@@ -529,7 +529,7 @@
                 <h4 class="modal-title" id="importModalLabel">核查结果导入</h4>
             </div>
             <div class="modal-body">
-                <form id="import-form" action="/livingAllowanceInfoImport/importProject" method="post" enctype="multipart/form-data" target="hiddenIframe">
+                <form id="import-form" action="/admin/living_allowance/importProject" method="post" enctype="multipart/form-data" target="hiddenIframe">
                     <input type="file" id="file" name="file" onchange="$('#fileName').val($('#file').val());" class="hidden">
                     <div class="form-group row">
                         <div class="col-sm-12">

+ 2 - 2
public/static/modular/master/livingAllowanceInfo/livingAllowanceInfo.js

@@ -504,7 +504,7 @@ LivingAllowanceInfo.showDataCheckModal = function (type) {
     }
     $('#dataTable').bootstrapTable('destroy');
     $('#dataTable').bootstrapTable({
-        url: Feng.ctxPath + "/livingAllowanceInfo/selectNeedCheckData?type=" + type,
+        url: Feng.ctxPath + "/admin/living_allowance/selectNeedCheckData?type=" + type,
         method: 'POST',
         contentType: "application/x-www-form-urlencoded; charset=UTF-8",
         search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
@@ -568,7 +568,7 @@ LivingAllowanceInfo.checkExport = function () {
     for (var i = 0; i < selected.length; i++) {
         ids = ids + selected[i].id + ",";
     }
-    window.location.href = Feng.ctxPath + "/livingAllowanceInfoExport/exportHczx?ids=" + ids;
+    window.location.href = Feng.ctxPath + "/admin/living_allowance/exportHczx?ids=" + ids;
 }
 
 LivingAllowanceInfo.actalUpload = function () {