Răsfoiți Sursa

【Add】增加宣发链接

liuxiangxin 2 luni în urmă
părinte
comite
31da1a66cf

+ 44 - 0
app/Http/Controllers/Admin/VideoCourse.php

@@ -1,6 +1,7 @@
 <?php namespace App\Http\Controllers\Admin;
 
 use App\Facades\Servers\Aliyun\Oss;
+use App\Facades\Servers\WechatMini\Mini;
 use App\Http\Requests\Admin\Video\Course as Request;
 use App\Models\Video\Course as Model;
 use App\Models\Video\CourseType;
@@ -46,6 +47,8 @@ class VideoCourse extends Auth{
 		$list						= $Model->query()->where($map)->orderByDesc('id')->paginate(request('limit',config('page_num',10)))->appends(request()->all());
 		// 循环处理数据
 		foreach ($list as $key => $value) {
+			// 小程序链接
+			$value['mp_urllink']	= $this->getUrlLinkDetail($value['id']);
 			// 类型名称
 			$value['service_name'] 	= $CourseService->getOne($value['service_id'],'name');
 			// 类型名称
@@ -54,17 +57,58 @@ class VideoCourse extends Auth{
 			$list[$key]				= $value;
 		}
 		// 获取类型列表
+		$urlLink					= $this->getUrlLink();
 		$typeList					= $CourseType->getList();
 		$serviceList				= $CourseService->getList();
 		// 分配数据
 		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
 		$this->assign('serviceList',$serviceList);
 		$this->assign('typeList',$typeList);
+		$this->assign('urlLink',$urlLink);
 		$this->assign('list', $list);
 		// 加载模板
 		return						$this->fetch();
     }
 
+
+	/**
+	 * 获取小程序链接
+	 * 
+	 */
+	private function getUrlLink(){
+		// 结果数据
+        $link                  = cache('admin:video:index:urllink');
+        // 不存在数据
+        if ( is_null($link) ) {
+            // 从数据库获取数据
+            $link              = Mini::getUrlLink('pages/video/index');
+            // 存起来
+            cache(['admin:video:index:urllink'=>$link],$link ? now()->addDays(28) : now()->addMinutes(3));
+        }
+        // 返回结果
+        return                  $link;
+	}
+
+
+	/**
+	 * 获取小程序链接
+	 * 
+	 */
+	private function getUrlLinkDetail($id){
+		// 结果数据
+        $link                  = cache('admin:video:detail:urllink:'.$id);
+        // 不存在数据
+        if ( is_null($link) ) {
+            // 从数据库获取数据
+            $link              = Mini::getUrlLink('pages/video/detail','id='.$id);
+            // 存起来
+            cache(['admin:video:detail:urllink:'.$id=>$link],$link ? now()->addDays(28) : now()->addMinutes(3));
+        }
+        // 返回结果
+        return                  $link;
+	}
+
+
 	/**
 	 * 添加
 	 * 

+ 4 - 1
app/Http/Controllers/Api/Video/LearnRecord.php

@@ -43,8 +43,11 @@ class LearnRecord extends Api{
 		$uid 					= $this->checkLogin();
 		// 接收参数
 		$id						= request('record_id',0);
+		// 查询记录
 		$data['video_lasttime']	= (int) ceil(request('video_playtime',0));
-		$data['status']			= request('status',0);
+		// 获取记录
+		if( request('status',0) ) $data['status'] = request('status',0);
+		// 结束时间
 		$data['end_time']		= time();
 		// 查询播放记录
 		$data['id']				= $Model->edit($id,$data);

+ 3 - 0
resources/views/admin/video_course/index.blade.php

@@ -46,6 +46,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 	@csrf
 </form>
 <div class="row">
+	<div class="col-xs-12 text-center text-red">列表页宣发链接:{{$urlLink??''}}</div>
 	<div class="col-xs-12">
 		<div class="table-responsive">
 			<table class="table table-striped table-bordered table-hover">
@@ -59,6 +60,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>课程状态</th>
 						<th>课程类型</th>
 						<th>课程客服</th>
+						<th>宣发链接</th>
 						<th>修改时间</th>
 						<th>操作</th>
 					</tr>
@@ -89,6 +91,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<td> @if ($a['status'] == 0) 启用 @endif @if ($a['status'] == 1) 停用 @endif</td>
 						<td> {{$a['type_name']}}</td>
 						<td> {{$a['service_name']}}</td>
+						<td> {{$a['mp_urllink']??''}} </td>
 						<td> {{date('Y/m/d H:i',$a['update_time'])}}</td>
 						<td>
 							@if( check_auth('admin/video_course/edit') )