Browse Source

各处不允许删除,试课作为约课的一个资格

lizhen_gitee 1 year ago
parent
commit
fd2e3d3dea

+ 1 - 0
application/admin/controller/Lessonslot.php

@@ -25,6 +25,7 @@ class Lessonslot extends Backend
         $this->model = new \app\admin\model\Lessonslot;
         $this->view->assign("statusList", $this->model->getStatusList());
         $this->view->assign("noticeStatusList", $this->model->getNoticeStatusList());
+        $this->view->assign("isShowList", $this->model->getIsShowList());
     }
 
 

+ 3 - 0
application/admin/lang/en/lessonslot.php

@@ -21,6 +21,9 @@ return [
     'Finishtime'      => 'Signed time',
     'Cancel_reason'   => 'Cancel reason',
     'Cancel_time'     => 'Cancel time',
+    'Is_show'       => 'show or not',
+    'Is_show 1'     => 'show',
+    'Is_show 0'     => 'not show',
     'Coach.nickname'  => 'Coach nickname',
     'Lesson.name'     => 'Lesson name',
     'Lesson.name_en'  => 'Lesson name(en)'

+ 3 - 0
application/admin/lang/zh-cn/lessonslot.php

@@ -21,6 +21,9 @@ return [
     'Finishtime'      => '点名时间',
     'Cancel_reason'   => '取消原因',
     'Cancel_time'     => '取消时间',
+    'Is_show'       => '是否显示',
+    'Is_show 1'     => '上架',
+    'Is_show 0'     => '下架',
     'Coach.nickname'  => '教练昵称',
     'Lesson.name'     => '课程标题',
     'Lesson.name_en'  => '课程标题(en)'

+ 14 - 1
application/admin/model/Lessonslot.php

@@ -30,7 +30,8 @@ class Lessonslot extends Model
         'status_text',
         'notice_status_text',
         'finishtime_text',
-        'cancel_time_text'
+        'cancel_time_text',
+        'is_show_text'
     ];
     
 
@@ -45,6 +46,11 @@ class Lessonslot extends Model
         return ['0' => __('Notice_status 0'), '1' => __('Notice_status 1')];
     }
 
+    public function getIsShowList()
+    {
+        return ['1' => __('Is_show 1'), '0' => __('Is_show 0')];
+    }
+
 
     public function getStarttimeTextAttr($value, $data)
     {
@@ -109,6 +115,13 @@ class Lessonslot extends Model
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
     }
 
+    public function getIsShowTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_show']) ? $data['is_show'] : '');
+        $list = $this->getIsShowList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
 
     public function coach()
     {

+ 12 - 0
application/admin/view/lessonslot/add.html

@@ -66,6 +66,18 @@
             <input id="c-remark" class="form-control" name="row[remark]" type="text" value="">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_show')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <select  id="c-is_show" data-rule="required" class="form-control selectpicker" name="row[is_show]">
+                {foreach name="isShowList" item="vo"}
+                <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Notice_status')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 12 - 0
application/admin/view/lessonslot/edit.html

@@ -66,6 +66,18 @@
             <input id="c-remark" class="form-control" name="row[remark]" type="text" value="{$row.remark|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_show')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <select  id="c-is_show" data-rule="required" class="form-control selectpicker" name="row[is_show]">
+                {foreach name="isShowList" item="vo"}
+                <option value="{$key}" {in name="key" value="$row.is_show"}selected{/in}>{$vo}</option>
+                {/foreach}
+            </select>
+
+        </div>
+    </div>
     <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Notice_status')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 1 - 0
application/api/controller/Index.php

@@ -71,6 +71,7 @@ class Index extends Api
         //搜课时表
         $where = [
             'slot.status' => 0,//报名中
+            'slot.is_show' => 1,
             'slot.starttime' => ['gt',time()],
         ];
 

+ 39 - 4
application/api/controller/Lesson.php

@@ -85,7 +85,9 @@ class Lesson extends Api
         $enddate   = $getdate.'-'.$endday;
         $where = [
             'starttime' => ['BETWEEN',[strtotime($startdate),strtotime($enddate)+86399]],
-            'status'    => 0
+            'status'    => 0,
+            'is_show' => 1,
+
         ];
         //dump($where);exit;
         $slots = Db::name('lesson_slot')->where($where)->field('id,starttime')->select();
@@ -138,7 +140,8 @@ class Lesson extends Api
 
         $where = [
             'slot.starttime' => ['BETWEEN',[$date,$date+86399]],
-            'slot.status' => 0
+            'slot.status' => 0,
+            'slot.is_show' => 1,
         ];
         if($cate_id){
             $where['lesson.lessoncate_id'] = $cate_id;
@@ -214,7 +217,7 @@ class Lesson extends Api
         $info = Db::name('lesson_slot')->alias('slot')
             ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price')
             ->join('lesson','slot.lesson_id = lesson.id','LEFT')
-            ->where('slot.id',$slot_id)->find();
+            ->where('slot.id',$slot_id)->where('slot.is_show',1)->find();
         if(empty($info)){
             $this->error('课程可能已取消,请刷新重试');
         }
@@ -282,6 +285,38 @@ class Lesson extends Api
         }
 
         $info['package_list'] = $package_list;
+
+        //可用试课
+        if($number == 1){
+            $try_map = [
+                'o.user_id' => $this->auth->id,
+                'o.endtime' => ['gt',time()],
+                'o.order_status' => 10,
+            ];
+            $tryorder_list = Db::name('trylesson_order')->alias('o')
+                ->join('trylesson','o.trylesson_id = trylesson.id','LEFT')
+                ->field('o.id,o.starttime,o.endtime,trylesson.name,trylesson.name_en')
+                ->where($try_map)
+                ->where('find_in_set(:lesson_ids,o.lesson_ids)', ['lesson_ids' => $info['lesson_id']])
+                ->order('o.endtime asc')->select();
+            $tryorder_list = $this->list_lang($tryorder_list,['name']);
+            if(!empty($tryorder_list)){
+                foreach($tryorder_list as $key => &$val){
+
+                    if($this->lang == 'zh-cn'){
+                        $val['time_text'] = date('m月d,Y',$val['starttime']).'-'.date('m月d,Y',$val['endtime']);
+                    }else{
+                        $val['time_text'] = date('M d,Y',$val['starttime']).'-'.date('M d,Y',$val['endtime']);
+                    }
+                }
+            }
+        }else{
+            $tryorder_list = [];
+        }
+
+        $info['tryorder_list'] = $tryorder_list;
+
+
         //hours转换
         $info['hours'] = floatval($info['hours']);
 
@@ -309,7 +344,7 @@ class Lesson extends Api
         $info = Db::name('lesson_slot')->alias('slot')
             ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price')
             ->join('lesson','slot.lesson_id = lesson.id','LEFT')
-            ->where('slot.id',$slot_id)->where('slot.status',0)->find();
+            ->where('slot.id',$slot_id)->where('slot.status',0)->where('slot.is_show',1)->find();
         if(empty($info)){
             $this->error('课程可能已取消,请刷新重试');
         }

+ 4 - 0
application/api/controller/Trylesson.php

@@ -69,9 +69,13 @@ class Trylesson extends Api
             'order_no'     => createUniqueNo('T',$this->auth->id),
             'user_id'      => $this->auth->id,
             'trylesson_id' => $id,
+            'lesson_ids' => $info['lesson_ids'],
             'order_amount' => $info['price'],
             'order_status' => 0,
             'createtime'   => time(),
+
+            'starttime'   => time(),
+            'endtime'     => time() + (30 * 86400),
         ];
         $data = array_merge($data,$sysdata);
 

+ 2 - 0
application/api/controller/coach/Lesson.php

@@ -28,6 +28,7 @@ class Lesson extends Apic
         $date = input('date',date('Y-m-d'),'strtotime');
         $where = [
             'slot.starttime' => ['BETWEEN',[$date,$date+86399]],
+            'slot.is_show' => 1,
         ];
 
         //课时
@@ -112,6 +113,7 @@ class Lesson extends Apic
         $where = [
             'starttime' => ['BETWEEN',[strtotime($startdate),strtotime($enddate)+86399]],
             'status'    => 0,
+            'is_show' => 1,
         ];
         //dump($where);exit;
         $slots = Db::name('lesson_slot')

+ 1 - 1
public/assets/js/backend/lesson.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     index_url: 'lesson/index' + location.search,
                     add_url: 'lesson/add',
                     edit_url: 'lesson/edit',
-                    del_url: 'lesson/del',
+//                    del_url: 'lesson/del',
                     multi_url: 'lesson/multi',
                     import_url: 'lesson/import',
                     table: 'lesson',

+ 3 - 1
public/assets/js/backend/lessonslot.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     index_url: 'lessonslot/index' + location.search,
                     add_url: 'lessonslot/add',
                     edit_url: 'lessonslot/edit',
-                    del_url: 'lessonslot/del',
+//                    del_url: 'lessonslot/del',
                     multi_url: 'lessonslot/multi',
                     import_url: 'lessonslot/import',
                     table: 'lesson_slot',
@@ -44,6 +44,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'finishtime', title: __('Finishtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'cancel_reason', title: __('Cancel_reason'), operate: 'LIKE'},
                         {field: 'cancel_time', title: __('Cancel_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
+
 //                        {field: 'coach.nickname', title: __('Coach.nickname'), operate: 'LIKE'},
 
                         {field: 'operate', title: __('Operate'), table: table,

+ 1 - 1
public/assets/js/backend/trylesson.js

@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     index_url: 'trylesson/index' + location.search,
                     add_url: 'trylesson/add',
                     edit_url: 'trylesson/edit',
-                    del_url: 'trylesson/del',
+//                    del_url: 'trylesson/del',
                     multi_url: 'trylesson/multi',
                     import_url: 'trylesson/import',
                     table: 'trylesson',