From 4cdd4c8a510ed3b4f3cba3083b098c25aef786a7 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 21 Aug 2020 10:19:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E8=B4=AD=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20mock=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/ErrorCode.php | 5 ++++ app/Controller/PurchaseLimitController.php | 29 +++++++++++++++++++ app/Service/PurchaseLimitService.php | 17 +++++++++++ app/Service/PurchaseLimitServiceInterface.php | 10 +++++++ config/autoload/dependencies.php | 2 +- config/routes.php | 3 ++ 6 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 app/Controller/PurchaseLimitController.php create mode 100644 app/Service/PurchaseLimitService.php create mode 100644 app/Service/PurchaseLimitServiceInterface.php diff --git a/app/Constants/ErrorCode.php b/app/Constants/ErrorCode.php index ca97510..205e0b8 100644 --- a/app/Constants/ErrorCode.php +++ b/app/Constants/ErrorCode.php @@ -54,4 +54,9 @@ class ErrorCode extends AbstractConstants */ const PAY_FAILURE = 400; + /** + * @Message("Goods failure!") + */ + const GOODS_FAILURE = 700; + } diff --git a/app/Controller/PurchaseLimitController.php b/app/Controller/PurchaseLimitController.php new file mode 100644 index 0000000..d56ca24 --- /dev/null +++ b/app/Controller/PurchaseLimitController.php @@ -0,0 +1,29 @@ +purchaseLimitService->addShopCar($this->request->all()); + if (!$res) { + return $this->result(ErrorCode::GOODS_FAILURE, '', '商品已超过购买数量'); + } + return $this->success($res); + } + +} diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php new file mode 100644 index 0000000..c6b1ffe --- /dev/null +++ b/app/Service/PurchaseLimitService.php @@ -0,0 +1,17 @@ + \App\Service\MqttSpeakerService::class, \App\Service\FeiePrintServiceInterface::class => \App\Service\FeiePrintService::class, \App\Service\MiniprogramServiceInterface::class => \App\Service\MiniprogramService::class, - \App\Service\UserServiceInterface::class => \App\Service\UserService::class, + \App\Service\PurchaseLimitServiceInterface::class => \App\Service\PurchaseLimitService::class, ]; diff --git a/config/routes.php b/config/routes.php index b68b0e4..b2093b6 100644 --- a/config/routes.php +++ b/config/routes.php @@ -54,6 +54,9 @@ Router::addGroup('/v1/',function (){ //小程序支付相关 Router::post('wxminipay/online', 'App\Controller\PaymentController@wxminiPayOnline'); Router::post('wxminipay/offline', 'App\Controller\PaymentController@wxminiPayOffline'); + + //加入购物车 + Router::post('PurchaseLimit/addShopCar', 'App\Controller\PurchaseLimitController@addShopCar'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); Router::addGroup('/wechat/',function () {