Browse Source

预约完成通知,whatsapp新模版

lizhen_gitee 5 months ago
parent
commit
1c4cf893fb

+ 9 - 3
application/admin/controller/Lessonslot.php

@@ -140,9 +140,10 @@ class Lessonslot extends Backend
 
             //课时
             $info = Db::name('lesson_slot')->alias('slot')
-                ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price,coach.nickname as coach_nickname')
+                ->field('slot.*,lesson.name,lesson.name_en,lesson.image,lesson.price,coach.nickname as coach_nickname,danceroom.name_en as danceroom_name_en')
                 ->join('lesson','slot.lesson_id = lesson.id','LEFT')
                 ->join('coach','slot.coach_ids = coach.id','LEFT')
+                ->join('danceroom','slot.danceroom_id = danceroom.id','LEFT')
                 ->where('slot.id',$slot_id)->where('slot.status',0)->find();
             if(empty($info)){
                 $this->error('课程可能已取消,请刷新重试');
@@ -306,6 +307,7 @@ class Lessonslot extends Backend
                     Your booking is confirmed and you’re all set now to fly with us! Here are the details of your booking:
                     Class:'.$info['name_en'].'<br/>
                     Instructor:'.$info['coach_nickname'].'<br/>
+                    Location: '. $info['danceroom_name_en'] .'<br/>
                     Date: '.date('d F Y',$info['starttime']).'<br/>
                     Time: '.date('H:i a',$info['starttime']).'<br/>
                     Please arrive 10 minutes before the class timing to prepare for the harness fitting!<br/>
@@ -336,10 +338,14 @@ class Lessonslot extends Backend
                     ],
                     [
                         'type' => 'text',
-                        'text' => date('Y-m-d H:i',$info['starttime']),
+                        'text' => date('D l Y',$info['starttime']) .' at '.date('H:i a',$info['starttime']),
+                    ],
+                    [
+                        'type' => 'text',
+                        'text' => $info['danceroom_name_en'],
                     ],
                 ];
-                //$this->whatapp($userinfo['whatsapp'],'lessonorder_alternate_to_booking','en_US',$parameters);
+                $this->whatapp($userinfo['whatsapp'],'class_booked_confirmation','en_US',$parameters);
 
             } catch (Exception $e) {
 

+ 21 - 11
application/index/controller/Plantask.php

@@ -42,7 +42,6 @@ class Plantask extends Controller
                 ->join('user','order.user_id = user.id','LEFT')
                 ->join('lesson','order.lesson_id = lesson.id','LEFT')
                 ->where($map)->order('order.id asc')->select();
-            //$order_list = $this->list_lang($order_list,['name']);
             if(empty($order_list)){
                 continue;
             }
@@ -116,11 +115,15 @@ class Plantask extends Controller
     //课程取消,通知。计划任务5分钟执行一次
     public function auto_lesson_slot_cancel(){
         $map = [
-            'status' => 30,
-            'cancel_notice_status' => 0,
+            'slot.status' => 30,
+            'slot.cancel_notice_status' => 0,
         ];
 
-        $task_list = Db::name('lesson_slot')->where($map)->order('starttime asc')->limit(1)->select();
+        $task_list = Db::name('lesson_slot')->alias('slot')
+            ->field('slot.*,coach.nickname as coach_nickname,coach.email as coach_email,coach.whatsapp as coach_whatsapp,lesson.lesson_name_en')
+            ->join('coach','slot.coach_ids = coach.id','LEFT')
+            ->join('lesson','slot.lesson_id = lesson.id','LEFT')
+            ->where($map)->order('slot.starttime asc')->limit(1)->select();
         if(empty($task_list)){
             echo 'empty';
             exit;
@@ -129,17 +132,24 @@ class Plantask extends Controller
         foreach($task_list as $slot){
             //找出这节课时的预约单
             $map = [
-//                'order.order_status' => 10,
                 'order.slot_id' => $slot['id'],
             ];
 
             $order_list = Db::name('lesson_order')->alias('order')
-                ->field('lesson.name,lesson.name_en,user.firstname,user.lastname,user.email,user.whatsapp')
+                ->field('user.firstname,user.lastname,user.email,user.whatsapp')
                 ->join('user','order.user_id = user.id','LEFT')
-                ->join('lesson','order.lesson_id = lesson.id','LEFT')
                 ->where('(order.jointype = 1 and order.order_status = 10) or (order.jointype = 2 and order.order_status = 0)') //已支付的 或 候补单
                 ->where($map)->order('order.id asc')->select();
-            //$order_list = $this->list_lang($order_list,['name']);
+
+            //把教练也加入到发送列表里
+            $coach_sender = [
+                'firstname'  => $slot['coach_nickname'],
+                'lastname'   => '',
+                'name_en'    => $slot['lesson_name_en'],
+                'email'      => $slot['coach_email'],
+                'whatsapp'   => $slot['coach_whatsapp'],
+            ];
+
             if(empty($order_list)){
                 continue;
             }
@@ -152,7 +162,7 @@ class Plantask extends Controller
                     $message =
                         'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
                     We regret to inform you that the following class has been cancelled.<br/>
-                    Class:'.$order['name_en'].'<br/>
+                    Class:'.$slot['lesson_name_en'].'<br/>
                     Date: '.date('d F Y',$slot['starttime']).'<br/>
                     Time: '.date('H:i a',$slot['starttime']).'<br/>
                     Thank you for your kind understanding and look forward to seeing you in our studio soon!❤<br/>
@@ -167,7 +177,7 @@ class Plantask extends Controller
                         ->message($message)
                         ->send();
 
-                    $coach_name = Db::name('coach')->where('id',$slot['coach_ids'])->value('nickname');
+                    //$coach_name = Db::name('coach')->where('id',$slot['coach_ids'])->value('nickname');
 
                     //发whatsapp
                     $parameters = [
@@ -177,7 +187,7 @@ class Plantask extends Controller
                         ],
                         [
                             'type' => 'text',
-                            'text' => $order['name_en'],
+                            'text' => $slot['lesson_name_en'],
                         ],
                        /* [
                             'type' => 'text',