Enable gated multi-level referral profit and harden chat/SMS notify paths.

Honor enable_customer_level_profit for order referral payouts, and tighten support-chat webhook/SMS plus SuperAdmin SMS panel sync settings.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-10 16:48:53 +03:30
co-authored by Cursor
parent f421fcb83f
commit 279e4bc881
8 changed files with 277 additions and 110 deletions
@@ -144,6 +144,7 @@ class SmsPanelController extends Controller
/**
* خلاصه سبک کیف پول برای نمایش «اعتبار پیامک» در هدر؛ برای همه ادمین‌ها.
* اگر سوپرادمین قطع باشد، روی آینهٔ محلی برمی‌گردیم — نه 502 (ویجت هدر نباید بترکد).
*/
public function walletSummary()
{
@@ -159,24 +160,39 @@ class SmsPanelController extends Controller
if ($this->useSuperAdmin()) {
$balanceData = $this->sa()->balance();
$charge = $this->sa()->chargeInfo();
if ($balanceData === null || $charge === null) {
$this->abortSaUnavailable();
if ($balanceData !== null) {
$deposit = is_array($charge)
? $this->depositFromChargeInfo($charge)
: SmsWalletService::getDepositInfo();
$this->mirrorLocalFromSa(array_merge($balanceData, [
'charge_info' => is_array($charge) ? $charge : [],
'deposit' => $deposit,
]));
return response()->json([
'enabled' => true,
'balance' => (int) ($balanceData['balance'] ?? 0),
'is_blocked' => (bool) ($balanceData['is_blocked'] ?? false),
'deposit' => $deposit,
'source' => 'superadmin',
'sa_partial' => $charge === null,
]);
}
$this->mirrorLocalFromSa(array_merge($balanceData, [
'charge_info' => $charge,
'deposit' => $this->depositFromChargeInfo($charge),
]));
return response()->json([
'enabled' => true,
'balance' => (int) ($balanceData['balance'] ?? 0),
'is_blocked' => (bool) ($balanceData['is_blocked'] ?? false),
'deposit' => $this->depositFromChargeInfo($charge),
'source' => 'superadmin',
]);
// SA فعال است ولی balance نرسید — آخرین آینهٔ محلی
return response()->json($this->localWalletSummaryPayload('local_fallback'));
}
return response()->json($this->localWalletSummaryPayload('local'));
}
/**
* @return array{enabled: bool, balance: int, is_blocked: bool, deposit: array, source: string}
*/
private function localWalletSummaryPayload(string $source): array
{
$balance = 0;
$isBlocked = false;
@@ -186,12 +202,13 @@ class SmsPanelController extends Controller
$isBlocked = (bool) $wallet->is_blocked;
}
return response()->json([
return [
'enabled' => true,
'balance' => $balance,
'is_blocked' => $isBlocked,
'deposit' => SmsWalletService::getDepositInfo(),
]);
'source' => $source,
];
}
/**