diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 6153af67..633985cf 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -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') ]; diff --git a/routes/web.php b/routes/web.php index 104ebe18..5115d518 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,8 +1,11 @@ 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'); \ No newline at end of file