From f606c59979fcf4861e634fa7857dca58c8e9011c Mon Sep 17 00:00:00 2001 From: mattoid Date: Sun, 30 Jun 2024 23:23:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=89=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=81=E5=90=8E=E7=BD=AE=E5=87=BA=E6=9D=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/BuyGoodsController.php | 6 ++++-- src/Goods/After.php | 2 +- src/Goods/Validate.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Controller/BuyGoodsController.php b/src/Controller/BuyGoodsController.php index 592df23..20c231f 100644 --- a/src/Controller/BuyGoodsController.php +++ b/src/Controller/BuyGoodsController.php @@ -76,7 +76,8 @@ protected function data(ServerRequestInterface $request, Document $document) { } $validate = StoreExtend::getValidate($store->code); - if ($validate && !$validate->validate($actor, $store, $params, $this->translator, $this->settings, $this->events, $this->cache)) { + // $this->translator, $this->settings, $this->events, $this->cache + if ($validate && !$validate->validate($actor, $store, $params)) { throw new ValidationException(['message' => $this->translator->trans('mattoid-store.forum.error.validate-fail')]); } @@ -117,7 +118,8 @@ protected function data(ServerRequestInterface $request, Document $document) { $after = StoreExtend::getAfter($store->code); if ($after) { // 商品处理失败,通知购买失败事件进行回滚操作 - if (!$after->after($actor, $store, $params, $this->translator, $this->settings, $this->events, $this->cache)) { + // $this->translator, $this->settings, $this->events, $this->cache + if (!$after->after($actor, $store, $params)) { $this->events->dispatch(new StoreBuyFailEvent($user, $store, $cart, $params)); throw new ValidationException(['message' => $this->translator->trans('mattoid-store.forum.error.buy-goods-fail', ['title' => $store->title])]); } diff --git a/src/Goods/After.php b/src/Goods/After.php index 4a21b99..e3679af 100644 --- a/src/Goods/After.php +++ b/src/Goods/After.php @@ -12,5 +12,5 @@ abstract class After { - abstract static function after(User $user, StoreModel $store, $params, Translator $translator = null, SettingsRepositoryInterface $settings = null, Dispatcher $events = null, CacheContract $cache = null); + abstract static function after(User $user, StoreModel $store, $params); } diff --git a/src/Goods/Validate.php b/src/Goods/Validate.php index 5b7b7ab..788bb4c 100644 --- a/src/Goods/Validate.php +++ b/src/Goods/Validate.php @@ -15,5 +15,5 @@ abstract class Validate * @param array $params 购买入参 * @return boolean 返回 true-验证成功 false-验证失败 */ - abstract static function validate(User $user, StoreModel $store, $params, Translator $translator = null, SettingsRepositoryInterface $settings = null, Dispatcher $events = null, CacheContract $cache = null); + abstract static function validate(User $user, StoreModel $store, $params); }