|
@@ -50,7 +50,7 @@ class Cart extends Controller
|
|
|
$cartMoney = bcadd($cartMoney, $temp, 2);
|
|
|
}
|
|
|
|
|
|
- return view('shoppingCart', ['list' => $list, 'cartTotal' => $cartTotal,'cartMoney'=>$cartMoney, 'points' => $user['points']]);
|
|
|
+ return view('shoppingCart', ['list' => $list, 'cartTotal' => $cartTotal, 'cartMoney' => $cartMoney, 'points' => $user['points']]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -95,11 +95,11 @@ class Cart extends Controller
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function add(int $goodsId, string $goodsSkuId, int $goodsNum) :Json
|
|
|
+ public function add(int $goodsId, string $goodsSkuId, int $goodsNum): Json
|
|
|
{
|
|
|
$userId = Session::get('user_id');
|
|
|
if (empty($userId)) {
|
|
|
- return $this->renderJson( config('status.not_logged'),'Log in please!');
|
|
|
+ return $this->renderJson(config('status.not_logged'), 'Log in please!');
|
|
|
}
|
|
|
|
|
|
$model = new CartModel;
|
|
@@ -126,10 +126,10 @@ class Cart extends Controller
|
|
|
{
|
|
|
$userId = Session::get('user_id');
|
|
|
if (empty($userId)) {
|
|
|
- return $this->renderJson( config('status.not_logged'),'Log in please!');
|
|
|
+ return $this->renderJson(config('status.not_logged'), 'Log in please!');
|
|
|
}
|
|
|
|
|
|
- if ($goodsNum <= 0){
|
|
|
+ if ($goodsNum <= 0) {
|
|
|
return $this->renderError('Action Not Supported!');
|
|
|
}
|
|
|
|
|
@@ -151,6 +151,10 @@ class Cart extends Controller
|
|
|
*/
|
|
|
public function clear(array $cartIds = []): Json
|
|
|
{
|
|
|
+ $userId = Session::get('user_id');
|
|
|
+ if (empty($userId)) {
|
|
|
+ return $this->renderJson(config('status.not_logged'), 'Log in please!');
|
|
|
+ }
|
|
|
$model = new CartModel;
|
|
|
if (!$model->clear($cartIds)) {
|
|
|
return $this->renderError($model->getError() ?: '操作失败');
|