added seprated method for withdraw and deposit 2
This commit is contained in:
@@ -18,7 +18,7 @@ class ValidationMiddleware
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if($request->acceptsJson()){
|
||||
if ($request->acceptsJson() || $request->is('admin/wallet/withdraw/report')) {
|
||||
//convert fa digits to en digits
|
||||
$allData = array_merge($request->all(), $request->query());
|
||||
$converted = $this->fa2en_numbers($allData);
|
||||
|
||||
+38
-16
@@ -62,27 +62,49 @@ class Withdraw extends Model
|
||||
}
|
||||
|
||||
if ($flowType === 'withdraw') {
|
||||
return $query->where(function ($q) {
|
||||
$q->where('note', 'like', '%برداشت%')
|
||||
->orWhere('type', 2)
|
||||
->orWhereBetween('sts', [50, 52]);
|
||||
});
|
||||
return static::scopeWithdrawals($query);
|
||||
}
|
||||
|
||||
if ($flowType === 'deposit') {
|
||||
return $query->where(function ($q) {
|
||||
$q->where('note', 'like', '%واریز%')
|
||||
->orWhere('type', 1)
|
||||
->orWhere(function ($admin) {
|
||||
$admin->where('sts', 4)
|
||||
->where(function ($note) {
|
||||
$note->whereNull('note')
|
||||
->orWhere('note', 'not like', '%برداشت%');
|
||||
});
|
||||
});
|
||||
});
|
||||
return static::scopeDeposits($query);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/** برداشت: خروج پول/طلا از کیف (درخواست مشتری، برداشت فیزیکی، کسر ادمین) */
|
||||
public static function scopeWithdrawals($query)
|
||||
{
|
||||
return $query->where(function ($q) {
|
||||
$q->where('note', 'like', '%برداشت%')
|
||||
->orWhere('type', 2)
|
||||
->orWhereBetween('sts', [50, 52])
|
||||
->orWhere(function ($pending) {
|
||||
$pending->where('sts', 1)
|
||||
->whereNotNull('bank_account_id');
|
||||
})
|
||||
->orWhere(function ($completed) {
|
||||
$completed->where('sts', 2)
|
||||
->where('note', 'like', '%برداشت%');
|
||||
})
|
||||
->orWhere(function ($deduct) {
|
||||
$deduct->where('cash', '<', 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** واریز: ورود پول/طلا به کیف (درگاه، شارژ ادمین، پاداش) */
|
||||
public static function scopeDeposits($query)
|
||||
{
|
||||
return $query->where(function ($q) {
|
||||
$q->where(function ($inner) {
|
||||
$inner->where('note', 'like', '%واریز%')
|
||||
->orWhere('type', 1)
|
||||
->orWhereIn('sts', [4, 5, 9]);
|
||||
})->where(function ($excludeWithdrawNotes) {
|
||||
$excludeWithdrawNotes->whereNull('note')
|
||||
->orWhere('note', 'not like', '%برداشت%');
|
||||
})->whereNotBetween('sts', [50, 52]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user