Merge branch 'amir_dev_2' into 'main'
Merge amir_dev_2, api for Payment CDM See merge request online-sistem1/lelong!370
This commit is contained in:
@@ -625,9 +625,45 @@ class LelongMobileController extends Controller
|
||||
$namaCawangan = $getCawangan->caw_name;
|
||||
$kodCawangan = $getCawangan->caw_code;
|
||||
|
||||
|
||||
$status_payment_cawangan['status'] = 1;
|
||||
|
||||
$payment = Payment::where('norujukan', $groupBycaw[0]->norujukan)
|
||||
->where(function ($query) {
|
||||
$query->where('status', '=', 1)
|
||||
->orWhere('status', '=', 2);
|
||||
})
|
||||
->first();
|
||||
if ($payment != null) {
|
||||
$checkPayMethod = Resit::find($payment->resit_id);
|
||||
$date_convert = strtotime($checkPayMethod->created_at);
|
||||
$checkPayMethod['pay_time'] = date("H:i:s", $date_convert);
|
||||
$status_payment_cawangan['resit'] = $checkPayMethod->toArray();
|
||||
if ($checkPayMethod->billplz_id == "") {
|
||||
$status_payment_cawangan['payment_method'] = "TUNAI";
|
||||
$status_payment_cawangan['payment_method_opt'] = 1;
|
||||
} elseif (str_starts_with($checkPayMethod->billplz_id, 'CDM')) {
|
||||
$status_payment_cawangan['payment_method'] = "CDM";
|
||||
$status_payment_cawangan['payment_method_opt'] = 3;
|
||||
$file_resit = FileResit::where('user_id', $user_id)->where('lelong_id', $lelong_id)->where('kodcaw', $kodCawangan)->get();
|
||||
foreach($file_resit as $index => $resit)
|
||||
{
|
||||
$date_convert = strtotime($resit->created_at);
|
||||
$updatedDateTime = date("H:i:s", $date_convert);
|
||||
$file_resit[$index]['masa_upload'] = $updatedDateTime;
|
||||
}
|
||||
$status_payment_cawangan['file_resit'] = $file_resit;
|
||||
} else {
|
||||
$status_payment_cawangan['payment_method'] = "ONLINE";
|
||||
$status_payment_cawangan['payment_method_opt'] = 2;
|
||||
}
|
||||
if ($payment->disahkan_pada == NULL) {
|
||||
$status_payment_cawangan['status'] = 9; // status pending tunggu pengesahan
|
||||
}
|
||||
} else {
|
||||
$status_payment_cawangan['status'] = null;
|
||||
}
|
||||
|
||||
$total_hargabida = 0;
|
||||
$status_payment_cawangan = 1;
|
||||
foreach ($groupBycaw as $index => $hargabida) {
|
||||
$fileMarhun = FileMarhun::where('lelongbid_id', $hargabida->id)->get();
|
||||
if ($fileMarhun->isNotEmpty()) {
|
||||
@@ -641,9 +677,6 @@ class LelongMobileController extends Controller
|
||||
->first();
|
||||
$groupBycaw[$index]['hargabida'] = number_format($totalbida['hargabida'], 2, '.', ',');
|
||||
$total_hargabida = $total_hargabida + $totalbida['hargabida'];
|
||||
if($hargabida->status_payment == null) {
|
||||
$status_payment_cawangan = null;
|
||||
}
|
||||
}
|
||||
$sag = $groupBycaw;
|
||||
array_push($data, [
|
||||
@@ -1269,6 +1302,7 @@ class LelongMobileController extends Controller
|
||||
$addfile->user_id = $request->user_id;
|
||||
$addfile->lelong_id = $request->lelong_id;
|
||||
$addfile->file_type = $file_type;
|
||||
$addfile->kodcaw = $request->kodcaw;
|
||||
$addfile->save();
|
||||
|
||||
$directory = "/{$request->user_id}/{$request->lelong_id}/";
|
||||
@@ -1280,16 +1314,11 @@ class LelongMobileController extends Controller
|
||||
$stored_path = Storage::disk('resit')->path("{$directory}{$resitImageFileName}.${imageExtension}");
|
||||
$resitPhotoService = new ResitPhotoService();
|
||||
|
||||
// try {
|
||||
|
||||
$convertToWebP = $resitPhotoService->optimizeImageToWebP($stored_path, $directory, $resitImageFileName);
|
||||
|
||||
// } catch (\Exception $e)
|
||||
|
||||
// {
|
||||
// return $e;
|
||||
// }
|
||||
|
||||
try {
|
||||
$convertToWebP = $resitPhotoService->optimizeImageToWebP($stored_path, $directory, $resitImageFileName);
|
||||
} catch (\Exception $e) {
|
||||
return $e;
|
||||
}
|
||||
|
||||
Storage::disk('resit')->delete("{$directory}${resitImageFileName}.${imageExtension}");
|
||||
|
||||
@@ -1334,4 +1363,65 @@ class LelongMobileController extends Controller
|
||||
return response()->json(['lelong' => $lelong]);
|
||||
}
|
||||
|
||||
public function initializeCdmPayment(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$day = $current->day;
|
||||
$month = $current->month;
|
||||
$year = $current->format('y');
|
||||
|
||||
$this->addPhotoResit($request);
|
||||
|
||||
$previous_siri = Resit::orderBy('id','desc')->first();
|
||||
if($previous_siri){
|
||||
$nosiri = $previous_siri->id + 1;
|
||||
}else{
|
||||
$nosiri = 1;
|
||||
}
|
||||
|
||||
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
|
||||
|
||||
$cdm_reference = 'CDM' . sprintf('%06d', $nosiri);
|
||||
|
||||
$add_resit = new Resit();
|
||||
$add_resit->user_id = $request->user_id;
|
||||
$add_resit->lelong_id = $request->lelong_id;
|
||||
$add_resit->reference_no = $reference_no;
|
||||
$add_resit->invoice_id = $request->invoice_id;
|
||||
$add_resit->invoice_no = $request->invoice_no;
|
||||
$add_resit->billplz_id = $cdm_reference;
|
||||
$add_resit->total_payment = $request->total;
|
||||
$add_resit->resit_type = 2;
|
||||
$add_resit->save();
|
||||
|
||||
$selectedSag = $request->sag;
|
||||
foreach ($selectedSag as $index) {
|
||||
$add_payment = new Payment;
|
||||
$add_payment->user_id = $request->user_id;
|
||||
$add_payment->lelong_id = $request->lelong_id;
|
||||
$add_payment->kodcaw = $index['kodcaw'];
|
||||
$add_payment->lelongbid_id = $index['lelongbid_id'];
|
||||
$add_payment->norujukan = $index['norujukan'];
|
||||
$add_payment->total_payment = $index['total_payment'];
|
||||
$add_payment->status_payment_opt = 3; //bayar secara CDM 3
|
||||
$add_payment->status = 2; //paybidwin
|
||||
$add_payment->remark = 'CDM';
|
||||
$add_payment->resit_id = $add_resit->id;
|
||||
$add_payment->save();
|
||||
|
||||
$updateTagBid = LelongBid::where('norujukan', $index['norujukan'])->first();
|
||||
$updateTagBid->status_payment = 2;
|
||||
$updateTagBid->save();
|
||||
|
||||
$updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id)
|
||||
->where('user_id', $request->user_id)->first();
|
||||
$updateTagBidder->status_payment = 2;
|
||||
$updateTagBidder->payment_id = $add_payment->id;
|
||||
$updateTagBidder->save();
|
||||
}
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -105,7 +105,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
//===========PAY======================
|
||||
//get invoice detail
|
||||
Route::get('/invoice', [LelongMobileController::class, 'getInvoiceId']);
|
||||
//get invoice detail
|
||||
//get list photo's receipt
|
||||
Route::get('/listPhotoResit', [LelongMobileController::class, 'listPhotoResit']);
|
||||
//add photo resit
|
||||
Route::post('/addPhotoResit',[LelongMobileController::class, 'addPhotoResit']);
|
||||
@@ -113,6 +113,8 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
Route::get('/showPhotoResit',[LelongMobileController::class, 'showPhotoResit']);
|
||||
//delete photo resit
|
||||
Route::post('/deletePhotoResit',[LelongMobileController::class, 'deletePhotoResit']);
|
||||
//BY CAWANGAN -> initializie cdm payment
|
||||
Route::post('/initializeCdmPayment',[LelongMobileController::class, 'initializeCdmPayment']);
|
||||
|
||||
|
||||
// Lelong
|
||||
|
||||
Reference in New Issue
Block a user