| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 | <?phpnamespace app\enterprise\api;use app\enterprise\model\Talent;use app\common\api\DictApi;use app\common\api\TalentConditionApi;use app\common\api\TalentLogApi;use app\common\api\TalentState;/** * Description of TalentApi * * @author sgq */class TalentApi {    /**     * 判断是否可以编辑     * @param type $id     * @return boolean     */    public static function checkIsEditable($id) {        $info = Talent::findOrEmpty($id);        if (!$info || !in_array($info["checkState"], [0, 1, 3, 5]))            return false;        return true;    }    static public function chkIsOwner($id, $uid) {        $info = self::getOne($id);        if ($info["enterprise_id"] != $uid)            return null;        return $info;    }    public static function getOne($id) {        $one = Talent::findOrEmpty($id);        if ($one["headimgurl"]) {            $one["headimgurl"] = getStoragePath($one["headimgurl"]);        }        return $one;    }    public static function getList($request, $step = 0) {        $order = trim($request->param("order")) ?: "desc";        $offset = trim($request->param("offset")) ?: 0;        $limit = trim($request->param("limit")) ?: 10;        $name = trim($request->param("name"));        $idCard = trim($request->param("card_number"));        $sex = trim($request->param("sex"));        $nation = trim($request->param("nation"));        $nationality = trim($request->param("nationality"));        $talentArrange = trim($request->param("talent_arrange"));        $checkState = trim($request->param("checkState"));        $type = session("user")["type"];        $where = [];        $where[] = ["delete", "=", 0];        if (session("user")["usertype"] == 2) {            $where[] = ["enterprise_id", "=", session("user")["uid"]];        }        if ($step) {            switch ($step) {                case 1:                    $where[] = ["checkState", "in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];                    switch ($checkState) {                        case -1:                            $where[] = ["checkState", "=", TalentState::BASE_VERIFY_FAIL];                            break;                        case 1:                            $where[] = ["checkState", "=", TalentState::FST_SAVE];                            break;                        case 2:                            $where[] = ["checkState", "=", TalentState::BASE_REJECT];                            break;                        case 3:                            $where[] = ["checkState", "=", TalentState::FST_SUBMIT];                            break;                    }                    break;                case 2:                    $where[] = ["checkState", "not in", [TalentState::FST_SAVE, TalentState::BASE_REJECT, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_FAIL]];                    switch ($checkState) {                        case -1:                            $where[] = ["checkState", "in", [TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL]];                            break;                        case 1:                            $where[] = ["checkState", "=", TalentState::SCND_SAVE];                            break;                        case 2:                            $where[] = ["checkState", "in", [TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT]];                            break;                        case 3:                            $where[] = ["checkState", "in", [TalentState::SCND_SUBMIT, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::ZX_PASS,                                    TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS]];                            break;                        case 4:                            $where[] = ["checkState", "=", TalentState::CERTIFICATED];                            break;                    }            }            if ($name) {                $where[] = ["name", "like", "%" . $name . "%"];            }            if ($idCard) {                $where[] = ["card_number", "like", "%" . $idCard . "%"];            }            if ($sex) {                $where[] = ["sex", "=", $sex];            }            if ($nation) {                $where[] = ["nation", "=", $nation];            }            if ($nationality) {                $where[] = ["nationality", "=", $nationality];            }            if ($talentArrange) {                $where[] = ["talent_arrange", "=", $talentArrange];            }            $count = Talent::where($where)->count();            $list = Talent::where($where)->limit($offset, $limit)->order("createTime " . $order)->select()->toArray();            $talentTagList = DictApi::selectByParentCode("enterprise_tag"); //单位标签            $talentArangeList = DictApi::selectByParentCode("talent_arrange"); //人才层次            $industries = DictApi::selectByParentCode("industry_field"); //产业            $enterprise = \app\common\model\Enterprise::find(session("user")["uid"]);            foreach ($list as $key => $item) {                $condition = TalentConditionApi::getOne($item["talent_condition"]);                $list[$key]["talentArrangeName"] = isset($talentArangeList[$item["talent_arrange"]]) ? $talentArangeList[$item["talent_arrange"]] : "";                $list[$key]["identifyConditionText"] = $condition["name"];                $list[$key]["companyIds"] = $condition["companyIds"];                $list[$key]["type"] = $enterprise["type"];                $list[$key]["enterpriseName"] = $enterprise["name"];                $list[$key]["industryName"] = $industries[$enterprise["industryFieldNew"]];                $list[$key]["enterpriseTagName"] = $talentTagList[$enterprise["enterpriseTag"]];                $last_log = TalentLogApi::getLastLog($item["id"], 1);                $list[$key]["real_state"] = $last_log["state"];                $list[$key]["last_state"] = $last_log["last_state"];            }            return ["total" => $count, "rows" => $list];        }    }}
 |