VerifyApi.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. /**
  8. * Description of VerifyApi
  9. *
  10. * @author sgq
  11. */
  12. class VerifyApi {
  13. public static function getTalentInfoById($id) {
  14. $where = [];
  15. $where[] = ["id", "=", $id];
  16. $info = Talent::findOrEmpty($id)->toArray();
  17. if ($info) {
  18. if ($info["talent_type"]) {
  19. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  20. }
  21. if ($info["nationality"]) {
  22. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  23. }
  24. if ($info["nation"]) {
  25. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  26. }
  27. if ($info["politics"]) {
  28. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  29. }
  30. if ($info["province"]) {
  31. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  32. }
  33. if ($info["city"]) {
  34. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  35. }
  36. if ($info["county"]) {
  37. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  38. }
  39. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  40. $info["enterpriseName"] = $enterprise["name"];
  41. if ($enterprise["street"]) {
  42. $info["street"] = $enterprise["street"];
  43. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  44. }
  45. if ($enterprise["industryFieldNew"]) {
  46. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  47. }
  48. if ($enterprise["enterpriseTag"]) {
  49. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  50. }
  51. if ($info["headimgurl"]) {
  52. $info["headimgurl"] = "/storage/" . $info["headimgurl"];
  53. }
  54. if ($info["talent_arrange"]) {
  55. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  56. }
  57. if ($info["import_way"]) {
  58. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  59. }
  60. if ($info["source"]) {
  61. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  62. }
  63. if ($info["source_city"]) {
  64. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  65. }
  66. if ($info["source_county"]) {
  67. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  68. }
  69. if ($info["highest_degree"]) {
  70. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  71. }
  72. if ($info["talent_condition"]) {
  73. $info["talentConditionName"] = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"])["name"];
  74. }
  75. }
  76. return $info;
  77. }
  78. public static function getOne($id) {
  79. return Talent::findOrEmpty($id);
  80. }
  81. public static function getList($request) {
  82. $where = [];
  83. $order = trim($request->param("order")) ?: "desc";
  84. $offset = trim($request->param("offset")) ?: 0;
  85. $limit = trim($request->param("limit")) ?: 10;
  86. $process = $request->param("process");
  87. switch ($process) {
  88. case 1:
  89. $where[] = ["ti.checkState", "=", 2];
  90. break;
  91. case 2:
  92. $where[] = ["ti.checkState", "=", 6];
  93. break;
  94. case 3:
  95. $where[] = ["ti.checkState", "=", 7];
  96. break;
  97. case 4:
  98. $where[] = ["ti.checkState", "=", 9];
  99. break;
  100. }
  101. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  102. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  103. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  104. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  105. foreach ($list as &$item) {
  106. $item["enterprise_name"] = $item["agentName"];
  107. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  108. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  109. }unset($item);
  110. return ["total" => $count, "rows" => $list];
  111. }
  112. }