123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- namespace app\data\controller\api;
- use app\data\model\DataMerchants;
- use app\data\model\DataShipyard;
- use app\data\model\DataUser;
- use app\data\model\DataXw;
- use app\data\model\DataXwAd;
- use app\data\model\DataXwCategory;
- use app\data\model\SystemUser;
- use hg\apidoc\annotation\Param;
- use think\admin\Controller;
- use hg\apidoc\annotation\Title;
- use hg\apidoc\annotation\Returned;
- use hg\apidoc\annotation\Method;
- use think\db\Query;
- use think\Request;
- /**
- * @Title("船厂")
- */
- class ShipYard extends Auth
- {
- protected $noNeedLogin = ['index'];
- /**
- *@Title("列表")
- * @Param("sort",desc="1综合2距离")
- * @Param("keyword",desc="关键字")
- * @Param("longitude",desc="经度sort=2必须")
- * @Param("latitude",desc="维度sort=2必须")
- * @Returned("name",type="string",require=1,default="",desc="船厂名称")
- * @Returned("head_img",type="string",require=1,default="",desc="船厂头像")
- * @Returned("province",type="string",require=1,default="",desc="省")
- * @Returned("city",type="string",require=1,default="",desc="市")
- * @Returned("area",type="string",require=1,default="",desc="区/镇")
- * @Returned("address",type="string",require=1,default="",desc="详细地址")
- * @Returned("contact_name",type="string",require=1,default="",desc="联系人")
- * @Returned("contact_phone",type="string",require=1,default="",desc="联系电话")
- * @Returned("intro",type="string",require=1,default="",desc="船厂简介")
- * @Returned("longitude",type="string",require=1,default="",desc="经度")
- * @Returned("latitude",type="string",require=1,default="",desc="维度")
- * @Returned("environment_imgs",type="string",require=1,default="",desc="船厂环境,多个以英文逗号隔开")
- * @Returned("product_intro",type="string",require=1,default="",desc="产品简介")
- * @Returned("business_img",type="string",require=1,default="",desc="营业执照")
- * @Returned("id",type="string",require=0,default="",desc="ID")
- * @Returned("why",type="string",require=0,default="",desc="审核失败原因")
- * @Returned("audit",type="string",require=0,default="",desc="1:待审核 2:审核通过 3:审核不通过")
- * @Returned("audit_at",type="string",require=0,default="",desc="审核时间")
- * @Returned("num_staff",type="string",require=1,default="",desc="员工人数")
- * @Returned("pos",type="string",require=0,default="",desc="船厂位置,江南船厂什么的")
- * @Returned("is_fav",type="string",require=0,default="",desc="是否收藏")
- */
- public function index(Request $request,DataShipyard $shipyard){
- $list=$shipyard->newQuery();
- $list->where('audit',2);
- if($request['keyword']){
- $list->whereLike('name',"%{$request['keyword']}%");
- }
- $sort=$request['sort']?:1;
- if($sort==1){
- $list->order('id','desc');
- }elseif ($sort==2){
- $this->_vali([
- 'longitude.require'=>'经纬度必须',
- 'longitude.float'=>'经纬度有误',
- 'latitude.require'=>'经纬度必须',
- 'latitude.float'=>'经纬度有误',
- ],'get');
- $list
- ->field("*,st_distance(point(`longitude`,`latitude`),point({$request['longitude']},{$request['latitude']})) as distance")
- ->order('distance');
- }
- $record=$list->paginate($request['limit']?:15);
- $this->success('',$record);
- }
- /**
- *@Title("详情")
- *@Param("id",desc="ID")
- */
- public function show(Request $request,DataShipyard $shipyard){
- $ship = $shipyard->where('id', $request['id'])->findOrFail();
- if ($request['id']) {
- $ship['admin_id'] = SystemUser::mk()->where('usertype', 'shipyard')->where('link_id', $request['id'])->value('id');
- $condition = [
- 'id' => $request['id'],
- 'audit' => 2,
- ];
- $userhuanxinID = DataUser::mk()->where('id', DataShipyard::mk()->where($condition)->value('uuid'))->value('huanxinID');
- $ship->makeFav($this->uuid);
- $ship['huanxinID'] = $userhuanxinID;
- $this->success('', $ship);
- }
- }
- /**
- * @Title("职位列表")
- * @Param("shipyard_id",desc="船厂ID")
- * @Returned("job_name",desc="职位名称")
- * @Returned("salary",desc="薪资")
- * @Returned("salary_month",desc="薪资月数")
- * @Returned("job_addr",desc="工作地址")
- * @Returned("tags",desc="标签数组")
- * @Returned("com_name",desc="公司名")
- * @Returned("pub_user",desc="发布人")
- * @Returned("pub_user_avatar",desc="发布人头像")
- * @Returned("pub_user_job",type="string",require=0,default="",desc="发布者职位")
- */
- public function jobs(Request $request,DataShipyard $shipyard){
- $ship=$shipyard->where('id',$request['shipyard_id'])->findOrFail();
- $jobs=$ship->jobs()
- ->order('id','desc')
- ->where('state',1)
- ->show()
- ->select();
- $data=[];
- foreach ($jobs as $job){
- $temp=[
- 'id'=>$job['id'],
- 'job_name'=>$job['title'],
- 'salary'=>$job['salary_start'].'-'.$job['salary_end'],
- 'salary_month'=>'',
- 'job_addr'=>[$job['province'],$job['city']],
- 'tags'=>[$job['province']],
- 'com_name'=>$ship['name'],
- 'pub_user'=>$job['contact_person'],
- 'pub_user_avatar'=>$job['contact_headimg'],
- 'pub_user_job'=>$job['contact_position'],
- ];
- if(!empty($job['schooling'])){
- $temp['tags'][]=$job['schooling'];
- }else{
- $temp['tags'][]='学历不限';
- }
- if(!empty($job['experience'])){
- $temp['tags'][]=$job['experience'];
- }else{
- $temp['tags'][]='经验不限';
- }
- $data[]=$temp;
- }
- $this->success('',$data);
- }
- /**
- *@Title("收藏取消收藏")
- * @Param("shipyard_id",desc="船厂ID")
- * @Param("action",desc="1添加0取消收藏")
- */
- public function fav(Request $request,DataShipyard $shipyard){
- $ship=$shipyard->where('id',$request['shipyard_id'])->findOrFail();
- $this->success($request['action'] ? '收藏成功' : '取消成功',$ship->saveFav($this->uuid,$request['action']));
- }
- }
|