|
@@ -18,6 +18,8 @@ use app\admin\model\study\PlanSteps;
|
|
use app\admin\model\study\PlanItems;
|
|
use app\admin\model\study\PlanItems;
|
|
use app\wap\model\special\Special as SpecialModel;
|
|
use app\wap\model\special\Special as SpecialModel;
|
|
use app\wap\model\special\SpecialWatch as SpecialWatch;
|
|
use app\wap\model\special\SpecialWatch as SpecialWatch;
|
|
|
|
+use app\wap\model\special\SpecialTask;
|
|
|
|
+use app\wap\model\special\SpecialSource;
|
|
use app\wap\model\store\StoreOrder;
|
|
use app\wap\model\store\StoreOrder;
|
|
use service\JsonService;
|
|
use service\JsonService;
|
|
use think\Url;
|
|
use think\Url;
|
|
@@ -162,6 +164,10 @@ class Studyplan extends AuthController{
|
|
if (!$id) $this->failed('缺少参数,无法访问', Url::build('index/index'));
|
|
if (!$id) $this->failed('缺少参数,无法访问', Url::build('index/index'));
|
|
$planinfo = Plan::get($id);
|
|
$planinfo = Plan::get($id);
|
|
if (!$planinfo) $this->failed('参数错误,无法访问', Url::build('index/index'));
|
|
if (!$planinfo) $this->failed('参数错误,无法访问', Url::build('index/index'));
|
|
|
|
+ $buyinfo = PlanBuy::where('planid', $id)->where('uid', $this->uid)->where('is_del', 0)->find();
|
|
|
|
+ if (!$buyinfo) {
|
|
|
|
+ $this->failed('课程尚未购买,非法访问', Url::build('index/index'));
|
|
|
|
+ }
|
|
$planinfo['introduction'] = htmlspecialchars_decode($planinfo['introduction']);
|
|
$planinfo['introduction'] = htmlspecialchars_decode($planinfo['introduction']);
|
|
$steps = PlanSteps::where('is_del', 0)->where('pid', $id)->order('sort asc')->select();
|
|
$steps = PlanSteps::where('is_del', 0)->where('pid', $id)->order('sort asc')->select();
|
|
foreach($steps as $v){
|
|
foreach($steps as $v){
|
|
@@ -170,25 +176,56 @@ class Studyplan extends AuthController{
|
|
$join = [
|
|
$join = [
|
|
['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1'],
|
|
['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1'],
|
|
];
|
|
];
|
|
- $items = PlanItems::alias('it')->field('s.*, it.stepsid,it.pid')
|
|
|
|
|
|
+ $items = PlanItems::alias('it')->field('s.*, it.stepsid,it.pid, it.cid')
|
|
->join($join)
|
|
->join($join)
|
|
->where('pid', $id)
|
|
->where('pid', $id)
|
|
->where('stepsid', 'in', $stepids)
|
|
->where('stepsid', 'in', $stepids)
|
|
->order('sort asc')
|
|
->order('sort asc')
|
|
->select();
|
|
->select();
|
|
- $spids = [];
|
|
|
|
|
|
+ //$spids = [];
|
|
|
|
+ $itemsList = [];
|
|
|
|
+ $tasklist = [];
|
|
foreach ($items as $v) {
|
|
foreach ($items as $v) {
|
|
$v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
|
|
$v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
|
|
$itemsList[$v['stepsid']][] = $v->toArray();
|
|
$itemsList[$v['stepsid']][] = $v->toArray();
|
|
- $spids[] = $v['pid'];
|
|
|
|
|
|
+ //$spids[] = $v['cid'];
|
|
|
|
+ $join = [
|
|
|
|
+ ['SpecialWatch sw', 'sw.special_id = ss.special_id and sw.task_id = ss.source_id and sw.uid = ' . $this->uid, 'left'],
|
|
|
|
+ ];
|
|
|
|
+ $order = 'sort desc,id desc';
|
|
|
|
+ if ($v['sort_order']) {
|
|
|
|
+ $order = 'sort asc, id asc';
|
|
|
|
+ }
|
|
|
|
+ $specialWatchList = SpecialSource::alias('ss')->field('ss.*, sw.viewing_time,sw.percentage')
|
|
|
|
+ ->join($join)
|
|
|
|
+ ->where('ss.special_id', '=', $v['cid'])
|
|
|
|
+ ->order($order)
|
|
|
|
+ ->select();
|
|
|
|
+ foreach($specialWatchList as $v){
|
|
|
|
+ $tasklist[$v['special_id']][$v['source_id']] = $v->toArray();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- $buyinfo = PlanBuy::where('planid', $id)->where('uid', $this->uid)->where('is_del', 0)->find();
|
|
|
|
- if (!$buyinfo) {
|
|
|
|
- $this->failed('课程尚未购买,非法访问', Url::build('index/index'));
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $nowspid = 0;
|
|
|
|
+ $nowtaskid = 0;
|
|
|
|
+ $viewing_time= 0;
|
|
|
|
+ foreach ($itemsList as $v) {
|
|
|
|
+ foreach ($v as $v1) {
|
|
|
|
+ if ($tasklist[$v1['id']] && is_array($tasklist[$v1['id']])) {
|
|
|
|
+ foreach ($tasklist[$v1['id']] as $v2) {
|
|
|
|
+ if ($v2['percentage'] < 100) {
|
|
|
|
+ $nowspid = $v1['id'];
|
|
|
|
+ $nowtaskid = $v2['source_id'];
|
|
|
|
+ $viewing_time = $v2['viewing_time'];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- $spids = array_unique($spids);
|
|
|
|
- $specialWatchList = SpecialWatch::where('special_id', 'in', $spids)->where('uid', $this->uid)->group('special_id')->order('add_time desc')->select();
|
|
|
|
- print_r($specialWatchList);
|
|
|
|
|
|
+ //id=206&specialId=37&viewing_time=0
|
|
|
|
+ $this->redirect('wap/special/task_info', ['id' => $nowtaskid, 'specialId' => $nowspid, 'viewing_time' => $viewing_time, 'planid' => $id, ]);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|