fix bugs
This commit is contained in:
@@ -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
|
private function isCustomerApiRequest(): bool
|
||||||
{
|
{
|
||||||
$path = trim((string) request()->path(), '/');
|
$path = trim((string) request()->path(), '/');
|
||||||
@@ -569,14 +546,7 @@ class ProductController extends SuperController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app(ConfigService::class)->isStore()) {
|
// فروشگاه و خانگی: همان enrich قیمت لحظهای (آبشده/قیمت اپ/مرجع) — بدون UPDATE دیتابیس
|
||||||
$products->each(function (Product $product) {
|
|
||||||
$product->setAttribute('show', $this->storeProductShowForCustomer($product));
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||||
$displayPriceService->warmLivePriceCache();
|
$displayPriceService->warmLivePriceCache();
|
||||||
$displayPriceService->enrichForApi($products);
|
$displayPriceService->enrichForApi($products);
|
||||||
@@ -592,7 +562,7 @@ class ProductController extends SuperController
|
|||||||
*/
|
*/
|
||||||
private function enrichAdminTablePrices($rows): void
|
private function enrichAdminTablePrices($rows): void
|
||||||
{
|
{
|
||||||
if ($rows === null || app(ConfigService::class)->isStore()) {
|
if ($rows === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class AuthController extends Controller
|
|||||||
throw new UnprocessableEntityHttpException('شماره موبایل یا پسوورد وارد شده اشتباه است');
|
throw new UnprocessableEntityHttpException('شماره موبایل یا پسوورد وارد شده اشتباه است');
|
||||||
}
|
}
|
||||||
if (!$user->active) {
|
if (!$user->active) {
|
||||||
throw new UnprocessableEntityHttpException(trans('error.no_active'));
|
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
|
||||||
}
|
}
|
||||||
if ($user->is_archive) {
|
if ($user->is_archive) {
|
||||||
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
||||||
@@ -70,7 +70,7 @@ class AuthController extends Controller
|
|||||||
}
|
}
|
||||||
$user = auth($provider)->user();
|
$user = auth($provider)->user();
|
||||||
if (!$user->active) {
|
if (!$user->active) {
|
||||||
throw new UnprocessableEntityHttpException(trans('error.no_active'));
|
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
|
||||||
}
|
}
|
||||||
if ($provider == 'customer' && $user->is_archive) {
|
if ($provider == 'customer' && $user->is_archive) {
|
||||||
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
||||||
@@ -94,7 +94,7 @@ class AuthController extends Controller
|
|||||||
throw new UnprocessableEntityHttpException(trans('لطفا ابتدا ثبت نام بفرمایید'));
|
throw new UnprocessableEntityHttpException(trans('لطفا ابتدا ثبت نام بفرمایید'));
|
||||||
}
|
}
|
||||||
if (!$user->active) {
|
if (!$user->active) {
|
||||||
throw new UnprocessableEntityHttpException(trans('اکانت شما باید توسط ادمین فعال شود'));
|
throw new UnprocessableEntityHttpException('شما مجوز دسترسی به اکانت خود را ندارید');
|
||||||
}
|
}
|
||||||
if ($provider == 'customer' && $user->is_archive) {
|
if ($provider == 'customer' && $user->is_archive) {
|
||||||
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
throw new UnprocessableEntityHttpException('شما اجازه ورود به سیستم را ندارید');
|
||||||
@@ -124,7 +124,7 @@ class AuthController extends Controller
|
|||||||
$user->save();
|
$user->save();
|
||||||
return $this->respondWithToken($token);
|
return $this->respondWithToken($token);
|
||||||
}
|
}
|
||||||
throw new UnprocessableEntityHttpException(trans('error.wrong_code'));
|
throw new UnprocessableEntityHttpException('کد وارد شده اشتباه است');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function respondWithToken($token)
|
protected function respondWithToken($token)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use App\Http\Controllers\Admin\TahesabController;
|
|||||||
use App\Services\ConfigService;
|
use App\Services\ConfigService;
|
||||||
use App\Services\ReferralGiftService;
|
use App\Services\ReferralGiftService;
|
||||||
use App\Services\WalletBalanceService;
|
use App\Services\WalletBalanceService;
|
||||||
use App\Support\PersianDigits;
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
@@ -189,7 +188,6 @@ class CustomerController extends Controller
|
|||||||
$customer = Customer::findOrFail(auth('customer')->id());
|
$customer = Customer::findOrFail(auth('customer')->id());
|
||||||
$wasLegal = (int) $customer->is_legal;
|
$wasLegal = (int) $customer->is_legal;
|
||||||
$updateData = $request->except(['referral_id', 'referral_to_id', 'is_legal']);
|
$updateData = $request->except(['referral_id', 'referral_to_id', 'is_legal']);
|
||||||
$updateData = PersianDigits::toEnglish($updateData);
|
|
||||||
if (!empty($updateData['birth_date'])) {
|
if (!empty($updateData['birth_date'])) {
|
||||||
try {
|
try {
|
||||||
$updateData['birth_date'] = Carbon::parse($updateData['birth_date'])->format('Y-m-d');
|
$updateData['birth_date'] = Carbon::parse($updateData['birth_date'])->format('Y-m-d');
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ class EnsureCustomerIsActive
|
|||||||
|
|
||||||
if (!$customer->active) {
|
if (!$customer->active) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => trans('error.no_active') !== 'error.no_active'
|
'message' => 'شما مجوز دسترسی به اکانت خود را ندارید',
|
||||||
? trans('error.no_active')
|
|
||||||
: 'اکانت شما توسط کارشناس سیستم غیر فعال شد',
|
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,17 +79,12 @@ class ProductDisplayPriceService
|
|||||||
$this->resolveFallbackPayload();
|
$this->resolveFallbackPayload();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! app(ConfigService::class)->isStore()) {
|
// فروشگاه و خانگی هر دو ممکن است reading_method / قیمت اپ داشته باشند
|
||||||
app(ZaarboxPriceService::class)->cachedPriceList(false);
|
app(ZaarboxPriceService::class)->cachedPriceList(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enrichForApi(Collection|iterable $products): void
|
public function enrichForApi(Collection|iterable $products): void
|
||||||
{
|
{
|
||||||
if (app(ConfigService::class)->isStore()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$collection = collect($products);
|
$collection = collect($products);
|
||||||
$zaarbox = app(ZaarboxPriceService::class);
|
$zaarbox = app(ZaarboxPriceService::class);
|
||||||
// مثل ادمین — روی cache miss یک بار fetch؛ نه فقط getCachedPriceListOnly
|
// مثل ادمین — روی cache miss یک بار fetch؛ نه فقط getCachedPriceListOnly
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class ProductPriceSyncService
|
|||||||
: 'http://212.23.201.173:8381/price_list';
|
: 'http://212.23.201.173:8381/price_list';
|
||||||
|
|
||||||
if ($feed === null) {
|
if ($feed === null) {
|
||||||
return false;
|
// حتی بدون فید مرجع، محصولات قیمتاپ را با مظنه زنده همگام کن
|
||||||
|
return $this->syncAppPriceProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
$products = Product::query()->whereNotNull('reading_method')->get();
|
$products = Product::query()->whereNotNull('reading_method')->get();
|
||||||
@@ -77,6 +78,11 @@ class ProductPriceSyncService
|
|||||||
|
|
||||||
app(PriceSyncLogService::class)->record($source, $sourceUrl, $liquidGoldPrice, $logItems);
|
app(PriceSyncLogService::class)->record($source, $sourceUrl, $liquidGoldPrice, $logItems);
|
||||||
|
|
||||||
|
// مثل خانگی: آبشده / قیمتاپ را هم با مظنه زنده در DB همگام کن (fallback نمایش)
|
||||||
|
if ($this->syncAppPriceProducts()) {
|
||||||
|
$synced = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ($synced) {
|
if ($synced) {
|
||||||
app(PriceBroadcastService::class)->broadcastListIfChanged();
|
app(PriceBroadcastService::class)->broadcastListIfChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'no_active' => 'شما مجوز دسترسی به اکانت خود را ندارید',
|
||||||
|
'wrong_code' => 'کد وارد شده اشتباه است',
|
||||||
|
];
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'no_active' => 'شما مجوز دسترسی به اکانت خود را ندارید',
|
||||||
|
'wrong_code' => 'کد وارد شده اشتباه است',
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user