Browse Source

预约订单显示教练

lizhen_gitee 9 months ago
parent
commit
cd0d974b88

+ 2 - 1
application/admin/controller/Lessonorder.php

@@ -53,7 +53,7 @@ class Lessonorder extends Backend
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
 
             $list = $this->model
-                    ->with(['user','slot','lesson'])
+                    ->with(['user','slot','lesson','coach'])
                     ->where($where)
                     ->where('lessonorder.order_status','NEQ',0)
                     ->order($sort, $order)
@@ -64,6 +64,7 @@ class Lessonorder extends Backend
                 $row->getRelation('user')->visible(['firstname','lastname']);
 				$row->getRelation('slot')->visible(['starttime','endtime']);
 				$row->getRelation('lesson')->visible(['name','name_en']);
+				$row->getRelation('coach')->visible(['nickname']);
             }
 
             $result = array("total" => $list->total(), "rows" => $list->items());

+ 2 - 1
application/admin/lang/en/lessonorder.php

@@ -36,5 +36,6 @@ return [
     'Slot.starttime'   => 'start time',
     'Slot.endtime'     => 'end time',
     'Lesson.name'      => 'Lesson name',
-    'Lesson.name_en'   => 'Lesson name(en)'
+    'Lesson.name_en'   => 'Lesson name(en)',
+    'Coach.nickname'   => 'Instructor'
 ];

+ 2 - 1
application/admin/lang/zh-cn/lessonorder.php

@@ -36,5 +36,6 @@ return [
     'Slot.starttime'     => '开始时间',
     'Slot.endtime'       => '结束时间',
     'Lesson.name'        => '课程标题',
-    'Lesson.name_en'     => '课程标题(en)'
+    'Lesson.name_en'     => '课程标题(en)',
+    'Coach.nickname'     => '教练',
 ];

+ 7 - 1
application/admin/model/Lessonorder.php

@@ -105,7 +105,7 @@ class Lessonorder extends Model
 
     public function slot()
     {
-        return $this->belongsTo('app\admin\model\lesson\Slot', 'slot_id', 'id', [], 'LEFT')->setEagerlyType(0);
+        return $this->belongsTo('Lessonslot', 'slot_id', 'id', [], 'LEFT')->setEagerlyType(0);
     }
 
 
@@ -113,4 +113,10 @@ class Lessonorder extends Model
     {
         return $this->belongsTo('Lesson', 'lesson_id', 'id', [], 'LEFT')->setEagerlyType(0);
     }
+
+
+    public function coach()
+    {
+        return $this->belongsTo('Coach', 'slot.coach_ids', 'id', [], 'LEFT')->setEagerlyType(0);
+    }
 }

+ 1 - 0
public/assets/js/backend/lessonorder.js

@@ -39,6 +39,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'lesson_id', title: __('Lesson_id')},
                         {field: 'lesson.name', title: __('Lesson.name'), operate: 'LIKE'},
                         {field: 'lesson.name_en', title: __('Lesson.name_en'), operate: 'LIKE'},
+                        {field: 'coach.nickname', title: __('Coach.nickname')},
                         {field: 'order_amount', title: __('Order_amount'), operate:'BETWEEN'},
                         {field: 'order_status', title: __('Order_status'), searchList: {"0":__('Order_status 0'),"10":__('Order_status 10'),"20":__('Order_status 20'),"30":__('Order_status 30'),"40":__('Order_status 40')}, formatter: Table.api.formatter.status},
                         {field: 'paytype', title: __('Paytype'), searchList: {"1":__('Paytype 1'),"2":__('Paytype 2'),"3":__('Paytype 3'),"4":__('Paytype 4')}, formatter: Table.api.formatter.normal},

+ 10 - 1
thinkphp/library/think/model/relation/OneToOne.php

@@ -77,12 +77,21 @@ abstract class OneToOne extends Relation
         $joinAlias = $relation;
         $query->via($joinAlias);
 
+        //lizhen
+        if(strpos($this->foreignKey,'.')){
+            $new_foreignKey = $this->foreignKey;
+        }else{
+            $new_foreignKey = $name . '.' . $this->foreignKey;
+        }
+
         if ($this instanceof BelongsTo) {
-            $query->join([$joinTable => $joinAlias], $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
+            $query->join([$joinTable => $joinAlias], $new_foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
+          //$query->join([$joinTable => $joinAlias], $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
         } else {
             $query->join([$joinTable => $joinAlias], $name . '.' . $this->localKey . '=' . $joinAlias . '.' . $this->foreignKey, $this->joinType);
         }
 
+
         if ($closure) {
             // 执行闭包查询
             call_user_func_array($closure, [ & $query]);