From 5118008ef9d9ee168fa5d16697c150f0f254a595 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 09:41:30 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/CouponService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 5efe903..0d77114 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -161,11 +161,11 @@ class CouponService implements CouponServiceInterface $available = []; $notAvailable = []; - if ($this->empty($orderAmount) || $this->empty($userId)) { - return $this->success([ + if (empty($orderAmount) || empty($userId)) { + return [ 'available' => $available, 'not_available' => array_values($notAvailable) - ]); + ]; } // 获取用户优惠券 From d6990ccbaae4415317ee413daba7c7c5072e95da Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 11:12:13 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20order=5Fid=20=E6=94=B9=E4=B8=BA=20global?= =?UTF-8?q?=5Forder=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/OrderController.php | 7 +++++-- app/Service/CouponService.php | 10 ++++++---- app/Service/CouponServiceInterface.php | 2 +- app/Service/OrderService.php | 8 ++++---- app/Service/OrderServiceInterface.php | 2 +- app/Service/PurchaseLimitService.php | 2 +- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/Controller/OrderController.php b/app/Controller/OrderController.php index fb2ed20..0d019f5 100644 --- a/app/Controller/OrderController.php +++ b/app/Controller/OrderController.php @@ -102,8 +102,11 @@ class OrderController extends BaseController * 用户取消订单 */ public function onlineCancel(){ - $OrderId = $this->request->input('order_id'); - return $this->success($this->orderService->onlineCancel($OrderId)); + $orderId = $this->request->input('order_id'); + $orderMain = OrderMain::where('id',$orderId) + ->select('global_order_id') + ->first(); + return $this->success($this->orderService->onlineCancel($orderMain->global_order_id)); } } \ No newline at end of file diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index dcb01ef..483bc72 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -2,6 +2,7 @@ namespace App\Service; +use App\Model\OrderMain; use Hyperf\Di\Annotation\Inject; use Hyperf\DbConnection\Db; use App\Model\CouponUserRecType; @@ -284,7 +285,11 @@ class CouponService implements CouponServiceInterface * @param $order_id * @return bool */ - public function refundOrderCoupons($order_id){ + public function refundOrderCoupons($global_order_id){ + $order_main = OrderMain::where('global_order_id',$global_order_id) + ->select('id','user_id') + ->first(); + $order_id = $order_main->id; $coupon = CouponUserUse::where([ ['order_main_id','=',$order_id], ['status','=',CouponUserUse::COUPON_USE_STATE_USED], @@ -312,9 +317,6 @@ class CouponService implements CouponServiceInterface ]); //删除当日 redis 使用记录缓存 - $order_main = OrderMain::where('id',$order_id) - ->select('global_order_id','user_id') - ->first(); $redis = ApplicationContext::getContainer()->get(Redis::class); $remRes = $redis->sRem( 'coupon_'.date('Ymd').'_used_'.$order_main->user_id, diff --git a/app/Service/CouponServiceInterface.php b/app/Service/CouponServiceInterface.php index 2789efb..4f60de4 100644 --- a/app/Service/CouponServiceInterface.php +++ b/app/Service/CouponServiceInterface.php @@ -27,7 +27,7 @@ interface CouponServiceInterface */ public function getOrderCanUseCoupons($orderAmount, $marketId, $userId, $fields=[], $type=1, $storeTypeIds=[0]); - public function refundOrderCoupons($order_id); + public function refundOrderCoupons($global_order_id); public function clearTodayCouponUsed($userId, $couponId); public function orderRefundCoupon($global_order_id); } diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index 57aadf3..fc3c3e0 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -729,13 +729,13 @@ class OrderService implements OrderServiceInterface /** * @inheritDoc */ - public function onlineCancel($order_id){ - OrderMain::where('id',$order_id) + public function onlineCancel($global_order_id){ + OrderMain::where('global_order_id',$global_order_id) ->update(['state' => OrderMain::ORDER_STATE_CANCEL]); //撤销redis 用券记录 - $res = $this->couponService->refundOrderCoupons($order_id); + $res = $this->couponService->refundOrderCoupons($global_order_id); //撤销特价商品购买记录 - $res = $this->purchaseLimitService->delSsdbPurchaseRecord($order_id); + $res = $this->purchaseLimitService->delSsdbPurchaseRecord($global_order_id); return $res; } /** diff --git a/app/Service/OrderServiceInterface.php b/app/Service/OrderServiceInterface.php index 382f9e3..a371378 100644 --- a/app/Service/OrderServiceInterface.php +++ b/app/Service/OrderServiceInterface.php @@ -53,7 +53,7 @@ interface OrderServiceInterface * @param $global_order_id * @return mixed */ - public function onlineCancel($order_id); + public function onlineCancel($global_order_id); /** * 线上订单退款 diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 2a3abeb..41a531f 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -65,7 +65,7 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface ->toArray(); foreach ($goods as $k2 => $v2) { - $ssdb->exec('del', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$v1['user_id'].'_'.$v2['good_id'], $order->global_order_id); + $ssdb->exec('del', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$v1['user_id'].'_'.$v2['good_id']); var_dump($v1['user_id']); var_dump($v1['good_id']); } From 174044258171fea1d33873951bee505167a38870 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 11:27:15 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=92=A4=E9=94=80=E7=89=B9=E4=BB=B7?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E4=B9=B0=E8=AE=B0=E5=BD=95=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8global=5Forder=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/PurchaseLimitService.php | 7 ++++++- app/Service/PurchaseLimitServiceInterface.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 41a531f..717e45e 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -4,6 +4,7 @@ namespace App\Service; use App\Model\Order; use App\Model\OrderGoods; +use App\Model\OrderMain; use Hyperf\Di\Annotation\Inject; use Hyperf\DbConnection\Db; use App\Model\Goods; @@ -46,8 +47,12 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface return true; } - public function delSsdbPurchaseRecord($order_id) + public function delSsdbPurchaseRecord($global_order_id) { + $order_main = OrderMain::where('global_order_id',$global_order_id) + ->select('id','user_id') + ->first(); + $order_id = $order_main->id; $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $order = Order::query() ->where('order_main_id',$order_id) diff --git a/app/Service/PurchaseLimitServiceInterface.php b/app/Service/PurchaseLimitServiceInterface.php index 5c88b2c..f5e415b 100644 --- a/app/Service/PurchaseLimitServiceInterface.php +++ b/app/Service/PurchaseLimitServiceInterface.php @@ -10,7 +10,7 @@ interface PurchaseLimitServiceInterface public function ssdbPurchaseRecord($params,$user_id,$global_order_id); - public function delSsdbPurchaseRecord($order_id); + public function delSsdbPurchaseRecord($global_order_id); public function test($params); } \ No newline at end of file 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 4/7] =?UTF-8?q?=E4=B8=8B=E5=8D=95=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=89=B9=E4=BB=B7=E5=95=86=E5=93=81=E4=B8=8D=E7=BB=99=E7=94=A8?= =?UTF-8?q?=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); /** * 当前订单可用优惠券列表 From 117e356d0ae0b226e39afca95e65423268d8d49e Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 16:12:07 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=80=80=E5=8D=95=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=95=B4=E5=90=88=20=E6=9C=89=E5=A4=B1=E6=95=88=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=88=B8=E6=97=B6=E8=BF=94=E5=9B=9E=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E5=8E=9F=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/CouponUserUse.php | 6 ++++ app/Service/CouponService.php | 43 ++++++++++++++------------ app/Service/CouponServiceInterface.php | 2 +- app/Service/OrderService.php | 6 ++-- app/Service/PurchaseLimitService.php | 2 -- 5 files changed, 34 insertions(+), 25 deletions(-) diff --git a/app/Model/CouponUserUse.php b/app/Model/CouponUserUse.php index 0d53a14..76064ca 100644 --- a/app/Model/CouponUserUse.php +++ b/app/Model/CouponUserUse.php @@ -13,5 +13,11 @@ class CouponUserUse extends Model public $timestamps = false; + protected $fillable = [ + 'status', + 'return_time', + 'update_time' + ]; + protected $table = 'ims_system_coupon_user_use'; } \ No newline at end of file diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 8363f31..d64b786 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -160,18 +160,6 @@ class CouponService implements CouponServiceInterface { $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)) { @@ -218,12 +206,27 @@ class CouponService implements CouponServiceInterface foreach ($data as $key => &$item) { if (in_array($item->id, $couponIds)) { + $item->msg = '今日已使用'; $notAvailable[$item->id] = $item; } else { $available[] = $item; } } + //如果存在特价商品 不给用券 + $carIdsArr = explode(',',$carIds); + $shopCarExists = ShopCar::whereIn('id',$carIdsArr) + ->where('money',0.01) + ->exists(); + if($shopCarExists){ + var_dump(1111); + foreach ($available as $k => $v) { + $v->msg = '特价商品不可使用'; + $notAvailable[$v->id] = $v; + } + $available = []; + } + return [ 'available' => $available, 'not_available' => array_values($notAvailable) @@ -334,7 +337,7 @@ class CouponService implements CouponServiceInterface 'coupon_'.date('Ymd').'_used_'.$order_main->user_id, $coupon->system_coupon_id ); - return $res; + return $remRes; } /* 删除-优惠券今日使用的缓存 @@ -359,19 +362,22 @@ class CouponService implements CouponServiceInterface * 先查询是否正常使用优惠券 * 修改状态,退还领取记录库存,删除ssdb缓存 */ - public function orderRefundCoupon($global_order_id) + public function orderRefundCoupons($global_order_id) { + $order_main = OrderMain::where('global_order_id',$global_order_id) + ->select('id','user_id') + ->first(); $time = time(); Db::beginTransaction(); try { $couponUses = CouponUserUse::query() ->select('id','system_coupon_id','user_id','number','user_receive_id') - ->where('global_order_id',$global_order_id) + ->where('order_main_id',$order_main->id) ->where('status',CouponUserUse::COUPON_USE_STATE_USED) - ->select(); - if(!empty($couponUse)){ + ->get(); + if(!empty($couponUses)){ foreach($couponUses as $use){ - $use->status = CouponUserUse::COUPON_USE_STATE_USED; + $use->status = CouponUserUse::COUPON_USE_STATE_CANCEL; $use->return_time = $time; $use->update_time = $time; $res = $use->save(); @@ -397,6 +403,5 @@ class CouponService implements CouponServiceInterface Db::rollBack(); return false; } - return true; } } \ No newline at end of file diff --git a/app/Service/CouponServiceInterface.php b/app/Service/CouponServiceInterface.php index 669e086..e7c54b5 100644 --- a/app/Service/CouponServiceInterface.php +++ b/app/Service/CouponServiceInterface.php @@ -29,5 +29,5 @@ interface CouponServiceInterface public function refundOrderCoupons($global_order_id); public function clearTodayCouponUsed($userId, $couponId); - public function orderRefundCoupon($global_order_id); + public function orderRefundCoupons($global_order_id); } diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index fc3c3e0..a1d5734 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -733,10 +733,10 @@ class OrderService implements OrderServiceInterface OrderMain::where('global_order_id',$global_order_id) ->update(['state' => OrderMain::ORDER_STATE_CANCEL]); //撤销redis 用券记录 - $res = $this->couponService->refundOrderCoupons($global_order_id); + $redisRes = $this->couponService->orderRefundCoupons($global_order_id); //撤销特价商品购买记录 - $res = $this->purchaseLimitService->delSsdbPurchaseRecord($global_order_id); - return $res; + $ssdbRes = $this->purchaseLimitService->delSsdbPurchaseRecord($global_order_id); + return $redisRes && $ssdbRes; } /** * @inheritDoc diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 717e45e..8bbd222 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -71,8 +71,6 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface foreach ($goods as $k2 => $v2) { $ssdb->exec('del', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$v1['user_id'].'_'.$v2['good_id']); - var_dump($v1['user_id']); - var_dump($v1['good_id']); } } return true; From 579cd1fd60feba386a43c5fb0011ef9c8ebf58d9 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 16:23:40 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=94=B9=E4=BC=98=E6=83=A0?= =?UTF-8?q?=E5=88=B8=E5=A4=B1=E6=95=88=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/CouponService.php | 48 +---------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index d64b786..10ab91d 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -219,9 +219,8 @@ class CouponService implements CouponServiceInterface ->where('money',0.01) ->exists(); if($shopCarExists){ - var_dump(1111); foreach ($available as $k => $v) { - $v->msg = '特价商品不可使用'; + $v->msg = '不可使用'; $notAvailable[$v->id] = $v; } $available = []; @@ -295,51 +294,6 @@ class CouponService implements CouponServiceInterface return $setRes&&$expireRes; } - /** - * 取消订单返券 - * @param $order_id - * @return bool - */ - public function refundOrderCoupons($global_order_id){ - $order_main = OrderMain::where('global_order_id',$global_order_id) - ->select('id','user_id') - ->first(); - $order_id = $order_main->id; - $coupon = CouponUserUse::where([ - ['order_main_id','=',$order_id], - ['status','=',CouponUserUse::COUPON_USE_STATE_USED], - ]) - ->select('id','user_receive_id','number') - ->first(); - - if (empty($coupon)) { - return ''; - } - - // 返回用户优惠券数量并更新状态 - $res = Db::update("UPDATE ims_system_coupon_user_receive SET number_remain=number_remain+{$coupon->number}, status=IF(number=number_remain,0,1), update_time=".time()."" - ." WHERE id={$coupon->user_receive_id} AND number>=(number_remain+{$coupon->number})"); - - // 更新使用记录状态为已退回 - CouponUserUse::where([ - ['id','=',$coupon->id], - ['status','=',CouponUserUse::COUPON_USE_STATE_USED], - ]) - ->update([ - 'status' => CouponUserUse::COUPON_USE_STATE_CANCEL, - 'return_time' => time(), - 'update_time' => time(), - ]); - - //删除当日 redis 使用记录缓存 - $redis = ApplicationContext::getContainer()->get(Redis::class); - $remRes = $redis->sRem( - 'coupon_'.date('Ymd').'_used_'.$order_main->user_id, - $coupon->system_coupon_id - ); - return $remRes; - } - /* 删除-优惠券今日使用的缓存 * @param $userId * @param $couponId From e37f4c2cad1fe2594302707e51d41d2a0eb71546 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 16:30:19 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=89=B9=E4=BB=B7=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/CouponService.php | 47 +------------------------- app/Service/CouponServiceInterface.php | 2 -- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index d64b786..bb4be10 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -219,9 +219,8 @@ class CouponService implements CouponServiceInterface ->where('money',0.01) ->exists(); if($shopCarExists){ - var_dump(1111); foreach ($available as $k => $v) { - $v->msg = '特价商品不可使用'; + $v->msg = '不可使用'; $notAvailable[$v->id] = $v; } $available = []; @@ -295,50 +294,6 @@ class CouponService implements CouponServiceInterface return $setRes&&$expireRes; } - /** - * 取消订单返券 - * @param $order_id - * @return bool - */ - public function refundOrderCoupons($global_order_id){ - $order_main = OrderMain::where('global_order_id',$global_order_id) - ->select('id','user_id') - ->first(); - $order_id = $order_main->id; - $coupon = CouponUserUse::where([ - ['order_main_id','=',$order_id], - ['status','=',CouponUserUse::COUPON_USE_STATE_USED], - ]) - ->select('id','user_receive_id','number') - ->first(); - - if (empty($coupon)) { - return ''; - } - - // 返回用户优惠券数量并更新状态 - $res = Db::update("UPDATE ims_system_coupon_user_receive SET number_remain=number_remain+{$coupon->number}, status=IF(number=number_remain,0,1), update_time=".time()."" - ." WHERE id={$coupon->user_receive_id} AND number>=(number_remain+{$coupon->number})"); - - // 更新使用记录状态为已退回 - CouponUserUse::where([ - ['id','=',$coupon->id], - ['status','=',CouponUserUse::COUPON_USE_STATE_USED], - ]) - ->update([ - 'status' => CouponUserUse::COUPON_USE_STATE_CANCEL, - 'return_time' => time(), - 'update_time' => time(), - ]); - - //删除当日 redis 使用记录缓存 - $redis = ApplicationContext::getContainer()->get(Redis::class); - $remRes = $redis->sRem( - 'coupon_'.date('Ymd').'_used_'.$order_main->user_id, - $coupon->system_coupon_id - ); - return $remRes; - } /* 删除-优惠券今日使用的缓存 * @param $userId diff --git a/app/Service/CouponServiceInterface.php b/app/Service/CouponServiceInterface.php index e7c54b5..33bf11b 100644 --- a/app/Service/CouponServiceInterface.php +++ b/app/Service/CouponServiceInterface.php @@ -26,8 +26,6 @@ interface CouponServiceInterface * @return mixed */ public function getOrderCanUseCoupons($orderAmount, $marketId, $userId, $fields=[], $type=1, $storeTypeIds=[0]); - - public function refundOrderCoupons($global_order_id); public function clearTodayCouponUsed($userId, $couponId); public function orderRefundCoupons($global_order_id); }