This commit is contained in:
2026-07-16 14:33:57 +03:30
parent 41c2a20fd0
commit 69538226d2
9 changed files with 28 additions and 73 deletions
@@ -512,29 +512,6 @@ class ProductController extends SuperController
}
/** فروشگاه — نمایش در اپ کاربر: فعال + ساعات + قیمت ذخیره‌شده یا محصول وزنی */
private function storeProductShowForCustomer(Product $product): bool
{
if (! $product->active) {
return false;
}
if (! app(ConfigService::class)->isProductWithinTradingHours($product)) {
return false;
}
$storedPrice = (int) ($product->price ?? 0) + (int) ($product->price_profit ?? 0);
if ($storedPrice > 0) {
return true;
}
if ((int) ($product->direct_price ?? 0) === 0 && (float) ($product->amount ?? 0) > 0) {
return true;
}
return false;
}
private function isCustomerApiRequest(): bool
{
$path = trim((string) request()->path(), '/');
@@ -569,14 +546,7 @@ class ProductController extends SuperController
return;
}
if (app(ConfigService::class)->isStore()) {
$products->each(function (Product $product) {
$product->setAttribute('show', $this->storeProductShowForCustomer($product));
});
return;
}
// فروشگاه و خانگی: همان enrich قیمت لحظه‌ای (آبشده/قیمت اپ/مرجع) — بدون UPDATE دیتابیس
$displayPriceService = app(ProductDisplayPriceService::class);
$displayPriceService->warmLivePriceCache();
$displayPriceService->enrichForApi($products);
@@ -592,7 +562,7 @@ class ProductController extends SuperController
*/
private function enrichAdminTablePrices($rows): void
{
if ($rows === null || app(ConfigService::class)->isStore()) {
if ($rows === null) {
return;
}
+4 -4
View File
@@ -53,7 +53,7 @@ class AuthController extends Controller
throw new UnprocessableEntityHttpException('شماره موبایل یا پسوورد وارد شده اشتباه است');
}
if (!$user->active) {
throw new UnprocessableEntityHttpException(trans('error.no_active'));
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
}
if ($user->is_archive) {
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
@@ -70,7 +70,7 @@ class AuthController extends Controller
}
$user = auth($provider)->user();
if (!$user->active) {
throw new UnprocessableEntityHttpException(trans('error.no_active'));
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
}
if ($provider == 'customer' && $user->is_archive) {
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
@@ -94,7 +94,7 @@ class AuthController extends Controller
throw new UnprocessableEntityHttpException(trans('لطفا ابتدا ثبت نام بفرمایید'));
}
if (!$user->active) {
throw new UnprocessableEntityHttpException(trans('اکانت شما باید توسط ادمین فعال شود'));
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
}
if ($provider == 'customer' && $user->is_archive) {
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
@@ -124,7 +124,7 @@ class AuthController extends Controller
$user->save();
return $this->respondWithToken($token);
}
throw new UnprocessableEntityHttpException(trans('error.wrong_code'));
throw new UnprocessableEntityHttpException('کد وارد شده اشتباه است');
}
protected function respondWithToken($token)
@@ -20,7 +20,6 @@ use App\Http\Controllers\Admin\TahesabController;
use App\Services\ConfigService;
use App\Services\ReferralGiftService;
use App\Services\WalletBalanceService;
use App\Support\PersianDigits;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
@@ -189,7 +188,6 @@ class CustomerController extends Controller
$customer = Customer::findOrFail(auth('customer')->id());
$wasLegal = (int) $customer->is_legal;
$updateData = $request->except(['referral_id', 'referral_to_id', 'is_legal']);
$updateData = PersianDigits::toEnglish($updateData);
if (!empty($updateData['birth_date'])) {
try {
$updateData['birth_date'] = Carbon::parse($updateData['birth_date'])->format('Y-m-d');
@@ -23,9 +23,7 @@ class EnsureCustomerIsActive
if (!$customer->active) {
return response()->json([
'message' => trans('error.no_active') !== 'error.no_active'
? trans('error.no_active')
: 'اکانت شما توسط کارشناس سیستم غیر فعال شد',
'message' => 'شما مجوز دسترسی به اکانت خود را ندارید',
], 401);
}
+2 -7
View File
@@ -79,17 +79,12 @@ class ProductDisplayPriceService
$this->resolveFallbackPayload();
}
if (! app(ConfigService::class)->isStore()) {
app(ZaarboxPriceService::class)->cachedPriceList(false);
}
// فروشگاه و خانگی هر دو ممکن است reading_method / قیمت اپ داشته باشند
app(ZaarboxPriceService::class)->cachedPriceList(false);
}
public function enrichForApi(Collection|iterable $products): void
{
if (app(ConfigService::class)->isStore()) {
return;
}
$collection = collect($products);
$zaarbox = app(ZaarboxPriceService::class);
// مثل ادمین — روی cache miss یک بار fetch؛ نه فقط getCachedPriceListOnly
+7 -1
View File
@@ -37,7 +37,8 @@ class ProductPriceSyncService
: 'http://212.23.201.173:8381/price_list';
if ($feed === null) {
return false;
// حتی بدون فید مرجع، محصولات قیمت‌اپ را با مظنه زنده همگام کن
return $this->syncAppPriceProducts();
}
$products = Product::query()->whereNotNull('reading_method')->get();
@@ -77,6 +78,11 @@ class ProductPriceSyncService
app(PriceSyncLogService::class)->record($source, $sourceUrl, $liquidGoldPrice, $logItems);
// مثل خانگی: آبشده / قیمت‌اپ را هم با مظنه زنده در DB همگام کن (fallback نمایش)
if ($this->syncAppPriceProducts()) {
$synced = true;
}
if ($synced) {
app(PriceBroadcastService::class)->broadcastListIfChanged();
}
-24
View File
@@ -1,24 +0,0 @@
<?php
namespace App\Support;
class PersianDigits
{
public static function toEnglish(mixed $value): mixed
{
if (is_string($value)) {
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
$latin = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
$value = str_replace(array_merge($persian, $arabic), array_merge($latin, $latin), $value);
return str_replace('٫', '.', $value);
}
if (is_array($value)) {
return array_map([self::class, 'toEnglish'], $value);
}
return $value;
}
}
+6
View File
@@ -0,0 +1,6 @@
<?php
return [
'no_active' => 'شما مجوز دسترسی به اکانت خود را ندارید',
'wrong_code' => 'کد وارد شده اشتباه است',
];
+6
View File
@@ -0,0 +1,6 @@
<?php
return [
'no_active' => 'شما مجوز دسترسی به اکانت خود را ندارید',
'wrong_code' => 'کد وارد شده اشتباه است',
];