Merge branch 'master' of https://git.abbauf.com/MAGANG_TB_dan_PNP_2023/Aplikasi_Rekber into oktaa
This commit is contained in:
commit
2094fe9066
@ -19,22 +19,22 @@ class AdminDashboardController extends Controller
|
|||||||
$currentMonth = Carbon::now()->month;
|
$currentMonth = Carbon::now()->month;
|
||||||
$currentYear = Carbon::now()->year;
|
$currentYear = Carbon::now()->year;
|
||||||
|
|
||||||
$countSuccess = Transaction::where('status', 'settlement')
|
$countSuccess = Transaction::where('status_pembayaran', 'settlement')
|
||||||
->whereMonth('updated_at', $currentMonth)
|
->whereMonth('updated_at', $currentMonth)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$countPending = Transaction::where('status', 'pending')
|
$countPending = Transaction::where('status_pembayaran', 'pending')
|
||||||
->whereMonth('updated_at', $currentMonth)
|
->whereMonth('updated_at', $currentMonth)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$countCancelled = Transaction::where('status', 'cancel')
|
$countCancelled = Transaction::where('status_pembayaran', 'cancel')
|
||||||
->whereMonth('updated_at', $currentMonth)
|
->whereMonth('updated_at', $currentMonth)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
$countRefund = Transaction::where('status', 'refund')
|
$countRefund = Transaction::where('status_pembayaran', 'refund')
|
||||||
->whereMonth('updated_at', $currentMonth)
|
->whereMonth('updated_at', $currentMonth)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->count();
|
->count();
|
||||||
@ -46,7 +46,7 @@ class AdminDashboardController extends Controller
|
|||||||
$dataChartTransaction = [];
|
$dataChartTransaction = [];
|
||||||
$dataChartRefund = [];
|
$dataChartRefund = [];
|
||||||
|
|
||||||
$totalRefund = Transaction::where('status', 'refund')->count();
|
$totalRefund = Transaction::where('status_pembayaran', 'refund')->count();
|
||||||
$dataChartTotalRefund = [];
|
$dataChartTotalRefund = [];
|
||||||
|
|
||||||
$totalUser = User::where('status', 'Finished')->count();
|
$totalUser = User::where('status', 'Finished')->count();
|
||||||
@ -55,12 +55,12 @@ class AdminDashboardController extends Controller
|
|||||||
for ($bulan = 1; $bulan <= 12; $bulan++) {
|
for ($bulan = 1; $bulan <= 12; $bulan++) {
|
||||||
$transaction = Transaction::whereMonth('updated_at', $bulan)
|
$transaction = Transaction::whereMonth('updated_at', $bulan)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->where('status', 'settlement')
|
->where('status_pembayaran', 'settlement')
|
||||||
->sum('total_bayar');
|
->sum('total_bayar');
|
||||||
|
|
||||||
$refund = Transaction::whereMonth('updated_at', $bulan)
|
$refund = Transaction::whereMonth('updated_at', $bulan)
|
||||||
->whereYear('updated_at', $currentYear)
|
->whereYear('updated_at', $currentYear)
|
||||||
->where('status', 'partial refund')
|
->where('status_pembayaran', 'refund')
|
||||||
->sum('total_harga');
|
->sum('total_harga');
|
||||||
|
|
||||||
$dataChartTransaction[] = intval($transaction);
|
$dataChartTransaction[] = intval($transaction);
|
||||||
|
@ -17,6 +17,7 @@ use Illuminate\Support\Facades\Http;
|
|||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
|
use GuzzleHttp\Client;
|
||||||
use Stichoza\GoogleTranslate\GoogleTranslate;
|
use Stichoza\GoogleTranslate\GoogleTranslate;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@ -194,15 +195,23 @@ class UserTransactionController extends Controller
|
|||||||
'enabled_payments' => ['credit_card', 'gopay', 'qris'],
|
'enabled_payments' => ['credit_card', 'gopay', 'qris'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
|
$auth = base64_encode(env('MIDTRANS_SERVER_KEY'));
|
||||||
|
|
||||||
$response = Http::withHeaders([
|
$response = $client->request('POST', 'https://app.sandbox.midtrans.com/snap/v1/transactions', [
|
||||||
'Content-Type' => 'application/json',
|
'body' => json_encode($params),
|
||||||
'Authorization' => "Basic $auth",
|
'headers' => [
|
||||||
])->post('https://app.sandbox.midtrans.com/snap/v1/transactions', $params);
|
'accept' => 'application/json',
|
||||||
|
'authorization' => 'Basic '.$auth,
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$result = $response->getBody();
|
||||||
|
|
||||||
Transaction::where('id', $query->id)->update([
|
Transaction::where('id', $query->id)->update([
|
||||||
'token' => $response['token'],
|
'token' => $result['token'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contact = Contact::where('pemilik_kontak', $pembeli)
|
$contact = Contact::where('pemilik_kontak', $pembeli)
|
||||||
@ -561,11 +570,10 @@ class UserTransactionController extends Controller
|
|||||||
$result = json_decode($response->body(), true);
|
$result = json_decode($response->body(), true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
Transaction::where('id', $request->id)->update([
|
Transaction::where('id', $request->id)->update([
|
||||||
'status_pembayaran' => $result['transaction_status']
|
'status_pembayaran' => $result['transaction_status'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
|
Loading…
Reference in New Issue
Block a user