From b532ae133cf7e9f7eac12af0a106db7ccdf07548 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Tue, 25 Aug 2020 19:27:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=80=80=E6=AC=BE--=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=84=E7=90=86=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/Controller/NotifyPayRefundController.php | 11 ++++++++--- app/Service/CouponService.php | 2 +- app/Service/OrderService.php | 12 ++++++++++++ app/Service/OrderServiceInterface.php | 11 +++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/Controller/NotifyPayRefundController.php b/app/Controller/NotifyPayRefundController.php index b704d47..18176c6 100644 --- a/app/Controller/NotifyPayRefundController.php +++ b/app/Controller/NotifyPayRefundController.php @@ -69,13 +69,18 @@ class NotifyPayRefundController extends BaseController } /* --- 退款成功 --- */ - // 退款返还优惠券 - $this->couponService->orderRefundCoupon($message['out_trade_no']); - // 添加用户的流水 $orderMain = OrderMain::select('id','global_order_id','money','user_id') ->where('global_order_id',$message['out_trade_no']) ->where('state',OrderMain::ORDER_STATE_REFUNDED) ->first(); + + // 退款返还优惠券 + $this->couponService->orderRefundCoupon($message['out_trade_no']); + + // 删除特价商品缓存 + $this->orderService->clearTodayGoodPurchase($orderMain->user_id,1); + + // 添加用户的流水 if(!empty($orderMain)){ $this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money); } diff --git a/app/Service/CouponService.php b/app/Service/CouponService.php index 7339a43..b015c8d 100644 --- a/app/Service/CouponService.php +++ b/app/Service/CouponService.php @@ -262,7 +262,7 @@ class CouponService implements CouponServiceInterface * @param $couponId * @return bool */ - function clearTodayCouponUsed($userId, $couponId) + public function clearTodayCouponUsed($userId, $couponId) { $redis = ApplicationContext::getContainer()->get(Redis::class); diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index 05654a8..f46990c 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -22,6 +22,7 @@ use Hyperf\Di\Annotation\Inject; use App\Service\WxRefundServiceInterface; use App\Service\UserServiceInterface; use App\Model\Users; +use App\Constants\SsdbKeysPrefix; class OrderService implements OrderServiceInterface { @@ -779,6 +780,8 @@ class OrderService implements OrderServiceInterface // 返还优惠券 $this->couponService->orderRefundCoupon($global_order_id); + // 删除特价商品缓存 + $this->orderService->clearTodayGoodPurchase($orderMain->user_id,1); // 添加用户流水 $this->financialService->userByOLOrderRefund($orderMain->user_id, $orderMain->global_order_id, $orderMain->money); } @@ -836,4 +839,13 @@ class OrderService implements OrderServiceInterface return false; } } + + /** + * 删除特价商品缓存 + */ + public function clearTodayGoodPurchase($userId, $goodId) + { + $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + return $ssdb->exec('hdel', SsdbKeysPrefix::PURCHASE_RECORD. date('Ymd') .'_'.$userId, $goodId); + } } \ No newline at end of file diff --git a/app/Service/OrderServiceInterface.php b/app/Service/OrderServiceInterface.php index 4834c91..382f9e3 100644 --- a/app/Service/OrderServiceInterface.php +++ b/app/Service/OrderServiceInterface.php @@ -61,4 +61,15 @@ interface OrderServiceInterface * @return mixed */ public function onlineRefund($global_order_id); + + /** + * 订单退款失败 + * 回退订单状态 + */ + public function onlineRefundFail($global_order_id); + + /** + * 删除特价商品缓存 + */ + public function clearTodayGoodPurchase($userId, $goodId); } \ No newline at end of file