From 34cc643b6602d4127755a6aff63817c5d1699a2c Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 11:56:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=AD=98=E5=9C=A8=E7=89=B9?= =?UTF-8?q?=E4=BB=B7=E5=95=86=E5=93=81=E4=B8=8D=E7=BB=99=E7=94=A8=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CouponController.php | 6 ++++-- app/Service/CouponService.php | 18 +++++++++++++++--- app/Service/CouponServiceInterface.php | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Controller/CouponController.php b/app/Controller/CouponController.php index e7fd6c4..5caf76c 100644 --- a/app/Controller/CouponController.php +++ b/app/Controller/CouponController.php @@ -199,8 +199,10 @@ class CouponController extends BaseController $type = $this->request->input('type', 1); # 店铺类型id $storetypeId = $this->request->input('storetype_id', 0); - - $res = $this->couponService->getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId); + # 购物车商品id + $carIds = $this->request->input('car_ids', 0); + + $res = $this->couponService->getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId,$carIds); return $this->success($res); } diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 483bc72..8363f31 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -3,6 +3,7 @@ namespace App\Service; use App\Model\OrderMain; +use App\Model\ShopCar; use Hyperf\Di\Annotation\Inject; use Hyperf\DbConnection\Db; use App\Model\CouponUserRecType; @@ -155,12 +156,23 @@ class CouponService implements CouponServiceInterface * 获取用户当前订单可用的优惠券列表 * 按分类(1订单 等优惠)分组返回 */ - public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId) + public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId,$carIds) { - $storetypeIds = explode(',', str_replace(',', ',', $storetypeId)); - $available = []; $notAvailable = []; + //如果存在特价商品 不给用券 + $carIdsArr = explode(',',$carIds); + $shopCarExists = ShopCar::whereIn('id',$carIdsArr) + ->where('money',0.01) + ->exists(); + if($shopCarExists){ + return [ + 'available' => $available, + 'not_available' => array_values($notAvailable) + ]; + } + + $storetypeIds = explode(',', str_replace(',', ',', $storetypeId)); if (empty($orderAmount) || empty($userId)) { return [ diff --git a/app/Service/CouponServiceInterface.php b/app/Service/CouponServiceInterface.php index 4f60de4..669e086 100644 --- a/app/Service/CouponServiceInterface.php +++ b/app/Service/CouponServiceInterface.php @@ -13,7 +13,7 @@ interface CouponServiceInterface public function getUserReceiveCouponList(); - public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId); + public function getUserAvailableCoupons($orderAmount,$userId,$marketId,$type,$storetypeId,$carIds); /** * 当前订单可用优惠券列表