浏览代码

Merge branch 'master' of http://git.huxiukeji.com/lizhen/yueke

lizhen_gitee 2 月之前
父节点
当前提交
3a6703c595

+ 4 - 3
application/admin/controller/Lessonorder.php

@@ -215,7 +215,7 @@ class Lessonorder extends Backend
                         ->subject('Class is Cancelled!')
                         ->message($message)
                         ->send();
-
+                    $obj = '';
                     $coach_name = Db::name('coach')->where('id',$slot_info['coach_ids'])->value('nickname');
 
                     //发whatsapp
@@ -325,7 +325,7 @@ class Lessonorder extends Backend
                     $up_usernumber += $order['usernumber'];
 
                     //额外的通知
-                    $obj = new Email();
+
                     try {
                         $message =
                             'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
@@ -340,12 +340,13 @@ class Lessonorder extends Backend
                             ';
 
                         //给这些用户发邮件
+                        $obj = new Email();
                         $result = $obj
                             ->to($order['email'])
                             ->subject('A spot for your waitlisted class is ready and you are now added in!')
                             ->message($message)
                             ->send();
-
+                        $obj = '';
                         //发whatsapp
                         $parameters = [
                             [

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

@@ -300,7 +300,7 @@ class Lessonslot extends Backend
 
             //额外的通知
             $userinfo = Db::name('user')->where('id',$user_id)->find();
-            $obj = new Email();
+
             try {
                 $message =
                     'Hi,'.$userinfo['firstname']. ' ' .$userinfo['lastname'].'!<br/>
@@ -320,12 +320,13 @@ class Lessonslot extends Backend
                     ';
 
                 //给这些用户发邮件
+                $obj = new Email();
                 $result = $obj
                     ->to($userinfo['email'])
                     ->subject('You are now booked in for this class! ')
                     ->message($message)
                     ->send();
-
+                $obj = '';
                 //发whatsapp
                 $parameters = [
                     [
@@ -521,7 +522,7 @@ class Lessonslot extends Backend
         
         //给这些预约单的用户发邮件
         try {
-            $obj = new Email();
+
             foreach($order_list as $order){
 
                 $message =
@@ -537,11 +538,13 @@ class Lessonslot extends Backend
                 ';
 
                 if(!empty($order['email'])){
+                    $obj = new Email();
                     $result = $obj
                         ->to($order['email'])
                         ->subject('Class is Cancelled!')
                         ->message($message)
                         ->send();
+                    $obj = '';
                 }
 
 

+ 30 - 0
application/api/controller/Demo.php

@@ -48,6 +48,36 @@ class Demo extends Api
         })
      */
 
+    public function test_send_email(){
+
+
+        $emails = [
+            '',
+            '',
+            '',
+            '',
+        ];
+        foreach($emails as $email){
+            $message =
+                'Hi,'.$email.'!<br/>
+                    We are looking forward to seeing you at the following class tomorrow!<br/>
+                    Please arrive 10 minutes before the class timing to prepare for the harness fitting!<br/>
+                    We are located at 450 Alexandra Road, #02-01,<br/>
+                    Singapore 119960. For those who are driving, parking is available on level 2 of the building. For those who are taking public transport, the nearest mrt is Labrador Park MRT (7-10 minutes walk) and there is also a bus stop available just outside the building!<br/>
+                    We look forward to seeing you for an amazing session! ❤<br/>
+                    Best Regards,<br/>
+                    Elin Dance Studio<br/>
+                    ';
+            $obj = new Email();
+            $result = $obj
+                ->to($email)
+                ->subject('foreach email test '.date('Y-m-d H:i:s'))
+                ->message($message)
+                ->send();
+            $obj = '';
+        }
+    }
+
     public function auto_lesson_slot_notice(){
         $order = [
             'firstname' => '振',

+ 3 - 2
application/api/controller/Usercenter.php

@@ -483,7 +483,7 @@ class Usercenter extends Api
                     $up_usernumber += $order['usernumber'];
 
                     //额外的通知
-                    $obj = new Email();
+
                     try {
                         $message =
                             'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
@@ -498,12 +498,13 @@ class Usercenter extends Api
                             ';
 
                         //给这些用户发邮件
+                        $obj = new Email();
                         $result = $obj
                             ->to($order['email'])
                             ->subject('A spot for your waitlisted class is ready and you are now added in!')
                             ->message($message)
                             ->send();
-
+                        $obj = '';
                         //发whatsapp
                         $parameters = [
                             [

+ 16 - 5
application/api/controller/coach/Lesson.php

@@ -75,14 +75,25 @@ class Lesson extends Apic
         $this->success(1,$list);
     }
 
+    public function slot_index(){
+        $this_month = date('Y-m');
+        $this_month_data = $this->slot_index_month($this_month);
+
+        $next_month = date('Y-m',strtotime('first day of next month'));
+        $next_month_data = $this->slot_index_month($next_month);
+
+        $this->success(1,array_merge($this_month_data,$next_month_data));
+    }
+
+
     //课时列表首页
     //根据年,月获取当月剩余日期,有课程的标记1
-    public function slot_index(){
+    public function slot_index_month($getdate){
 
-        $getdate = input('date',date('Y-m'));
+       /* $getdate = input('date',date('Y-m'));
         if(empty($getdate)){
             $getdate = date('Y-m');
-        }
+        }*/
         $year = substr($getdate,0,4);
         $month = substr($getdate,-2,2);
 
@@ -175,8 +186,8 @@ class Lesson extends Apic
 
             $date_arr[] = $i_data;
         }
-
-        $this->success(1,$date_arr);
+        return $date_arr;
+//        $this->success(1,$date_arr);
     }
 
     //课时详情

+ 62 - 42
application/index/controller/Plantask.php

@@ -31,10 +31,18 @@ class Plantask extends Controller
         }
 
         foreach($task_list as $slot){
+
+            //这节课时,任务完成
+            $update = [
+                'notice_status' => 1,
+            ];
+            Db::name('lesson_slot')->where('id',$slot['id'])->update($update);
+            
             //找出这节课时的预约单
             $map = [
                 'order.order_status' => 10,
                 'order.slot_id' => $slot['id'],
+                'order.jointype' => 1, //预约类型:1=预约,2=候补
             ];
 
             $order_list = Db::name('lesson_order')->alias('order')
@@ -42,15 +50,13 @@ 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();
-            if(empty($order_list)){
-                continue;
-            }
+            if(!empty($order_list)){
 
             $coach_name = Db::name('coach')->where('id',$slot['coach_ids'])->value('nickname');
 
             //给这些预约单的用户发邮件
             try {
-                $obj = new Email();
+
                 foreach($order_list as $order){
 
                     $message =
@@ -67,13 +73,13 @@ class Plantask extends Controller
                     Elin Dance Studio<br/>
                     <img src="'.config('website_url').'/assets/img/logo3.png" style="width:100px;height:100px">
                     ';
-
+                    $obj = new Email();
                     $result = $obj
                         ->to($order['email'])
                         ->subject('You have a class tomorrow!')
                         ->message($message)
                         ->send();
-
+                    $obj = '';
                     //发whatsapp
                     $parameters = [
                         [
@@ -102,12 +108,8 @@ class Plantask extends Controller
             } catch (Exception $e) {
 
             }
+            }
 
-            //这节课时,任务完成
-            $update = [
-                'notice_status' => 1,
-            ];
-            Db::name('lesson_slot')->where('id',$slot['id'])->update($update);
         }
 
     }
@@ -131,6 +133,12 @@ class Plantask extends Controller
         }
 
         foreach($task_list as $slot){
+            //这节课时,任务完成
+            $update = [
+                'cancel_notice_status' => 1,
+            ];
+            Db::name('lesson_slot')->where('id',$slot['id'])->update($update);
+
             //找出这节课时的预约单
             $map = [
                 'order.slot_id' => $slot['id'],
@@ -157,7 +165,7 @@ class Plantask extends Controller
 
             //给这些预约单的用户发邮件
             try {
-                $obj = new Email();
+
                 foreach($order_list as $order){
 
                     $message =
@@ -173,12 +181,14 @@ class Plantask extends Controller
                     ';
 
                     if(!empty($order['email'])){
+                    $obj = new Email();
                     $result = $obj
                         ->to($order['email'])
                         ->subject('Class is Cancelled!')
                         ->message($message)
                         ->send();
                     }
+                    $obj = '';
 
                     //$coach_name = Db::name('coach')->where('id',$slot['coach_ids'])->value('nickname');
 
@@ -209,11 +219,7 @@ class Plantask extends Controller
 
             }
 
-            //这节课时,任务完成
-            $update = [
-                'cancel_notice_status' => 1,
-            ];
-            Db::name('lesson_slot')->where('id',$slot['id'])->update($update);
+
         }
     }
 
@@ -235,8 +241,15 @@ class Plantask extends Controller
             exit;
         }
 
-        $obj = new Email();
+
         foreach($task_list as $order){
+
+            //任务完成
+            $update = [
+                'buy_notice_status' => 1,
+            ];
+            Db::name('package_order')->where('id',$order['id'])->update($update);
+
             try {
                 $message =
                     'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
@@ -252,11 +265,13 @@ class Plantask extends Controller
                     ';
 
                 //给这些用户发邮件
+                $obj = new Email();
                 $result = $obj
                     ->to($order['email'])
                     ->subject('Your plan purchase has been received!')
                     ->message($message)
                     ->send();
+                $obj = '';
 
                 //发whatsapp
                 $parameters = [
@@ -287,11 +302,6 @@ class Plantask extends Controller
 
             }
 
-            //任务完成
-            $update = [
-                'buy_notice_status' => 1,
-            ];
-            Db::name('package_order')->where('id',$order['id'])->update($update);
         }
 
     }
@@ -318,8 +328,15 @@ class Plantask extends Controller
             exit;
         }
 
-        $obj = new Email();
+
         foreach($task_list as $order){
+
+            //任务完成
+            $update = [
+                'notice_status' => 1,//月通知已发送
+            ];
+            Db::name('package_order')->where('id',$order['id'])->update($update);
+
             try {
 
                 $message =
@@ -335,11 +352,13 @@ class Plantask extends Controller
                     ';
 
                 //给这些用户发邮件
+                $obj = new Email();
                 $result = $obj
                     ->to($order['email'])
                     ->subject('Your Membership Plan is Expiring in One Month’s Time!')
                     ->message($message)
                     ->send();
+                $obj = '';
 
                 //发whatsapp
                 $parameters = [
@@ -371,11 +390,6 @@ class Plantask extends Controller
 
             }
 
-            //任务完成
-            $update = [
-                'notice_status' => 1,//月通知已发送
-            ];
-            Db::name('package_order')->where('id',$order['id'])->update($update);
         }
 
     }
@@ -400,9 +414,15 @@ class Plantask extends Controller
             exit;
         }
 
-        $obj = new Email();
+
         foreach($task_list as $order){
 
+            //任务完成
+            $update = [
+                'notice_status' => 2,//2周通知已发送
+            ];
+            Db::name('package_order')->where('id',$order['id'])->update($update);
+
             try {
                 $message =
                     'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
@@ -417,11 +437,13 @@ class Plantask extends Controller
                     ';
 
                 //给这些用户发邮件
+                $obj = new Email();
                 $result = $obj
                     ->to($order['email'])
                     ->subject('Your Membership Plan is Expiring in Two Week’s Time!')
                     ->message($message)
                     ->send();
+                $obj = '';
 
                 //发whatsapp
                 $parameters = [
@@ -453,11 +475,6 @@ class Plantask extends Controller
 
             }
 
-            //任务完成
-            $update = [
-                'notice_status' => 2,//2周通知已发送
-            ];
-            Db::name('package_order')->where('id',$order['id'])->update($update);
         }
     }
     public function auto_package_order_notice_1week(){
@@ -480,8 +497,15 @@ class Plantask extends Controller
             exit;
         }
 
-        $obj = new Email();
+
         foreach($task_list as $order){
+
+            //任务完成
+            $update = [
+                'notice_status' => 3,//1周通知已发送
+            ];
+            Db::name('package_order')->where('id',$order['id'])->update($update);
+
             try {
                 $message =
                     'Hi,'.$order['firstname']. ' ' .$order['lastname'].'!<br/>
@@ -496,12 +520,13 @@ class Plantask extends Controller
                     ';
 
                 //给这些用户发邮件
+                $obj = new Email();
                 $result = $obj
                     ->to($order['email'])
                     ->subject('Your Membership Plan is Expiring in One Week’s Time!')
                     ->message($message)
                     ->send();
-
+                $obj = '';
                 //发whatsapp
                 $parameters = [
                     [
@@ -532,11 +557,6 @@ class Plantask extends Controller
 
             }
 
-            //任务完成
-            $update = [
-                'notice_status' => 3,//1周通知已发送
-            ];
-            Db::name('package_order')->where('id',$order['id'])->update($update);
         }
     }