| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- namespace app\wap\controller;
- use app\admin\model\study\Plan;
- use app\admin\model\study\PlanSteps;
- use app\admin\model\study\PlanItems;
- use app\wap\model\special\Special as SpecialModel;
- use service\JsonService;
- use think\Url;
- /**商品控制器
- * Class Store
- * @package app\wap\controller
- */
- class Studyplan extends AuthController{
- /*
- * 白名单
- * */
- public static function WhiteList(){
- return [
- 'index',
- 'detail',
- ];
- }
- public function index($page = 1, $limit = 20, $op = ''){
- if ($op == 'list') {
- $model = Plan::alias('p')->where('p.is_del', 0)->page((int)$page, (int)$limit);
- $model = $model->join('PlanBuy pb', 'pb.uid = ' . $this->uid .' and pb.planid = p.id ', 'left');
- $orderList = $model->order('p.shelf_time DESC')->field('p.*, pb.id as isbuy')->select();
- $orderList = count($orderList) > 0 ? $orderList->toArray() : [];
- return JsonService::successful($orderList);
- }
- return $this->fetch();
- }
- public function details($id = 0) {
- if (!$id) $this->failed('缺少参数,无法访问', Url::build('index/index'));
- $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)->select();
- $stepids = [];
- foreach($steps as $v){
- $stepids[] = $v['id'];
- }
- $itemsList = [];
- $join = [
- ['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')
- ->join($join)
- ->where('pid', $id)
- ->where('stepsid', 'in', $stepids)
- ->select();
- foreach ($items as $v) {
- $v['count'] = SpecialModel::numberChapters($v['type'], $v['id']);
- $itemsList[$v['stepsid']][] = $v->toArray();
- }
- $this->assign('steps', json_encode($steps));
- $this->assign('itemsList', json_encode($itemsList));
- $this->assign('planinfo', json_encode($planinfo));
-
- return $this->fetch();
- }
- }
|