| xqd
@@ -66,17 +66,22 @@ class Studyplan extends AuthController{
|
|
|
$planinfo = Plan::get($id);
|
|
|
if (!$planinfo) $this->failed('参数错误,无法访问', Url::build('index/index'));
|
|
|
$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()->toArray();
|
|
|
$stepids = [];
|
|
|
$isPay = 0;
|
|
|
$buyinfo = PlanBuy::where('planid', $id)->where('uid', $this->uid)->where('is_del', 0)->find();
|
|
|
if ($buyinfo) {
|
|
|
$isPay = 1;
|
|
|
}
|
|
|
+ $stepsList = [];
|
|
|
+ $itemsList = [];
|
|
|
foreach($steps as $v){
|
|
|
+ $stepsList[$v['id']] = $v;
|
|
|
+ $itemsList[$v['id']] = [];
|
|
|
$stepids[] = $v['id'];
|
|
|
}
|
|
|
- $itemsList = [];
|
|
|
+
|
|
|
+
|
|
|
$join = [
|
|
|
['special s', 's.id = it.cid and s.is_del = 0 and s.status = 1']
|
|
|
];
|
| xqd
@@ -86,17 +91,65 @@ class Studyplan extends AuthController{
|
|
|
->where('stepsid', 'in', $stepids)
|
|
|
->order('sort asc')
|
|
|
->select();
|
|
|
+ //$specialids = [];
|
|
|
foreach ($items as $v) {
|
|
|
$v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
|
|
|
$itemsList[$v['stepsid']][] = $v->toArray();
|
|
|
+ //$specialids[] = $v['id'];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ //标记计划步骤是否完成学习
|
|
|
+ $isopen = 1;
|
|
|
+ foreach ($itemsList as $key => &$v) {
|
|
|
+ $isend = 1;
|
|
|
+ foreach($v as $k1 => &$v1) {
|
|
|
+ //
|
|
|
+ $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 ($v1['sort_order']) {
|
|
|
+ $order = 'sort asc, id asc';
|
|
|
+ }
|
|
|
+ $specialWatchList = SpecialSource::alias('ss')->field('ss.*, sw.viewing_time,sw.percentage')
|
|
|
+ ->join($join)
|
|
|
+ ->where('ss.special_id', '=', $v1['id'])
|
|
|
+ ->order($order)
|
|
|
+ ->select();
|
|
|
+ foreach($specialWatchList as $v2){
|
|
|
+ $v1['tasklist'][$v2['special_id']][] = $v2->toArray();
|
|
|
+ if ($v2['percentage'] < 98 && $isend == 1) $isend = 0;
|
|
|
+ }
|
|
|
+ //echo $isend . '---' . $v1['id'];
|
|
|
+ if ($isend == 1) {
|
|
|
+ //判断是否有考试
|
|
|
+ $join = [
|
|
|
+ ['ExaminationRecord er', 'er.test_id = r.relation_id and er.uid = ' . $this->uid, 'left'],
|
|
|
+ ];
|
|
|
+ $examlist = Relation::alias('r')->where('r.relationship_id', $v1['id'])->where('r.relationship', 2)
|
|
|
+ ->field('r.relation_id as test_id, er.score')->join($join)->select();
|
|
|
+ if ($examlist) {
|
|
|
+ foreach ($examlist as $item) {
|
|
|
+ if ($item['score'] < 60) {
|
|
|
+ $isend = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $stepsList[$key]['isopen'] = $isopen;
|
|
|
+ if ($isend == 0) {
|
|
|
+ $isopen = 0;
|
|
|
+ }
|
|
|
+ //$stepsList[$key]['isend'] = $isend;
|
|
|
+ }
|
|
|
+ $stepsList = array_values($stepsList);
|
|
|
//微信支付相关代码
|
|
|
$user_level = !$this->uid ? 0 : $this->userInfo;
|
|
|
$this->assign('is_member', isset($user_level['level']) ? $user_level['level'] : 0);
|
|
|
|
|
|
$this->assign('isPay', $isPay);
|
|
|
- $this->assign('steps', json_encode($steps));
|
|
|
+ $this->assign('steps', json_encode($stepsList));
|
|
|
$this->assign('itemsList', json_encode($itemsList));
|
|
|
$this->assign('planinfo', json_encode($planinfo));
|
|
|
|