作者 何书鹏

PC二开

@@ -16,7 +16,7 @@ use think\Validate; @@ -16,7 +16,7 @@ use think\Validate;
16 */ 16 */
17 class Lists extends Api 17 class Lists extends Api
18 { 18 {
19 - protected $noNeedLogin = ['get_list','type_title','type_list','ke_list','index','policy','download','index_info','policy_info','video_list','video_detail','study','password_login','find_pwd','ke_list_detail','getcode','verify']; 19 + protected $noNeedLogin = ['get_list','type_title','type_list','ke_list','index','policy','download','index_info','policy_info','download_info','video_list','video_detail','study','password_login','find_pwd','ke_list_detail','getcode','verify'];
20 protected $noNeedRight = ['*']; 20 protected $noNeedRight = ['*'];
21 21
22 /** 22 /**
@@ -375,6 +375,58 @@ class Lists extends Api @@ -375,6 +375,58 @@ class Lists extends Api
375 } 375 }
376 376
377 /** 377 /**
  378 + * @ApiTitle (下载专区详情)
  379 + * @ApiSummary (下载专区详情)
  380 + * @ApiMethod (POST)
  381 + * @ApiRoute (/api/lists/download_info)
  382 + *
  383 + * @ApiParams (name="id", type="int", required=true, description="下载专区ID")
  384 + *
  385 + * @ApiReturn({
  386 + "code": 1,
  387 + "msg": "成功",
  388 + "time": "1571492001",
  389 + "data": {
  390 + "id"://ID
  391 + "title"://标题
  392 + "from"://转载于
  393 + "content"://内容详情
  394 + "file_name"://附件名称
  395 + "file"://附件
  396 + "is_up"://是否上架0否1是
  397 + "createtime"://创建时间
  398 + }
  399 + })
  400 + */
  401 + public function download_info()
  402 + {
  403 + $qiniu = get_addon_config('qiniu')['cdnurl'];
  404 + $id = $this->request->param('id');
  405 + if(empty($id)){
  406 + $this->error('缺少必要参数');
  407 + }
  408 + $data = Db::name('download')
  409 + ->where('id',$id)
  410 + ->field('updatetime',true)
  411 + ->find();
  412 + if(!empty($data['file'])){
  413 + $base_url = $data['file'];
  414 + $qiniu_url = $qiniu.$data['file'];
  415 + $a = file_get_contents($qiniu_url);
  416 + $path = './uploads/'.explode('/',$base_url)[2].'/';
  417 + if(!file_exists($path)) {
  418 + mkdir($path,0777,true);
  419 + }
  420 + file_put_contents('.'.$base_url,$a);
  421 + $data['file'] = request()->domain().$base_url;
  422 + }else{
  423 + $data['file'] = '';
  424 + }
  425 + $data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
  426 + $this->success('success',$data);
  427 + }
  428 +
  429 + /**
378 * @ApiTitle (优选课程列表) 430 * @ApiTitle (优选课程列表)
379 * @ApiSummary (优选课程列表) 431 * @ApiSummary (优选课程列表)
380 * @ApiMethod (POST) 432 * @ApiMethod (POST)
@@ -682,7 +682,7 @@ class User extends Api @@ -682,7 +682,7 @@ class User extends Api
682 $path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf'; 682 $path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
683 $year = date('Y'); 683 $year = date('Y');
684 //证书编号 684 //证书编号
685 - $text = 'TJAG'.$year.$data['studynum']; 685 + $text = 'TJAG'.$year.$data['studynum'].$id;
686 //培训单位盖章 686 //培训单位盖章
687 $text1 = '培训单位盖章'; 687 $text1 = '培训单位盖章';
688 688
@@ -704,6 +704,9 @@ class User extends Api @@ -704,6 +704,9 @@ class User extends Api
704 $image->text($text1,$path_ttf,30,'#000000',[1188,772]); 704 $image->text($text1,$path_ttf,30,'#000000',[1188,772]);
705 $image->save(ROOT_PATH . 'public' . DS . 'uploads' . DS . $file_path,'png',100); 705 $image->save(ROOT_PATH . 'public' . DS . 'uploads' . DS . $file_path,'png',100);
706 706
  707 + // 将编号存入数据库
  708 + Db::name('third_exam')->where('id',$id)->update(['certificate_sn'=>$text]);
  709 +
707 $answer['qrcodeurl'] = request()->domain().'/uploads/'.$id.'.png'; 710 $answer['qrcodeurl'] = request()->domain().'/uploads/'.$id.'.png';
708 $answer['score'] = $data['score']; 711 $answer['score'] = $data['score'];
709 $this->success('success',$answer); 712 $this->success('success',$answer);