123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <?php
- namespace app\common\api;
- use app\enterprise\model\Talent;
- use app\common\api\DictApi;
- use app\admin\model\Enterprise;
- use think\facade\Db;
- use app\common\model\TalentCondition;
- /**
- * Description of VerifyApi
- *
- * @author sgq
- */
- class VerifyApi {
- public static function getTalentInfoById($id) {
- $where = [];
- $where[] = ["id", "=", $id];
- $info = Talent::findOrEmpty($id)->toArray();
- if ($info) {
- if ($info["talent_type"]) {
- $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
- }
- if ($info["nationality"]) {
- $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
- }
- if ($info["nation"]) {
- $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
- }
- if ($info["politics"]) {
- $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
- }
- if ($info["province"]) {
- $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
- }
- if ($info["city"]) {
- $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
- }
- if ($info["county"]) {
- $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
- }
- $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
- $info["enterpriseName"] = $enterprise["name"];
- if ($enterprise["street"]) {
- $info["street"] = $enterprise["street"];
- $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
- }
- if ($enterprise["industryFieldNew"]) {
- $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
- }
- if ($enterprise["enterpriseTag"]) {
- $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
- }
- if ($info["headimgurl"]) {
- $info["headimgurl"] = "/storage/" . $info["headimgurl"];
- }
- if ($info["talent_arrange"]) {
- $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
- }
- if ($info["import_way"]) {
- $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
- }
- if ($info["source"]) {
- $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
- }
- if ($info["source_city"]) {
- $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
- }
- if ($info["source_county"]) {
- $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
- }
- if ($info["highest_degree"]) {
- $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
- }
- if ($info["talent_condition"]) {
- $info["talentConditionName"] = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"])["name"];
- }
- }
- return $info;
- }
- public static function getOne($id) {
- return Talent::findOrEmpty($id);
- }
- public static function getDeptList($request) {
- $where = [];
- $order = trim($request->param("order")) ?: "desc";
- $offset = trim($request->param("offset")) ?: 0;
- $limit = trim($request->param("limit")) ?: 10;
- $process = $request->param("process");
- switch ($process) {
- case 1:
- $where[] = ["ti.checkState", "=", 2];
- break;
- case 2:
- $where[] = ["ti.checkState", "=", 6];
- break;
- case 3:
- $where[] = ["ti.checkState", "=", 7];
- break;
- case 4:
- $where[] = ["ti.checkState", "=", 9];
- break;
- }
- $companyId = session("user")["companyId"];
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $count = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
- ->where($where)
- ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
- $list = Talent::alias("ti")
- ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
- ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
- ->where($where)
- ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
- ->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")
- ->limit($offset, $limit)->order("ti.createTime " . $order)
- ->select()->toArray();
- foreach ($list as &$item) {
- $item["enterprise_name"] = $item["agentName"];
- $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 getPublicList($params) {
- $type = $params["type"];
- $where = [];
- switch ($type) {
- case 1:
- case 2:
- $where[] = ["isPublic", 1];
- $where[] = ["checkState", 11];
- break;
- case 3: //公示
- case 7: //公示预览
- $where[] = ["isPublic", 2];
- $where[] = ["checkState", 11];
- break;
- case 4:
- $where[] = ["isPublic", 3];
- $where[] = ["checkState", 11];
- break;
- case 5:
- case 8: //公布预览
- $where[] = ["isPublic", 4];
- $where[] = ["checkState", 11];
- break;
- case 6:
- $where[] = ["isPublic", 5];
- $where[] = ["checkState", 11];
- break;
- }
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
- $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
- ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
- foreach ($list as &$item) {
- $item["enterprise_name"] = $item["agentName"];
- $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 getList($request) {
- $where = [];
- $order = trim($request->param("order")) ?: "desc";
- $offset = trim($request->param("offset")) ?: 0;
- $limit = trim($request->param("limit")) ?: 10;
- $process = $request->param("process");
- if ($process == 3) {
- return self::getDeptList($request);
- }
- switch ($process) {
- case 1:
- $where[] = ["ti.checkState", "=", 2];
- break;
- case 2:
- $where[] = ["ti.checkState", "=", 6];
- break;
- case 3:
- $where[] = ["ti.checkState", "=", 7];
- break;
- case 4:
- $where[] = ["ti.checkState", "=", 9];
- break;
- case 5:
- $where[] = ["ti.checkState", "=", 11];
- break;
- }
- $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
- $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
- $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
- $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
- ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
- foreach ($list as &$item) {
- $item["enterprise_name"] = $item["agentName"];
- $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
- $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
- $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
- $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
- }unset($item);
- return ["total" => $count, "rows" => $list];
- }
- public static function getExportDatas($params) {
- $where[] = [];
- //特殊字段处理
- $fields = [];
- foreach ($params as $param) {
- if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street"])) {
- $fields[] = "ti." . $param;
- }
- }
- $fields[] = "e.name as enterpriseName";
- $fields[] = "e.industryFieldNew";
- $fields[] = "e.enterpriseTag";
- $fields[] = "e.street";
- if (in_array("card_type", $params)) {
- $cardTypes = DictApi::selectByParentCode("card_type");
- }
- if (in_array("industryFieldNew", $params)) {
- $industry_fields = DictApi::selectByParentCode("industry_field");
- }
- if (in_array("enterpriseTag", $params)) {
- $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
- }
- if (in_array("street", $params)) {
- $streets = DictApi::selectByParentCode("street");
- }
- if (in_array("nation", $params)) {
- $nations = DictApi::selectByParentCode("nation");
- }
- if (in_array("nationality", $params)) {
- $nationalitys = DictApi::selectByParentCode("nationality");
- }
- if (in_array("politics", $params)) {
- $politics = DictApi::selectByParentCode("politics");
- }
- if (in_array("talent_type", $params)) {
- $talentTypes = DictApi::selectByParentCode("talent_type");
- }
- $sex = [1 => "男", 2 => "女"];
- $list = Talent::alias("ti")->field($fields)->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->select()->toArray();
- foreach ($list as &$item) {
- $item["card_type"] = $cardTypes[$item["card_type"]];
- $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
- $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
- $item["street"] = $streets[$item["street"]];
- $item["nation"] = $nations[$item["nation"]];
- $item["nationality"] = $nationalitys[$item["nationality"]];
- $item["politics"] = $politics[$item["politics"]];
- $item["talent_type"] = $talentTypes[$item["talent_type"]];
- $item["sex"] = $sex[$item["sex"]];
- if (in_array("province", $params)) {
- $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
- }
- if (in_array("city", $params)) {
- $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
- }
- if (in_array("county", $params)) {
- $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
- }
- }unset($item);
- return $list;
- }
- }
|