|  | @@ -53,26 +53,114 @@ class IntegralRecordApi {
 | 
	
		
			
				|  |  |          return ["total" => $count, "rows" => $list];
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public static function getPublicList($params) {
 | 
	
		
			
				|  |  | +        $order = $params["order"];
 | 
	
		
			
				|  |  | +        $offset = $params["offset"];
 | 
	
		
			
				|  |  | +        $limit = $params["limit"];
 | 
	
		
			
				|  |  | +        $where = [];
 | 
	
		
			
				|  |  | +        $where[] = ["e.type", "=", session("user")["type"]];
 | 
	
		
			
				|  |  | +        if ($params["name"]) {
 | 
	
		
			
				|  |  | +            $where[] = ["ir.name", "like", "%" . $params["name"] . "%"];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if ($params["checkState"]) {
 | 
	
		
			
				|  |  | +            $where[] = ["ir.checkState", "=", $params["checkState"]];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $type = $params["type"];
 | 
	
		
			
				|  |  | +        switch ($type) {
 | 
	
		
			
				|  |  | +            case 1:
 | 
	
		
			
				|  |  | +            case 2:
 | 
	
		
			
				|  |  | +                $where[] = ["ir.checkState", "=", TalentState::REVERIFY_PASS];
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 3:             //公示
 | 
	
		
			
				|  |  | +            case 7:             //公示预览
 | 
	
		
			
				|  |  | +                $where[] = ["ir.checkState", "=", TalentState::ZX_PASS];
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 4:             //公示通过
 | 
	
		
			
				|  |  | +                $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED];
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 5:
 | 
	
		
			
				|  |  | +            case 8:             //公布预览
 | 
	
		
			
				|  |  | +                $where[] = ["ir.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 6:
 | 
	
		
			
				|  |  | +                $where[] = ["ir.checkState", "=", TalentState::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)
 | 
	
		
			
				|  |  | +                        ->limit($offset, $limit)
 | 
	
		
			
				|  |  | +                        ->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) {
 | 
	
		
			
				|  |  |          $process = $params["process"] ?: 1;
 | 
	
		
			
				|  |  |          $where = [];
 | 
	
		
			
				|  |  |          switch ($process) {
 | 
	
		
			
				|  |  |              case 1://初审阶段
 | 
	
		
			
				|  |  | -                $where[] = ["checkState", "in", [IntegralState::SUBMIT, IntegralState::VERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                switch ($params["checkState"]) {
 | 
	
		
			
				|  |  | +                    case 1://待审核
 | 
	
		
			
				|  |  | +                        $where[] = ["ir.checkState", "=", IntegralState::SUBMIT];
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "=", IntegralState::SUBMIT];
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 2://驳回
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.new_state", "in", [IntegralState::SAVE]];
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "in", [IntegralState::VERIFY_REJECT]];
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 3:
 | 
	
		
			
				|  |  | +                        //审核失败
 | 
	
		
			
				|  |  | +                        $where[] = ["ir.checkState", "in", [IntegralState::VERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    default:
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "in", [IntegralState::SUBMIT, IntegralState::VERIFY_REJECT, IntegralState::VERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  break;
 | 
	
		
			
				|  |  |              case 2://复审阶段
 | 
	
		
			
				|  |  | -                $where[] = ["checkState", "in", [IntegralState::VERIFY_PASS, IntegralState::REVERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                switch ($params["checkState"]) {
 | 
	
		
			
				|  |  | +                    case 1://待审核
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "=", IntegralState::VERIFY_PASS];
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    case 3:
 | 
	
		
			
				|  |  | +                        //审核失败
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "in", [IntegralState::VERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    default:
 | 
	
		
			
				|  |  | +                        $where[] = ["tl.state", "in", [IntegralState::VERIFY_PASS, IntegralState::REVERIFY_FAIL]];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  break;
 | 
	
		
			
				|  |  |              case 3://复审后征信公示等状态
 | 
	
		
			
				|  |  | -                $where[] = ["checkState", "in", [IntegralState::REVERIFY_PASS, IntegralState::ZX_PASS, IntegralState::ZX_FAIL, IntegralState::ANNOUNCED, IntegralState::ANNOUNCED_REVERIFY_PASS, IntegralState::ANNOUNCED_REVERIFY_FAIL, IntegralState::PUBLISH_PASS, IntegralState::PUBLISH_FAIL, IntegralState::SUCCESS]];
 | 
	
		
			
				|  |  | +                if ($params["checkState"]) {
 | 
	
		
			
				|  |  | +                    $where[] = ["ir.checkState", "=", $params["checkState"]];
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $where[] = ["ir.checkState", "in", [IntegralState::REVERIFY_PASS, IntegralState::ZX_PASS, IntegralState::ZX_FAIL, IntegralState::ANNOUNCED, IntegralState::ANNOUNCED_REVERIFY_PASS, IntegralState::ANNOUNCED_REVERIFY_FAIL, IntegralState::PUBLISH_PASS, IntegralState::PUBLISH_FAIL, IntegralState::SUCCESS]];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  break;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          $order = $params["order"] ?: "desc";
 | 
	
		
			
				|  |  |          $offset = $params["offset"] ?: 0;
 | 
	
		
			
				|  |  |          $limit = $params["limit"] ?: 10;
 | 
	
		
			
				|  |  |          $where[] = ["delete", "=", 0];
 | 
	
		
			
				|  |  | -        $count = IntegralRecord::where($where)->count();
 | 
	
		
			
				|  |  | -        $list = IntegralRecord::where($where)->field("*,if(updateTime is not null,updateTime,createTime) as orderTime")->limit($offset, $limit)->order("orderTime " . $order)->select();
 | 
	
		
			
				|  |  | +        if ($params["name"]) {
 | 
	
		
			
				|  |  | +            $where[] = ["ir.name", "like", "%{$params['name']}%"];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if ($params["card_number"]) {
 | 
	
		
			
				|  |  | +            $where[] = ["ir.card_number", "like", "%{$params['card_number']}%"];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if ($params["shareholder"]) {
 | 
	
		
			
				|  |  | +            $where[] = ["ir.shareholder", "=", $params['shareholder']];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $count = IntegralRecord::alias("ir")->where($where)
 | 
	
		
			
				|  |  | +                ->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("(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.*,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) {
 | 
	
		
			
				|  |  |              $list[$key]["apply_year"] = BatchApi::getOne($item["batch_id"])["batch"];
 | 
	
		
			
				|  |  |              $tmp_items = [];
 | 
	
	
		
			
				|  | @@ -80,11 +168,11 @@ class IntegralRecordApi {
 | 
	
		
			
				|  |  |                  $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
 | 
	
		
			
				|  |  |                  $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            $list[$key]["details"] = implode(",", $tmp_items);
 | 
	
		
			
				|  |  | +            $list[$key]["details"] = implode(";", $tmp_items);
 | 
	
		
			
				|  |  |              $list[$key]["type"] = session("user")["type"];
 | 
	
		
			
				|  |  | -            $last_log = TalentLogApi::getLastLog($item["id"], \app\common\state\ProjectState::INTEGRAL);
 | 
	
		
			
				|  |  | -            $list[$key]["real_state"] = $last_log["state"];
 | 
	
		
			
				|  |  | -            $list[$key]["last_state"] = $last_log["last_state"];
 | 
	
		
			
				|  |  | +            //$last_log = TalentLogApi::getLastLog($item["id"], \app\common\state\ProjectState::INTEGRAL);
 | 
	
		
			
				|  |  | +            //$list[$key]["real_state"] = $last_log["state"];
 | 
	
		
			
				|  |  | +            //$list[$key]["last_state"] = $last_log["last_state"];
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return ["total" => $count, "rows" => $list];
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -103,6 +191,71 @@ class IntegralRecordApi {
 | 
	
		
			
				|  |  |          return $info;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 导出
 | 
	
		
			
				|  |  | +     * @param type $process
 | 
	
		
			
				|  |  | +     * @param type $params
 | 
	
		
			
				|  |  | +     * @return type
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public static function getExportDatas($process, $params) {
 | 
	
		
			
				|  |  | +        $where[] = [];
 | 
	
		
			
				|  |  | +        //特殊字段处理
 | 
	
		
			
				|  |  | +        $fields = [];
 | 
	
		
			
				|  |  | +        $fields[] = "ir.id";
 | 
	
		
			
				|  |  | +        foreach ($params as $param) {
 | 
	
		
			
				|  |  | +            if (!in_array($param, ["enterpriseName", "street", "checkMsg", "project", "year"])) {
 | 
	
		
			
				|  |  | +                $fields[] = "ir." . $param;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $fields[] = "e.name as enterpriseName";
 | 
	
		
			
				|  |  | +        $fields[] = "e.street";
 | 
	
		
			
				|  |  | +        $fields[] = "tl.description as checkMsg";
 | 
	
		
			
				|  |  | +        $fields[] = "b.batch as year";
 | 
	
		
			
				|  |  | +        if (in_array("card_type", $params)) {
 | 
	
		
			
				|  |  | +            $cardTypes = DictApi::selectByParentCode("card_type");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (in_array("street", $params)) {
 | 
	
		
			
				|  |  | +            $streets = DictApi::selectByParentCode("street");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $sex = [1 => "男", 2 => "女"];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        $where = [];
 | 
	
		
			
				|  |  | +        $where[] = ["e.type", "=", session("user")["type"]];
 | 
	
		
			
				|  |  | +        switch ($process) {
 | 
	
		
			
				|  |  | +            case 1:
 | 
	
		
			
				|  |  | +                $where = "ir.checkState in (" . IntegralState::SUBMIT . "," . IntegralState::VERIFY_FAIL . ")";
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 2:
 | 
	
		
			
				|  |  | +                $where = "ir.checkState in (" . IntegralState::VERIFY_PASS . "," . IntegralState::REVERIFY_FAIL . ")";
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +            case 3:
 | 
	
		
			
				|  |  | +                $where = "ir.checkState >= " . IntegralState::REVERIFY_PASS;
 | 
	
		
			
				|  |  | +                break;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        $list = IntegralRecord::alias("ir")
 | 
	
		
			
				|  |  | +                        ->field($fields)
 | 
	
		
			
				|  |  | +                        ->leftJoin("un_enterprise e", "e.id=ir.enterprise_id")
 | 
	
		
			
				|  |  | +                        ->leftJoin("sys_batch b", "b.id=ir.batch_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")
 | 
	
		
			
				|  |  | +                        //->leftJoin("new_talent_checklog tl", "tl.mainId=ti.id and tl.id=(select id from new_talent_checklog where mainId=ti.id and `step` is null and active=1 and typeFileId is null order by createTime desc limit 1)")
 | 
	
		
			
				|  |  | +                        ->whereRaw($where)
 | 
	
		
			
				|  |  | +                        ->select()->toArray();
 | 
	
		
			
				|  |  | +        foreach ($list as &$item) {
 | 
	
		
			
				|  |  | +            $item["card_type"] = $cardTypes[$item["card_type"]];
 | 
	
		
			
				|  |  | +            $item["street"] = $streets[$item["street"]];
 | 
	
		
			
				|  |  | +            $item["sex"] = $sex[$item["sex"]];
 | 
	
		
			
				|  |  | +            $item["checkState"] = IntegralState::getStateName($item["checkState"]);
 | 
	
		
			
				|  |  | +            $detail = \app\common\model\IntegralDetail::where("record_id", $item["id"])->select();
 | 
	
		
			
				|  |  | +            $tmp_items = [];
 | 
	
		
			
				|  |  | +            foreach ($detail as $_item) {
 | 
	
		
			
				|  |  | +                $integral_item_info = getCacheById("IntegralItem", $_item["item_id"]);
 | 
	
		
			
				|  |  | +                $tmp_items[] = sprintf("%s(%s%s)", $integral_item_info["name"], $_item["amount"], $integral_item_info["unit"]);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $item["project"] = implode(";", $tmp_items);
 | 
	
		
			
				|  |  | +        }unset($item);
 | 
	
		
			
				|  |  | +        return $list;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 计算积分
 | 
	
		
			
				|  |  |       * @param type $enterpriseId 企业id
 |