ShipYard.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace app\data\controller\api;
  3. use app\data\model\DataMerchants;
  4. use app\data\model\DataShipyard;
  5. use app\data\model\DataUser;
  6. use app\data\model\DataXw;
  7. use app\data\model\DataXwAd;
  8. use app\data\model\DataXwCategory;
  9. use app\data\model\SystemUser;
  10. use hg\apidoc\annotation\Param;
  11. use think\admin\Controller;
  12. use hg\apidoc\annotation\Title;
  13. use hg\apidoc\annotation\Returned;
  14. use hg\apidoc\annotation\Method;
  15. use think\db\Query;
  16. use think\Request;
  17. /**
  18. * @Title("船厂")
  19. */
  20. class ShipYard extends Auth
  21. {
  22. protected $noNeedLogin = ['index'];
  23. /**
  24. *@Title("列表")
  25. * @Param("sort",desc="1综合2距离")
  26. * @Param("keyword",desc="关键字")
  27. * @Param("longitude",desc="经度sort=2必须")
  28. * @Param("latitude",desc="维度sort=2必须")
  29. * @Returned("name",type="string",require=1,default="",desc="船厂名称")
  30. * @Returned("head_img",type="string",require=1,default="",desc="船厂头像")
  31. * @Returned("province",type="string",require=1,default="",desc="省")
  32. * @Returned("city",type="string",require=1,default="",desc="市")
  33. * @Returned("area",type="string",require=1,default="",desc="区/镇")
  34. * @Returned("address",type="string",require=1,default="",desc="详细地址")
  35. * @Returned("contact_name",type="string",require=1,default="",desc="联系人")
  36. * @Returned("contact_phone",type="string",require=1,default="",desc="联系电话")
  37. * @Returned("intro",type="string",require=1,default="",desc="船厂简介")
  38. * @Returned("longitude",type="string",require=1,default="",desc="经度")
  39. * @Returned("latitude",type="string",require=1,default="",desc="维度")
  40. * @Returned("environment_imgs",type="string",require=1,default="",desc="船厂环境,多个以英文逗号隔开")
  41. * @Returned("product_intro",type="string",require=1,default="",desc="产品简介")
  42. * @Returned("business_img",type="string",require=1,default="",desc="营业执照")
  43. * @Returned("id",type="string",require=0,default="",desc="ID")
  44. * @Returned("why",type="string",require=0,default="",desc="审核失败原因")
  45. * @Returned("audit",type="string",require=0,default="",desc="1:待审核 2:审核通过 3:审核不通过")
  46. * @Returned("audit_at",type="string",require=0,default="",desc="审核时间")
  47. * @Returned("num_staff",type="string",require=1,default="",desc="员工人数")
  48. * @Returned("pos",type="string",require=0,default="",desc="船厂位置,江南船厂什么的")
  49. * @Returned("is_fav",type="string",require=0,default="",desc="是否收藏")
  50. */
  51. public function index(Request $request,DataShipyard $shipyard){
  52. $list=$shipyard->newQuery();
  53. $list->where('audit',2);
  54. if($request['keyword']){
  55. $list->whereLike('name',"%{$request['keyword']}%");
  56. }
  57. $sort=$request['sort']?:1;
  58. if($sort==1){
  59. $list->order('id','desc');
  60. }elseif ($sort==2){
  61. $this->_vali([
  62. 'longitude.require'=>'经纬度必须',
  63. 'longitude.float'=>'经纬度有误',
  64. 'latitude.require'=>'经纬度必须',
  65. 'latitude.float'=>'经纬度有误',
  66. ],'get');
  67. $list
  68. ->field("*,st_distance(point(`longitude`,`latitude`),point({$request['longitude']},{$request['latitude']})) as distance")
  69. ->order('distance');
  70. }
  71. $record=$list->paginate($request['limit']?:15);
  72. $this->success('',$record);
  73. }
  74. /**
  75. *@Title("详情")
  76. *@Param("id",desc="ID")
  77. */
  78. public function show(Request $request,DataShipyard $shipyard){
  79. $ship = $shipyard->where('id', $request['id'])->findOrFail();
  80. if ($request['id']) {
  81. $ship['admin_id'] = SystemUser::mk()->where('usertype', 'shipyard')->where('link_id', $request['id'])->value('id');
  82. $condition = [
  83. 'id' => $request['id'],
  84. 'audit' => 2,
  85. ];
  86. $userhuanxinID = DataUser::mk()->where('id', DataShipyard::mk()->where($condition)->value('uuid'))->value('huanxinID');
  87. $ship->makeFav($this->uuid);
  88. $ship['huanxinID'] = $userhuanxinID;
  89. $this->success('', $ship);
  90. }
  91. }
  92. /**
  93. * @Title("职位列表")
  94. * @Param("shipyard_id",desc="船厂ID")
  95. * @Returned("job_name",desc="职位名称")
  96. * @Returned("salary",desc="薪资")
  97. * @Returned("salary_month",desc="薪资月数")
  98. * @Returned("job_addr",desc="工作地址")
  99. * @Returned("tags",desc="标签数组")
  100. * @Returned("com_name",desc="公司名")
  101. * @Returned("pub_user",desc="发布人")
  102. * @Returned("pub_user_avatar",desc="发布人头像")
  103. * @Returned("pub_user_job",type="string",require=0,default="",desc="发布者职位")
  104. */
  105. public function jobs(Request $request,DataShipyard $shipyard){
  106. $ship=$shipyard->where('id',$request['shipyard_id'])->findOrFail();
  107. $jobs=$ship->jobs()
  108. ->order('id','desc')
  109. ->where('state',1)
  110. ->show()
  111. ->select();
  112. $data=[];
  113. foreach ($jobs as $job){
  114. $temp=[
  115. 'id'=>$job['id'],
  116. 'job_name'=>$job['title'],
  117. 'salary'=>$job['salary_start'].'-'.$job['salary_end'],
  118. 'salary_month'=>'',
  119. 'job_addr'=>[$job['province'],$job['city']],
  120. 'tags'=>[$job['province']],
  121. 'com_name'=>$ship['name'],
  122. 'pub_user'=>$job['contact_person'],
  123. 'pub_user_avatar'=>$job['contact_headimg'],
  124. 'pub_user_job'=>$job['contact_position'],
  125. ];
  126. if(!empty($job['schooling'])){
  127. $temp['tags'][]=$job['schooling'];
  128. }else{
  129. $temp['tags'][]='学历不限';
  130. }
  131. if(!empty($job['experience'])){
  132. $temp['tags'][]=$job['experience'];
  133. }else{
  134. $temp['tags'][]='经验不限';
  135. }
  136. $data[]=$temp;
  137. }
  138. $this->success('',$data);
  139. }
  140. /**
  141. *@Title("收藏取消收藏")
  142. * @Param("shipyard_id",desc="船厂ID")
  143. * @Param("action",desc="1添加0取消收藏")
  144. */
  145. public function fav(Request $request,DataShipyard $shipyard){
  146. $ship=$shipyard->where('id',$request['shipyard_id'])->findOrFail();
  147. $this->success($request['action'] ? '收藏成功' : '取消成功',$ship->saveFav($this->uuid,$request['action']));
  148. }
  149. }