Browse Source

add WA integration

Rahmat Ade Saputra 3 years ago
parent
commit
0166ed4403
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      app/Http/Controllers/TransactionController.php

+ 21
- 0
app/Http/Controllers/TransactionController.php View File

13
 use Illuminate\Database\QueryException;
13
 use Illuminate\Database\QueryException;
14
 use Illuminate\Support\Facades\Auth;
14
 use Illuminate\Support\Facades\Auth;
15
 use Illuminate\Support\Facades\DB;
15
 use Illuminate\Support\Facades\DB;
16
+use Illuminate\Support\Facades\Http;
16
 
17
 
17
 class TransactionController extends Controller
18
 class TransactionController extends Controller
18
 {
19
 {
126
             $thermalPrinting = new ThermalPrinting($transaction);
127
             $thermalPrinting = new ThermalPrinting($transaction);
127
             $thermalPrinting->startPrinting(2);
128
             $thermalPrinting->startPrinting(2);
128
 
129
 
130
+            $customer = Customer::find($request->customer_id);
131
+
132
+            Http::post('https://gerbangchatapi.dijitalcode.com/chat/send?id=bambslaundry', [
133
+                'receiver' => $customer->phone,
134
+                'message' => 'Terima kasih sudah mempercayakan layanan laundry kepada Bamb\'s Laundry. Nomor transaksi Anda adalah *'.$request->transaction_number.'*',
135
+            ]);
136
+
129
             return to_route('transactions.index')->with('success', __('Transaksi berhasil ditambahkan'));
137
             return to_route('transactions.index')->with('success', __('Transaksi berhasil ditambahkan'));
130
         } catch (QueryException $e) {
138
         } catch (QueryException $e) {
131
             return back()->with('error', __('Penambahan transaksi gagal'));
139
             return back()->with('error', __('Penambahan transaksi gagal'));
194
     {
202
     {
195
         $transaction->update($request->validated());
203
         $transaction->update($request->validated());
196
 
204
 
205
+        if($transaction->transaction_status_id==2) {
206
+            $status_message = " sudah diproses, harap menunggu sampai pemberitahuan selanjutnya.";
207
+        } else if($transaction->transaction_status_id==3) {
208
+            $status_message = " sudah selesai, silahkan diambil.";
209
+        } else {
210
+            $status_message = " sudah diambil. Silahkan datang lagi di kemudian hari jika ingin laundry kembali, terima kasih.";
211
+        }
212
+
213
+        Http::post('https://gerbangchatapi.dijitalcode.com/chat/send?id=bambslaundry', [
214
+            'receiver' => $transaction->customer->phone,
215
+            'message' => 'Layanan laundry Anda dengan nomor transaksi *'.$transaction->transaction_number.'*'.$status_message,
216
+        ]);
217
+
197
         return back()->with('success', __('Transaksi berhasil diperbaharui'));
218
         return back()->with('success', __('Transaksi berhasil diperbaharui'));
198
     }
219
     }
199
 
220