sugangqiang 2 lat temu
rodzic
commit
d8d0b3077c

+ 222 - 132
app/admin/controller/IntegralVerify.php

@@ -17,6 +17,7 @@ use app\common\api\IntegralRecordApi;
 use app\common\state\ProjectState;
 use app\common\state\IntegralState;
 use app\common\model\IntegralRecord;
+use app\common\model\IntegralDetail;
 
 /**
  * Description of Talent
@@ -88,7 +89,7 @@ class IntegralVerify extends AdminController {
      * 预备人才库
      */
     public function pre_list() {
-        if (session("user")["type"] == 1) {
+        if ($this->user["type"] == 1) {
             $message = [
                 "typeName" => "晋江市现代产业体系人才积分评定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
                 "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
@@ -118,11 +119,11 @@ class IntegralVerify extends AdminController {
             $res = ["code" => 500, "msg" => "没有选择导出的名单"];
             echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
         }
-        $where[] = ["ti.id", "in", $ids_arr];
-        $list = TalentModel::alias("ti")->leftJoin("un_enterprise e", "e.id=ti.enterprise_id")->field("ti.name,ti.card_type,ti.card_number,e.name as enterpriseName,e.description")->where($where)->select();
+        $where[] = ["ir.id", "in", $ids_arr];
+        $list = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->field("ir.name,ir.card_type,ir.card_number,e.name as enterpriseName,e.description")->where($where)->select();
         if (!$list) {
             $res = ["code" => 500, "msg" => "没有可以导出的内容"];
-            echo sprintf("<script>TalentInfo.callBack(%s);</script>", json_encode($res));
+            echo sprintf("<script>IntegralInfo.callBack(%s);</script>", json_encode($res));
         }
         $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
         $rows = [];
@@ -135,7 +136,7 @@ class IntegralVerify extends AdminController {
             $rows[] = $row;
             $i++;
         }
-        $filename = "现代产业体系人才核查征信名单导出";
+        $filename = "积分申报核查征信名单导出";
         if ($rows) {
             export($columns, $rows, $filename);
             exit();
@@ -152,18 +153,18 @@ class IntegralVerify extends AdminController {
         $ids = array_filter(explode(",", $ids));
 
         $msg = "征信通过";
-        $state = TalentState::ZX_PASS; //征信通过
+        $state = IntegralState::ZX_PASS; //征信通过
 
         $total = count($ids);
         $error = 0;
         $success = 0;
         foreach ($ids as $id) {
-            $talent_info = VerifyApi::getOne($id);
-            if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
+            $record = IntegralRecordApi::getOne($id);
+            if ($record["checkState"] != IntegralState::REVERIFY_PASS) {
                 $error++;
                 continue;
             }
-            if (VerifyApi::setPublic($id, $state, $msg)) {
+            if (IntegralRecordApi::setPublic($id, $state, $msg)) {
                 $success++;
             } else {
                 $error++;
@@ -182,12 +183,12 @@ class IntegralVerify extends AdminController {
         if (!$msg)
             return json(["msg" => "请填写审核意见"]);
         $msg = "征信失信:" . $msg;
-        $state = TalentState::ZX_FAIL; //征信不通过
-        $talent_info = VerifyApi::getOne($id);
-        if ($talent_info["checkState"] != TalentState::REVERIFY_PASS) {
+        $state = IntegralState::ZX_FAIL; //征信不通过
+        $record = IntegralRecordApi::getOne($id);
+        if ($record["checkState"] != IntegralState::REVERIFY_PASS) {
             return json(["msg" => "当前记录不是待核查征信状态,无法核查"]);
         }
-        if (VerifyApi::setPublic($id, $state, $msg)) {
+        if (IntegralRecordApi::setPublic($id, $state, $msg)) {
             return json(["code" => 200, "msg" => "已设置征信失信"]);
         }
         return json(["msg" => "设置征信失信失败"]);
@@ -199,26 +200,34 @@ class IntegralVerify extends AdminController {
     public function publicExportBefore() {
         $params = $this->request->param();
         $ids_arr = array_filter(explode(",", $params["ids"]));
-        $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
+        $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
         if ($ids_arr) {
-            $where[] = ["id", "in", $ids_arr];
-            $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
+            $where[] = ["ir.id", "in", $ids_arr];
+            $list = IntegralRecord::alias("ir")->where($where)
+                            ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                            ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
+                            ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
+                            ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
             $rows = [];
             $i = 1;
-            $talentArranges = DictApi::selectByParentCode("talent_arrange");
+            $card_types = DictApi::selectByParentCode("card_type");
             foreach ($list as $item) {
-                $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
-                $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
-                $checkLog = TalentLogApi::getLastLog($item["id"], 1);
+                $tmp_items = [];
+                $total_points = 0;
+                foreach ($item["detail"] as $_item) {
+                    $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
+                    $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
+                    $total_points += $_item["point"];
+                }
                 $row = [
-                    $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ZX_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
+                    $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ZX_PASS ? "审核通过" : "审核不通过", $item["description"]
                 ];
                 $rows[] = $row;
                 $i++;
             }
         }
         if ($rows) {
-            $filename = "现代产业体系人才公示预览导出";
+            $filename = "积分申报公示预览导出";
             export($columns, $rows, $filename);
             exit();
         }
@@ -230,29 +239,37 @@ class IntegralVerify extends AdminController {
      */
     public function publicExport() {
         $params = $this->request->param();
-        $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "拟认定人才层次", "审核状态", "备注"];
+        $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
         $startTime = $params["startTime"];
         $endTime = $params["endTime"];
         if (!strtotime($startTime) || !strtotime($endTime))
             return json(["msg" => "时间格式错误"]);
-        $where[] = ["checkState", "=", TalentState::ANNOUNCED];
+        $where[] = ["ir.checkState", "=", IntegralState::ANNOUNCED];
         $where[] = ["publicBatch", "between", [$startTime, $endTime]];
-        $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
+        $list = IntegralRecord::alias("ir")->where($where)
+                        ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                        ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
+                        ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
+                        ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
         $rows = [];
         $i = 1;
-        $talentArranges = DictApi::selectByParentCode("talent_arrange");
+        $card_types = DictApi::selectByParentCode("card_type");
         foreach ($list as $item) {
-            $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
-            $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
-            $checkLog = TalentLogApi::getLastLog($item["id"], 1);
+            $tmp_items = [];
+            $total_points = 0;
+            foreach ($item["detail"] as $_item) {
+                $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
+                $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
+                $total_points += $_item["point"];
+            }
             $row = [
-                $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED ? "审核通过" : "审核不通过", $checkLog["description"]
+                $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ANNOUNCED ? "审核通过" : "审核不通过", $item["description"]
             ];
             $rows[] = $row;
             $i++;
         }
         if ($rows) {
-            $filename = "现代产业体系人才公示导出";
+            $filename = "积分申报公示导出";
             export($columns, $rows, $filename);
             exit();
         }
@@ -278,22 +295,21 @@ class IntegralVerify extends AdminController {
         $ids = array_filter(explode(",", $ids));
 
         $msg = "已公示";
-        $state = TalentState::ANNOUNCED; //公示
+        $state = IntegralState::ANNOUNCED; //公示
 
         $total = count($ids);
         $error = 0;
         $success = 0;
         $phones = [];
         foreach ($ids as $id) {
-            $talent_info = VerifyApi::getOne($id);
-            if ($talent_info["checkState"] != TalentState::ZX_PASS) {
+            $record = IntegralRecordApi::getOne($id);
+            if ($record["checkState"] != IntegralState::ZX_PASS) {
                 $error++;
                 continue;
             }
-            if (VerifyApi::setPublic($id, $state, $msg, $publicBatch)) {
+            if (IntegralRecordApi::setPublic($id, $state, $msg, $publicBatch)) {
                 $success++;
-                $ep = EnterpriseApi::getOne($talent_info['enterprise_id']);
-                $phones[] = $ep->agentPhone;
+                $phones[] = $record["enterprise"]->agentPhone;
             } else {
                 $error++;
             }
@@ -312,7 +328,7 @@ class IntegralVerify extends AdminController {
 
                 $record_data = [
                     'id' => $recordId,
-                    'bizId' => $recordId,
+                    'bizId' => $result["msgId"],
                     'type' => 2,
                     'smsType' => 1,
                     'phone' => $phone,
@@ -342,16 +358,16 @@ class IntegralVerify extends AdminController {
             return json(["msg" => "请填写审核意见"]);
         if ($checkState == 1) {
             $msg = "公示再审核通过:" . $msg;
-            $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
+            $state = IntegralState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
         } else {
             $msg = "公示再审核不通过:" . $msg;
-            $state = TalentState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
+            $state = IntegralState::ANNOUNCED_REVERIFY_FAIL; //公示再审核不通过
         }
-        $talent_info = VerifyApi::getOne($id);
-        if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
+        $record = IntegralRecordApi::getOne($id);
+        if ($record["checkState"] != IntegralState::ANNOUNCED) {
             return json(["msg" => "当前记录不是公示状态,无法审核"]);
         }
-        if (VerifyApi::setPublic($id, $state, $msg)) {
+        if (IntegralRecordApi::setPublic($id, $state, $msg)) {
             return json(["code" => 200, "msg" => "公示再审核完成"]);
         }
         return json(["msg" => "公示再审核失败"]);
@@ -365,18 +381,18 @@ class IntegralVerify extends AdminController {
         $ids = $params["ids"];
         $ids = array_filter(explode(",", $ids));
         $msg = "公示再审核批量通过";
-        $state = TalentState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
+        $state = IntegralState::ANNOUNCED_REVERIFY_PASS; //公示再审核通过
 
         $total = count($ids);
         $error = 0;
         $success = 0;
         foreach ($ids as $id) {
-            $talent_info = VerifyApi::getOne($id);
-            if ($talent_info["checkState"] != TalentState::ANNOUNCED) {
+            $record = IntegralRecordApi::getOne($id);
+            if ($record["checkState"] != IntegralState::ANNOUNCED) {
                 $error++;
                 continue;
             }
-            if (VerifyApi::setPublic($id, $state, $msg)) {
+            if (IntegralRecordApi::setPublic($id, $state, $msg)) {
                 $success++;
             } else {
                 $error++;
@@ -393,24 +409,33 @@ class IntegralVerify extends AdminController {
         $ids = $params["ids"];
         $ids = array_filter(explode(",", $ids));
         if ($ids) {
-            $where[] = ["id", "in", $ids];
-            $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
+            $where[] = ["ir.id", "in", $ids];
+            $list = IntegralRecord::alias("ir")->where($where)
+                            ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                            ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
+                            ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
+                            ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
             $rows = [];
             $i = 1;
-            $talentArranges = DictApi::selectByParentCode("talent_arrange");
+
+            $card_types = DictApi::selectByParentCode("card_type");
             foreach ($list as $item) {
-                $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
-                $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
-                $checkLog = TalentLogApi::getLastLog($item["id"], 1);
+                $tmp_items = [];
+                $total_points = 0;
+                foreach ($item["detail"] as $_item) {
+                    $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
+                    $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
+                    $total_points += $_item["point"];
+                }
                 $row = [
-                    $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
+                    $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::ANNOUNCED_REVERIFY_PASS ? "审核通过" : "审核不通过", $item["description"]
                 ];
                 $rows[] = $row;
                 $i++;
             }
         }
-        $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
-        $filename = "现代产业体系人才" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
+        $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
+        $filename = "积分申报" . date("Ym") . "公布预览名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
         if ($rows) {
             export($columns, $rows, $filename);
             exit();
@@ -427,24 +452,34 @@ class IntegralVerify extends AdminController {
         $endTime = $params["endTime"];
         if (!strtotime($startTime) || !strtotime($endTime))
             return json(["msg" => "时间格式错误"]);
-        $where[] = ["checkState", "=", TalentState::PUBLISH_PASS];
-        $where[] = ["certificateGetTime", "between", [$startTime, $endTime]];
-        $list = TalentModel::where($where)->order("talent_arrange asc,enterprise_id asc")->select();
+        $where[] = ["ir.checkState", "=", IntegralState::PUBLISH_PASS];
+        $where[] = ["ir.getTime", "between", [$startTime, $endTime]];
+
+        $list = IntegralRecord::alias("ir")->where($where)
+                        ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                        ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
+                        ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
+                        ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,tl.description")->order("createTime asc")->select();
         $rows = [];
         $i = 1;
-        $talentArranges = DictApi::selectByParentCode("talent_arrange");
+
+        $card_types = DictApi::selectByParentCode("card_type");
         foreach ($list as $item) {
-            $talent_condition = TalentConditionApi::getOne($item["talent_condition"]);
-            $enterprise = EnterpriseApi::getOne($item["enterprise_id"]);
-            $checkLog = TalentLogApi::getLastLog($item["id"], 1);
+            $tmp_items = [];
+            $total_points = 0;
+            foreach ($item["detail"] as $_item) {
+                $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
+                $tmp_items[] = sprintf("%s(%s%s)+%d积分", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"], $_item["point"]);
+                $total_points += $_item["point"];
+            }
             $row = [
-                $i, $item["apply_year"], $item["name"], $item["sex"] == 1 ? "男" : "女", $enterprise["name"], $talent_condition["name"], $talentArranges[$item["talent_arrange"]], $item["checkState"] == TalentState::PUBLISH_PASS ? "审核通过" : "审核不通过", $checkLog["description"]
+                $i, $item["apply_year"], $item["name"], $card_types[$item["card_type"]], $item["card_number"], $item["enterpriseName"], implode(";", $tmp_items), $total_points, $item["checkState"] == IntegralState::PUBLISH_PASS ? "审核通过" : "审核不通过", $item["description"]
             ];
             $rows[] = $row;
             $i++;
         }
-        $columns = ["序号", "批次", "姓名", "性别", "工作单位", "本人具备的认定条件", "认定人才层次", "审核状态", "备注"];
-        $filename = "现代产业体系人才" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
+        $columns = ["序号", "批次", "姓名", "证件类型", "证件号码", "工作单位", "申请积分项目", "拟认定获得积分", "审核状态", "备注"];
+        $filename = "积分申报" . date("Ym") . "公布名单导出(公示批次-" . $list[0]["publicBatch"] . ")";
         if ($rows) {
             export($columns, $rows, $filename);
             exit();
@@ -462,25 +497,25 @@ class IntegralVerify extends AdminController {
         $checkState = $params["checkState"];
         $batch = $params["batch"];
         if ($checkState == 1) {
-            $state = TalentState::PUBLISH_PASS;
+            $state = IntegralState::PUBLISH_PASS;
             $msg = "公布审核通过:" . $msg;
         } else {
-            $state = TalentState::PUBLISH_FAIL;
+            $state = IntegralState::PUBLISH_FAIL;
             $msg = "公布审核不通过:" . $msg;
         }
         if (!$batch || !strtotime($batch))
             return json(["msg" => "公布批次时间错误"]);
         if (!$msg)
             return json(["msg" => "请填写审核意见"]);
-        $state = TalentState::PUBLISH_PASS; //公示再审核通过
+        $state = IntegralState::PUBLISH_PASS; //公示再审核通过
         $batch = $params["batch"];
         if (!strtotime($batch))
             return json(["msg" => "公布批次时间错误"]);
-        $talent_info = VerifyApi::getOne($id);
-        if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
+        $record = IntegralRecordApi::getOne($id);
+        if ($record["checkState"] != IntegralState::ANNOUNCED_REVERIFY_PASS) {
             return json(["msg" => "当前记录不是公示再审核通过状态,无法审核"]);
         }
-        if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
+        if (IntegralRecordApi::setPublic($id, $state, $msg, $batch)) {
             return json(["code" => 200, "msg" => "公布审核完成"]);
         }
         return json(["msg" => "公布审核失败"]);
@@ -494,7 +529,7 @@ class IntegralVerify extends AdminController {
         $ids = $params["ids"];
         $ids = array_filter(explode(",", $ids));
         $msg = "批量公布";
-        $state = TalentState::PUBLISH_PASS; //公示再审核通过
+        $state = IntegralState::PUBLISH_PASS; //公示再审核通过
         $batch = $params["batch"];
         if (!strtotime($batch))
             return json(["msg" => "公布批次时间错误"]);
@@ -502,12 +537,12 @@ class IntegralVerify extends AdminController {
         $error = 0;
         $success = 0;
         foreach ($ids as $id) {
-            $talent_info = VerifyApi::getOne($id);
-            if ($talent_info["checkState"] != TalentState::ANNOUNCED_REVERIFY_PASS) {
+            $record = IntegralRecordApi::getOne($id);
+            if ($record["checkState"] != IntegralState::ANNOUNCED_REVERIFY_PASS) {
                 $error++;
                 continue;
             }
-            if (VerifyApi::setPublic($id, $state, $msg, $batch)) {
+            if (IntegralRecordApi::setPublic($id, $state, $msg, $batch)) {
                 $success++;
             } else {
                 $error++;
@@ -522,63 +557,46 @@ class IntegralVerify extends AdminController {
     public function prepareCertification() {
         $lockFile = fopen("send_certificate.lock", "a");
         if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
-//查询所有待发放人才码的数据
             $params = $this->request->param();
             $ids = array_filter(explode(",", $params["ids"]));
-//晋江市优秀人才证书:当前年份+层次+四位递增数字
-//集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
             Db::startTrans();
-            $talent_max_no = [];
-            $user = session("user");
+            $user = $this->user;
             try {
-                $talent_list = VerifyApi::getListByIds($ids);
+                $record_list = IntegralRecordApi::getListByIds($ids);
                 $year = date("Y");
-                foreach ($talent_list as $talent_info) {
-                    if ($talent_info["checkState"] != TalentState::PUBLISH_PASS) {
+                foreach ($record_list as $record) {
+                    if ($record["checkState"] != IntegralState::PUBLISH_PASS) {
                         Db::rollback();
-                        return json(["msg" => "只能对公布通过的对象发放人才码,请核查待发放人才码名单后再重新发放人才码"]);
+                        return json(["msg" => "只能对公布通过的对象发放积分,请核查待发放积分名单后再重新发放积分"]);
                     }
 
-                    $no_prefix = $year . $talent_info["talent_arrange"];
-                    $where[] = ["certificateNo", "like", $no_prefix . "%"];
-                    $max_no = $talent_max_no[$talent_info["talent_arrange"]] ?: Db::table("new_talent_info")->where($where)->max("certificateNo");
-                    if (!$max_no) {
-                        $max_no = $no_prefix . "0001";
-                    } else {
-                        $new_no = intval(substr($max_no, 5)) + 1;
-                        $max_no = $no_prefix . str_pad($new_no, 4, "0", STR_PAD_LEFT);
-                    }
-//更新证书编号
-                    $data["id"] = $talent_info["id"];
-                    $data["certificateNo"] = $max_no;
-                    $data["checkState"] = TalentState::CERTIFICATED;
+                    $data["id"] = $record["id"];
+                    $data["checkState"] = IntegralState::SUCCESS;
                     $data["isPublic"] = 5;
-                    Db::table("new_talent_info")->update($data);
+                    Db::table("new_integral_record")->update($data);
 
 //写入日志
-                    $log["last_state"] = TalentState::PUBLISH_PASS;
+                    $log["last_state"] = IntegralState::PUBLISH_PASS;
                     $log["id"] = getStringId();
-                    $log["state"] = $log["new_state"] = TalentState::CERTIFICATED;
-                    $log["type"] = 1;
-                    $log["mainId"] = $talent_info["id"];
+                    $log["state"] = $log["new_state"] = IntegralState::SUCCESS;
+                    $log["type"] = ProjectState::INTEGRAL;
+                    $log["mainId"] = $record["id"];
                     $log["companyId"] = $user["companyId"];
                     $log["active"] = 1;
-                    $log["description"] = "人才码为:" . $max_no;
+                    $log["description"] = "积分申报成功";
                     $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);
                     $log["createTime"] = date("Y-m-d H:i:s");
                     Db::table("new_talent_checklog")->insert($log);
-
-                    $talent_max_no[$talent_info["talent_arrange"]] = $max_no;
                 }
                 Db::commit();
-                return json(["code" => 200, "msg" => "发放人才码成功"]);
+                return json(["code" => 200, "msg" => "发放积分成功"]);
             } catch (\Exception $e) {
                 Db::rollback();
-                return json(["msg" => "发放人才码失败:" . $e->getMessage()]);
+                return json(["msg" => "发放积分失败:" . $e->getMessage()]);
             }
             flock($lockFile, LOCK_UN);
         } else {
-            return json(["msg" => "同一时间只能有一个管理员进行发放人才码操作"]);
+            return json(["msg" => "同一时间只能有一个管理员进行发放积分操作"]);
         }
     }
 
@@ -640,21 +658,25 @@ class IntegralVerify extends AdminController {
         IntegralRecord::update($data);
         TalentLogApi::setActive($log["id"], 1);
         $userIds = [];
-        if (in_array($data["checkState"], [IntegralState::VERIFY_PASS])) {
+        if (in_array($log["state"], [IntegralState::VERIFY_PASS])) {
             //初审成功需要发送短信给复核部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
             //从复核权限,逆推复核人员
-            $privs = ["/admin/integralVerify/re_verify"];
-            $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+            $codes = ["integralVerify_reCheck"];
+            $menuIds = MenuApi::getMenuIdsByCodes($codes);
+
             $where = [];
             $where[] = ["menuid", "in", $menuIds];
-            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+
             $where = [];
             $where[] = ["status", "=", 1];
-            $where[] = ["roleid", "in", $roleIds];
+            $where[] = ["type", "=", $this->user["type"]];
             $where[] = ["roleid", "<>", 1];
-            $userIds = User::where($where)->column("id");
+            $regstr = ",(" . implode("|", $roleIds) . "),";
+            $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+            $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
         }
-        $this->sendMsgByState($record, $log["new_state"], $userIds);
+        $this->sendMsgByState($record, $log["state"], $userIds);
         return json(["code" => 200, "msg" => "审核成功"]);
     }
 
@@ -668,9 +690,18 @@ class IntegralVerify extends AdminController {
         $params = $request->param();
         $data["modify_files"] = null;
         $data["modify_fields"] = null;
+        $totalPoints = 0;
         if ($params["checkState"] == 1) {
             //审核成功
             $log_checkState = $checkState = IntegralState::REVERIFY_PASS; //复核成功
+            foreach ($record->detail as $item) {
+                $result = IntegralRecordApi::calIntegral($record["enterprise_id"], $record["card_type"], $record["card_number"], $item["item_id"], $item["amount"]);
+                $totalPoints += $result->points;
+                $iData["id"] = $item["id"];
+                $iData["point"] = $result->points;
+                IntegralDetail::update($iData);
+            }
+            $data["totalPoints"] = $totalPoints;
         } else if ($params["checkState"] == 2) {
             //审核驳回并记录需要修改的字段和上传文件
             $checkState = IntegralState::SUBMIT; //退回待初审
@@ -707,25 +738,31 @@ class IntegralVerify extends AdminController {
         IntegralRecord::update($data);
         TalentLogApi::setActive($log["id"], 1);
         $userIds = [];
-        if (in_array($data["checkState"], [IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_REJECT])) {
+        if (in_array($log["state"], [IntegralState::REVERIFY_PASS, IntegralState::REVERIFY_REJECT])) {
             //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
             //从征信审核权限,逆推征信部门
+
             if ($data["checkState"] == IntegralState::REVERIFY_PASS) {
-                $privs = ["/admin/integralVerify/hczxReject", "/admin/integralVerify/hczxPass"];
+                $codes = ["integralVerify_hczxReject", "integralVerify_firstCheck_hczxPass"];
             } else {
-                $privs = ["admin/integralVerify/fst_check"];
+                $codes = ["integralVerify_firstCheck"];
             }
-            $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+
+            $menuIds = MenuApi::getMenuIdsByCodes($codes);
+
             $where = [];
             $where[] = ["menuid", "in", $menuIds];
-            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+
             $where = [];
             $where[] = ["status", "=", 1];
-            $where[] = ["roleid", "in", $roleIds];
+            $where[] = ["type", "=", $this->user["type"]];
             $where[] = ["roleid", "<>", 1];
-            $userIds = User::where($where)->column("id");
+            $regstr = ",(" . implode("|", $roleIds) . "),";
+            $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+            $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
         }
-        $this->sendMsgByState($record, $data["checkState"], $userIds);
+        $this->sendMsgByState($record, $log["state"], $userIds);
         return json(["code" => 200, "msg" => "审核成功"]);
     }
 
@@ -739,32 +776,32 @@ class IntegralVerify extends AdminController {
         switch ($state) {
             case IntegralState::VERIFY_PASS://初审通过发送短信通知并审部门
                 $type = 1;
-                $processName = "初级审核";
+                $processName = "积分申报-初级审核";
                 $template = "【晋江市人才服务平台】您的部门有新的积分申报需要审批,请及时登录审批系统处理。";
                 break;
             case IntegralState::VERIFY_REJECT; //初审驳回发送短信通知用户
                 $type = 2;
-                $processName = "初级审核";
+                $processName = "积分申报-初级审核";
                 $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核驳回,原因是:{$log['description']},请及时登录申报系统修改并重新提交。";
                 break;
             case IntegralState::VERIFY_FAIL://初审不通过发送短信通知用户
                 $type = 2;
-                $processName = "初级审核";
+                $processName = "积分申报-初级审核";
                 $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
                 break;
             case IntegralState::REVERIFY_PASS://复核通过发短信通知征信部门
                 $type = 1;
-                $processName = "复审";
+                $processName = "积分申报-复审";
                 $template = "【晋江市人才服务平台】有新的积分申报通过复审进入征信阶段,请及时登录审批系统处理。";
                 break;
             case IntegralState::REVERIFY_REJECT://复核驳回发短信通知初审部门
                 $type = 1;
-                $processName = "复审";
+                $processName = "积分申报-复审";
                 $template = "【晋江市人才服务平台】有积分申报在复审阶段被驳回,原因是:{$log['description']},请及时登录审批系统处理。";
                 break;
             case IntegralState::REVERIFY_FAIL://并审驳回发送短信通知初审部门
                 $type = 2;
-                $processName = "复审";
+                $processName = "积分申报-复审";
                 $template = "【晋江市人才服务平台】尊敬的用户,您提交的积分申报审核不通过,原因是:{$log['description']}。";
                 break;
         }
@@ -789,7 +826,7 @@ class IntegralVerify extends AdminController {
                 $record_data = [
                     'id' => $id,
                     'userId' => $userId,
-                    'bizId' => $id,
+                    'bizId' => $result["msgId"],
                     'type' => $type,
                     'smsType' => 2,
                     'name' => $name,
@@ -880,7 +917,59 @@ class IntegralVerify extends AdminController {
     }
 
     public function findFieldsAndFiles() {
-        
+        $id = $this->request["id"];
+        $record = IntegralRecordApi::getOne($id);
+        $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
+        $responseObj = new \stdClass();
+        if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
+            $items = $record["detail"]->toArray(); //项目明细
+            $checkState = $record["checkState"];
+            $fields = DictApi::getIntegralFields();
+            $field_tmp = [];
+            foreach ($fields as $key => $field) {
+                $field_tmp[] = ["key" => $key, "value" => $field];
+            }
+            $record["files"] = $record["modify_files"];
+            $record["fields"] = array_filter(explode(",", $record["modify_fields"]));
+            return json(["code" => 200, "obj" => ["record" => $record, "fieldList" => $field_tmp]]);
+            $responseObj->code = 200;
+            $responseObj->id = $id;
+            $responseObj->obj = ["record" => $record, "fieldList" => $field_tmp];
+        } else {
+            $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
+        }
+        return json($responseObj);
+    }
+
+    public function updateFieldsAndFiles() {
+        $id = $this->request["id"];
+        $fields = array_filter(explode(",", $this->request["fields"]));
+        $files = array_filter(explode(",", $this->request["files"]));
+
+        $record = IntegralRecordApi::getOne($id);
+        $lastLog = TalentLogApi::getLastLog($id, ProjectState::INTEGRAL);
+        $responseObj = new \stdClass();
+        if ($record["checkState"] == IntegralState::SAVE && $lastLog["state"] == IntegralState::VERIFY_REJECT) {
+            if (!$fields && !$files) {
+                $responseObj->msg = "请选择可修改的字段或附件!";
+                return json($responseObj);
+            }
+            try {
+                $data["id"] = $id;
+                $data["modify_fields"] = $fields ? implode(",", $fields) : null;
+                $data["modify_files"] = $files ? implode(",", $files) : null;
+                IntegralRecord::update($data);
+                $responseObj->code = 200;
+                $responseObj->msg = "驳回字段修改成功";
+                return json($responseObj);
+            } catch (\think\db\exception\DbException $e) {
+                $responseObj->msg = $e->getMessage();
+                return json($responseObj);
+            }
+        } else {
+            $responseObj->msg = "不是驳回状态不可以编辑驳回内容";
+            return json($responseObj);
+        }
     }
 
     public function fstVerifyListExport() {
@@ -906,6 +995,7 @@ class IntegralVerify extends AdminController {
         $names["project"] = "申报项目";
         $names["checkState"] = "审核状态";
         $names["checkMsg"] = "审核意见";
+        $names["year"] = "申报年度";
         $list = IntegralRecordApi::getExportDatas($process, $fields);
         foreach ($fields as $field) {
             $columns[] = $names[$field];

+ 76 - 26
app/admin/controller/Talent.php

@@ -183,7 +183,7 @@ class Talent extends AdminController {
      * @auth {{/talentInfo/gotoIndex/4}}
      */
     public function pre_list() {
-        if (session("user")["type"] == 1) {
+        if ($this->user["type"] == 1) {
             $message = [
                 "typeName" => "晋江市现代产业体系人才认定", "address" => "聚才网/人才晋江微信公众号", "dep" => "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心",
                 "phone" => "0595-85633128", "email" => "jjrc85661234@163.com"
@@ -637,7 +637,7 @@ class Talent extends AdminController {
 //集成电路优秀人才证书:IC+当前年份+递增四位数,如IC20190001
             Db::startTrans();
             $talent_max_no = [];
-            $user = session("user");
+            $user = $this->user;
             try {
                 $talent_list = VerifyApi::getListByIds($ids);
                 $year = date("Y");
@@ -853,7 +853,7 @@ class Talent extends AdminController {
             $data["highProcess"] = $nowProcess > $talent_info["highProcess"] ? $nowProcess : $talent_info["highProcess"];
         }
         $userIds = [];
-        if ($log["new_state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
+        if ($log["state"] == TalentState::FST_VERIFY_PASS && $talent_info["pass_dept_check"] == 0) {
             $data["first_dept_check_time"] = date("Y-m-d H:i:s");
             $condition = TalentConditionApi::getOne($talent_info["talent_condition"]);
             $companyIds = array_filter(explode(",", $condition["companyIds"])); //该条件下需要审核的所有单位
@@ -872,23 +872,39 @@ class Talent extends AdminController {
                 TalentLogApi::writeDeptLogs($talent_info["id"], $unpass_companyIds, TalentState::FST_VERIFY_PASS);
 
                 //初审通过发送短信通知并审部门
-                $privs = ["/admin/talent/dept_check"];
-                $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+                $codes = ["talentInfo_depCheck"];
+                $menuIds = MenuApi::getMenuIdsByCodes($codes);
+
+                $where = [];
                 $where[] = ["menuid", "in", $menuIds];
-                $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+                $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+
                 $where = [];
                 $where[] = ["status", "=", 1];
+                $where[] = ["type", "=", $this->user["type"]];
                 $where[] = ["companyId", "in", $unpass_companyIds];
-                $where[] = ["roleid", "in", $roleIds];
                 $where[] = ["roleid", "<>", 1];
-                $userIds = User::where($where)->column("id");
+                $regstr = ",(" . implode("|", $roleIds) . "),";
+                $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+                $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
+
+                /* $privs = ["/admin/talent/dept_check"];
+                  $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+                  $where[] = ["menuid", "in", $menuIds];
+                  $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+                  $where = [];
+                  $where[] = ["status", "=", 1];
+                  $where[] = ["companyId", "in", $unpass_companyIds];
+                  $where[] = ["roleid", "in", $roleIds];
+                  $where[] = ["roleid", "<>", 1];
+                  $userIds = User::where($where)->column("id"); */
             }
         }
         $data["id"] = $talent_info["id"];
         $data["checkState"] = $log["new_state"];
         TalentModel::update($data);
         TalentLogApi::setActive($log["id"], 1);
-        $this->sendMsgByState($talent_info, $log["new_state"], $userIds);
+        $this->sendMsgByState($talent_info, $log["state"], $userIds);
         return json(["code" => 200, "msg" => "审核成功"]);
     }
 
@@ -1020,16 +1036,31 @@ class Talent extends AdminController {
             TalentModel::update($data);
             TalentLogApi::write(1, $talent_info["id"], [$log_checkState, $checkState], "部门审核结束", 1);
             if ($log_checkState == TalentState::DEPT_VERIFY_REJECT) {
-                //部门驳回发送短信通知
-                $privs = ["admin/talent/fst_check"];
-                $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+                //部门驳回发送短信通知                
+                $codes = ["talentInfo_firstCheck"];
+                $menuIds = MenuApi::getMenuIdsByCodes($codes);
+
+                $where = [];
                 $where[] = ["menuid", "in", $menuIds];
-                $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+                $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+
                 $where = [];
                 $where[] = ["status", "=", 1];
-                $where[] = ["roleid", "in", $roleIds];
+                $where[] = ["type", "=", $this->user["type"]];
                 $where[] = ["roleid", "<>", 1];
-                $userIds = User::where($where)->column("id");
+                $regstr = ",(" . implode("|", $roleIds) . "),";
+                $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+                $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
+
+                /* $privs = ["admin/talent/fst_check"];
+                  $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+                  $where[] = ["menuid", "in", $menuIds];
+                  $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+                  $where = [];
+                  $where[] = ["status", "=", 1];
+                  $where[] = ["roleid", "in", $roleIds];
+                  $where[] = ["roleid", "<>", 1];
+                  $userIds = User::where($where)->column("id"); */
 
                 $this->sendMsgByState($talent_info, $log_checkState, $userIds);
             }
@@ -1093,25 +1124,44 @@ class Talent extends AdminController {
         TalentModel::update($data);
         TalentLogApi::setActive($log["id"], 1);
         $userIds = [];
-        if (in_array($data["checkState"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
+        if (in_array($log["state"], [TalentState::REVERIFY_PASS, TalentState::REVERIFY_REJECT])) {
             //复核成功需要发送短信给征信部门,复核的其它状态发送通知给用户,调用此方法的还有基础审核的每个状态都要发送通知给用户
             //从征信审核权限,逆推征信部门
             if ($data["checkState"] == TalentState::REVERIFY_PASS) {
-                $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
+                $codes = ["talentInfohczxReject", "talentInfohczxPass"];
             } else {
-                $privs = ["admin/talent/fst_check"];
+                $codes = ["talentInfo_firstCheck"];
             }
-            $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+            $menuIds = MenuApi::getMenuIdsByCodes($codes);
+
             $where = [];
             $where[] = ["menuid", "in", $menuIds];
-            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+            $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($codes))->column("roleid");
+
             $where = [];
             $where[] = ["status", "=", 1];
-            $where[] = ["roleid", "in", $roleIds];
+            $where[] = ["type", "=", $this->user["type"]];
             $where[] = ["roleid", "<>", 1];
-            $userIds = User::where($where)->column("id");
-        }
-        $this->sendMsgByState($talent_info, $data["checkState"], $userIds);
+            $regstr = ",(" . implode("|", $roleIds) . "),";
+            $whereRaw = "concat(',',roleid,',') REGEXP '$regstr'";
+            $userIds = User::where($where)->whereRaw($whereRaw)->column("id");
+
+            /* if ($data["checkState"] == TalentState::REVERIFY_PASS) {
+              $privs = ["/admin/talent/hczxReject", "/admin/talent/hczxPass"];
+              } else {
+              $privs = ["admin/talent/fst_check"];
+              }
+              $menuIds = MenuApi::getMenuIdsByNewUrls($privs);
+              $where = [];
+              $where[] = ["menuid", "in", $menuIds];
+              $roleIds = SysRelation::where($where)->group("roleid")->having("count(*)=" . count($privs))->column("roleid");
+              $where = [];
+              $where[] = ["status", "=", 1];
+              $where[] = ["roleid", "in", $roleIds];
+              $where[] = ["roleid", "<>", 1];
+              $userIds = User::where($where)->column("id"); */
+        }
+        $this->sendMsgByState($talent_info, $log["state"], $userIds);
         return json(["code" => 200, "msg" => "审核成功"]);
     }
 
@@ -1190,7 +1240,7 @@ class Talent extends AdminController {
                 $record_data = [
                     'id' => $id,
                     'userId' => $userId,
-                    'bizId' => $id,
+                    'bizId' => $result["msgId"],
                     'type' => $type,
                     'smsType' => 2,
                     'name' => $name,
@@ -1445,7 +1495,7 @@ class Talent extends AdminController {
         $lastLog = TalentLogApi::getLastLog($id, ProjectState::TALENT);
         $responseObj = new \stdClass();
         if ($talentInfo["checkState"] == TalentState::SCND_SAVE && $lastLog["state"] == TalentState::FST_VERIFY_REJECT) {
-            if (session("user")["type"] == 2) {
+            if ($this->user["type"] == 2) {
                 $fields = DictApi::getTalentFields_IC();
             } else {
                 $fields = DictApi::getTalentFields(4, $talentInfo["isImport"]);

+ 9 - 9
app/admin/view/integral_verify/fst_verify.html

@@ -114,27 +114,27 @@
                             </div>
                         </div>
                         <div class="hidden-xs" id="IntegralVerifyTableToolbar" role="group">
-                            {if condition="chkCommission('/admin/talent/base_verify','')"}
+                            {if condition="chkCommission('/admin/integralVerify/fst_verify','')"}
                             <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.openCheckIntegralVerify()" id="">
                                 <i class="fa fa-check"></i>&nbsp;审核
                             </button>
                             {/if}
-                            {if condition="chkCommission('/admin/talent/base_export','')"}
+                            {if condition="chkCommission('/admin/integralVerify/fstVerifyListExport','')"}
                             <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.showExportModal(1)" id="">
                                 <i class="fa fa-file-excel-o"></i>&nbsp;导出
                             </button>
                             {/if}
-                            {if condition="chkCommission('/admin/talent/base_download','')"}
+                            {if condition="chkCommission('/admin/integralVerify/firstDownload','')"}
                             <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.download()" id="">
                                 <i class="fa fa-download"></i>&nbsp;下载
                             </button>
                             {/if}
-                            <!--{if condition="chkCommission('/admin/talent/modify_reject_fields','')"}
-                                <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.updateFieldsAndFiles()" id="">
-                                    <i class="fa fa-edit"></i>&nbsp;修改驳回字段
-                                </button>
-                            {/if}-->
-                            {if condition="chkCommission('/admin/talent/setNotPass','')"}
+                            {if condition="chkCommission('/admin/integralVerify/updateFieldsAndFiles','')"}
+                            <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.updateFieldsAndFiles()" id="">
+                                <i class="fa fa-edit"></i>&nbsp;修改驳回字段
+                            </button>
+                            {/if}
+                            {if condition="chkCommission('/admin/integralVerify/cancel_verify','')"}
                             <button type="button" class="btn btn-sm btn-primary " onclick="IntegralVerify.setNotPass()" id="">
                                 <i class="fa fa-mobile"></i>&nbsp;审核不通过
                             </button>

+ 6 - 6
app/admin/view/integral_verify/pre_list.html

@@ -102,7 +102,7 @@
                                         <option value="23">公示中</option>
                                         <option value="24">待公布</option>
                                         <option value="26">待发放积分</option>
-                                        <option value="28">积分已账</option>
+                                        <option value="28">积分已账</option>
                                         <option value="22">征信不通过</option>
                                         <option value="25">公示审核不通过</option>
                                         <option value="27">公布不通过</option>
@@ -364,8 +364,8 @@
                                 <div class="col-sm-3 spacing">
                                     <select type="text" class="form-control input-sm"  id="pub_checkState" name="checkState" >
                                         <option value="">请选择</option>
-                                        <option value="13">审核不通过</option>
-                                        <option value="11">已通过</option>
+                                        <option value="2">审核不通过</option>
+                                        <option value="1">已通过</option>
                                     </select>
                                 </div>
                             </div>
@@ -460,14 +460,14 @@
                             </ul>
                         </div>
                         <div class="form-group" style="text-align: center">
-                            <button type="button" class="btn btn-primary" onclick="IntegralVerify.checkAll()">全选</button>
-                            <button type="button" class="btn btn-success" onclick="IntegralVerify.unCheckAll()">反选</button>
+                            <button type="button" class="btn btn-primary" onclick="IntegralInfo.checkAll()">全选</button>
+                            <button type="button" class="btn btn-success" onclick="IntegralInfo.unCheckAll()">反选</button>
                         </div>
                     </div>
                 </form>
             </div>
             <div class="modal-footer">
-                <button type="button" class="btn btn-primary" onclick="IntegralVerify.export(3)">导出</button>
+                <button type="button" class="btn btn-primary" onclick="IntegralInfo.export(3)">导出</button>
                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
             </div>
         </div>

+ 1 - 1
app/common/api/BatchApi.php

@@ -191,7 +191,7 @@ class BatchApi {
             if (strtotime($batch["endTime"]) < $now)
                 return ["msg" => "申报已结束,无法申报"];
         }
-        return ["code" => 200, "batch" => $batch["batch"]];
+        return ["code" => 200, "batch" => $batch["batch"], "id" => $batch["id"]];
     }
 
     /**

+ 62 - 16
app/common/api/IntegralRecordApi.php

@@ -18,6 +18,7 @@ class IntegralRecordApi {
     public static function getOne($id) {
         $result = IntegralRecord::where("id", "=", $id)->find();
         $result["enterprise"] = EnterpriseApi::getOne($result["enterprise_id"]);
+        $result["apply_year"] = BatchApi::getOne($result["batch_id"])["batch"];
         $result["enterprise"]["streetName"] = DictApi::findDictByCode($result["enterprise"]["street"])["name"];
         if ($result) {
             $result["items"] = $result->detail;
@@ -26,11 +27,13 @@ class IntegralRecordApi {
     }
 
     public static function getList($params) {
-        $where = [];
         $order = $params["order"] ?: "desc";
         $offset = $params["offset"] ?: 0;
         $limit = $params["limit"] ?: 10;
+
+        $where = [];
         $where[] = ["e.type", "=", session("user")["type"]];
+
         if (session("user")["usertype"] == 2) {
             $where[] = ["enterprise_id", "=", session("user")["uid"]];
         }
@@ -109,31 +112,35 @@ class IntegralRecordApi {
         if ($params["name"]) {
             $where[] = ["ir.name", "like", "%" . $params["name"] . "%"];
         }
-        if ($params["checkState"]) {
-            $where[] = ["ir.checkState", "=", $params["checkState"]];
+        switch ($params["checkState"]) {
+            case 1:
+                $where[] = ["ir.checkState", "in", [IntegralState::REVERIFY_PASS, IntegralState::ZX_PASS, IntegralState::ANNOUNCED, IntegralState::ANNOUNCED_REVERIFY_PASS, IntegralState::PUBLISH_PASS]];
+                break;
+            case 2:
+                $where[] = ["ir.checkState", "in", [IntegralState::REVERIFY_FAIL, IntegralState::ZX_FAIL, IntegralState::ANNOUNCED_REVERIFY_FAIL, IntegralState::PUBLISH_FAIL]];
+                break;
         }
         $type = $params["type"];
         switch ($type) {
             case 1:
             case 2:
-                $where[] = ["ir.checkState", "=", TalentState::REVERIFY_PASS];
+                $where[] = ["ir.checkState", "=", IntegralState::REVERIFY_PASS];
                 break;
             case 3:             //公示
             case 7:             //公示预览
-                $where[] = ["ir.checkState", "=", TalentState::ZX_PASS];
+                $where[] = ["ir.checkState", "=", IntegralState::ZX_PASS];
                 break;
             case 4:             //公示通过
-                $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED];
+                $where[] = ["ir.checkState", "=", IntegralState::ANNOUNCED];
                 break;
             case 5:
             case 8:             //公布预览
-                $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
+                $where[] = ["ir.checkState", "=", IntegralState::ANNOUNCED_REVERIFY_PASS];
                 break;
             case 6:
-                $where[] = ["ir.checkState", "=", TalentState::PUBLISH_PASS];
+                $where[] = ["ir.checkState", "=", IntegralState::PUBLISH_PASS];
                 break;
         }
-        $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
         $count = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")->where($where)->count();
         $list = IntegralRecord::alias("ir")->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
                         ->where($where)
@@ -141,14 +148,18 @@ class IntegralRecordApi {
                         ->order("ir.createTime " . $order)->field("ir.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
         foreach ($list as &$item) {
             $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江市现代产业体系人才" : "集成电路优秀人才";
-            $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
         }unset($item);
         return ["total" => $count, "rows" => $list];
     }
 
     public static function getListByProcess($params) {
+        $order = $params["order"] ?: "desc";
+        $offset = $params["offset"] ?: 0;
+        $limit = $params["limit"] ?: 10;
         $process = $params["process"] ?: 1;
+
         $where = [];
+        $where[] = ["e.type", "=", session("user")["type"]];
         switch ($process) {
             case 1://初审阶段
                 switch ($params["checkState"]) {
@@ -189,10 +200,7 @@ class IntegralRecordApi {
                 }
                 break;
         }
-        $order = $params["order"] ?: "desc";
-        $offset = $params["offset"] ?: 0;
-        $limit = $params["limit"] ?: 10;
-        $where[] = ["delete", "=", 0];
+        $where[] = ["ir.delete", "=", 0];
         if ($params["apply_year"]) {
             $where[] = ["b.batch", "like", "%{$params['apply_year']}%"];
         }
@@ -213,12 +221,14 @@ class IntegralRecordApi {
         }
         $count = IntegralRecord::alias("ir")->where($where)
                 ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
                 ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
                 ->count();
         $list = IntegralRecord::alias("ir")->where($where)
                         ->leftJoin("sys_batch b", "b.id=ir.batch_id")
+                        ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
                         ->leftJoin("(select description,mainId,last_state,new_state,state,createTime from new_talent_checklog where createTime in (select max(createTime) from `new_talent_checklog` where `type`=20 and `step` is null and active=1 and typeFileId is null group by mainId,`type`)) tl", "`tl`.`mainId`=ir.id")
-                        ->field("ir.*,b.batch as apply_year,tl.state as real_state,tl.last_state,if(ir.updateTime is not null,ir.updateTime,ir.createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
+                        ->field("ir.*,e.name as enterpriseName,b.batch as apply_year,tl.state as real_state,tl.last_state,if(ir.updateTime is not null,ir.updateTime,ir.createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
         foreach ($list as $key => $item) {
             $tmp_items = [];
             foreach ($item["detail"] as $_item) {
@@ -313,6 +323,11 @@ class IntegralRecordApi {
         return $list;
     }
 
+    public static function getListByIds($ids) {
+        $where[] = ["id", "in", $ids];
+        return IntegralRecord::where($where)->select()->toArray();
+    }
+
     /**
      * 计算积分
      * @param type $enterpriseId 企业id
@@ -322,7 +337,7 @@ class IntegralRecordApi {
      * @param type $amount 达成数额
      * @return \stdClass 完整积分记录对象
      */
-    public static function calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount) {
+    public static function calIntegral($enterprise_id, $cardType, $cardNumber, $itemId, $amount) {
         $returnObj = new \stdClass();
         $returnObj->amount = $amount;
         $item = getCacheById("IntegralItem", $itemId);
@@ -451,4 +466,35 @@ class IntegralRecordApi {
         return $returnObj;
     }
 
+    public static function setPublic($mainId, $state, $msg, $batch = null) {
+        $data["id"] = $mainId;
+        $data["checkState"] = $state;
+        switch ($state) {
+            case IntegralState::ZX_PASS:
+            case IntegralState::ZX_FAIL:
+                $data["isPublic"] = 2;
+                break;
+            case IntegralState::ANNOUNCED:
+                $data["isPublic"] = 3;
+                $data["publicBatch"] = $batch;
+                break;
+            case IntegralState::ANNOUNCED_REVERIFY_PASS:
+            case IntegralState::ANNOUNCED_REVERIFY_FAIL:
+                $data["isPublic"] = 3;
+                break;
+            case IntegralState::PUBLISH_PASS:
+                $data["getTime"] = $batch;
+                $data["isPublic"] = 4;
+                break;
+            case IntegralState::PUBLISH_FAIL:
+                $data["isPublic"] = 4;
+                break;
+        }
+        if (IntegralRecord::update($data)) {
+            TalentLogApi::write(\app\common\state\ProjectState::INTEGRAL, $mainId, $state, $msg, 1);
+            return true;
+        }
+        return false;
+    }
+
 }

+ 2 - 2
app/common/state/IntegralState.php

@@ -54,7 +54,7 @@ class IntegralState {
             case 27:
                 return "公布不通过";
             case 28:
-                return "积分已账";
+                return "积分已账";
         }
     }
 
@@ -79,7 +79,7 @@ class IntegralState {
             case 27:
                 return '<span class="label label-info">公布</span>';
             case 28:
-                return '<span class="label label-inverse">发放人才码</span>';
+                return '<span class="label label-inverse">发放积分</span>';
             default:
                 return "<span class='label'>用户操作</span>";
         }

+ 4 - 3
app/enterprise/controller/Integral.php

@@ -11,6 +11,7 @@ use app\common\api\TalentLogApi;
 use app\common\state\ProjectState;
 use app\enterprise\validate\IntegralValidator;
 use think\exception\ValidateException;
+use app\common\api\BatchApi;
 
 /**
  * Description of 积分申报
@@ -167,9 +168,9 @@ class Integral extends EnterpriseController {
     private function save($info, \think\Request $request, $checkState) {
         try {
             $param = $request->param();
-            $batch = \app\common\api\BatchApi::getValidBatch(ProjectState::INTEGRAL, $this->user["type"]);
-            if (!$batch) {
-                throw new ValidateException("不在积分申报申请时间内");
+            $batch = BatchApi::checkBatchValid(["type" => ProjectState::INTEGRAL, "year" => $info["apply_year"]], $this->user["type"]);
+            if ($batch["code"] != 200) {
+                throw new ValidateException($batch["msg"]);
             }
             $data["batch_id"] = $batch["id"];
             validate(IntegralValidator::class)->check($param);

+ 2 - 2
public/static/modular/gate/integral/integral.js

@@ -99,7 +99,7 @@ Integral.initColumn = function () {
                             return "<span class='label label-danger'>公布不通过</span>";
                             break;
                         case 28:
-                            return "<span class='label label-inverse'>已发放人才码</span>";
+                            return "<span class='label label-inverse'>积分已入账</span>";
                             break;
                     }
                 }
@@ -250,7 +250,7 @@ Integral.editInfo = function () {
             Feng.error("校验失败!" + data.responseJSON.message + "!");
         });
         ajax.set("type", CONFIG.project_integral_apply);
-        ajax.set("year", Integral.seItem.year);
+        ajax.set("year", Integral.seItem.apply_year);
         ajax.start();
     }
 };

+ 20 - 15
public/static/modular/talentIdentify/integralMgr/IntegralVerify.js

@@ -244,7 +244,7 @@ IntegralVerify.showLog = function (id) {
 IntegralVerify.updateFieldsAndFiles = function () {
     if (this.check()) {
         var ajax = new $ax("/admin/integralVerify/findFieldsAndFiles?id=" + IntegralVerify.seItem.id, function (data) {
-            var obj = data.obj.obj;
+            var obj = data.obj;
             if (data.code == 200) {
                 layer.open({
                     type: 1,
@@ -259,32 +259,37 @@ IntegralVerify.updateFieldsAndFiles = function () {
                     btnAlign: 'c',
                     zIndex: layer.zIndex,
                     success: function (layero, index) {
-                        var fileList = data.obj.fileList;
-                        var html = '';
-                        for (var key in fileList) {
-                            html = html + '<ul><li style="width: 100%"><input type="checkbox" value="' + fileList[key].id + '"><span>' + fileList[key].name + '</span></li></ul>';
+                        var obj = data.obj.record;
+                        if (typeof data.obj.fieldList != "undefined" && data.obj.fieldList.length > 0) {
+                            var fieldList = data.obj.fieldList;
+                            var html1 = '';
+                            for (var key in fieldList) {
+                                html1 = html1 + '<li style="float:left;margin:0 10px 10px 0;"><input type="checkbox" value="' + fieldList[key]["key"] + '"><span>' + fieldList[key]["value"] + '</span></li>';
+                            }
                         }
-                        $("#field_file").empty().append(html);
+                        var html2 = '';
+                        html2 = html2 + '<ul><li style="width: 100%"><input type="checkbox" value="1"><span>允许修改</span></li></ul>';
+
+                        $("#field_info ul").css("overflow", "hidden").empty().append(html1);
+                        $("#field_file").css("overflow", "hidden").empty().append(html2);
+
                         if (obj.fields != null && obj.fields != '') {
                             $("#field_info input").each(function () {
-                                var arr = obj.fields.split(",");
-                                for (var key in arr) {
-                                    if ($(this).val() == arr[key]) {
+                                for (var key in obj.fields) {
+                                    if ($(this).val() == obj.fields[key]) {
                                         this.checked = true;
                                     }
                                 }
                             });
                         }
-                        if (obj.files != null && obj.files != '') {
+                        if (obj.files == 1) {
                             $("#field_file input").each(function () {
-                                if (obj.files.indexOf($(this).val()) != -1) {
-                                    this.checked = true;
-                                }
+                                this.checked = true;
                             });
                         }
                     },
                     yes: function (index, layero) {
-                        IntegralVerify.submitFieldsAndFiles(index, obj.id);
+                        IntegralVerify.submitFieldsAndFiles(index, IntegralVerify.seItem.id);
                     }
                 });
             } else {
@@ -305,7 +310,7 @@ IntegralVerify.updateFieldsAndFiles = function () {
 IntegralVerify.submitFieldsAndFiles = function (index, id) {
     var fields = '';
     var files = '';
-    $("#field_info li input").each(function (index) {
+    $("#firstCheckForm #field_info li input").each(function (index) {
         if ($(this).is(":checked")) {
             fields = fields + $(this).val() + ",";
         }

+ 10 - 10
public/static/modular/talentIdentify/integralMgr/IntegralVerify_prepare.js

@@ -76,7 +76,7 @@ IntegralInfo.initColumn = function () {
                         return "<span class='label label-success'>待发放积分</span>";
                         break;
                     case 28:
-                        return "<span class='label label-primary'>积分已账</span>";
+                        return "<span class='label label-primary'>积分已账</span>";
                         break;
                     case 13:
                         return "<span class='label label-danger'>复核失败</span>";
@@ -118,7 +118,7 @@ IntegralInfo.check = function () {
 
 
 /**
- * 打开查看人才认定-初级审核详情
+ * 打开查看积分申报-初级审核详情
  */
 IntegralInfo.openIntegralInfoDetail = function () {
     if (this.check()) {
@@ -128,7 +128,7 @@ IntegralInfo.openIntegralInfoDetail = function () {
             area: ['800px', '420px'], //宽高
             fix: false, //不固定
             maxmin: true,
-            content: Feng.ctxPath + '/admin/integralVerify/common_check/id/' + IntegralInfo.seItem.id
+            content: '/admin/integralVerify/detail/id/' + IntegralInfo.seItem.id
         });
         layer.full(index);
         IntegralInfo.layerIndex = index;
@@ -186,7 +186,7 @@ IntegralInfo.showDataCheckModal = function (type) {
             break;
         case 6:                     //待发放人才码名单
             $("#hczxButton").attr("onclick", "IntegralInfo.sendCard()").text("提交");
-            $("#exportCommonModalLabel").text("待发放人才码名单");
+            $("#exportCommonModalLabel").text("待发放积分名单");
             break;
         case 7:                     //公示名单预览
             $("#hczxButton").attr("onclick", "IntegralInfo.needPublicExport()").text("导出");
@@ -228,10 +228,10 @@ IntegralInfo.showDataCheckModal = function (type) {
                     {title: '企业名称', field: 'enterpriseName', visible: true, align: 'center', valign: 'middle', width: "40%"},
                     {title: '审核状态', field: 'checkState', visible: true, align: 'center', valign: 'middle', width: "10%",
                         formatter: function (value, row, index) {
-                            if (value == 16) {
+                            if (value == 8 || value == 22 || value == 25 || value == 27) {
                                 return "<span style='color: #ed5565;'>审核不通过</span>";
                             }
-                            if (value == 14) {
+                            if (value == 6 || value == 21 || value == 23 || value == 24 || value == 26 || value == 28) {
                                 return "<span style='color: #1ab394;'>审核通过</span>";
                             }
                         }
@@ -293,7 +293,7 @@ IntegralInfo.hczxPass = function () {
  */
 IntegralInfo.showHczxRejectModal = function () {
     if (this.check()) {
-        if (IntegralInfo.seItem.checkState != 11) {
+        if (IntegralInfo.seItem.checkState != 6) {
             Feng.info("当前记录不是待核查征信状态,无法核查");
             return;
         }
@@ -801,7 +801,7 @@ IntegralInfo.canclePublish = function () {
     }
 }
 
-//发放人才码
+//发放积分
 IntegralInfo.sendCard = function () {
     var selected = $('#dataTable').bootstrapTable('getSelections');
     if (!selected || selected.length < 1) {
@@ -822,12 +822,12 @@ IntegralInfo.sendCard = function () {
                 Feng.error(data.msg);
             }
         }, function (data) {
-            Feng.error("发放人才码失败!" + data.responseJSON.message + "!");
+            Feng.error("发放积分失败!" + data.responseJSON.message + "!");
         });
         ajax.set("ids", ids);
         ajax.start();
     }
-    Feng.confirm("一旦发放人才码无法修改,确定要发放人才码吗?", operation);
+    Feng.confirm("积分发放后无法修改,确定要发放积分吗?", operation);
 }
 
 //回调