wallet controller withdraw and transactions handled
This commit is contained in:
@@ -84,36 +84,44 @@ class WalletController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($records['rows'] as &$record) {
|
foreach ($records['rows'] as &$record) {
|
||||||
if (empty($record->title) or $record->title == "تعریف نشده"){
|
|
||||||
$record->title = $record->type_str ;
|
|
||||||
$record->unit = "گرم";
|
|
||||||
if (isset($record->wallet)) {
|
|
||||||
$wallet = Wallet::with('product')->where('id',$record->wallet)->first();
|
|
||||||
if (isset($wallet->product)) {
|
|
||||||
if ($record->gold > 0){
|
|
||||||
$record->title = " خرید " ;
|
|
||||||
|
|
||||||
}else{
|
// اولویت اول: واریز توسط ادمین
|
||||||
$record->title = " فروش " ;
|
// حتی اگر title قبلاً برداشت ریالی ذخیره شده باشد، باید اصلاح شود
|
||||||
|
if (
|
||||||
|
isset($record->withdraw) &&
|
||||||
|
(int) $record->withdraw->sts === 4
|
||||||
|
) {
|
||||||
|
$record->title = "واریز ریالی";
|
||||||
|
|
||||||
}
|
// اگر میخوای تو دیتابیس هم اصلاح بشه
|
||||||
$record->title .= $wallet->product->title ;
|
|
||||||
$record->unit = "عدد";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
(int) $record->type === 4 &&
|
|
||||||
isset($record->withdraw) &&
|
|
||||||
(int) $record->withdraw->sts === 4
|
|
||||||
) {
|
|
||||||
$record->title = "واریز ریالی";
|
|
||||||
} else {
|
|
||||||
$record->title = $record->type_str;
|
|
||||||
}
|
|
||||||
$record->save();
|
$record->save();
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// بقیه رکوردها فقط اگر title ندارند یا تعریف نشده هستند اصلاح شوند
|
||||||
|
if (empty($record->title) || $record->title == "تعریف نشده") {
|
||||||
|
|
||||||
|
$record->title = $record->type_str;
|
||||||
|
$record->unit = "گرم";
|
||||||
|
|
||||||
|
if (isset($record->wallet)) {
|
||||||
|
$wallet = Wallet::with('product')->where('id', $record->wallet)->first();
|
||||||
|
|
||||||
|
if (isset($wallet->product)) {
|
||||||
|
if ($record->gold > 0) {
|
||||||
|
$record->title = " خرید ";
|
||||||
|
} else {
|
||||||
|
$record->title = " فروش ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->title .= $wallet->product->title;
|
||||||
|
$record->unit = "عدد";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json($records);
|
return response()->json($records);
|
||||||
|
|||||||
Reference in New Issue
Block a user