<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\common\state;

/**
 * Description of CommonConst
 * 公共常量
 * @author sgq
 */
class CommonConst {

    const RSJ = "rsj";         //人社局code
    const SBJ = "sbj";         //社保局code
    const SWJ = "swj";         //税务局code
    const IC = "ic";           //集成电路code
    const ZJJ = "zjj";         //住建局
    const MZJ = "mzj";         //民政局
    const ZRZYJ = "zrzyj";     //自然资源局
    const visit = "visitGroup";     //走访核查小组
    const JYJ = "jyj";         //教育局
    const ENTERPRISE_NORMAL = 1; //通常企业
    const ENTERPRISE_JC = 2; //电路企业
    const ENTERPRISE_WJ = 5; //卫健医院
    const ENTERPRISE_GJ = 6; //高教学校

    /**
     * 晋江市优秀人才津补贴审核单位 
     */
    public static function JBTLIST() {
        return [
            self::RSJ, self::SBJ, self::SWJ
        ];
    }

    /**
     * 集成电路优秀人才津补贴审核单位 
     */
    public static function JBTICLIST() {
        return [
            self::IC, self::SBJ, self::SWJ
        ];
    }

    /**
     * 晋江市优秀人才购房补贴审核单位 
     */
    public static function HOUSELIST() {
        return [
            self::ZJJ, self::MZJ, self::ZRZYJ, self::RSJ
        ];
    }

    /**
     * 通过层次得到层次基础积分
     * @param type $level
     * @return int
     */
    public static function getLayerPointsByLayer($level) {
        $level = $level ?: 8;
        $levelAndPoints = [
            1 => 6000,
            2 => 4000,
            3 => 2000,
            4 => 1000,
            5 => 500,
            6 => 200,
            7 => 100,
            8 => 0
        ];
        return $levelAndPoints[$level];
    }

    /**
     * 通过层次得到层次名
     * @param type $level
     * @return string
     */
    public static function getLayerNameByLayer($level) {
        $level = $level ?: 8;
        $levelAndNames = [
            1 => "第一层次",
            2 => "第二层次",
            3 => "第三层次",
            4 => "第四层次",
            5 => "第五层次",
            6 => "第六层次",
            7 => "第七层次",
            8 => "非优秀人才"
        ];
        return $levelAndNames[$level];
    }

    /**
     * 通过层次得到层次名
     * @param type $level
     * @return string
     */
    public static function getTypeName($type) {
        $typeAndNames = [
            1 => "晋江市现代产业体系人才",
            2 => "晋江市集成电路产业优秀人才",
            5 => "晋江市医疗卫生人才",
            6 => "晋江市高等教育人才"
        ];
        return $typeAndNames[$type];
    }

    /**
     * 通过积分得到层次
     * @param type $points
     * @return int
     */
    public static function getLayerByPoints($points) {
        $level = 1;
        while ($levelPoints = CommonConst::getLayerPointsByLayer($level)) {
            if ($points >= $levelPoints) {
                break;
            }
            $level++;
        }
        return $level;
    }

}
