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:
@@ -82,6 +82,10 @@ class GiftCardController extends Controller
|
||||
throw new UnprocessableEntityHttpException('auth failed!');
|
||||
}
|
||||
|
||||
if (!app(ConfigService::class)->getBool('has_page_gift_card', false)) {
|
||||
throw new UnprocessableEntityHttpException('قابلیت کارت هدیه غیرفعال است.');
|
||||
}
|
||||
|
||||
$redeem = $request->code;
|
||||
$giftcode = GiftCardCodes::where('code', $redeem)->first();
|
||||
$gift = GiftCard::find($giftcode->giftcard_id);
|
||||
|
||||
@@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user