mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 22:13:59 +00:00
fix duplicated bill plz problem
This commit is contained in:
@@ -16,23 +16,6 @@ class TransactionResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
if ($this->type === TransactionType::BILL){
|
||||
|
||||
$order = 1;
|
||||
|
||||
$bills = $this->booking->transactions()->bills()->where('original_amount', '=', $this->original_amount)->get();
|
||||
|
||||
if(count($bills) > 1){
|
||||
$key = $bills->search(function($bill){
|
||||
return $bill === $this->id;
|
||||
});
|
||||
$order = $key + 1;
|
||||
}
|
||||
|
||||
$payment = $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->get($order);
|
||||
|
||||
|
||||
}
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'booking' => new BookingResource($this->booking),
|
||||
@@ -52,7 +35,7 @@ class TransactionResource extends JsonResource
|
||||
'status' => (int) $this->status,
|
||||
'details' => TransactionDetailResource::collection($this->transactionDetails),
|
||||
'documents' => new DocumentResource($this->documents()->first()),
|
||||
'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, [])),
|
||||
'customer_booking' => new TransactionResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->transactions()->payments()->complete()->where('original_amount', '=', $this->original_amount)->where('id', '<', $this->id)->orderByDesc('id')->first())),
|
||||
'expires_on' => Carbon::parse($this->expires_on)->format('d-m-Y h:i:s A'),
|
||||
'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A')
|
||||
];
|
||||
|
||||
+7
-13
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
@@ -85,18 +88,9 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP
|
||||
})->name('products.random');
|
||||
|
||||
|
||||
Route::get('/1688', function (Request $request) {
|
||||
$token = Auth::fromUser(User::find(1));
|
||||
$request->headers->set('Authorization', 'Bearer '.$token);
|
||||
$bookings = \App\Models\Booking::whereHas('bank', function ($query){
|
||||
return $query->where('bank_name', 'like', '%浙江网商银行%');
|
||||
})->get();
|
||||
|
||||
$sum = 0;
|
||||
foreach ($bookings as $booking){
|
||||
$sum += $booking->transactions()->whereMonth('created_at', 12)->where('type', 1)->whereIn('status', [\App\Classes\ValueObjects\Constants\ApprovalStatus::APPROVED, \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED])->sum('amount');
|
||||
}
|
||||
|
||||
dd($sum);
|
||||
Route::get('/duplicated_bills', function (Request $request) {
|
||||
Auth()->login(User::find(1));
|
||||
$bookings = Booking::whereIn('id', [10391, 10275, 10109, 10108, 10070, 10066, 10063, 9801, 9166, 8895, 8790, 8544, 8264, 6957, 5409, 4717])->with('transactions')->pluck('marking');
|
||||
dd($bookings);
|
||||
|
||||
})->name('x2.data');
|
||||
Reference in New Issue
Block a user