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