added tahesab options 3

This commit is contained in:
2026-06-25 23:06:29 +03:30
parent 1f93408c7b
commit 44733aabdb
2 changed files with 76 additions and 0 deletions
@@ -20,6 +20,7 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use App\Http\Controllers\Admin\TahesabController;
use App\Models\Setting;
use App\Models\User;
use App\Models\TransactionsAdmin;
use App\Services\BalanceReportService;
use App\Services\ConfigService;
use App\Services\WalletBalanceService;
@@ -124,6 +125,8 @@ class WalletController extends Controller
'active' => true
], $type, true, $deposit, $gold_block);
$this->recordAccountingTransaction($customer, $Withdraw, (int) $user->id, (float) $data['value'], 0, $data['note'] ?? null);
if($this->Config('send_to_tahesab') == "true"){
try {
$data['direction'] = $deposit ? 0 : 1;
@@ -192,6 +195,8 @@ class WalletController extends Controller
'active' => true
], 7, $deposit, false, $gold_block);
$this->recordAccountingTransaction($customer, $Withdraw, (int) $user->id, 0, (float) $data['value'], $data['note'] ?? null);
//send to tahesab
if($this->Config('send_to_tahesab') == "true"){
try {
@@ -325,6 +330,15 @@ class WalletController extends Controller
'active' => true,
], 7, $deposit, false, $goldBlock);
$this->recordAccountingTransaction(
$customer,
$Withdraw,
(int) $user->id,
0,
(float) $data['value'],
($data['note'] ?? null) ?: ('شارژ ' . $product->title)
);
if ($this->Config('send_to_tahesab') == 'true') {
try {
$data['direction'] = $deposit ? 1 : 0;
@@ -621,4 +635,29 @@ class WalletController extends Controller
return response()->json(true);
}
private function recordAccountingTransaction(
Customer $customer,
Withdraw $withdraw,
int $adminUserId,
float $cash = 0,
float $gold = 0,
?string $note = null
): void {
$transaction = Transaction::where('withdraw_id', $withdraw->id)->latest('id')->first();
TransactionsAdmin::create([
'customer_id' => $customer->id,
'customer_to_id' => $customer->id,
'user_id' => $adminUserId,
'wallet' => null,
'transaction_id' => $transaction?->id,
'cash' => $cash,
'note' => $note ?? $withdraw->note,
'type' => 1,
'gold' => $gold,
'balance_cash' => 0,
'withdraw_id' => $withdraw->id,
]);
}
}