fixed data

This commit is contained in:
Edward Yang 2022-06-29 15:39:29 +08:00
parent e8d46d7278
commit 477009c020
2 changed files with 33 additions and 2 deletions

View File

@ -131,7 +131,37 @@ function image_resize($image, int $width = 100, int $height = 100)
return asset($image);
}
function current_language_id()
/**
* 当前语言ID
* @return int
*/
function current_language_id(): int
{
return 1;
}
/**
* 返回json序列化结果
*/
function json_success($message, $data = []): array
{
$result = [
'status' => 'success',
'message' => $message,
'data' => $data,
];
return $result;
}
/**
* 返回json序列化结果
*/
function json_fail($message, $data = []): array
{
$result = [
'status' => 'fail',
'message' => $message,
'data' => $data,
];
return $result;
}

View File

@ -130,12 +130,13 @@ class CartService
$selected = collect($carts)->where('selected', 1);
$quantity = $selected->sum('quantity');
$amount = $selected->sum('subtotal');
$data = [
'carts' => $carts,
'quantity' => $quantity,
'amount' => $amount,
'amount_format' => currency_format($amount)
];
return $data;
return json_success('获取成功', $data);
}
}