fix pargar bugs 2
This commit is contained in:
@@ -247,7 +247,7 @@ class CustomerController extends SuperController
|
|||||||
if ($active){
|
if ($active){
|
||||||
$message ='اکانت شما توسط کارشناس سیستم تایید شد '."\n".
|
$message ='اکانت شما توسط کارشناس سیستم تایید شد '."\n".
|
||||||
'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n".
|
'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n".
|
||||||
$this->Config('app_url')."\n".
|
self::publicSiteUrl(request())."\n".
|
||||||
'با تشکر'.$this->Config('name_fa');
|
'با تشکر'.$this->Config('name_fa');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -315,10 +315,10 @@ class CustomerController extends SuperController
|
|||||||
|
|
||||||
|
|
||||||
$companyName = $this->Config('name_fa');
|
$companyName = $this->Config('name_fa');
|
||||||
$companyurl = $this->Config('app_url');
|
$companyurl = self::publicSiteUrl(request());
|
||||||
$message ='حساب کاربری شما توسط کارشناس سیستم تایید شد '."\n".
|
$message ='حساب کاربری شما توسط کارشناس سیستم تایید شد '."\n".
|
||||||
'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n".
|
'با رفتن به لینک زیر وارد حساب کاربری خود شوید'."\n".
|
||||||
$this->Config('app_url')."\n".
|
$companyurl."\n".
|
||||||
'با تشکر'.$this->Config('name_fa');
|
'با تشکر'.$this->Config('name_fa');
|
||||||
$this->Send($customer->mobile, $message);
|
$this->Send($customer->mobile, $message);
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class MassageController extends Controller
|
|||||||
|
|
||||||
$cfg = app(ConfigService::class);
|
$cfg = app(ConfigService::class);
|
||||||
$appName = (string) ($cfg->get('name_fa', '') ?: '');
|
$appName = (string) ($cfg->get('name_fa', '') ?: '');
|
||||||
$appUrl = (string) ($cfg->get('app_url', '') ?: '');
|
$appUrl = $cfg->resolvePublicSiteUrl($request);
|
||||||
|
|
||||||
$message = str_replace(
|
$message = str_replace(
|
||||||
['%name%', '%نام%', '%app_name%', '%نام_اپ%', '%app_url%', '%لینک_اپ%', '%لینک%'],
|
['%name%', '%نام%', '%app_name%', '%نام_اپ%', '%app_url%', '%لینک_اپ%', '%لینک%'],
|
||||||
|
|||||||
@@ -275,12 +275,24 @@ class PargarController extends Controller
|
|||||||
$result = app(PargarInboundWalletService::class)->syncWalletFromPargar($customer);
|
$result = app(PargarInboundWalletService::class)->syncWalletFromPargar($customer);
|
||||||
$appliedDocs = (int) ($result['documents']['applied'] ?? 0);
|
$appliedDocs = (int) ($result['documents']['applied'] ?? 0);
|
||||||
$appliedMande = (bool) ($result['mande']['applied'] ?? false);
|
$appliedMande = (bool) ($result['mande']['applied'] ?? false);
|
||||||
|
$mandeMessage = (string) ($result['mande']['message'] ?? '');
|
||||||
|
|
||||||
|
$messages = [];
|
||||||
|
if ($appliedDocs > 0) {
|
||||||
|
$messages[] = "{$appliedDocs} سند از پرگار اعمال شد";
|
||||||
|
}
|
||||||
|
if ($appliedMande) {
|
||||||
|
$messages[] = 'ماندهٔ پرگار روی کیف اعمال شد';
|
||||||
|
}
|
||||||
|
if ($mandeMessage !== '' && ! $appliedMande) {
|
||||||
|
$messages[] = $mandeMessage;
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'ok' => $appliedDocs > 0 || $appliedMande,
|
'ok' => $appliedDocs > 0 || $appliedMande,
|
||||||
'message' => $appliedDocs > 0 || $appliedMande
|
'message' => $messages !== []
|
||||||
? 'مانده از پرگار روی کیف اعمال شد'
|
? implode(' — ', $messages)
|
||||||
: ($result['mande']['message'] ?? 'سند قابلاعمالی یافت نشد'),
|
: 'سند قابلاعمالی یافت نشد',
|
||||||
'result' => $result,
|
'result' => $result,
|
||||||
], $appliedDocs > 0 || $appliedMande ? 200 : 422);
|
], $appliedDocs > 0 || $appliedMande ? 200 : 422);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,12 +83,12 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
protected function _loginWithSms($mobile, $provider)
|
protected function _loginWithSms($mobile, $provider)
|
||||||
{
|
{
|
||||||
|
$cfg = app(ConfigService::class);
|
||||||
|
|
||||||
if ($provider == 'user') {
|
if ($provider == 'user') {
|
||||||
$user = User::where('mobile', $mobile)->first();
|
$user = User::where('mobile', $mobile)->first();
|
||||||
$subDomain = $this->Config('admin_url');
|
|
||||||
} else {
|
} else {
|
||||||
$user = Customer::where('mobile', $mobile)->first();
|
$user = Customer::where('mobile', $mobile)->first();
|
||||||
$subDomain = $this->Config('app_url');
|
|
||||||
}
|
}
|
||||||
if (is_null($user)) {
|
if (is_null($user)) {
|
||||||
throw new UnprocessableEntityHttpException(trans('لطفا ابتدا ثبت نام بفرمایید'));
|
throw new UnprocessableEntityHttpException(trans('لطفا ابتدا ثبت نام بفرمایید'));
|
||||||
@@ -105,7 +105,14 @@ class AuthController extends Controller
|
|||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
if (self::isSmsNotifEnabled('sms_notif_login_otp')) {
|
if (self::isSmsNotifEnabled('sms_notif_login_otp')) {
|
||||||
$this->SendMessage($mobile, 'رمز عبور یکبار مصرف شما جهت ورود به اپلیکشن ' . $this->Config('name_fa') . ' ' . $rand . ' می باشد' . PHP_EOL . "@$subDomain" . " #" . $rand,true ,"sms");
|
$otpHost = $cfg->resolvePublicHost(request());
|
||||||
|
$otpLine = $otpHost !== '' ? PHP_EOL . "@{$otpHost} #{$rand}" : '';
|
||||||
|
$this->SendMessage(
|
||||||
|
$mobile,
|
||||||
|
'رمز عبور یکبار مصرف شما جهت ورود به اپلیکشن ' . $this->Config('name_fa') . ' ' . $rand . ' می باشد' . $otpLine,
|
||||||
|
true,
|
||||||
|
'sms'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user->id;
|
return $user->id;
|
||||||
@@ -229,7 +236,7 @@ class AuthController extends Controller
|
|||||||
$message .= "\nپس از اولین خرید مقدار، " . number_format((int) ($bonusValues[0]['customer'] ?? 0)) . ' ریال پاداش دریافت خواهید کرد.';
|
$message .= "\nپس از اولین خرید مقدار، " . number_format((int) ($bonusValues[0]['customer'] ?? 0)) . ' ریال پاداش دریافت خواهید کرد.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$message .= "\nنام کاربری: {$data['mobile']}\nورود به نرم افزار: {$this->Config('app_url')}";
|
$message .= "\nنام کاربری: {$data['mobile']}\nورود به نرم افزار: " . self::publicSiteUrl(request());
|
||||||
if (self::isSmsNotifEnabled('sms_notif_register_customer')) {
|
if (self::isSmsNotifEnabled('sms_notif_register_customer')) {
|
||||||
$this->Send($data['mobile'], $message);
|
$this->Send($data['mobile'], $message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,18 @@ class Controller extends BaseController
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** دامنهٔ عمومی سایت — فقط از درخواست HTTP فعلی */
|
||||||
|
protected static function publicHost(?\Illuminate\Http\Request $request = null): string
|
||||||
|
{
|
||||||
|
return app(ConfigService::class)->resolvePublicHost($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** آدرس کامل وباپ کاربر — مثلاً https://example.ir */
|
||||||
|
protected static function publicSiteUrl(?\Illuminate\Http\Request $request = null): string
|
||||||
|
{
|
||||||
|
return app(ConfigService::class)->resolvePublicSiteUrl($request);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function metalTypeSettingValue(): ?string
|
protected static function metalTypeSettingValue(): ?string
|
||||||
{
|
{
|
||||||
$metalType = Setting::where('key', 'metal_type')->value('value');
|
$metalType = Setting::where('key', 'metal_type')->value('value');
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ class SingleOrderController extends Controller
|
|||||||
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
|
"مبلغ کل: " . number_format($totalPrice) . "\n\n" .
|
||||||
"موجودی {$balanceLabel}: {$goldBalance}\n" .
|
"موجودی {$balanceLabel}: {$goldBalance}\n" .
|
||||||
"مانده ریالی: " . number_format($cashBalance) . "\n" .
|
"مانده ریالی: " . number_format($cashBalance) . "\n" .
|
||||||
$this->Config('app_url');
|
self::publicSiteUrl(request());
|
||||||
|
|
||||||
|
|
||||||
if (self::isSmsNotifEnabled('sms_notif_order_customer')) {
|
if (self::isSmsNotifEnabled('sms_notif_order_customer')) {
|
||||||
@@ -964,7 +964,7 @@ class SingleOrderController extends Controller
|
|||||||
->where('owner_type', $customer->type)
|
->where('owner_type', $customer->type)
|
||||||
->main()
|
->main()
|
||||||
->first();
|
->first();
|
||||||
$companyurl = $this->Config('app_url');
|
$companyurl = self::publicSiteUrl(request());
|
||||||
$weight = $data['amount'];
|
$weight = $data['amount'];
|
||||||
$totalAmount = $data['total_price'];
|
$totalAmount = $data['total_price'];
|
||||||
$pricePerGram = $weight > 0 ? $totalAmount / $weight : 0;
|
$pricePerGram = $weight > 0 ? $totalAmount / $weight : 0;
|
||||||
|
|||||||
@@ -204,11 +204,11 @@ class RequestsController extends Controller
|
|||||||
if($data['method'] == 'cash') {
|
if($data['method'] == 'cash') {
|
||||||
$customerMessage = "$companyName\nبرداشت ریالی \nمبلغ: {$data['amount']}\n" .
|
$customerMessage = "$companyName\nبرداشت ریالی \nمبلغ: {$data['amount']}\n" .
|
||||||
"\nموجودی طلایی: {$goldBalance}\n" .
|
"\nموجودی طلایی: {$goldBalance}\n" .
|
||||||
"مانده ریالی: " . number_format($cashBalance) . "\n" . $this->Config('app_url');
|
"مانده ریالی: " . number_format($cashBalance) . "\n" . self::publicSiteUrl(request());
|
||||||
}elseif ($data['method'] == 'gold') {
|
}elseif ($data['method'] == 'gold') {
|
||||||
$customerMessage = "$companyName\nبرداشت طلایی \nگرم: {$data['amount']}\nقیمت گرم: " . number_format($pricePerGram) .
|
$customerMessage = "$companyName\nبرداشت طلایی \nگرم: {$data['amount']}\nقیمت گرم: " . number_format($pricePerGram) .
|
||||||
"\nمبلغ کل: " . number_format($data['total_price']) . "\nموجودی طلایی: {$goldBalance}\n" .
|
"\nمبلغ کل: " . number_format($data['total_price']) . "\nموجودی طلایی: {$goldBalance}\n" .
|
||||||
"مانده ریالی: " . number_format($cashBalance) . "\n" . $this->Config('app_url');
|
"مانده ریالی: " . number_format($cashBalance) . "\n" . self::publicSiteUrl(request());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class SuperController extends Controller
|
|||||||
} while ($existingCustomer); // تکرار تا زمانی که کد یونیک ایجاد شود
|
} while ($existingCustomer); // تکرار تا زمانی که کد یونیک ایجاد شود
|
||||||
$data['referral_id'] = $uniqueId; // ذخیره کد یونیک در فیلد referral_id
|
$data['referral_id'] = $uniqueId; // ذخیره کد یونیک در فیلد referral_id
|
||||||
|
|
||||||
$message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\nورود به نرم افزار: {$this->Config('app_url')}";
|
$message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\nورود به نرم افزار: " . self::publicSiteUrl(request());
|
||||||
|
|
||||||
$this->Send($data['mobile'], $message);
|
$this->Send($data['mobile'], $message);
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class paypingController extends Controller
|
|||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'title' => $this->Config('name_fa'),
|
'title' => $this->Config('name_fa'),
|
||||||
'return_url' => 'https://' . $this->Config('app_url') . '/transactions',
|
'return_url' => $this->cfg()->resolvePublicSiteUrl(request()) . '/transactions',
|
||||||
'server_call_url' => url('/customer/charge_account_verify/' . $Withdraw->id),
|
'server_call_url' => url('/customer/charge_account_verify/' . $Withdraw->id),
|
||||||
'item' => $this->resolveGatewayItem(),
|
'item' => $this->resolveGatewayItem(),
|
||||||
];
|
];
|
||||||
@@ -158,7 +158,7 @@ class paypingController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$Withdraw = Withdraw::with('customer')->where('id', $id)->first();
|
$Withdraw = Withdraw::with('customer')->where('id', $id)->first();
|
||||||
$app_url = $this->Config('app_url');
|
$site_url = $this->cfg()->resolvePublicSiteUrl(request());
|
||||||
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
||||||
|
|
||||||
$GTransaction = Http::withHeaders($this->paypingHeaders())
|
$GTransaction = Http::withHeaders($this->paypingHeaders())
|
||||||
@@ -206,7 +206,7 @@ class paypingController extends Controller
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view('showTransactionReport', compact('Withdraw', 'app_url'));
|
return view('showTransactionReport', compact('Withdraw', 'site_url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'مبلغ پرداختی دستکاری شده !';
|
return 'مبلغ پرداختی دستکاری شده !';
|
||||||
@@ -221,13 +221,13 @@ class paypingController extends Controller
|
|||||||
$Withdraw->sts = 3;
|
$Withdraw->sts = 3;
|
||||||
$Withdraw->save();
|
$Withdraw->save();
|
||||||
|
|
||||||
return view('showTransactionReport', compact('Withdraw', 'app_url'));
|
return view('showTransactionReport', compact('Withdraw', 'site_url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifyTransation()
|
public function verifyTransation()
|
||||||
{
|
{
|
||||||
$Withdraw = Withdraw::with('customer')->where('id', $_GET['clientrefid'])->first();
|
$Withdraw = Withdraw::with('customer')->where('id', $_GET['clientrefid'])->first();
|
||||||
$app_url = $this->Config('app_url');
|
$site_url = $this->cfg()->resolvePublicSiteUrl(request());
|
||||||
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
$User = Customer::where('id', $Withdraw->customer_id)->first();
|
||||||
|
|
||||||
$verifyResponse = Http::withToken('cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525')
|
$verifyResponse = Http::withToken('cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525')
|
||||||
@@ -297,7 +297,7 @@ class paypingController extends Controller
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view('showTransactionReport', compact('Withdraw', 'app_url'));
|
return view('showTransactionReport', compact('Withdraw', 'site_url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'مبلغ پرداختی دستکاری شده !';
|
return 'مبلغ پرداختی دستکاری شده !';
|
||||||
@@ -306,6 +306,6 @@ class paypingController extends Controller
|
|||||||
$Withdraw->sts = 3;
|
$Withdraw->sts = 3;
|
||||||
$Withdraw->save();
|
$Withdraw->save();
|
||||||
|
|
||||||
return view('showTransactionReport', compact('Withdraw', 'app_url'));
|
return view('showTransactionReport', compact('Withdraw', 'site_url'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-16
@@ -170,7 +170,7 @@ class File extends Model
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$rows = Setting::query()
|
$rows = Setting::query()
|
||||||
->whereIn('key', ['bace_url', 'server_url', 'admin_url', 'app_url'])
|
->whereIn('key', ['bace_url', 'server_url'])
|
||||||
->where('is_active', 1)
|
->where('is_active', 1)
|
||||||
->pluck('value', 'key');
|
->pluck('value', 'key');
|
||||||
|
|
||||||
@@ -180,21 +180,6 @@ class File extends Model
|
|||||||
return rtrim($value, '/');
|
return rtrim($value, '/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminUrl = trim((string) ($rows['admin_url'] ?? ''));
|
|
||||||
if ($adminUrl !== '' && preg_match('#/admin#i', $adminUrl)) {
|
|
||||||
return rtrim(preg_replace('#/admin/?$#i', '/server', rtrim($adminUrl, '/')), '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
$siteUrl = trim((string) ($rows['app_url'] ?? ''));
|
|
||||||
if ($siteUrl !== '') {
|
|
||||||
$siteUrl = rtrim($siteUrl, '/');
|
|
||||||
if (! preg_match('#/server$#i', $siteUrl)) {
|
|
||||||
$siteUrl .= '/server';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $siteUrl;
|
|
||||||
}
|
|
||||||
} catch (\Throwable) {
|
} catch (\Throwable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -756,4 +756,102 @@ class ConfigService
|
|||||||
{
|
{
|
||||||
return $this->accountingProvider() === self::ACCOUNTING_PARGAR;
|
return $this->accountingProvider() === self::ACCOUNTING_PARGAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname for WebOTP SMS (@domain #code) and other public links.
|
||||||
|
* Only from the current HTTP request — no settings, no .env.
|
||||||
|
*/
|
||||||
|
public function resolvePublicHost(?\Illuminate\Http\Request $request = null): string
|
||||||
|
{
|
||||||
|
foreach ($this->publicHostCandidates($request) as $host) {
|
||||||
|
if ($this->isUsableHost($host)) {
|
||||||
|
return $this->normalizeHost($host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Full user-facing site URL, e.g. https://example.ir */
|
||||||
|
public function resolvePublicSiteUrl(?\Illuminate\Http\Request $request = null): string
|
||||||
|
{
|
||||||
|
if ($request !== null) {
|
||||||
|
$origin = rtrim(trim((string) $request->getSchemeAndHttpHost()), '/');
|
||||||
|
$host = $this->parseHostFromUrl($origin);
|
||||||
|
if ($this->isUsableHost($host)) {
|
||||||
|
return $origin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! app()->runningInConsole() && request()) {
|
||||||
|
$origin = rtrim(trim((string) request()->getSchemeAndHttpHost()), '/');
|
||||||
|
$host = $this->parseHostFromUrl($origin);
|
||||||
|
if ($this->isUsableHost($host)) {
|
||||||
|
return $origin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$host = $this->resolvePublicHost($request);
|
||||||
|
if ($host !== '') {
|
||||||
|
return 'https://' . $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use resolvePublicHost() — kept for backward compatibility */
|
||||||
|
public function resolveHostForOtp(string $urlSettingKey = 'app_url', ?\Illuminate\Http\Request $request = null): string
|
||||||
|
{
|
||||||
|
return $this->resolvePublicHost($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return list<string> */
|
||||||
|
private function publicHostCandidates(?\Illuminate\Http\Request $request): array
|
||||||
|
{
|
||||||
|
$candidates = [];
|
||||||
|
|
||||||
|
if ($request !== null) {
|
||||||
|
$candidates[] = trim((string) $request->getHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! app()->runningInConsole() && request()) {
|
||||||
|
$candidates[] = trim((string) request()->getHost());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $candidates;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isUsableHost(string $host): bool
|
||||||
|
{
|
||||||
|
$host = strtolower(trim($host));
|
||||||
|
|
||||||
|
return $host !== ''
|
||||||
|
&& ! in_array($host, ['localhost', '127.0.0.1', '0.0.0.0'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseHostFromUrl(string $url): string
|
||||||
|
{
|
||||||
|
$url = trim($url);
|
||||||
|
if ($url === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! preg_match('#^https?://#i', $url)) {
|
||||||
|
$url = 'https://' . ltrim($url, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$host = parse_url($url, PHP_URL_HOST);
|
||||||
|
if (! is_string($host) || $host === '') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->normalizeHost($host);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeHost(string $host): string
|
||||||
|
{
|
||||||
|
$host = strtolower(trim($host));
|
||||||
|
|
||||||
|
return str_starts_with($host, 'www.') ? substr($host, 4) : $host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,6 +172,13 @@ class PargarInboundWalletService
|
|||||||
*/
|
*/
|
||||||
public function applyLatestMandeDifference(Customer $customer): array
|
public function applyLatestMandeDifference(Customer $customer): array
|
||||||
{
|
{
|
||||||
|
if ($this->hasPendingOutboundWalletSync((int) $customer->id)) {
|
||||||
|
return [
|
||||||
|
'applied' => false,
|
||||||
|
'message' => 'سند ارسالی از پنل به پرگار هنوز تأیید نشده — برای جلوگیری از برگشت شارژ، ماندهٔ پرگار اعمال نشد',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$log = PargarSyncLog::query()
|
$log = PargarSyncLog::query()
|
||||||
->where('customer_id', $customer->id)
|
->where('customer_id', $customer->id)
|
||||||
->where('type', PargarSyncService::TYPE_MANDE)
|
->where('type', PargarSyncService::TYPE_MANDE)
|
||||||
@@ -393,6 +400,15 @@ class PargarInboundWalletService
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function hasPendingOutboundWalletSync(int $customerId): bool
|
||||||
|
{
|
||||||
|
return PargarSyncLog::query()
|
||||||
|
->where('customer_id', $customerId)
|
||||||
|
->whereIn('type', [PargarSyncService::TYPE_WALLET_CASH, PargarSyncService::TYPE_WALLET_GOLD])
|
||||||
|
->where('sync_status', PargarSyncService::STATUS_PENDING)
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
|
||||||
private function parseNumber(mixed $value): float
|
private function parseNumber(mixed $value): float
|
||||||
{
|
{
|
||||||
if ($value === null || $value === '') {
|
if ($value === null || $value === '') {
|
||||||
|
|||||||
@@ -38,36 +38,7 @@ class PriceStreamService
|
|||||||
|
|
||||||
public function resolveHost(?Request $request = null): string
|
public function resolveHost(?Request $request = null): string
|
||||||
{
|
{
|
||||||
$config = app(ConfigService::class);
|
return app(ConfigService::class)->resolvePublicHost($request);
|
||||||
|
|
||||||
$appUrl = trim($config->getString('app_url', ''));
|
|
||||||
if ($appUrl !== '') {
|
|
||||||
$host = parse_url($appUrl, PHP_URL_HOST);
|
|
||||||
if (is_string($host) && $host !== '') {
|
|
||||||
return $this->normalizeHost($host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request !== null) {
|
|
||||||
$requestHost = trim((string) $request->getHost());
|
|
||||||
if ($requestHost !== '') {
|
|
||||||
return $this->normalizeHost($requestHost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! app()->runningInConsole() && request()) {
|
|
||||||
$requestHost = trim((string) request()->getHost());
|
|
||||||
if ($requestHost !== '') {
|
|
||||||
return $this->normalizeHost($requestHost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$nameEn = trim((string) $config->getString('name_en', ''));
|
|
||||||
if ($nameEn !== '') {
|
|
||||||
return $this->normalizeHost($nameEn);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function currentSeq(): int
|
public function currentSeq(): int
|
||||||
@@ -219,11 +190,4 @@ class PriceStreamService
|
|||||||
|
|
||||||
return md5(json_encode($data, JSON_UNESCAPED_UNICODE));
|
return md5(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeHost(string $host): string
|
|
||||||
{
|
|
||||||
$host = strtolower(trim($host));
|
|
||||||
|
|
||||||
return strpos($host, 'www.') === 0 ? substr($host, 4) : $host;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class ReferralGiftService
|
|||||||
$giftForInviter = (float) $config->get('gift_for_referrer', 0);
|
$giftForInviter = (float) $config->get('gift_for_referrer', 0);
|
||||||
$giftForInvited = (float) $config->get('gift_for_referral', 0);
|
$giftForInvited = (float) $config->get('gift_for_referral', 0);
|
||||||
$companyName = $config->getString('name_fa');
|
$companyName = $config->getString('name_fa');
|
||||||
$companyUrl = $config->getString('app_url');
|
$companyUrl = $config->resolvePublicSiteUrl(request());
|
||||||
|
|
||||||
if ($referrer && $referrerGiftAllowed && $giftForInviter > 0 && !$this->referrerGiftAlreadyGiven($customer, $referrer)) {
|
if ($referrer && $referrerGiftAllowed && $giftForInviter > 0 && !$this->referrerGiftAlreadyGiven($customer, $referrer)) {
|
||||||
$this->giveReferrerGift($customer, $referrer, $giftForInviter, $companyName, $companyUrl, $config);
|
$this->giveReferrerGift($customer, $referrer, $giftForInviter, $companyName, $companyUrl, $config);
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class WebsocketBroadcastService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$body = array_merge($payload, ['trigger' => $trigger]);
|
$body = array_merge($payload, ['trigger' => $trigger]);
|
||||||
$host = $this->resolveHost();
|
$host = app(ConfigService::class)->resolvePublicHost();
|
||||||
if ($host !== '') {
|
if ($host !== '') {
|
||||||
$body['host'] = $host;
|
$body['host'] = $host;
|
||||||
}
|
}
|
||||||
@@ -103,31 +103,4 @@ class WebsocketBroadcastService
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function resolveHost(): string
|
|
||||||
{
|
|
||||||
$config = app(ConfigService::class);
|
|
||||||
|
|
||||||
$appUrl = trim($config->getString('app_url', ''));
|
|
||||||
if ($appUrl !== '') {
|
|
||||||
$host = parse_url($appUrl, PHP_URL_HOST);
|
|
||||||
if (is_string($host) && $host !== '') {
|
|
||||||
return $host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! app()->runningInConsole() && request()) {
|
|
||||||
$requestHost = trim((string) request()->getHost());
|
|
||||||
if ($requestHost !== '') {
|
|
||||||
return $requestHost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$nameEn = trim((string) $config->getString('name_en', ''));
|
|
||||||
if ($nameEn !== '') {
|
|
||||||
return $nameEn;
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -338,7 +338,7 @@
|
|||||||
<script>
|
<script>
|
||||||
function redirectAfterDelay() {
|
function redirectAfterDelay() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.location.href = 'https://' + '{{$app_url}}';
|
window.location.href = '{{ $site_url }}/transactions';
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\Services\ConfigService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ConfigServiceOtpHostTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_uses_request_host_without_settings(): void
|
||||||
|
{
|
||||||
|
$request = Request::create('https://boursemes.com/server/auth/login', 'POST');
|
||||||
|
$this->app->instance('request', $request);
|
||||||
|
|
||||||
|
$host = app(ConfigService::class)->resolvePublicHost($request);
|
||||||
|
|
||||||
|
$this->assertSame('boursemes.com', $host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_resolve_public_site_url_from_request(): void
|
||||||
|
{
|
||||||
|
$request = Request::create('https://boursemes.com/server/auth/login', 'POST');
|
||||||
|
|
||||||
|
$url = app(ConfigService::class)->resolvePublicSiteUrl($request);
|
||||||
|
|
||||||
|
$this->assertSame('https://boursemes.com', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_returns_empty_without_request(): void
|
||||||
|
{
|
||||||
|
$host = app(ConfigService::class)->resolvePublicHost();
|
||||||
|
|
||||||
|
$this->assertSame('', $host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_strips_www_prefix(): void
|
||||||
|
{
|
||||||
|
$request = Request::create('https://www.boursemes.com/server/auth/login', 'POST');
|
||||||
|
|
||||||
|
$host = app(ConfigService::class)->resolvePublicHost($request);
|
||||||
|
|
||||||
|
$this->assertSame('boursemes.com', $host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_skips_localhost_request_host(): void
|
||||||
|
{
|
||||||
|
$request = Request::create('http://localhost/server/auth/login', 'POST');
|
||||||
|
$this->app->instance('request', $request);
|
||||||
|
|
||||||
|
$host = app(ConfigService::class)->resolvePublicHost($request);
|
||||||
|
|
||||||
|
$this->assertSame('', $host);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user