| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 | <?phpnamespace app\common\api;use app\common\model\TalentLog;/** * Description of TalentLogApi * * @author sgq */class TalentLogApi {    public static function getList($type, $mainId, $active = 1) {        $where[] = ["type", "=", $type];        $where[] = ["mainId", "=", $mainId];        $where[] = ["active", "=", $active];        $whr[] = ["step", "=", 3];        $whr[] = ["type", "=", $type];        $whr[] = ["mainId", "=", $mainId];        return $list = TalentLog::whereOr([$where, $whr])->order("createTime desc")->select()->toArray();    }    public static function getPassDepts($mainId) {        $where[] = ["type", "=", 1];        $where[] = ["mainId", "=", $mainId];        $where[] = ["active", "=", 1];        $where[] = ["step", "=", 3];        $where[] = ["new_state", "=", 9];        return TalentLog::where($where)->column("companyId");    }    public static function getLastLog($mainId, $type, $companyId = 0, $extra_where = []) {        $where = [];        $where[] = ["mainId", "=", $mainId];        $where[] = ["type", "=", $type];        $where[] = ["typeFileId", "null"];        if ($companyId) {            $where[] = ["companyId", "=", $companyId];        }        if ($extra_where) {            $where[] = $extra_where;        }        $last_log = TalentLog::where($where)->order("createTime desc")->findOrEmpty()->toArray();        return $last_log;    }    public static function getLogByCompanyId($mainId, $companyId, $fst_dept_check_time) {        $where = [];        $where[] = ["mainId", "=", $mainId];        $where[] = ["companyId", "=", $companyId];        $where[] = ["createTime", ">=", $fst_dept_check_time];        $one = TalentLog::where($where)->findOrEmpty();        return $one;    }    public static function getListLogByTime($id, $time, $type = 1) {        $where = [];        $where[] = ["mainId", "=", $id];        $where[] = ["type", "=", $type];        $where[] = ["createTime", ">=", $time];        $where[] = ["typeFileId", "null"];        $list = TalentLog::where($where)->order("createTime desc")->select()->toArray();        return $list;    }    public static function writeDeptLogs($mainId, $companyIds, $state = []) {        $user = session("user");        $last_log = self::getLastLog($mainId, 1);        for ($i = 0; $i < count($companyIds); $i++) {            $log["last_state"] = $last_log["state"] ?: 0;            $log["id"] = getStringId();            if (is_array($state)) {                $log["state"] = $state[0];                $log["new_state"] = $state[1];            } else {                $log["state"] = $log["new_state"] = $state;            }            $log["type"] = 1;            $log["mainId"] = $mainId;            $log["companyId"] = $companyIds[$i];            $log["description"] = "等待部门审核";            $log["step"] = 3; //部门审核阶段            $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);            $log["createTime"] = date("Y-m-d H:i:s");            TalentLog::create($log);        }    }    public static function write($type, $mainId, $state = [], $description = "", $active = 0, $fileType = null, $fileId = null) {        $user = session("user");        $last_log = self::getLastLog($mainId, $type);        $log["last_state"] = $last_log["state"] ?: 0;        $log["id"] = getStringId();        if (is_array($state)) {            $log["state"] = $state[0];            $log["new_state"] = $state[1];            if ($state[2]) {                $log["step"] = $state[2];            }        } else {            $log["state"] = $log["new_state"] = $state;        }        $log["type"] = $type;        $log["mainId"] = $mainId;        $log["typeFileId"] = $fileType;        $log["fileId"] = $fileId;        $log["companyId"] = $user["companyId"];        $log["active"] = $active;        $log["description"] = $description;        $log["createUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);        $log["createTime"] = date("Y-m-d H:i:s");        return TalentLog::create($log);    }    public static function rewrite($id, $state = [], $description = "", $active = 0) {        $user = session("user");        if (is_array($state)) {            $log["state"] = $state[0];            $log["new_state"] = $state[1];        } else {            $log["state"] = $log["new_state"] = $state;        }        $log["id"] = $id;        $log["companyId"] = $user["companyId"];        $log["active"] = $active;        $log["description"] = $description;        $log["updateUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);        $log["updateTime"] = date("Y-m-d H:i:s");        return TalentLog::update($log);    }    public static function setActive($id, $value) {        $user = session("user");        $data["id"] = $id;        $data["active"] = $value;        $data["updateUser"] = sprintf("%s(%s)", $user["account"], $user["companyName"] ?: $user["rolename"]);        $data["updateTime"] = date("Y-m-d H:i:s");        return TalentLog::update($data);    }}
 |