Browse Source

购物车

master
Lemon 5 years ago
parent
commit
bc33820d47
  1. 12
      app/Service/v3/Implementations/ShopCartUpdateService.php

12
app/Service/v3/Implementations/ShopCartUpdateService.php

@ -11,6 +11,7 @@ use App\Model\v3\ShoppingCart;
use App\Model\v3\Goods; use App\Model\v3\Goods;
use App\Model\v3\GoodsActivity; use App\Model\v3\GoodsActivity;
use App\Constants\v3\Goods as GoodsConstants; use App\Constants\v3\Goods as GoodsConstants;
use App\Service\v3\Interfaces\StoreServiceInterface;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
class ShopCartUpdateService implements ShopCartUpdateServiceInterface class ShopCartUpdateService implements ShopCartUpdateServiceInterface
{ {
@ -26,6 +27,12 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
*/ */
protected $goodsActivityService; protected $goodsActivityService;
/**
* @Inject
* @var StoreServiceInterface
*/
protected $storeService;
public function do($userId,$goodsId,$num,$activityType) public function do($userId,$goodsId,$num,$activityType)
{ {
$goodsType = ''; $goodsType = '';
@ -56,7 +63,7 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
throw new ErrorCodeException($goodsCheck); throw new ErrorCodeException($goodsCheck);
} }
return ShoppingCart::query()->lockForUpdate()->updateOrCreate(
$shoppingCart = ShoppingCart::query()->lockForUpdate()->updateOrCreate(
[ [
'user_id' => $userId, 'user_id' => $userId,
'goods_id' => $goodsId, 'goods_id' => $goodsId,
@ -69,6 +76,9 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface
'goods_type' => $goodsType 'goods_type' => $goodsType
] ]
); );
$storeCheck = $this->storeService->check($goods->store_id);
$shoppingCart->check = $storeCheck;
return $shoppingCart;
} }
public function check() public function check()

Loading…
Cancel
Save