|
@@ -109,6 +109,18 @@ class Lessonorder extends Backend
|
|
|
$this->error('取消失败');
|
|
|
}
|
|
|
}
|
|
|
+ if($info['paytype'] == 4){
|
|
|
+ $update = [
|
|
|
+ 'order_status' => 10,
|
|
|
+ 'lesson_order_id' => 0,
|
|
|
+ 'updatetime' => time(),
|
|
|
+ ];
|
|
|
+ $rs_remain = Db::name('trylesson_order')->where('id',$info['trylesson_order_id'])->update($update);
|
|
|
+ if($rs_remain === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('取消失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
//现金支付不给退,线下处理
|
|
|
|
|
|
//取消预约单
|
|
@@ -117,7 +129,7 @@ class Lessonorder extends Backend
|
|
|
'cancel_time' => $cancel_time,
|
|
|
'cancel_reason' => $cancel_reason,
|
|
|
];
|
|
|
- if($info['paytype'] == 1){
|
|
|
+ if($info['paytype'] == 1 || $info['paytype'] == 4){
|
|
|
$update2['order_status'] = 40;
|
|
|
}
|
|
|
|
|
@@ -129,16 +141,46 @@ class Lessonorder extends Backend
|
|
|
}
|
|
|
|
|
|
$slot_info = Db::name('lesson_slot')->where('id',$info['slot_id'])->find();
|
|
|
+ $lesson_info = Db::name('lesson')->where('id',$slot_info['lesson_id'])->find();
|
|
|
|
|
|
//给用户发通知
|
|
|
$user_info = Db::name('user')->where('id',$info['user_id'])->find();
|
|
|
- if($user_info['notice_email'] == 1 && !empty($user_info['email'])){
|
|
|
- $obj = new Email();
|
|
|
- $result = $obj
|
|
|
- ->to($user_info['email'])
|
|
|
- ->subject('Elin Dance Studio 订单取消!')
|
|
|
- ->message('Hi,'.$user_info['firstname']. ' ' .$user_info['lastname'].',您预约的'.date('Y-m-d H:i',$slot_info['starttime']).'的课程已被取消,原因:'.$cancel_reason.'!')
|
|
|
- ->send();
|
|
|
+ if(!empty($user_info['email'])){
|
|
|
+
|
|
|
+ try {
|
|
|
+ $obj = new Email();
|
|
|
+ $result = $obj
|
|
|
+ ->to($user_info['email'])
|
|
|
+ ->subject('Class is Cancelled!')
|
|
|
+ ->message('Hi,'.$user_info['firstname']. ' ' .$user_info['lastname'].',您预约的'.$lesson_info['name'].'已取消')
|
|
|
+ ->send();
|
|
|
+
|
|
|
+ $coach_name = Db::name('coach')->where('id',$slot_info['coach_ids'])->value('nickname');
|
|
|
+
|
|
|
+ //发whatsapp
|
|
|
+ $parameters = [
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'text' => $user_info['firstname'].' '.$user_info['lastname'],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'text' => $lesson_info['name_en'],
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'text' => $coach_name,
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'type' => 'text',
|
|
|
+ 'text' => date('Y-m-d H:i',$slot_info['starttime']),
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ $this->whatapp($user_info['whatsapp'],'class_cancelled','en_US',$parameters);
|
|
|
+
|
|
|
+ } catch (Exception $e) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
@@ -150,6 +192,45 @@ class Lessonorder extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
+ private function whatapp($receive_mobile,$template,$code,$parameters){
|
|
|
+ if(empty($receive_mobile)){return true;}
|
|
|
+
|
|
|
+ $token = config('site.whatsapp_token');
|
|
|
+
|
|
|
+ //发送者
|
|
|
+ $mobile_id = '337736419413019'; //Elin Dance Stuido 2:+65 8015 4154 , WhatsApp Business Account ID: 336509229537586
|
|
|
+
|
|
|
+ //发送
|
|
|
+ $url = 'https://graph.facebook.com/v19.0/'.$mobile_id.'/messages';
|
|
|
+ $header = [
|
|
|
+ 'Authorization: Bearer ' . $token,
|
|
|
+ 'Content-Type: application/json',
|
|
|
+ ];
|
|
|
+ $body = [
|
|
|
+ 'messaging_product' => 'whatsapp',
|
|
|
+ 'recipient_type' => 'individual',
|
|
|
+ 'to' => $receive_mobile,
|
|
|
+ 'type' => 'template',
|
|
|
+ 'template' => [
|
|
|
+ 'name' => $template,
|
|
|
+ 'language' => [
|
|
|
+ 'code' => $code
|
|
|
+ ],
|
|
|
+ 'components' => [
|
|
|
+ [
|
|
|
+ 'type' => 'body',
|
|
|
+ 'parameters' => $parameters
|
|
|
+ ]
|
|
|
+
|
|
|
+ ],
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+ $body = json_encode($body);
|
|
|
+
|
|
|
+ $rs = curl_post($url,$body,$header);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|