Deploy Ladill Merchant / deploy (push) Successful in 28s
The give→merchant transform left several independent breakages that 500'd
once a logged-in user hit the pages:
- /storefronts/{create,show,update,...} were wired to Qr\QrCodeController,
which renders events-lineage qr-codes.* views referencing 14 undefined
events.* routes. Rewire to StorefrontController (clean storefronts.* views).
- storefronts/show.blade.php @include('give.storefronts.partials.*') — the
view dir was renamed give→merchant but the include namespace wasn't.
- /payouts + /search queried qr_sale_orders.*_minor; migration created *_ghs.
- Remove dead GiveDonation model (nonexistent give_donations table).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Merchant;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\QrSaleOrder;
|
|
use App\Models\QrCode;
|
|
use App\Services\Billing\BillingClient;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\View\View;
|
|
use Throwable;
|
|
|
|
class PayoutsController extends Controller
|
|
{
|
|
public function __construct(private BillingClient $billing) {}
|
|
|
|
public function index(): View
|
|
{
|
|
$account = ladill_account();
|
|
|
|
$qrIds = $account->qrCodes()
|
|
->where('type', QrCode::TYPE_SHOP)
|
|
->pluck('id');
|
|
|
|
$revenueMinor = (int) round(QrSaleOrder::query()
|
|
->whereIn('qr_code_id', $qrIds)
|
|
->where('status', QrSaleOrder::STATUS_PAID)
|
|
->sum('merchant_amount_ghs') * 100);
|
|
|
|
$balanceMinor = 0;
|
|
try {
|
|
$balanceMinor = $this->billing->balanceMinor($account->public_id);
|
|
} catch (Throwable $e) {
|
|
Log::warning('Give payouts could not load wallet balance', [
|
|
'user' => $account->public_id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
}
|
|
|
|
$accountWalletUrl = 'https://'.config('app.account_domain').'/wallet';
|
|
|
|
return view('merchant.payouts', [
|
|
'revenueMinor' => $revenueMinor,
|
|
'balanceMinor' => $balanceMinor,
|
|
'accountWalletUrl' => $accountWalletUrl,
|
|
]);
|
|
}
|
|
}
|