fix withdraw

This commit is contained in:
2026-06-09 20:08:06 +03:30
parent ae9ba34ca8
commit 566053cf98
+16 -11
View File
@@ -186,7 +186,7 @@ class WalletController extends Controller
'active' => true 'active' => true
], 7, $deposit, false, $gold_block); ], 7, $deposit, false, $gold_block);
//send to tahesan //send to tahesab
if($this->Config('send_to_tahesab') == "true"){ if($this->Config('send_to_tahesab') == "true"){
try { try {
$data['direction'] = $deposit ? 1 : 0; $data['direction'] = $deposit ? 1 : 0;
@@ -359,25 +359,30 @@ class WalletController extends Controller
public function getWithdraw(Request $request, $id) public function getWithdraw(Request $request, $id)
{ {
// پیدا کردن رکورد Withdraw با استفاده از شناسه $withdraw = Withdraw::with(['customer', 'bank_account', 'Address', "Transaction"])->find($id);
return $withdraw = Withdraw::with(['customer', 'bank_account', 'Address', "Transaction"])->find($id);
// بررسی وجود رکورد
if (!$withdraw) { if (!$withdraw) {
return response()->json(['error' => 'Withdraw not found'], 404); return response()->json(['error' => 'Withdraw not found'], 404);
} }
$withdraw->sts = $request->sts; return response()->json($withdraw);
$withdraw->save();
return response()->json(['message' => 'Withdraw updated successfully', 'withdraw' => $withdraw]);
} }
public function completeWithdraw(Request $request) public function completeWithdraw(Request $request)
{ {
$data = $request->all(); $request->validate([
'id' => 'required|integer|exists:withdraws,id',
'tracked_number' => 'required|string|max:50',
'date_at' => 'nullable|date',
]);
$data = $request->only(['tracked_number', 'date_at']);
$data['user_id'] = auth('user')->id(); $data['user_id'] = auth('user')->id();
$data['sts'] = 2; $data['sts'] = 2;
$data['date_at'] = now(); $data['tracked_number'] = (string) $data['tracked_number'];
Withdraw::findOrFail($data['id'])->update($data); if (empty($data['date_at'])) {
$withdraw = Withdraw::findOrFail($data['id']); $data['date_at'] = now();
}
$withdraw = Withdraw::findOrFail($request->id);
$withdraw->update($data); $withdraw->update($data);
// $tahesab = new TahesabController(); // $tahesab = new TahesabController();
// $tahesab->wallet([ // $tahesab->wallet([