VerifyApi.php 15 KB

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