From de97e5ee3823f679abc14106b5f6796fb8f4e822 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 9 Sep 2020 17:24:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8A=A5=E9=94=99=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/ErrorCode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index 75df14e..8fe3c65 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -118,25 +118,25 @@ class ErrorCode extends AbstractConstants * 微信登录失败:无效的code * @Message("微信登录失败:无效的code") */ - const WXLOGIN_INVALID_CODE = 704; + const WXLOGIN_INVALID_CODE = 705; /** * 更新失败 * @Message("更新失败") */ - const USER_INFO_UPDATE_ERROR = 705; + const USER_INFO_UPDATE_ERROR = 706; /** * 商户账户密码不匹配 * @Message("账号密码错误") */ - const STORE_LOGIN_ERROR = 706; + const STORE_LOGIN_ERROR = 707; /** * 商户异常,当前商户可能不存在或失效了 * @Message("当前商户异常") */ - const STORE_NOT_AVAILABLE = 707; + const STORE_NOT_AVAILABLE = 708; /************************************/ /* 定位相关 751-800 */ From cfc677abcfefdfe19fa3b6a10c2cd66f66572de9 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 9 Sep 2020 18:11:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ShopCartService.php | 44 ++++--------------- .../Implementations/ShopCartUpdateService.php | 6 ++- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/app/Service/v3/Implementations/ShopCartService.php b/app/Service/v3/Implementations/ShopCartService.php index 50b34cb..b145fb7 100644 --- a/app/Service/v3/Implementations/ShopCartService.php +++ b/app/Service/v3/Implementations/ShopCartService.php @@ -136,47 +136,21 @@ class ShopCartService implements ShopCartServiceInterface 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) { - $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) diff --git a/app/Service/v3/Implementations/ShopCartUpdateService.php b/app/Service/v3/Implementations/ShopCartUpdateService.php index 0aafcbd..04e7aaf 100644 --- a/app/Service/v3/Implementations/ShopCartUpdateService.php +++ b/app/Service/v3/Implementations/ShopCartUpdateService.php @@ -59,6 +59,10 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface */ public function doClear($userId, $marketId) { - + return ShoppingCart::query()->where([ + ['user_id','=',$userId], + ['market_id','=',$marketId], + ]) + ->delete(); } } \ No newline at end of file