Browse Source

Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix

master
weigang 5 years ago
parent
commit
36c3aea25e
  1. 4
      app/Constants/v3/ErrorCode.php
  2. 12
      app/Service/v3/Implementations/ShopCartUpdateService.php

4
app/Constants/v3/ErrorCode.php

@ -233,8 +233,8 @@ class ErrorCode extends AbstractConstants
/* 商品相关 1101-1150 */
/************************************/
/**
* 已卖光
* @Message("有商品已卖光")
* 库存不足
* @Message("库存不足")
*/
const GOODS_INVENTORY_ERROR = 1101;

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\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()

Loading…
Cancel
Save