fix deposite and withdraw
This commit is contained in:
@@ -110,6 +110,7 @@ class WalletController extends Controller
|
|||||||
"note" => $data['note'],
|
"note" => $data['note'],
|
||||||
'sts' => 4,
|
'sts' => 4,
|
||||||
]);
|
]);
|
||||||
|
$type = $deposit ? 3 : 4;
|
||||||
new TransactionInterface($wallet_interface, $_inp = [
|
new TransactionInterface($wallet_interface, $_inp = [
|
||||||
'gold' => 0,
|
'gold' => 0,
|
||||||
'cash' => $data['value'],
|
'cash' => $data['value'],
|
||||||
@@ -117,7 +118,7 @@ class WalletController extends Controller
|
|||||||
"note" => $data['note'],
|
"note" => $data['note'],
|
||||||
'withdraw_id' => $Withdraw->id,
|
'withdraw_id' => $Withdraw->id,
|
||||||
'active' => true
|
'active' => true
|
||||||
], 4, true, $deposit, $gold_block);
|
], $type, true, $deposit, $gold_block);
|
||||||
|
|
||||||
if($this->Config('send_to_tahesab') == "true"){
|
if($this->Config('send_to_tahesab') == "true"){
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ class AuthController extends Controller
|
|||||||
if (isset($data['referral_to_id'])) {
|
if (isset($data['referral_to_id'])) {
|
||||||
$referrer = Customer::where('referral_id', $data['referral_to_id'])->first();
|
$referrer = Customer::where('referral_id', $data['referral_to_id'])->first();
|
||||||
if (!$referrer) {
|
if (!$referrer) {
|
||||||
return response()->json(['message' => 'کد نامعتبره'], 422);
|
return response()->json(['message' => 'کد نامعتبر می باشد'], 422);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($this->Config('referral_id') == 'required') {
|
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;
|
||||||
|
-- =============================================================================
|
||||||
Reference in New Issue
Block a user