审查视图

api/index/controller/ReleaseController.php 28.4 KB
郭盛 authored
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/9/4
 * Time: 15:15
 */

namespace api\index\controller;


use cmf\controller\RestBaseController;
use think\Db;
use api\index\model\JobModel;
use think\Validate;

/**
 * @title 我的发布
 * @description
 */
class ReleaseController extends RestBaseController
{

    /**
     * @title 我的发布
     * @description 全部我的发布信息
     * @author GuoSheng
     * @url /index/Release/index
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:page type:int require:0 other: desc:当前页(默认1)
     * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
     *
     * @return id:信息ID
     * @return job_type:信息标签类型
     * @return job_title:信息标题
     * @return create_time:发布日期
     *
     */
    public function index()
    {
        $user_id = $this->getUserId();
        $page = $this->request->param('page',1,'intval');
        $pageNum = $this->request->param('pageNum',10,'intval');
        $where['delete_time'] = ['eq',0];
        $where['job_type'] = ['in',[1,2,4]];
        $where['user_id'] = ['eq',$user_id];
        $list = Db::name('job')
            ->where($where)
            ->field('id,job_type,job_title,create_time')
            ->order('create_time desc')
            ->page($page,$pageNum)
            ->select()
            ->toArray();
        foreach ($list as $k=>$v){
            $list[$k]['create_time'] = date('Y-m-d',$v['create_time']);
        }
        $this->success('SUCCESS',$list);
    }

    /**
     * @title 我发布的分类信息
     * @description 各类信息
     * @author GuoSheng
     * @url /index/Release/myType_info
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:job_type type:int require:1 other: desc:类型 (供给信息为1,需求信息为2,招商加盟为4)
     * @param name:page type:int require:0 other: desc:当前页(默认1)
     * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
     *
     * @return id:信息ID
     * @return job_type:信息标签类型
     * @return job_title:信息标题
     * @return create_time:发布日期
     * @return status:是否提交(0未提交 1已提交)
     *
     */
    public function myType_info()
    {
        $user_id = $this->getUserId();
        $page = $this->request->param('page',1,'intval');
        $pageNum = $this->request->param('pageNum',10,'intval');
        $job_type = $this->request->param('job_type');
        if(empty($job_type)){
            $this->error(['code'=>40002,'msg'=>'缺少必要参数']);
        }
        $where['delete_time'] = ['eq',0];
        $where['job_type'] = ['eq',$job_type];
        $where['user_id'] = ['eq',$user_id];
        $list = Db::name('job')
            ->where($where)
            ->field('id,job_type,job_title,city,create_time,stick')
            ->order('stick desc,create_time desc')
            ->page($page,$pageNum)
            ->select()
            ->toArray();
        foreach ($list as $k=>$v){
            $list[$k]['create_time'] = date('Y-m-d',$v['create_time']);
        }

        $this->success('SUCCESS',$list);
    }

    /**
     * @title 我的融资列表
     * @description
     * @author GuoSheng
     * @url /index/Release/finance
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:page type:int require:0 other: desc:当前页(默认1)
     * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
     *
     * @return id:信息ID
     * @return job_title:信息标题
     * @return create_time:发布日期
     *
     */
    public function finance()
    {
        $user_id = $this->getUserId();
        $page = $this->request->param('page',1,'intval');
        $pageNum = $this->request->param('pageNum',10,'intval');
        $where['delete_time'] = ['eq',0];
        $where['user_id'] = ['eq',$user_id];
        $list = Db::name('finance')
            ->where($where)
郭盛 authored
135
            ->field('id,company_name,create_time')
郭盛 authored
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
            ->order('create_time desc')
            ->page($page,$pageNum)
            ->select()
            ->toArray();
        foreach ($list as $k=>$v){
            $list[$k]['create_time'] = date('Y-m-d',$v['create_time']);
        }
        $this->success('SUCCESS',$list);
    }

    /**
     * @title 我的供给详情
     * @description 我的供给详情
     * @author GuoSheng
     * @url /index/Release/myProvide
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:供给信息ID
     *
     * @return id:信息ID
     * @return job_title:信息标题
     * @return end_time:有效日期
     * @return linkman:联系人
161
     * @return needpeople:需求人数
郭盛 authored
162 163
     * @return linkman_tel:联系人电话
     * @return city:城市
郭盛 authored
164
     * @return city_id:城市ID
郭盛 authored
165 166 167
     * @return company_name:公司名称
     * @return content:项目详情
     * @return status:是否提交(0未提交 1已提交)
郭盛 authored
168
     * @return image:详情图片
郭盛 authored
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
     */
    public function myProvide()
    {
        $user_id = $this->getUserId();
        //供给信息ID
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $where['id'] = ['eq',$id];
        $jobModel = new JobModel();
        $info = $jobModel->getOne($where);
        $data['id'] = $info['id'];
        $data['job_title'] = $info['job_title'];
        $data['end_time'] = date('Y-m-d',$info['end_time']);
        $data['linkman'] = $info['linkman'];
        $data['linkman_tel'] = $info['linkman_tel'];
186
        $data['needpeople'] = $info['needpeople'];
郭盛 authored
187
        $data['city_id'] = $info['city'];
郭盛 authored
188 189 190
        $city = explode(',',trim($info['city'],','));
        $data['city'] = Db::name('area')->whereIn('id',$city)->column('name');
        $data['company_name'] = $info['company_name'];
郭盛 authored
191
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($info['content']));
郭盛 authored
192
        $data['status'] = $info['status'];
郭盛 authored
193
        $data['image'] = $info['image'];
郭盛 authored
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 修改我的供给详情
     * @description 修改我的供给详情
     * @author GuoSheng
     * @url /index/Release/updProvide
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:供给信息ID
     * @param name:job_title type:string require:1 desc:信息标题
     * @param name:end_time type:string require:0 desc:有效日期
     * @param name:linkman type:string require:1 desc:联系人
210
     * @param name:needpeople type:int require:1 desc:需求人数
郭盛 authored
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
     * @param name:linkman_tel type:string require:1 desc:手机号码
     * @param name:city type:string require:1 desc: 城市(最多添加五个)
     * @param name:company_name type:string require:1 desc:公司名称不能为空
     * @param name:content type:text require:1 desc:项目详情
     * @param name:status type:int require:1 desc:保存为0  发布为1
     */
    public function updProvide()
    {
        $user_id = $this->getUserId();
        //供给信息ID
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $param = $this->request->param();
        $param['user_id'] = $user_id;
郭盛 authored
227
        $param['create_time'] = time();
郭盛 authored
228 229 230 231 232 233 234 235 236 237
        $param['update_time'] = time();
        if(empty($param['end_time'])){
            $param['end_time'] = $param['create_time']+7*24*60*60;
        }else{
            $param['end_time'] = strtotime($param['end_time']);
        }
        $validate = new Validate([
            'job_title' => 'require',
            'linkman' => 'require',
            'city'=>'require',
郭盛 authored
238
            'needpeople'=>'require',
郭盛 authored
239 240 241 242 243 244 245
            'linkman_tel'=>'require|number|max:11',
            'company_name'=>'require',
            'content'=>'require',
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
郭盛 authored
246 247 248 249 250 251
        $this->secCheck($param['job_title'],1);
        $this->secCheck($param['company_name'],1);
        $this->secCheck($param['content'],1);
        if(!empty($param['image'])){
            $this->secCheck($param['image'],2);
        }
郭盛 authored
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
        $data = Db::name('job')
            ->where('id',$id)
            ->update($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');
    }

    /**
     * @title 我的需求详情
     * @description 我的需求详情
     * @author GuoSheng
     * @url /index/Release/myDemand
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:需求信息ID
     *
     * @return id:信息ID
     * @return job_title:信息标题
     * @return create_time:发布日期
     * @return end_time:有效日期
     * @return linkman:联系人
     * @return linkman_tel:联系人电话
     * @return workplace:工作地点
     * @return sex:性别 (0女 1男 2不限)
     * @return needpeople:需求人数
     * @return min_age:最小年龄
     * @return max_age:最大年龄
     * @return education:最低学历
     * @return company_name:公司名称
     * @return empoying:用工单位
     * @return content:项目详情
     * @return status:是否提交(0未提交 1已提交)
郭盛 authored
288
     * @return image:详情图片
郭盛 authored
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
     */
    public function myDemand()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $where['id'] = ['eq',$id];
        $jobModel = new JobModel();
        $info = $jobModel->getOne($where);
        $data['id'] = $info['id'];
        $data['job_title'] = $info['job_title'];
        $data['end_time'] = date('Y-m-d',$info['end_time']);
        $data['linkman'] = $info['linkman'];
        $data['linkman_tel'] = $info['linkman_tel'];
        $data['workplace'] = $info['workplace'];
        $data['sex'] = $info['sex'];
郭盛 authored
307
        $data['city_id'] = $info['city'];
郭盛 authored
308 309
        $city = explode(',',trim($info['city'],','));
        $data['city'] = Db::name('area')->whereIn('id',$city)->column('name');
郭盛 authored
310 311 312 313 314 315
        $data['needpeople'] = $info['needpeople'];
        $data['min_age'] = $info['min_age'];
        $data['max_age'] = $info['max_age'];
        $data['education'] = $info['education'];
        $data['company_name'] = $info['company_name'];
        $data['empoying'] = $info['empoying'];
郭盛 authored
316
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($info['content']));
郭盛 authored
317
        $data['status'] = $info['status'];
郭盛 authored
318
        $data['image'] = $info['image'];
郭盛 authored
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 修改我的需求详情
     * @description 修改我的需求详情
     * @author GuoSheng
     * @url /index/Release/updDemand
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 desc:信息的ID
     * @param name:job_title type:string require:1 desc:信息标题
     * @param name:end_time type:string require:0 desc:有效日期
     * @param name:linkman type:string require:1 desc:联系人
     * @param name:linkman_tel type:string require:1 desc:手机号码
     * @param name:workplace type:string require:1 desc:工作地点
     * @param name:needpeople type:int require:1 desc:需求人数
     * @param name:sex type:int require:1 desc:性别 (0女 1男 2不限 )
     * @param name:min_age type:int require:0 desc:年龄(最小年龄)
     * @param name:max_age type:int require:0 desc:年龄(最大年龄)
     * @param name:education type:string require:1 desc:学历
     * @param name:company_name type:string require:1 desc:公司名称不能为空
     * @param name:empoying type:string require:1 desc:用工单位
     * @param name:content type:text require:1 desc:项目详情
     * @param name:status type:int require:1 desc:保存为0  发布为1
     */
    public function updDemand()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $param = $this->request->param();
        $param['user_id'] = $user_id;
        $param['update_time'] = time();
郭盛 authored
357
        $param['create_time'] = time();
郭盛 authored
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
        if(empty($param['end_time'])){
            $param['end_time'] = $param['create_time']+7*24*60*60;
        }else{
            $param['end_time'] = strtotime($param['end_time']);
        }
        if(empty($param['min_age'])){
            $param['min_age'] = 18;
        }
        if(empty($param['max_age'])){
            $param['max_age'] = 45;
        }
        $validate = new Validate([
            'job_title' => 'require',
            'linkman' => 'require',
            'workplace'=>'require',
            'needpeople' =>'require|number',
            'sex'=>'require|number',
            'education'=>'require',
            'company_name'=>'require',
            'empoying'=>'require',
            'content'=>'require',
            'linkman_tel'=>'require|number|max:11',
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
郭盛 authored
384 385 386 387 388 389 390 391
        $this->secCheck($param['job_title'],1);
        $this->secCheck($param['workplace'],1);
        $this->secCheck($param['company_name'],1);
        $this->secCheck($param['empoying'],1);
        $this->secCheck($param['content'],1);
        if(!empty($param['image'])){
            $this->secCheck($param['image'],2);
        }
郭盛 authored
392 393 394 395 396 397 398 399 400 401 402 403 404
        $data = Db::name('job')
            ->where('id',$id)
            ->update($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');
    }

    /**
     * @title 我的招商详情
     * @description 我的招商详情
     * @author GuoSheng
405
     * @url /index/Release/myAttract
郭盛 authored
406 407 408 409 410 411 412 413 414 415 416 417 418
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:信息ID
     * @return id:信息ID
     * @return job_title:信息标题
     * @return end_time:有效日期
     * @return linkman:联系人
     * @return linkman_tel:联系人电话
     * @return company_name:公司名称
     * @return content:项目详情
     * @return status:是否提交(0未提交 1已提交)
郭盛 authored
419
     * @return adress:公司地址
郭盛 authored
420
     * @return image:详情图片
郭盛 authored
421 422 423 424 425 426 427 428
     */
    public function myAttract()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
429
        $where['id'] = ['eq',$id];
郭盛 authored
430
        $jobModel = new JobModel();
431
        $info = $jobModel->getOne($where);
郭盛 authored
432 433 434 435 436
        $data['id'] = $info['id'];
        $data['job_title'] = $info['job_title'];
        $data['end_time'] = date('Y-m-d',$info['end_time']);
        $data['linkman'] = $info['linkman'];
        $data['linkman_tel'] = $info['linkman_tel'];
郭盛 authored
437
        $data['adress'] = $info['adress'];
郭盛 authored
438
        $data['city_id'] = $info['city'];
郭盛 authored
439 440
        $city = explode(',',trim($info['city'],','));
        $data['city'] = Db::name('area')->whereIn('id',$city)->column('name');
郭盛 authored
441
        $data['company_name'] = $info['company_name'];
郭盛 authored
442
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($info['content']));
郭盛 authored
443
        $data['status'] = $info['status'];
郭盛 authored
444
        $data['image'] = $info['image'];
郭盛 authored
445 446 447 448 449 450 451
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 修改我的招商详情
     * @description 修改我的招商详情
     * @author GuoSheng
郭盛 authored
452
     * @url /index/Release/updAttract
郭盛 authored
453 454 455 456 457 458 459 460 461 462
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:信息ID
     * @param name:job_title type:string require:1 desc:信息标题
     * @param name:end_time type:string require:0 desc:有效日期
     * @param name:linkman type:string require:1 desc:联系人
     * @param name:linkman_tel type:string require:1 desc:手机号码
     * @param name:company_name type:string require:1 desc:公司名称不能为空
郭盛 authored
463
     * @param name:adress type:string require:0 desc:地址
郭盛 authored
464 465 466 467 468 469 470 471 472 473 474 475
     * @param name:content type:text require:1 desc:项目详情
     * @param name:status type:int require:1 desc:保存为0  发布为1
     */
    public function updAttract()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $param = $this->request->param();
        $param['user_id'] = $user_id;
郭盛 authored
476
        $param['create_time'] = time();
郭盛 authored
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
        $param['update_time'] = time();
        if(empty($param['end_time'])){
            $param['end_time'] = $param['create_time']+7*24*60*60;
        }else{
            $param['end_time'] = strtotime($param['end_time']);
        }
        $validate = new Validate([
            'job_title' => 'require',
            'linkman' => 'require',
            'adress'=>'require',
            'linkman_tel'=>'require|number|max:11',
            'company_name'=>'require',
            'content'=>'require',
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
郭盛 authored
494 495 496 497 498 499 500
        $this->secCheck($param['job_title'],1);
        $this->secCheck($param['company_name'],1);
        $this->secCheck($param['adress'],1);
        $this->secCheck($param['content'],1);
        if(!empty($param['image'])){
            $this->secCheck($param['image'],2);
        }
郭盛 authored
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
        $data = Db::name('job')
            ->where('id',$id)
            ->update($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');
    }

    /**
     * @title 我的融资详情
     * @description 我的融资详情
     * @author GuoSheng
     * @url /index/Release/myFinance
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:id type:int require:1 other: desc:融资信息ID
     * @return id:信息ID
     * @return company_name:公司名称
     * @return content:公司简介
     * @return employing:用工单位
     * @return money_purpose:资金用途
     * @return linkman_tel:联系人电话
     * @return work_adress:办公地址
     * @return user_name:用户名
     * @return user_tel:电话
     * @return user_wx:微信
     * @return user_email:联系人邮箱
     * @return status:是否提交(0未提交 1已提交)
     */
    public function myFinance()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $data = Db::name('finance')
            ->where('id',$id)
            ->find();
郭盛 authored
543
        $data['employing'] = explode(',',$data['employing']);
郭盛 authored
544
        $data['content'] = cmf_replace_content_file_url(htmlspecialchars_decode($data['content']));
郭盛 authored
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
        $this->success('SUCCESS',$data);
    }

    /**
     * @title 修改我的融资详情
     * @description 修改我的融资详情
     * @author GuoSheng
     * @url /index/Release/updFinance
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:company_name type:string require:1 desc:公司名称
     * @param name:content type:text require:1 desc:公司简介
     * @param name:employing type:text require:1 desc:用工单位
郭盛 authored
560
     * @param name:money type:float require:1 desc:融资金额 (float型)
郭盛 authored
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
     * @param name:money_purpose type:string require:1 desc:资金用途
     * @param name:work_adress type:string require:1 desc:办公地址
     * @param name:user_name type:string require:1 desc:联系人
     * @param name:user_tel type:string require:1 desc:手机号码
     * @param name:user_wx type:string require:1 desc: 微信号
     * @param name:user_email type:string require:1 desc:邮箱
     * @param name:status type:int require:1 desc:保存为0 提交为1
     */
    public function updFinance()
    {
        $user_id = $this->getUserId();
        $id = $this->request->param('id',0,'intval');
        if(empty($id)){
            $this -> error(['code'=>40005,'msg'=>'缺少必要参数']);
        }
        $param = $this->request->param();
        $validate = new Validate([
            'company_name' => 'require',
            'content' => 'require',
            'employing' => 'require',
            'money'=>'require|number',
            'money_purpose'=>'require',
            'work_adress'=>'require',
            'user_name'=>'require',
            'user_tel'=>'require|number|max:11',
            'user_email'=>'require'
        ]);
        if (!$validate->check($param)) {
            $this->error(['code'=>40005,'msg'=>$validate->getError()]);
        }
        $param['user_id'] = $user_id;
        $param['update_time'] = time();
        $data = Db::name('finance')
            ->where('id',$id)
            ->update($param);
        if(empty($data)){
            $this->error(['code'=>40006,'msg'=>'sql执行失败']);
        }
        $this->success('SUCCESS');
    }

    /**
     * @title 我的收藏
     * @description 我的收藏信息
     * @author GuoSheng
     * @url /index/Release/myCollect
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
     * @param name:page type:int require:0 other: desc:当前页(默认1)
     * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
     *
     * @return id:信息ID
     * @return job_type:信息标签类型
     * @return job_title:信息标题
     * @return create_time:发布日期
     *
     */
    public function myCollect()
    {
        $user_id = $this->getUserId();
        $page = $this->request->param('page',1,'intval');
        $pageNum = $this->request->param('pageNum',10,'intval');
郭盛 authored
625
        $where['j.delete_time'] = ['eq',0];
郭盛 authored
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
        $where['c.user_id'] = ['eq',$user_id];
        $list = Db::name('collect')
            ->alias('c')
            ->field('j.id,j.job_type,job_title,j.create_time')
            ->join('job j','c.job_id = j.id')
            ->where($where)
            ->page($page,$pageNum)
            ->select()
            ->toArray();
        foreach ($list as $k=>$v){
            $list[$k]['create_time'] = date('Y-m-d',$v['create_time']);
        }
        $this->success('SUCCESS',$list);
    }

    /**
     * @title 我收藏分类信息
     * @description 我收藏各类信息
     * @author GuoSheng
     * @url /index/Release/type_info
     * @method GET
     *
     * @header name:XX-Token require:1 default: desc:token
     *
郭盛 authored
650
     * @param name:job_type type:int require:1 other: desc:类型 (供给信息为1,需求信息为2,招商加盟为4)
郭盛 authored
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666
     * @param name:page type:int require:0 other: desc:当前页(默认1)
     * @param name:pageNum type:int require:0 other: desc:每页显示数据个数(默认10)
     *
     * @return id:信息ID
     * @return job_type:信息标签类型
     * @return job_title:信息标题
     * @return create_time:发布日期
     *
     */
    public function type_info()
    {
        $user_id = $this->getUserId();
        $page = $this->request->param('page',1,'intval');
        $pageNum = $this->request->param('pageNum',10,'intval');

        $job_type = $this->request->param('job_type');
郭盛 authored
667
        $where['j.delete_time'] = ['eq',0];
郭盛 authored
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
        $where['c.user_id'] = ['eq',$user_id];
        $where['j.job_type'] = ['eq',$job_type];

        $list = Db::name('collect')
            ->alias('c')
            ->field('j.id,j.job_type,job_title,j.create_time')
            ->join('job j','c.job_id = j.id')
            ->where($where)
            ->page($page,$pageNum)
            ->select()
            ->toArray();
        foreach ($list as $k=>$v){
            $list[$k]['create_time'] = date('Y-m-d',$v['create_time']);
        }
        $this->success('SUCCESS',$list);
    }
郭盛 authored
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792


    public function get_access_token()
    {
        $app_id = config('app_id');
        $app_secret = config('app_secret');
        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$app_id.'&secret='.$app_secret;
        $res = $this->http_get($url);
        $json_arr = json_decode($res,true);
        $token = $json_arr['access_token'];
        return $token;
    }
    //curl  get请求
    public function http_get($url){
        $curl = curl_init();//启动一个CURL会话
        curl_setopt($curl, CURLOPT_URL,$url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
        curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
        curl_setopt($curl, CURLOPT_HEADER, false);//不开启header
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
        $result = curl_exec($curl); //执行操作
        curl_close($curl);
        return $result;
    }

    /**
     * 小程序内容安全审核
     * @param $content 审核内容
     * @param $type 类型(1,文本;2,图片;3,音频)
     */
    public function secCheck($content,$type = 1) {
//        if(!$type) {
//            return true;
//        }
        $access_token = $this->get_access_token();
        $basic_url = 'https://api.weixin.qq.com/wxa';
        if($type == 1) {
            $url = $basic_url.'/msg_sec_check?access_token='.$access_token;
            if(is_array($content)) {
                foreach ($content as $v) {
                    $this->setUrl($url,['content'=>$v]);
                }
            } else {
                $this->setUrl($url,['content'=>$content]);
            }
        }
        if($type == 2) {
            $url = $basic_url.'/media_check_async?access_token='.$access_token;
            if(is_array($content)) {
                foreach ($content as $v) {
                    $this->setUrl($url,['media_url'=>$v,'media_type'=>2],'图片');
                }
            } else {
                $this->setUrl($url,['media_url'=>$content,'media_type'=>2],'图片');
            }
        }
        if($type == 3) {
            $url = $basic_url.'/media_check_async?access_token='.$access_token;
            if(is_array($content)) {
                foreach ($content as $v) {
                    $this->setUrl($url,['media_url'=>$v,'media_type'=>1],'语音');
                }
            } else {
                $this->setUrl($url,['media_url'=>$content,'media_type'=>1],'语音');
            }
        }
    }
    /**
     * 调用接口审核
     * @param $url 跳转地址
     * @param $post 审核内容
     * @param $type_name
     * @param $image
     */
    private function setUrl($url,$post,$type_name = '文本') {
        $result = $this->curls($url,json_encode($post,JSON_UNESCAPED_UNICODE));
        $return_data = json_decode($result,true);
        if($return_data['errcode'] != 0) {
            $this->error($type_name.'内容含有违法违规内容');
        }
    }
    // curl方法
    function curls($url, $post = null, $header = null) {
        // 初始化
        $curl = curl_init();
        // 设置抓取的url
        curl_setopt($curl, CURLOPT_URL, $url);
        if($header) {
            // 请求头
            curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
        }
        // 设置头文件的信息作为数据流输出
        curl_setopt($curl, CURLOPT_TIMEOUT, 500);
        curl_setopt($curl, CURLINFO_HEADER_OUT, true);
        // 设置获取的信息以文件流的形式返回,而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if($post) {
            curl_setopt($curl, CURLOPT_POST, 1);
            //把POST的变量加上
            curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
        }
        // 执行命令
        $data = curl_exec($curl);
        if (curl_errno($curl)) {
            $data = curl_error($curl);
        }
        return $data;
    }
郭盛 authored
793
}