Przeglądaj źródła

硕博生活补贴,将除电路之外的类型全部归于人社,涉及更改包括批次部分及审核部分

sugangqiang 1 rok temu
rodzic
commit
51d0d7b1e9

+ 39 - 8
app/admin/controller/LivingAllowance.php

@@ -22,7 +22,11 @@ use think\facade\Db;
 class LivingAllowance extends AdminController {
 
     public function index() {
-        $enterpriseList = EnterpriseApi::getSimpleList();
+        if ($this->user["type"] == CommonConst::ENTERPRISE_NORMAL) {
+            $enterpriseList = EnterpriseApi::getMultipleList([CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]);
+        } else {
+            $enterpriseList = EnterpriseApi::getSimpleList();
+        }
         $provinceList = \app\common\api\LocationApi::findProvinceSelect();
         $process = $this->request->param("process");
         $message = [];
@@ -140,6 +144,9 @@ class LivingAllowance extends AdminController {
             case 4:
                 break;
         }
+        if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
+            $responseObj->msg = "当前账号类型没有操作权限";
+        }
         if ($responseObj->code == 500) {
             return json($responseObj);
         }
@@ -182,6 +189,10 @@ class LivingAllowance extends AdminController {
             $responseObj->msg = "系统错误,请联系管理员";
             return json($responseObj);
         }
+        if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
+            $responseObj->msg = "当前账号类型没有操作权限";
+            return json($responseObj);
+        }
         if (!$obj["checkState"]) {
             $responseObj->msg = "请选择审核状态";
             return json($responseObj);
@@ -227,6 +238,10 @@ class LivingAllowance extends AdminController {
         $ids = trim($this->request->param("ids"));
         $msg = trim($this->request->param("msg"));
         $ids = array_filter(explode(",", $ids));
+        if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
+            $responseObj->msg = "当前账号类型没有操作权限";
+            return json($responseObj);
+        }
         if (!$ids) {
             $responseObj->msg = "请选择需要设置审核不通过的数据";
             return json($responseObj);
@@ -297,6 +312,10 @@ class LivingAllowance extends AdminController {
             $responseObj->msg = "系统错误,请联系管理员!";
             return json($responseObj);
         }
+        if (!in_array($this->user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
+            $responseObj->msg = "当前账号类型没有操作权限";
+            return json($responseObj);
+        }
         $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
         $oldState = $oldInfo["checkState"];
 
@@ -473,12 +492,16 @@ class LivingAllowance extends AdminController {
         $sex = $this->request->param("sex");
         $checkState = $this->request->param("checkState");
 
-        if (!in_array($user["type"], [1, 2])) {
+        if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
             $response->msg = "当前账号类型没有操作权限";
             return json($response);
         }
         $where = [];
-        $where[] = ["type", "=", $user["type"]];
+        if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
+            $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
+        } else {
+            $where[] = ["type", "=", $user["type"]];
+        }
         if ($name) {
             $where[] = ["name", "like", "%" . $name . "%"];
         }
@@ -527,7 +550,7 @@ class LivingAllowance extends AdminController {
 
         $request = $this->request;
         $user = $this->user;
-        if (!in_array($user["type"], [1, 2])) {
+        if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
             $response->msg = "当前账号类型没有操作权限";
             return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
         }
@@ -539,7 +562,11 @@ class LivingAllowance extends AdminController {
         $keys = array_filter(explode(",", $values)); //标题对应的字段
 
         $where = [];
-        $where[] = ["type", "=", $user["type"]];
+        if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
+            $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
+        } else {
+            $where[] = ["type", "=", $user["type"]];
+        }
         if ($_where = LivingAllowanceApi::setLivingAllowanceCheckStateCondition($request->param())) {
             $where = array_merge($where, $_where);
         }
@@ -779,7 +806,7 @@ class LivingAllowance extends AdminController {
         $response = new \stdClass();
         $response->code = 500;
         $user = $this->user;
-        if (!in_array($user["type"], [1, 2])) {
+        if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
             $response->msg = "当前账号类型没有操作权限";
             return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
         }
@@ -865,7 +892,7 @@ class LivingAllowance extends AdminController {
         $response = new \stdClass();
         $response->code = 500;
         $user = $this->user;
-        if (!in_array($user["type"], [1, 2])) {
+        if (!in_array($user["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC])) {
             $response->msg = "当前账号类型没有操作权限";
             return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
         }
@@ -873,7 +900,11 @@ class LivingAllowance extends AdminController {
         $endTime = $this->request["endTime"];
         $where = [];
         $where[] = ["publicBatch", "between", [$startTime, $endTime]];
-        $where[] = ["type", "=", $user["type"]];
+        if ($user["type"] == CommonConst::ENTERPRISE_NORMAL) {
+            $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
+        } else {
+            $where[] = ["type", "=", $user["type"]];
+        }
         $list = LaModel::where($where)->order("publicBatch")->select()->toArray();
         if (!$list) {
             $response->msg = "所选时间段内无公示数据";

+ 43 - 5
app/common/api/BatchApi.php

@@ -3,6 +3,7 @@
 namespace app\common\api;
 
 use app\common\model\Batch;
+use app\common\state\CommonConst;
 
 /**
  * Description of BatchApi
@@ -43,6 +44,9 @@ class BatchApi {
             return ["msg" => "申报类别不能为空"];
         if (!$params["batch"])
             return ["msg" => "批次不能为空"];
+        if (!in_array(session("user")["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC]) && $params["type"] == \app\common\state\ProjectState::LIVINGALLOWANCE) {
+            return ["msg" => "当前账号类型没有操作权限"];
+        }
         $where[] = ["type", "=", $params["type"]];
         $where[] = ["batch", "=", $params["batch"]];
         $where[] = ["source", "=", $params["source"]];
@@ -97,6 +101,9 @@ class BatchApi {
             return ["msg" => "申报类别不能为空"];
         if (!$params["batch"])
             return ["msg" => "批次不能为空"];
+        if (!in_array(session("user")["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC]) && $params["type"] == \app\common\state\ProjectState::LIVINGALLOWANCE) {
+            return ["msg" => "当前账号类型没有操作权限"];
+        }
         $where[] = ["type", "=", $params["type"]];
         $where[] = ["batch", "=", $params["batch"]];
         $where[] = ["source", "=", $params["source"]];
@@ -182,11 +189,21 @@ class BatchApi {
             $where[] = ["source", "=", $batch["source"]];
         }
         $where[] = ["active", "=", 1];
-        $whereRaw = sprintf("startTime between '%s'and '%s' or endTime between '%s' and '%s'", $startTime, $endTime, $startTime, $endTime);
-        $exists = Batch::where($where)->whereRaw($whereRaw)->find();
-        if ($exists)
-            return false;
-        return true;
+        //$whereRaw = sprintf("startTime between '%s'and '%s' or endTime between '%s' and '%s'", $startTime, $endTime, $startTime, $endTime);存在错误
+        //$exists = Batch::where($where)->whereRaw($whereRaw)->fetchSql(true)->find();
+        $activeList = Batch::where($where)->select()->toArray();
+        $startTime = strtotime($startTime);
+        $endTime = strtotime($endTime);
+        $allowed = true;
+        while ($active = array_shift($activeList)) {
+            $_startTime = strtotime($active["startTime"]);
+            $_endTime = strtotime($active["endTime"]);
+            if (($startTime >= $_startTime && $startTime <= $_endTime) || ($endTime >= $_startTime && $endTime <= $_endTime)) {
+                $allowed = false;
+                break;
+            }
+        }
+        return $allowed;
     }
 
     public static function setOtherNoActive($except_id) {
@@ -208,6 +225,13 @@ class BatchApi {
     public static function checkBatchValid($params, $talentType) {
         $now = time();
         $where = [];
+        if ($params["type"] == \app\common\state\ProjectState::LIVINGALLOWANCE) {
+            if ($talentType == CommonConst::ENTERPRISE_JC) {
+                $talentType = CommonConst::ENTERPRISE_JC;
+            } else {
+                $talentType = CommonConst::ENTERPRISE_NORMAL; //除电路外如果是硕博生活补贴申请,跟晋江人才同批次判断(也就是跟人社同批次)
+            }
+        }
         $where[] = ["source", "=", $talentType];
         if ($params["type"]) {
             $where[] = ["type", "=", $params["type"]];
@@ -248,6 +272,13 @@ class BatchApi {
     public static function getValidBatch($type, $talentType, $batch = "") {
         $now = date("Y-m-d H:i:s");
         $where = [];
+        if ($type == \app\common\state\ProjectState::LIVINGALLOWANCE) {
+            if ($talentType == CommonConst::ENTERPRISE_JC) {
+                $talentType = CommonConst::ENTERPRISE_JC;
+            } else {
+                $talentType = CommonConst::ENTERPRISE_NORMAL; //除电路外如果是硕博生活补贴申请,跟晋江人才同批次判断(也就是跟人社同批次)
+            }
+        }
         if ($batch) {
             $where[] = ["batch", "=", $batch];
         } else {
@@ -269,6 +300,13 @@ class BatchApi {
     public static function getValidBatchs($type, $talentType) {
         $now = date("Y-m-d H:i:s");
         $where = [];
+        if ($type == \app\common\state\ProjectState::LIVINGALLOWANCE) {
+            if ($talentType == CommonConst::ENTERPRISE_JC) {
+                $talentType = CommonConst::ENTERPRISE_JC;
+            } else {
+                $talentType = CommonConst::ENTERPRISE_NORMAL; //除电路外如果是硕博生活补贴申请,跟晋江人才同批次判断(也就是跟人社同批次)
+            }
+        }
         if ($batch) {
             $where[] = ["batch", "=", $batch];
         } else {

+ 7 - 0
app/common/api/EnterpriseApi.php

@@ -33,6 +33,13 @@ class EnterpriseApi {
         return $list = Enterprise::where($where)->order("name", 'asc')->field("name,id")->select()->toArray();
     }
 
+    public static function getMultipleList($typeList = array()) {
+        $where[] = ["active", "=", 1];
+        $where[] = ["delete", "=", 0];
+        $where[] = ['type', 'in', $typeList];
+        return $list = Enterprise::where($where)->order("name", 'asc')->field("name,id")->select()->toArray();
+    }
+
     public static function getList($request, $isExport = false) {
         $companyId = session('user')['companyId'];
         $company_info = CompanyApi::getOne($companyId);

+ 8 - 1
app/common/api/LivingAllowanceApi.php

@@ -5,6 +5,7 @@ namespace app\common\api;
 use app\common\model\LivingAllowance as LaModel;
 use app\common\state\LivingAllowanceState as LaState;
 use think\facade\Db;
+use app\common\state\CommonConst;
 
 /**
  * Description of LivingAllowanceApi
@@ -25,7 +26,13 @@ class LivingAllowanceApi {
             $where = array_merge($where, $_where);
         }
         $type = session("user")["type"];
-        $where[] = ["type", "=", $type];
+        if ($type == CommonConst::ENTERPRISE_NORMAL) {
+            $where[] = ["type", "in", [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]];
+        } else if ($type == CommonConst::ENTERPRISE_JC) {
+            $where[] = ["type", "=", $type];
+        } else {
+            $where[] = ["type", "=", "you have no power"];
+        }
         $count = laModel::where($where)->count();
         $list = laModel::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();
         $masterTypes = DictApi::selectByParentCode("un_master_education"); //申报对象类型