|
|
@ -136,47 +136,21 @@ class ShopCartService implements ShopCartServiceInterface |
|
|
|
|
|
|
|
|
public function countGoods($userId,$marketId) |
|
|
public function countGoods($userId,$marketId) |
|
|
{ |
|
|
{ |
|
|
$ShoppingCart = ShoppingCart::query()->where([ |
|
|
|
|
|
['user_id','=',$userId], |
|
|
|
|
|
['market_id','=',$marketId], |
|
|
|
|
|
])->get(); |
|
|
|
|
|
$num = 0; |
|
|
|
|
|
foreach ($ShoppingCart as $cart){ |
|
|
|
|
|
if($cart->activity_type == 2){ |
|
|
|
|
|
$goods = GoodsActivity::query()->find($cart->goods_id); |
|
|
|
|
|
$goodsCheck = $this->goodsActivityService->check($goods,$cart->num,$cart->user_id); |
|
|
|
|
|
}else{ |
|
|
|
|
|
$goods = Goods::query()->find($cart->goods_id); |
|
|
|
|
|
$goodsCheck = $this->goodsService->check($goods,$cart->num); |
|
|
|
|
|
} |
|
|
|
|
|
if($goodsCheck){ |
|
|
|
|
|
$num+= $cart->num; |
|
|
|
|
|
|
|
|
$shoppingCart = $this->allForUser($userId,$marketId); |
|
|
|
|
|
$count = 0; |
|
|
|
|
|
foreach ($shoppingCart['store_lists'] as $store){ |
|
|
|
|
|
foreach ($store['shopping_cart'] as $cart) { |
|
|
|
|
|
$num = $cart['num']; |
|
|
|
|
|
$count += $num; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return $num; |
|
|
|
|
|
|
|
|
return $count; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getTotal($userId,$marketId) |
|
|
public function getTotal($userId,$marketId) |
|
|
{ |
|
|
{ |
|
|
$ShoppingCart = ShoppingCart::query()->where([ |
|
|
|
|
|
['user_id','=',$userId], |
|
|
|
|
|
['market_id','=',$marketId], |
|
|
|
|
|
])->get(); |
|
|
|
|
|
$total = 0; |
|
|
|
|
|
foreach ($ShoppingCart as $cart){ |
|
|
|
|
|
if($cart->activity_type == 2){ |
|
|
|
|
|
$goods = GoodsActivity::query()->find($cart->goods_id); |
|
|
|
|
|
$goodsCheck = $this->goodsActivityService->check($goods,$cart->num,$cart->user_id); |
|
|
|
|
|
}else{ |
|
|
|
|
|
$goods = Goods::query()->find($cart->goods_id); |
|
|
|
|
|
$goodsCheck = $this->goodsService->check($goods,$cart->num); |
|
|
|
|
|
} |
|
|
|
|
|
if($goodsCheck){ |
|
|
|
|
|
$subTotal = bcmul($goods->price,$cart->num); |
|
|
|
|
|
$total = bcadd($subTotal,$total,2); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return $total; |
|
|
|
|
|
|
|
|
$shoppingCart = $this->allForUser($userId,$marketId); |
|
|
|
|
|
return $shoppingCart['total']; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getGoodsByShopcartId($shopcartIds) |
|
|
public function getGoodsByShopcartId($shopcartIds) |
|
|
|