all customer from pargar fixing 3
This commit is contained in:
@@ -400,6 +400,10 @@ class CustomerController extends SuperController
|
||||
|
||||
public function cardChecker(Request $request){
|
||||
|
||||
if (!app(ConfigService::class)->isJibitEnabled()) {
|
||||
throw new UnprocessableEntityHttpException('سرویس احراز هویت جیبیت غیرفعال است.');
|
||||
}
|
||||
|
||||
if (strlen($request->cart_number) != 16) {
|
||||
throw new UnprocessableEntityHttpException('شماره کارت اشتباه میباشد.');
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class AuthController extends Controller
|
||||
} while (Customer::where('referral_id', $uniqueId)->exists());
|
||||
$data['referral_id'] = $uniqueId;
|
||||
|
||||
if (isset($data['n_code']) && $cfg->getBool('register_jibit_verify', false)) {
|
||||
if (isset($data['n_code']) && $cfg->isRegisterJibitVerifyEnabled()) {
|
||||
$existing = Customer::where('n_code', $data['n_code'])->first();
|
||||
if (!empty($existing)) {
|
||||
return response()->json(['message' => 'کد ملی تکراری است'], 422);
|
||||
@@ -247,7 +247,7 @@ class AuthController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($cfg->getBool('register_jibit_verify', false) && isset($customer->is_legal)) {
|
||||
if ($cfg->isRegisterJibitVerifyEnabled() && isset($customer->is_legal)) {
|
||||
$message = $customer->is_legal === 1
|
||||
? 'احرازهویت برای ' . $customer->name . ' با کد ' . $customer->id . ' انجام شد.'
|
||||
: 'احرازهویت برای ' . $customer->name . ' با کد ' . $customer->id . ' تأیید نشد لطفا از پنل ادمین اقدام فرمایید.';
|
||||
|
||||
@@ -734,6 +734,10 @@ class Controller extends BaseController
|
||||
|
||||
public function jibitNcode($nationalCode, $mobile)
|
||||
{
|
||||
if (!app(ConfigService::class)->isJibitEnabled()) {
|
||||
return ['matched' => false, 'message' => 'سرویس احراز هویت جیبیت غیرفعال است.'];
|
||||
}
|
||||
|
||||
$counter = Cnt::where('key', 'jibit_counter')->first();
|
||||
if (empty($counter)) {
|
||||
$counter = new Cnt();
|
||||
@@ -784,6 +788,10 @@ class Controller extends BaseController
|
||||
|
||||
public static function jibit($method, $p1 = null, $p2 = null, $p3 = null)
|
||||
{
|
||||
if (!app(ConfigService::class)->isJibitEnabled()) {
|
||||
throw new UnprocessableEntityHttpException('سرویس احراز هویت جیبیت غیرفعال است.');
|
||||
}
|
||||
|
||||
$counter = Cnt::where('key', 'jibit_counter')->first();
|
||||
if(empty($counter)){
|
||||
$counter = new Cnt();
|
||||
|
||||
@@ -206,7 +206,7 @@ class CustomerController extends Controller
|
||||
// $tah = new TahesabController();
|
||||
// $tah->store(["customer_id" => $customer->id]);
|
||||
$cfg = app(ConfigService::class);
|
||||
if (!$wasLegal && $cfg->getBool('register_jibit_verify', false)) {
|
||||
if (!$wasLegal && $cfg->isRegisterJibitVerifyEnabled()) {
|
||||
$response = $this->jibitNcode($customer->n_code, $customer->mobile);
|
||||
|
||||
if (isset($response['matched']) and $response['matched'] == true) {
|
||||
@@ -235,7 +235,7 @@ class CustomerController extends Controller
|
||||
}
|
||||
|
||||
|
||||
} elseif (!$customer->is_legal && !$cfg->getBool('register_jibit_verify', false)) {
|
||||
} elseif (!$customer->is_legal && !$cfg->isRegisterJibitVerifyEnabled()) {
|
||||
return response()->json([
|
||||
'message' => 'اطلاعات شما با موفقیت ثبت شد. لطفاً برای تکمیل احراز هویت با پشتیبانی یا مدیر سامانه تماس بگیرید.',
|
||||
], 422);
|
||||
|
||||
@@ -219,7 +219,12 @@ class PargarInboundController extends Controller
|
||||
], 422);
|
||||
}
|
||||
|
||||
$this->sync()->confirmOrders($orderIds);
|
||||
$result = $this->sync()->confirmOrders($orderIds);
|
||||
|
||||
// سند در پرگار ثبت شد → ماندهٔ معطلمانده را همگام کن
|
||||
foreach ($result['customer_ids'] ?? [] as $customerId) {
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customerId);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
@@ -243,37 +248,41 @@ class PargarInboundController extends Controller
|
||||
? Customer::where('pargar_account_id', $accountId)->first()
|
||||
: null;
|
||||
|
||||
// فقط لاگ — اعمال خودکار روی کیف کاملاً خاموش است
|
||||
// اگر هنوز موجودی بالا میرود = worker/php قدیمی هنوز زنده است → ریاستارت الزامی
|
||||
// فقط لاگ — replay تاریخچه روی کیف خاموش است؛ بعد از ذخیره، مانده بهصورت خودکار همتراز میشود
|
||||
PargarSyncLog::create([
|
||||
'customer_id' => $customer?->id,
|
||||
'amount' => $summary['amount'],
|
||||
'desc' => $customer
|
||||
? ('[no-apply] '.($summary['desc'] !== '' ? $summary['desc'] : 'دریافت اسناد از پرگار'))
|
||||
: '[no-apply] دریافت اسناد از پرگار — مشتری یافت نشد',
|
||||
? ($summary['desc'] !== '' ? $summary['desc'] : 'دریافت اسناد از پرگار')
|
||||
: 'دریافت اسناد از پرگار — مشتری یافت نشد',
|
||||
'type' => PargarSyncService::TYPE_DOCUMENT,
|
||||
'sync_status' => PargarSyncService::STATUS_SUCCESS,
|
||||
'pargar_ref' => $accountId !== '' ? $accountId : null,
|
||||
'data' => json_encode(array_merge($data, [
|
||||
'_summary' => $summary,
|
||||
'wallet_applied' => false,
|
||||
'auto_apply_disabled' => true,
|
||||
'code_build' => 'no-apply-v2',
|
||||
'code_build' => 'docs-then-mande-auto',
|
||||
]), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT),
|
||||
]);
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Pargar documents stored without wallet apply', [
|
||||
\Illuminate\Support\Facades\Log::info('Pargar documents stored; queue auto mande sync', [
|
||||
'account_id' => $accountId,
|
||||
'customer_id' => $customer?->id,
|
||||
'tx_count' => is_array($data['transactions'] ?? null) ? count($data['transactions']) : 0,
|
||||
]);
|
||||
|
||||
// بهمحض ورود اسناد → ack + اعمال آخرین مانده
|
||||
if ($customer) {
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'اسناد ثبت شد بدون تغییر کیف (no-apply-v2)',
|
||||
'message' => 'اسناد ثبت شد؛ همگامسازی مانده در صف است',
|
||||
'data' => [
|
||||
'wallet_applied' => false,
|
||||
'build' => 'no-apply-v2',
|
||||
'auto_mande_queued' => (bool) $customer,
|
||||
'build' => 'docs-then-mande-auto',
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -285,7 +294,6 @@ class PargarInboundController extends Controller
|
||||
|
||||
$customer = Customer::where('pargar_account_id', $accountId)->first();
|
||||
|
||||
// اگر مشتری هنوز وارد نشده، مانده را با pargar_ref نگه میداریم تا بعد از import/claim اعمال شود
|
||||
$goldInv = isset($data['GoldInv']) ? (float) str_replace('/', '.', (string) $data['GoldInv']) : 0;
|
||||
$rialInv = isset($data['RialInv']) ? (float) str_replace('/', '.', (string) $data['RialInv']) : 0;
|
||||
|
||||
@@ -310,7 +318,6 @@ class PargarInboundController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// فقط مقایسه برای لاگ — اعمال روی کیف فقط با دکمه ادمین / صف auto پس از import-claim
|
||||
$ownerType = (int) ($customer->type ?? 2);
|
||||
$walletInterface = new WalletInterface($customer->id, $ownerType);
|
||||
$wallet = $walletInterface->wallet;
|
||||
@@ -321,9 +328,13 @@ class PargarInboundController extends Controller
|
||||
$rialDiff = $rialInv - $appCash;
|
||||
$hasDiff = abs($goldDiff) >= 0.01 || abs($rialDiff) >= 1;
|
||||
|
||||
$desc = $hasDiff
|
||||
? 'اختلاف مانده پرگار با اپ — کیف اپ دست نخورده'
|
||||
: 'دریافت مانده از پرگار — بدون اختلاف';
|
||||
$pendingOutbound = $this->inboundWallet()->hasPendingOutboundToPargar($customer);
|
||||
|
||||
$desc = $pendingOutbound
|
||||
? 'مانده دریافت شد — منتظر ثبت سند پنل در پرگار'
|
||||
: ($hasDiff
|
||||
? 'اختلاف مانده پرگار با اپ — در صف همگامسازی خودکار'
|
||||
: 'دریافت مانده از پرگار — بدون اختلاف');
|
||||
|
||||
PargarSyncLog::create([
|
||||
'customer_id' => $customer->id,
|
||||
@@ -338,18 +349,22 @@ class PargarInboundController extends Controller
|
||||
'gold_diff' => $goldDiff,
|
||||
'rial_diff' => $rialDiff,
|
||||
'wallet_adjusted' => false,
|
||||
'awaiting_outbound_confirm' => $pendingOutbound,
|
||||
]), JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
|
||||
// اولین مانده برای مشتریِ هنوز واردنشده به اپ — یکبار همتراز کن
|
||||
if ($customer->last_seen_at === null && $hasDiff) {
|
||||
app(PargarInboundWalletService::class)->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
}
|
||||
// همیشه صف همگامسازی: اگر سند pending نباشد اعمال میشود؛ وگرنه بعد از تأیید سند اعمال میشود
|
||||
$this->inboundWallet()->queueWalletSyncAfterResponse((int) $customer->id);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'مانده مشتری با موفقیت دریافت شد',
|
||||
'data' => null,
|
||||
'message' => $pendingOutbound
|
||||
? 'مانده ذخیره شد؛ بعد از ثبت سند در پرگار خودکار سینک میشود'
|
||||
: 'مانده دریافت شد؛ همگامسازی خودکار در صف است',
|
||||
'data' => [
|
||||
'awaiting_outbound_confirm' => $pendingOutbound,
|
||||
'auto_sync_queued' => true,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use Illuminate\Http\Request;
|
||||
use Hekmatinasser\Verta\Verta;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Log;
|
||||
use App\Services\ConfigService;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
class BankAccountController extends SuperController
|
||||
@@ -55,7 +56,7 @@ class BankAccountController extends SuperController
|
||||
}
|
||||
|
||||
//with verification in jibit
|
||||
if($this->Config('jibit_verification') == 'true') {
|
||||
if (app(ConfigService::class)->isJibitCardVerificationEnabled()) {
|
||||
$p1 = $apiData['iban'] = preg_replace('/\D/', '', $request->cart_number);
|
||||
$p2 = $apiData['nationalCode'] = $user->n_code;
|
||||
$p3 = $apiData['birthDate'] = Verta::instance(Carbon::parse($request->birth_date ?? $user->birth_date))->format('Ymd');
|
||||
|
||||
Reference in New Issue
Block a user