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] =?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); }