fix deposite and withdraw

This commit is contained in:
2026-06-07 12:25:32 +03:30
parent 82d94caacf
commit 085237364d
3 changed files with 49 additions and 2 deletions
@@ -110,6 +110,7 @@ class WalletController extends Controller
"note" => $data['note'],
'sts' => 4,
]);
$type = $deposit ? 3 : 4;
new TransactionInterface($wallet_interface, $_inp = [
'gold' => 0,
'cash' => $data['value'],
@@ -117,7 +118,7 @@ class WalletController extends Controller
"note" => $data['note'],
'withdraw_id' => $Withdraw->id,
'active' => true
], 4, true, $deposit, $gold_block);
], $type, true, $deposit, $gold_block);
if($this->Config('send_to_tahesab') == "true"){
try {
+1 -1
View File
@@ -160,7 +160,7 @@ class AuthController extends Controller
if (isset($data['referral_to_id'])) {
$referrer = Customer::where('referral_id', $data['referral_to_id'])->first();
if (!$referrer) {
return response()->json(['message' => 'کد نامعتبره'], 422);
return response()->json(['message' => 'کد نامعتبر می باشد'], 422);
}
} else {
if ($this->Config('referral_id') == 'required') {
@@ -0,0 +1,46 @@
-- =============================================================================
-- اصلاح transaction_type تراکنش‌های ریالی قبلی
--
-- مشکل: متد charge() در WalletController همیشه type=4 (برداشت ریالی) استفاده می‌کرد
-- حتی وقتی پول مثبت (شارژ) بود.
--
-- راه‌حل:
-- - cash > 0 و type = 4 → type = 3 (واریز ریالی)
-- - cash < 0 و type = 3 → type = 4 (برداشت ریالی)
--
-- این اسکریپت idempotent است و چند بار اجرا مشکلی ایجاد نمی‌کند.
-- =============================================================================
START TRANSACTION;
-- ۱) شارژ ریالی که اشتباه type=4 گرفته → اصلاح به type=3
UPDATE `transactions`
SET `type` = 3,
`updated_at` = NOW()
WHERE `type` = 4
AND `cash` > 0
AND `fund_id` IS NULL;
-- ۲) برداشت ریالی که اشتباه type=3 گرفته → اصلاح به type=4
UPDATE `transactions`
SET `type` = 4,
`updated_at` = NOW()
WHERE `type` = 3
AND `cash` < 0
AND `fund_id` IS NULL;
-- ۳) گزارش تعداد تغییرات (اختیاری — برای لاگ)
-- SELECT
-- (SELECT COUNT(*) FROM `transactions` WHERE `type` = 3 AND `cash` > 0 AND `fund_id` IS NULL) AS fixed_to_deposit,
-- (SELECT COUNT(*) FROM `transactions` WHERE `type` = 4 AND `cash` < 0 AND `fund_id` IS NULL) AS fixed_to_withdraw;
COMMIT;
-- =============================================================================
-- بعد از اجرا، جدول transactions را چک کنید:
-- SELECT id, type, type_str, cash, note, created_at
-- FROM `transactions`
-- WHERE `fund_id` IS NULL AND `type` IN (3,4)
-- ORDER BY `created_at` DESC
-- LIMIT 20;
-- =============================================================================