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