handled some bugs and adde some feature for banner
This commit is contained in:
@@ -62,6 +62,22 @@ class CustomerController extends SuperController
|
||||
Customer::assertMobileUnique($data['mobile'], (int) $id);
|
||||
}
|
||||
|
||||
if (array_key_exists('pargar_account_id', $data)) {
|
||||
$data['pargar_account_id'] = $this->normalizeAndAssertUniqueAccountingCode(
|
||||
$data['pargar_account_id'],
|
||||
'pargar_account_id',
|
||||
(int) $id
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('moshtari_code', $data)) {
|
||||
$data['moshtari_code'] = $this->normalizeAndAssertUniqueAccountingCode(
|
||||
$data['moshtari_code'],
|
||||
'moshtari_code',
|
||||
(int) $id
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($data['gold'])){
|
||||
$user = Customer::find($id);
|
||||
if ($user) {
|
||||
@@ -74,6 +90,32 @@ class CustomerController extends SuperController
|
||||
return response()->json($user);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* خالی / 0 / -1 → null؛ در غیر این صورت یکتا بودن کد بین مشتریان فعال.
|
||||
*/
|
||||
private function normalizeAndAssertUniqueAccountingCode(mixed $value, string $column, int $customerId): ?string
|
||||
{
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = trim((string) $value);
|
||||
if ($code === '' || in_array($code, ['0', '-1'], true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$exists = Customer::whereNull('deleted_at')
|
||||
->where($column, $code)
|
||||
->where('id', '!=', $customerId)
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
throw new UnprocessableEntityHttpException('این کد حسابداری قبلاً برای مشتری دیگری ثبت شده است');
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
public function referrals(Request $request,$customer_id)
|
||||
{
|
||||
$customer_referral_id = Customer::where("id",$customer_id)->first()->referral_id;
|
||||
|
||||
@@ -13,6 +13,16 @@ class SettingsController extends Controller
|
||||
|
||||
private const NEW_SETTING_NOTIFY_MOBILE = '09134469985';
|
||||
|
||||
/**
|
||||
* کلیدهایی که پنل ادمین باید بتواند ویرایش کند حتی اگر در DB هنوز can_edit=0 باشد
|
||||
* (بنرها / سایتهای ریگیری).
|
||||
*/
|
||||
private const PANEL_MANAGED_KEYS = [
|
||||
'tracking_systems',
|
||||
'tracking_systems_enabled',
|
||||
'banner_enabled',
|
||||
];
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = Setting::query()
|
||||
@@ -56,7 +66,7 @@ class SettingsController extends Controller
|
||||
$setting = new Setting();
|
||||
$setting->key = $request->key;
|
||||
$setting->can_edit = $isSystemDeploy ? 0 : 1;
|
||||
} elseif (!$setting->can_edit && !$isDeployAdmin) {
|
||||
} elseif (!$setting->can_edit && !$isDeployAdmin && !$this->isPanelManagedKey((string) $request->key)) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
@@ -119,4 +129,9 @@ class SettingsController extends Controller
|
||||
|
||||
return $this->normalizeAdminMobile($user->mobile ?? '') === self::DEPLOY_ADMIN_MOBILE_SUFFIX;
|
||||
}
|
||||
|
||||
private function isPanelManagedKey(string $key): bool
|
||||
{
|
||||
return in_array($key, self::PANEL_MANAGED_KEYS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class WalletController extends Controller
|
||||
$record->unit = "گرم";
|
||||
|
||||
if ((int) ($record->type ?? 0) === 22) {
|
||||
$record->title = 'تعدیل مانده پرگار';
|
||||
$record->title = 'تعدیل حسابداری پرگار';
|
||||
$record->unit = 'گرم';
|
||||
} elseif ((int) ($record->type ?? 0) === 12) {
|
||||
$record->title = 'برداشت وجه نقد';
|
||||
@@ -802,7 +802,7 @@ class WalletController extends Controller
|
||||
}
|
||||
|
||||
if ((int) $record->type === 22) {
|
||||
return 'تعدیل مانده پرگار';
|
||||
return 'تعدیل حسابداری پرگار';
|
||||
}
|
||||
|
||||
return $record->type_str;
|
||||
|
||||
@@ -284,7 +284,7 @@ class PargarInboundController extends Controller
|
||||
new TransactionInterface($walletInterface, [
|
||||
'cash' => $rialDiff,
|
||||
'gold' => $goldDiff,
|
||||
'title' => 'تعدیل مانده پرگار',
|
||||
'title' => 'تعدیل حسابداری پرگار',
|
||||
'expire_at' => now(),
|
||||
'active' => true,
|
||||
'start_at' => now(),
|
||||
@@ -312,7 +312,12 @@ class PargarInboundController extends Controller
|
||||
{
|
||||
$customers = Customer::query()
|
||||
->whereNull('deleted_at')
|
||||
->whereNull('pargar_account_id')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('pargar_account_id')
|
||||
->orWhere('pargar_account_id', '')
|
||||
->orWhere('pargar_account_id', '0')
|
||||
->orWhere('pargar_account_id', '-1');
|
||||
})
|
||||
->limit(100)
|
||||
->get(['id', 'fname', 'lname', 'name', 'mobile']);
|
||||
|
||||
@@ -372,9 +377,14 @@ class PargarInboundController extends Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
$normalizedAccountId = trim((string) $accountId);
|
||||
if ($normalizedAccountId === '' || in_array($normalizedAccountId, ['0', '-1'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$customer = Customer::find($customerId);
|
||||
if ($customer) {
|
||||
$customer->pargar_account_id = (string) $accountId;
|
||||
$customer->pargar_account_id = $normalizedAccountId;
|
||||
$customer->save();
|
||||
|
||||
$log = PargarSyncLog::query()
|
||||
@@ -385,7 +395,7 @@ class PargarInboundController extends Controller
|
||||
->first();
|
||||
|
||||
if ($log) {
|
||||
$this->sync()->markSuccess($log, (string) $accountId);
|
||||
$this->sync()->markSuccess($log, $normalizedAccountId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Rooyesh\Wallet\interfaces\TransactionInterface;
|
||||
use Rooyesh\Wallet\interfaces\WalletInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
class paypingController extends Controller
|
||||
{
|
||||
@@ -80,6 +81,16 @@ class paypingController extends Controller
|
||||
$finalPriseP = (int) (ceil($finalPriseP / 10) * 10);
|
||||
}
|
||||
|
||||
// شارژ کیف (بدون سفارش): حداقل واریز از تنظیمات
|
||||
if (!isset($request->order_id)) {
|
||||
$minDeposit = $this->cfg()->getInt('min_deposit', 0);
|
||||
if ($minDeposit > 0 && (int) $finalPriseP < $minDeposit) {
|
||||
throw new UnprocessableEntityHttpException(
|
||||
'حداقل مقدار واریز ' . number_format($minDeposit) . ' ریال است'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$Withdraw = Withdraw::create([
|
||||
'customer_id' => auth('customer')->id(),
|
||||
'cash' => $finalPriseP,
|
||||
|
||||
Reference in New Issue
Block a user