VerifyApi.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <?php
  2. namespace app\common\api;
  3. use app\enterprise\model\Talent;
  4. use app\common\api\DictApi;
  5. use app\admin\model\Enterprise;
  6. use think\facade\Db;
  7. use app\common\model\TalentCondition;
  8. /**
  9. * Description of VerifyApi
  10. *
  11. * @author sgq
  12. */
  13. class VerifyApi {
  14. public static function getTalentInfoById($id) {
  15. $where = [];
  16. $where[] = ["id", "=", $id];
  17. $info = Talent::findOrEmpty($id)->toArray();
  18. if ($info) {
  19. if ($info["talent_type"]) {
  20. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  21. }
  22. if ($info["nationality"]) {
  23. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  24. }
  25. if ($info["nation"]) {
  26. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  27. }
  28. if ($info["politics"]) {
  29. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  30. }
  31. if ($info["province"]) {
  32. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  33. }
  34. if ($info["city"]) {
  35. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  36. }
  37. if ($info["county"]) {
  38. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  39. }
  40. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  41. $info["enterpriseName"] = $enterprise["name"];
  42. $info["enterpriseTag"] = $enterprise["enterpriseTag"];
  43. if ($enterprise["street"]) {
  44. $info["street"] = $enterprise["street"];
  45. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  46. }
  47. if ($enterprise["industryFieldNew"]) {
  48. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  49. }
  50. if ($enterprise["enterpriseTag"]) {
  51. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  52. }
  53. if ($info["headimgurl"]) {
  54. $info["headimgurl"] = "/storage/" . $info["headimgurl"];
  55. }
  56. if ($info["talent_arrange"]) {
  57. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  58. }
  59. if ($info["import_way"]) {
  60. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  61. }
  62. if ($info["source"]) {
  63. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  64. }
  65. if ($info["source_city"]) {
  66. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  67. }
  68. if ($info["source_county"]) {
  69. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  70. }
  71. if ($info["highest_degree"]) {
  72. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  73. }
  74. if ($info["talent_condition"]) {
  75. $talent_condition = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"]);
  76. $info["talentConditionName"] = $talent_condition["name"];
  77. $info["talent_arrange_category"] = $talent_condition["talentLevelCat"];
  78. $info["talentArrangeCatName"] = DictApi::selectByParentCode("talent_condition_cats")[$talent_condition["talentLevelCat"]];
  79. }
  80. }
  81. return $info;
  82. }
  83. public static function getOne($id) {
  84. return Talent::findOrEmpty($id);
  85. }
  86. public static function getDeptList($request) {
  87. $where = [];
  88. $order = trim($request->param("order")) ?: "desc";
  89. $offset = trim($request->param("offset")) ?: 0;
  90. $limit = trim($request->param("limit")) ?: 10;
  91. $where[] = ["ti.checkState", "=", 7];
  92. $where[] = ["ti.pass_dept_check", "=", 0];
  93. $companyId = session("user")["companyId"];
  94. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  95. $count = Talent::alias("ti")
  96. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  97. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  98. ->where($where)
  99. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  100. $list = Talent::alias("ti")
  101. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  102. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  103. ->where($where)
  104. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  105. ->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  106. ->limit($offset, $limit)->order("ti.createTime " . $order)
  107. ->select()->toArray();
  108. foreach ($list as &$item) {
  109. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  110. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  111. }unset($item);
  112. return ["total" => $count, "rows" => $list];
  113. }
  114. public static function getPublicList($params) {
  115. $order = $params["order"];
  116. $offset = $params["offset"];
  117. $limit = $params["limit"];
  118. $where = [];
  119. if ($params["name"]) {
  120. $where[] = ["ti.name", "like", "%" . $params["name"] . "%"];
  121. }
  122. if ($params["sex"]) {
  123. $where[] = ["ti.sex", "=", $params["sex"]];
  124. }
  125. if ($params["checkState"]) {
  126. $where[] = ["ti.checkState", "=", $params["checkState"]];
  127. }
  128. $type = $params["type"];
  129. switch ($type) {
  130. case 1:
  131. case 2:
  132. $where[] = ["ti.checkState", "=", TalentState::REVERIFY_PASS];
  133. break;
  134. case 3: //公示
  135. case 7: //公示预览
  136. $where[] = ["ti.checkState", "=", TalentState::ZX_PASS];
  137. break;
  138. case 4: //公示通过
  139. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED];
  140. break;
  141. case 5:
  142. case 8: //公布预览
  143. $where[] = ["ti.checkState", "=", TalentState::ANNOUNCED_REVERIFY_PASS];
  144. break;
  145. case 6:
  146. $where[] = ["ti.checkState", "=", TalentState::PUBLISH_PASS];
  147. break;
  148. }
  149. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  150. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  151. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  152. ->where($where)
  153. ->limit($offset, $limit)
  154. ->order("ti.createTime " . $order)->field("ti.*,e.name as enterpriseName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  155. foreach ($list as &$item) {
  156. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  157. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  158. }unset($item);
  159. return ["total" => $count, "rows" => $list];
  160. }
  161. public static function getListByIds($ids) {
  162. $where[] = ["id", "in", $ids];
  163. return Talent::where($where)->select()->toArray();
  164. }
  165. public static function getList($request) {
  166. $where = [];
  167. $order = trim($request->param("order")) ?: "desc";
  168. $offset = trim($request->param("offset")) ?: 0;
  169. $limit = trim($request->param("limit")) ?: 10;
  170. $process = $request->param("process");
  171. if ($process == 3) {
  172. return self::getDeptList($request);
  173. }
  174. if ($process == 4) {
  175. $where = sprintf("(ti.checkState in (11,12,13)) or (ti.checkState=9 and ti.pass_dept_check=0) or (ti.checkState=7 and ti.pass_dept_check=1) or (ti.checkState=7 and (tc.companyIds is null or tc.companyIds = ''))");
  176. $count = Talent::alias("ti")
  177. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  178. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  179. ->whereRaw($where)->count();
  180. $list = Talent::alias("ti")
  181. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  182. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  183. ->whereRaw($where)
  184. ->limit($offset, $limit)
  185. ->order("ti.createTime " . $order)
  186. ->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  187. ->select()->toArray();
  188. } else {
  189. switch ($process) {
  190. case 1:
  191. $where[] = ["ti.checkState", "in", [2, -1]];
  192. break;
  193. case 2:
  194. $where[] = ["ti.checkState", "in", [6, -2]];
  195. break;
  196. case 5:
  197. $where[] = ["ti.checkState", ">=", 11];
  198. break;
  199. }
  200. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  201. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  202. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  203. }
  204. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  205. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  206. foreach ($list as &$item) {
  207. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  208. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  209. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  210. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  211. $last_log = TalentLogApi::getLastLog($item["id"], 1, 0, ["step", "=", null]);
  212. $item["lastState"] = $last_log["last_state"];
  213. $item["realState"] = $last_log["state"];
  214. }unset($item);
  215. return ["total" => $count, "rows" => $list];
  216. }
  217. public static function getExportDatas($params) {
  218. $where[] = [];
  219. //特殊字段处理
  220. $fields = [];
  221. foreach ($params as $param) {
  222. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street"])) {
  223. $fields[] = "ti." . $param;
  224. }
  225. }
  226. $fields[] = "e.name as enterpriseName";
  227. $fields[] = "e.industryFieldNew";
  228. $fields[] = "e.enterpriseTag";
  229. $fields[] = "e.street";
  230. if (in_array("card_type", $params)) {
  231. $cardTypes = DictApi::selectByParentCode("card_type");
  232. }
  233. if (in_array("industryFieldNew", $params)) {
  234. $industry_fields = DictApi::selectByParentCode("industry_field");
  235. }
  236. if (in_array("enterpriseTag", $params)) {
  237. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  238. }
  239. if (in_array("street", $params)) {
  240. $streets = DictApi::selectByParentCode("street");
  241. }
  242. if (in_array("nation", $params)) {
  243. $nations = DictApi::selectByParentCode("nation");
  244. }
  245. if (in_array("nationality", $params)) {
  246. $nationalitys = DictApi::selectByParentCode("nationality");
  247. }
  248. if (in_array("politics", $params)) {
  249. $politics = DictApi::selectByParentCode("politics");
  250. }
  251. if (in_array("talent_type", $params)) {
  252. $talentTypes = DictApi::selectByParentCode("talent_type");
  253. }
  254. $sex = [1 => "男", 2 => "女"];
  255. $list = Talent::alias("ti")->field($fields)->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->select()->toArray();
  256. foreach ($list as &$item) {
  257. $item["card_type"] = $cardTypes[$item["card_type"]];
  258. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  259. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  260. $item["street"] = $streets[$item["street"]];
  261. $item["nation"] = $nations[$item["nation"]];
  262. $item["nationality"] = $nationalitys[$item["nationality"]];
  263. $item["politics"] = $politics[$item["politics"]];
  264. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  265. $item["sex"] = $sex[$item["sex"]];
  266. if (in_array("province", $params)) {
  267. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  268. }
  269. if (in_array("city", $params)) {
  270. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  271. }
  272. if (in_array("county", $params)) {
  273. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  274. }
  275. }unset($item);
  276. return $list;
  277. }
  278. public static function getListByProcess($process) {
  279. switch ($process) {
  280. case 1:
  281. $where[] = ["ti.checkState", "in", [2, -1]];
  282. break;
  283. case 2:
  284. $where[] = ["ti.checkState", "in", [6, -2]];
  285. break;
  286. default:
  287. return null;
  288. }
  289. return Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->field("ti.*,e.agentName,e.agentPhone")->select()->toArray();
  290. }
  291. public static function setPublic($mainId, $state, $msg, $batch = null, $type = 1) {
  292. $data["id"] = $mainId;
  293. $data["checkState"] = $state;
  294. switch ($state) {
  295. case TalentState::ZX_PASS:
  296. case TalentState::ZX_FAIL:
  297. $data["isPublic"] = 2;
  298. break;
  299. case TalentState::ANNOUNCED:
  300. $data["isPublic"] = 3;
  301. $data["publicBatch"] = $batch;
  302. break;
  303. case TalentState::ANNOUNCED_REVERIFY_PASS:
  304. case TalentState::ANNOUNCED_REVERIFY_FAIL:
  305. $data["isPublic"] = 3;
  306. break;
  307. case TalentState::PUBLISH_PASS:
  308. $data["isPublic"] = 4;
  309. $data["certificateGetTime"] = $batch;
  310. $data["certificateExpireTime"] = date("Y-m-d", strtotime(sprintf("%s +6 years", $batch)));
  311. break;
  312. case TalentState::PUBLISH_FAIL:
  313. $data["isPublic"] = 4;
  314. break;
  315. }
  316. if (Talent::update($data)) {
  317. TalentLogApi::write($type, $mainId, $state, $msg, 1);
  318. return true;
  319. }
  320. return false;
  321. }
  322. }