diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index e203d2d..40490b9 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -30,6 +30,7 @@ class ErrorCode extends AbstractConstants /************************************/ /* 用户相关 701-750 */ /************************************/ + /** * 验证码错误或已失效 * @Message("验证码错误或已失效") @@ -48,6 +49,12 @@ class ErrorCode extends AbstractConstants */ const UNBIND_TEL_ERROR = 703; + /** + * 用户未绑定手机号 + * @Message("请绑定手机号") + */ + const NOT_BIND_TEL_ERROR = 704; + /** * 微信登录失败:无效的code * @Message("微信登录失败:无效的code") @@ -59,7 +66,6 @@ class ErrorCode extends AbstractConstants * @Message("更新失败") */ const USER_INFO_UPDATE_ERROR = 705; - /************************************/ /* 定位相关 751-800 */ /************************************/ @@ -84,4 +90,25 @@ class ErrorCode extends AbstractConstants * @Message("短信发送失败") */ const SMS_SEND_FAILURE = 1003; + + /************************************/ + /* 商品相关 1101-1200 */ + /************************************/ + /** + * 库存不足 + * @Message("库存不足") + */ + const GOODS_INVENTORY_ERROR = 1101; + + /** + * 超过商品购买数量限制 + * @Message("超过商品购买数量限制") + */ + const PURCHASE_LIMIT_ERROR = 1102; + + /** + * 当前特价商品已被购买过 + * @Message("当前特价商品已被购买过") + */ + const SPERCIAL_OFFER_GOODS_ERROR = 1103; } \ No newline at end of file diff --git a/app/Controller/v3/ExampleController.php b/app/Controller/v3/ExampleController.php index 78821c4..3733bc0 100644 --- a/app/Controller/v3/ExampleController.php +++ b/app/Controller/v3/ExampleController.php @@ -6,5 +6,18 @@ use App\Controller\BaseController; class ExampleController extends BaseController { + public function do() + { + } + + public function check() + { + + } + + public function undo() + { + + } } \ No newline at end of file diff --git a/app/Controller/v3/GoodsController.php b/app/Controller/v3/GoodsController.php index 30b344a..0af2d77 100644 --- a/app/Controller/v3/GoodsController.php +++ b/app/Controller/v3/GoodsController.php @@ -12,7 +12,8 @@ class GoodsController extends BaseController * @var GoodsServiceInterface */ protected $goods; - public function detail(){ + public function detail() + { $res = $this->goods->detail(); return $this->success($res); } diff --git a/app/Controller/v3/OnlineOrderController.php b/app/Controller/v3/OnlineOrderController.php new file mode 100644 index 0000000..1348581 --- /dev/null +++ b/app/Controller/v3/OnlineOrderController.php @@ -0,0 +1,127 @@ +request->all(); + //判断用户有没有绑定手机 + $telExists = $this->userBindTel->check($params['user_id']); + if(!$telExists){ + throw new ErrorCodeException(ErrorCode::NOT_BIND_TEL_ERROR); + } + //获取用户收货地址 + $res['address'] = [ + 'address' => '南宁市良庆区五象海尔·青啤联合广场', + 'area' => 'A栋八单元' , + 'lat' => '22.759950637817383', + 'lng' => '108.3835678100586', + 'sex' => '1', + 'tel' => '15677717734', + 'user_name' => '李小龙', + 'user_id' => '214' + ]; + //返回预约送达时间 数组 + $res['appointment_time'] = [ + '08:30 - 09:00', + '09:00 - 09:30', + '09:30 - 10:00', + '10:00 - 10:30' + ]; + // + $res['store_list'] = [ + '50' => [ + 'store_nmae' => '五金杂货铺', + 'goods_list' => [ + 'id' => 3765, + 'goods_id' => 836, + 'name' => '扳手', + 'num' => 2, + 'price' => '50.00', + 'total' => '100.00' + ] + ], + '99' => [ + 'store_nmae' => '回味手撕鸡J009', + 'goods_list' => + [ + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ], + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ] + ] + ], + ]; + //获取用户优惠券 + $res['coupon'] = $this->couponService->getUserAvailableCoupons('',$params['user_id'],'',2,'',''); + //获取配送费 + $res['distribution'] = '5.0'; + //增值服务接口 + $res['value_added_service'] = [ + 'select' => 1, + 'price' => 3.50 + ]; + return $this->success($res); + } + + public function check() + { + + } + + public function undo() + { + + } +} \ No newline at end of file diff --git a/app/Controller/v3/OrderController.php b/app/Controller/v3/OrderController.php deleted file mode 100644 index ecbb5f9..0000000 --- a/app/Controller/v3/OrderController.php +++ /dev/null @@ -1,19 +0,0 @@ -order->detail(); - return $this->success($res); - } -} \ No newline at end of file diff --git a/app/Controller/v3/ShopCartController.php b/app/Controller/v3/ShopCartController.php new file mode 100644 index 0000000..b180dbb --- /dev/null +++ b/app/Controller/v3/ShopCartController.php @@ -0,0 +1,36 @@ +shopCart->detail(); + //获取购物车失效商品信息 + $res['store_invalid_goood_lists'] = $this->shopCart->undo(); + //计算购物车价格 + $res['total'] = '820.00'; + return $this->success($res); + } + + public function check() + { + + } + + public function undo() + { + + } +} \ No newline at end of file diff --git a/app/Controller/v3/UpdateShopCartController.php b/app/Controller/v3/UpdateShopCartController.php new file mode 100644 index 0000000..71414b6 --- /dev/null +++ b/app/Controller/v3/UpdateShopCartController.php @@ -0,0 +1,32 @@ +updateShopCarService->update($this->request->all()); + return $this->success($res); + } + + public function check() + { + + } + + public function delete() + { + $res = $this->updateShopCarService->delete($this->request->all()); + return $this->success($res); + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/AppointmentTimeService.php b/app/Service/v3/Implementations/AppointmentTimeService.php new file mode 100644 index 0000000..b69d328 --- /dev/null +++ b/app/Service/v3/Implementations/AppointmentTimeService.php @@ -0,0 +1,29 @@ + '五金杂货铺', + 'price' => '100.00', + 'note' => '多放辣椒', + 'store_id' => 66, + 'goods_list' => + [ + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ] + ] + ], + [ + 'store_nmae' => '回味手撕鸡J009', + 'note' => '手撕鸡加辣', + 'store_price' => '720.00', + 'store_id' => 123, + 'goods_list' => + [ + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ], + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ] + ] + ], + ]; + return $res; + } + + public function check() + { + // TODO: Implement check() method. + } + + public function undo() + { + $res = [ + [ + 'store_nmae' => '五金杂货铺', + 'price' => '100.00', + 'note' => '多放辣椒', + 'store_id' => 66, + 'goods_list' => + [ + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ] + ] + ], + [ + 'store_nmae' => '回味手撕鸡J009', + 'note' => '手撕鸡加辣', + 'store_price' => '720.00', + 'store_id' => 123, + 'goods_list' => + [ + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ], + [ + 'id' => 3971, + 'goods_id' => 1301, + 'name' => '半边手撕鸡', + 'num' => 4, + 'price' => '90.00', + 'total' => '360.00' + ] + ] + ], + ]; + return $res; + } +} \ No newline at end of file diff --git a/app/Service/v3/Implementations/UpdateShopCartService.php b/app/Service/v3/Implementations/UpdateShopCartService.php new file mode 100644 index 0000000..0cf3977 --- /dev/null +++ b/app/Service/v3/Implementations/UpdateShopCartService.php @@ -0,0 +1,38 @@ + \App\Service\v3\Implementations\HelperService::class, \App\Service\v3\Interfaces\VerifyCodeServiceInterface::class => \App\Service\v3\Implementations\VerifyCodeService::class, \App\Service\v3\Interfaces\UserBindTelServiceInterface::class => \App\Service\v3\Implementations\UserBindTelService::class, - \App\Service\v3\Interfaces\OrderServiceInterface::class => \App\Service\v3\Implementations\OrderService::class, + \App\Service\v3\Interfaces\OnlineOrderServiceInterface::class => \App\Service\v3\Implementations\OnlineOrderService::class, + \App\Service\v3\Interfaces\DistributionPriceServiceInterface::class => \App\Service\v3\Implementations\DistributionPriceService::class, + \App\Service\v3\Interfaces\AppointmentTimeServiceInterface::class => \App\Service\v3\Implementations\AppointmentTimeService::class, \App\Service\v3\Interfaces\CategoryServiceInterface::class => \App\Service\v3\Implementations\CategoryService::class, + \App\Service\v3\Interfaces\UpdateShopCartServiceInterface::class => \App\Service\v3\Implementations\UpdateShopCartService::class, + \App\Service\v3\Interfaces\ShopCartServiceInterface::class => \App\Service\v3\Implementations\ShopCartService::class, \App\Service\v3\Interfaces\WxLoginServiceInterface::class => \App\Service\v3\Implementations\WxLoginService::class, \App\Service\v3\Interfaces\UserInfoServiceInterface::class => \App\Service\v3\Implementations\UserInfoService::class, ]; diff --git a/config/routes.php b/config/routes.php index 60f2fe7..72d2bdd 100644 --- a/config/routes.php +++ b/config/routes.php @@ -79,10 +79,13 @@ Router::addGroup('/wechat/',function () { Router::addGroup('/v3/', function () { Router::post('location/getNearestMarket', 'App\Controller\v3\LocationController@getNearestMarket'); Router::post('home/appletIndex', 'App\Controller\v3\HomeController@appletIndex'); - Router::post('Goods/detail', 'App\Controller\v3\GoodsController@detail'); + Router::post('goods/detail', 'App\Controller\v3\GoodsController@detail'); Router::post('goodsRecommend/getByTabsForAppletIndex', 'App\Controller\v3\GoodsRecommendController@getByTabsForAppletIndex'); - Router::post('Order/detail', 'App\Controller\v3\OrderController@detail'); + Router::post('onlineOrder/detail', 'App\Controller\v3\OnlineOrderController@detail'); + Router::post('distributionPrice/get', 'App\Controller\v3\DistributionPriceController@get'); Router::post('category/all', 'App\Controller\v3\CategoryController@all'); + Router::post('UpdateShopCart/update', 'App\Controller\v3\UpdateShopCartController@update'); + Router::post('ShopCart/detail', 'App\Controller\v3\ShopCartController@detail'); Router::post('login/wxLogin', 'App\Controller\v3\LoginController@wxLogin'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);