Browse Source

接口规范 获取购物车信息接口初始化

master
Lemon 6 years ago
parent
commit
b7405d5509
  1. 6
      app/Controller/v3/ExampleController.php
  2. 3
      app/Controller/v3/GoodsController.php
  3. 8
      app/Controller/v3/OnlineOrderController.php
  4. 36
      app/Controller/v3/ShopCartController.php
  5. 10
      app/Controller/v3/UpdateShopCartController.php
  6. 2
      app/Service/v3/Implementations/AppointmentTimeService.php
  7. 2
      app/Service/v3/Implementations/OnlineOrderService.php
  8. 111
      app/Service/v3/Implementations/ShopCartService.php
  9. 6
      app/Service/v3/Implementations/UpdateShopCartService.php
  10. 2
      app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php
  11. 2
      app/Service/v3/Interfaces/OnlineOrderServiceInterface.php
  12. 12
      app/Service/v3/Interfaces/ShopCartServiceInterface.php
  13. 4
      app/Service/v3/Interfaces/UpdateShopCartServiceInterface.php
  14. 1
      config/autoload/dependencies.php
  15. 7
      config/routes.php

6
app/Controller/v3/ExampleController.php

@ -11,11 +11,13 @@ class ExampleController extends BaseController
}
public function check(){
public function check()
{
}
public function undo(){
public function undo()
{
}
}

3
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);
}

8
app/Controller/v3/OnlineOrderController.php

@ -41,7 +41,7 @@ class OnlineOrderController extends BaseController
* 配送费独立接口 可根据距离动态计算费用
* 增值服务接口
* */
public function do()
public function detail()
{
$params = $this->request->all();
//判断用户有没有绑定手机
@ -115,11 +115,13 @@ class OnlineOrderController extends BaseController
return $this->success($res);
}
public function check(){
public function check()
{
}
public function undo(){
public function undo()
{
}
}

36
app/Controller/v3/ShopCartController.php

@ -0,0 +1,36 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\ShopCartServiceInterface;
class ShopCartController extends BaseController
{
/**
* @Inject
* @var ShopCartServiceInterface
*/
protected $shopCart;
public function detail()
{
//获取购物车商品信息
$res['store_goood_lists'] = $this->shopCart->detail();
//获取购物车失效商品信息
$res['store_invalid_goood_lists'] = $this->shopCart->undo();
//计算购物车价格
$res['total'] = '820.00';
return $this->success($res);
}
public function check()
{
}
public function undo()
{
}
}

10
app/Controller/v3/UpdateShopCartController.php

@ -13,17 +13,19 @@ class UpdateShopCartController extends BaseController
* @var UpdateShopCartServiceInterface
*/
protected $updateShopCarService;
public function do()
public function update()
{
$res = $this->updateShopCarService->do($this->request->all());
$res = $this->updateShopCarService->update($this->request->all());
return $this->success($res);
}
public function check(){
public function check()
{
}
public function undo(){
public function delete()
{
}
}

2
app/Service/v3/Implementations/AppointmentTimeService.php

@ -7,7 +7,7 @@ use phpDocumentor\Reflection\Types\Object_;
class AppointmentTimeService implements AppointmentTimeServiceInterface
{
public function do()
public function get()
{
return [
'08:30 - 09:00',

2
app/Service/v3/Implementations/OnlineOrderService.php

@ -6,7 +6,7 @@ use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OnlineOrderServiceInterface;
class OnlineOrderService implements OnlineOrderServiceInterface
{
public function do($params){
public function detail($params){
return [];
}

111
app/Service/v3/Implementations/ShopCartService.php

@ -0,0 +1,111 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\ShopCartServiceInterface;
class ShopCartService implements ShopCartServiceInterface
{
public function detail()
{
$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;
}
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;
}
}

6
app/Service/v3/Implementations/UpdateShopCartService.php

@ -8,7 +8,7 @@ use App\Service\v3\Interfaces\UpdateShopCartServiceInterface;
class UpdateShopCartService implements UpdateShopCartServiceInterface
{
public function do($params)
public function update($params)
{
switch ($params['goods_id'])
{
@ -31,8 +31,8 @@ class UpdateShopCartService implements UpdateShopCartServiceInterface
// TODO: Implement check() method.
}
public function undo()
public function delete()
{
// TODO: Implement undo() method.
return true;
}
}

2
app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php

@ -4,7 +4,7 @@ namespace App\Service\v3\Interfaces;
interface AppointmentTimeServiceInterface
{
public function do();
public function get();
public function check();

2
app/Service/v3/Interfaces/OnlineOrderServiceInterface.php

@ -4,7 +4,7 @@ namespace App\Service\v3\Interfaces;
interface OnlineOrderServiceInterface
{
public function do($params);
public function detail($params);
public function check();

12
app/Service/v3/Interfaces/ShopCartServiceInterface.php

@ -0,0 +1,12 @@
<?php
namespace App\Service\v3\Interfaces;
interface ShopCartServiceInterface
{
public function detail();
public function check();
public function undo();
}

4
app/Service/v3/Interfaces/UpdateShopCartServiceInterface.php

@ -4,9 +4,9 @@ namespace App\Service\v3\Interfaces;
interface UpdateShopCartServiceInterface
{
public function do($params);
public function update($params);
public function check();
public function undo();
public function delete();
}

1
config/autoload/dependencies.php

@ -45,4 +45,5 @@ return [
\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,
];

7
config/routes.php

@ -81,10 +81,11 @@ Router::addGroup('/v3/', function () {
Router::post('home/appletIndex', 'App\Controller\v3\HomeController@appletIndex');
Router::post('goods/detail', 'App\Controller\v3\GoodsController@detail');
Router::post('goodsRecommend/getByTabsForAppletIndex', 'App\Controller\v3\GoodsRecommendController@getByTabsForAppletIndex');
Router::post('onlineOrder/confirm', 'App\Controller\v3\OnlineOrderController@do');
Router::post('distributionPrice/get', 'App\Controller\v3\DistributionPriceController@do');
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@do');
Router::post('UpdateShopCart/update', 'App\Controller\v3\UpdateShopCartController@update');
Router::post('ShopCart/detail', 'App\Controller\v3\ShopCartController@detail');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);
// 需要登录的路由

Loading…
Cancel
Save