added tahesab options
This commit is contained in:
@@ -127,10 +127,10 @@ class WalletController extends Controller
|
||||
if($this->Config('send_to_tahesab') == "true"){
|
||||
try {
|
||||
$data['direction'] = $deposit ? 0 : 1;
|
||||
$tahesab = new TahesabController();
|
||||
$tahesab->wallet($data);
|
||||
}catch (\Exception $e){
|
||||
return response($e->getMessage(), 500);
|
||||
$data['withdraw_id'] = $Withdraw->id;
|
||||
app(TahesabController::class)->wallet($data);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,10 +196,10 @@ class WalletController extends Controller
|
||||
if($this->Config('send_to_tahesab') == "true"){
|
||||
try {
|
||||
$data['direction'] = $deposit ? 1 : 0;
|
||||
$tahesab = new TahesabController();
|
||||
$tahesab->walletGold($data);
|
||||
}catch (\Exception $e){
|
||||
return response($e->getMessage(), 500);
|
||||
$data['withdraw_id'] = $Withdraw->id;
|
||||
app(TahesabController::class)->walletGold($data);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
//send sms to users and customer
|
||||
@@ -328,10 +328,10 @@ class WalletController extends Controller
|
||||
if ($this->Config('send_to_tahesab') == 'true') {
|
||||
try {
|
||||
$data['direction'] = $deposit ? 1 : 0;
|
||||
$tahesab = new TahesabController();
|
||||
$tahesab->walletGold($data);
|
||||
$data['withdraw_id'] = $Withdraw->id;
|
||||
app(TahesabController::class)->walletGold($data);
|
||||
} catch (\Exception $e) {
|
||||
return response($e->getMessage(), 500);
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,6 +517,33 @@ class WalletController extends Controller
|
||||
->select([
|
||||
'*', Withdraw::$SELECT_STS_STR, Withdraw::$SELECT_DAJ
|
||||
])->export($records);
|
||||
|
||||
if ($this->Config('send_to_tahesab') === 'true' && isset($records['rows']) && is_array($records['rows'])) {
|
||||
$withdrawIds = collect($records['rows'])->pluck('id')->filter()->values()->all();
|
||||
if ($withdrawIds !== []) {
|
||||
$failedByWithdraw = \App\Models\Tahesab::query()
|
||||
->whereIn('withdraw_id', $withdrawIds)
|
||||
->where(function ($query) {
|
||||
$query->whereNull('tahesab_id');
|
||||
if (\Illuminate\Support\Facades\Schema::hasColumn('tahesab', 'sync_status')) {
|
||||
$query->orWhere('sync_status', \App\Services\TahesabSyncService::STATUS_FAILED);
|
||||
}
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->unique('withdraw_id')
|
||||
->keyBy('withdraw_id');
|
||||
|
||||
foreach ($records['rows'] as &$row) {
|
||||
$tahesab = $failedByWithdraw->get($row['id'] ?? null);
|
||||
if ($tahesab) {
|
||||
$row['tahesab_failed_id'] = $tahesab->id;
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($records);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user