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 () {