Browse Source

确认订单接口 初始化 mock数据

master
Lemon 5 years ago
parent
commit
83e6344461
  1. 7
      app/Constants/v3/ErrorCode.php
  2. 11
      app/Controller/v3/ExampleController.php
  3. 125
      app/Controller/v3/OnlineOrderController.php
  4. 19
      app/Controller/v3/OrderController.php
  5. 29
      app/Service/v3/Implementations/AppointmentTimeService.php
  6. 25
      app/Service/v3/Implementations/DistributionPriceService.php
  7. 13
      app/Service/v3/Implementations/ExampleService.php
  8. 22
      app/Service/v3/Implementations/OnlineOnlineOrderService.php
  9. 12
      app/Service/v3/Implementations/OrderService.php
  10. 12
      app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php
  11. 12
      app/Service/v3/Interfaces/DistributionPriceServiceInterface.php
  12. 4
      app/Service/v3/Interfaces/ExampleServiceInterface.php
  13. 12
      app/Service/v3/Interfaces/OnlineOrderServiceInterface.php
  14. 8
      app/Service/v3/Interfaces/OrderServiceInterface.php
  15. 4
      config/autoload/dependencies.php
  16. 5
      config/routes.php

7
app/Constants/v3/ErrorCode.php

@ -30,6 +30,7 @@ class ErrorCode extends AbstractConstants
/************************************/ /************************************/
/* 用户相关 701-750 */ /* 用户相关 701-750 */
/************************************/ /************************************/
/** /**
* 验证码错误或已失效 * 验证码错误或已失效
* @Message("验证码错误或已失效") * @Message("验证码错误或已失效")
@ -48,6 +49,12 @@ class ErrorCode extends AbstractConstants
*/ */
const UNBIND_TEL_ERROR = 703; const UNBIND_TEL_ERROR = 703;
/**
* 用户未绑定手机号
* @Message("请绑定手机号")
*/
const NOT_BIND_TEL_ERROR = 704;
/************************************/ /************************************/
/* 定位相关 751-800 */ /* 定位相关 751-800 */
/************************************/ /************************************/

11
app/Controller/v3/ExampleController.php

@ -6,5 +6,16 @@ use App\Controller\BaseController;
class ExampleController extends BaseController class ExampleController extends BaseController
{ {
public function do()
{
}
public function check(){
}
public function undo(){
}
} }

125
app/Controller/v3/OnlineOrderController.php

@ -0,0 +1,125 @@
<?php
namespace App\Controller\v3;
use App\Constants\v3\ErrorCode;
use App\Controller\BaseController;
use App\Exception\ErrorCodeException;
use App\Service\CouponServiceInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OnlineOrderServiceInterface;
use App\Service\v3\Interfaces\UserBindTelServiceInterface;
use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
class OnlineOrderController extends BaseController
{
/**
* @Inject
* @var OnlineOrderServiceInterface
*/
protected $order;
/**
* @Inject
* @var UserBindTelServiceInterface
*/
protected $userBindTel;
/**
* @Inject
* @var CouponServiceInterface
*/
protected $couponService;
/**
* @Inject
* @var AppointmentTimeServiceInterface
*/
protected $appointmentTime;
/*
* 如果没有绑手机号去绑定页面
* 收货地址接口
* 返回预约送达时间
* 商品数据接口
* 红包独立接口
* 配送费独立接口 可根据距离动态计算费用
* 增值服务接口
* */
public function do()
{
$params = $this->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(){
}
}

19
app/Controller/v3/OrderController.php

@ -1,19 +0,0 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OrderServiceInterface;
class OrderController extends BaseController
{
/**
* @Inject
* @var OrderServiceInterface
*/
protected $order;
public function detail(){
$res = $this->order->detail();
return $this->success($res);
}
}

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

@ -0,0 +1,29 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
use phpDocumentor\Reflection\Types\Object_;
class AppointmentTimeService implements AppointmentTimeServiceInterface
{
public function do()
{
return [
'08:30 - 09:00',
'09:00 - 09:30',
'09:30 - 10:00',
'10:00 - 10:30'
];
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

25
app/Service/v3/Implementations/DistributionPriceService.php

@ -0,0 +1,25 @@
<?php
namespace App\Service\v3\Implementations;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\DistributionPriceServiceInterface;
class DistributionPriceService implements DistributionPriceServiceInterface
{
public function do()
{
return '配送费';
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

13
app/Service/v3/Implementations/ExampleService.php

@ -6,5 +6,18 @@ use App\Service\v3\Interfaces\ExampleServiceInterface;
class ExampleService implements ExampleServiceInterface class ExampleService implements ExampleServiceInterface
{ {
public function do()
{
// TODO: Implement check() method.
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
} }

22
app/Service/v3/Implementations/OnlineOnlineOrderService.php

@ -0,0 +1,22 @@
<?php
namespace App\Service\v3\Implementations;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\OnlineOrderServiceInterface;
class OnlineOnlineOrderService implements OnlineOrderServiceInterface
{
public function do($params){
return [];
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

12
app/Service/v3/Implementations/OrderService.php

@ -1,12 +0,0 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\OrderServiceInterface;
class OrderService implements OrderServiceInterface
{
public function detail(){
return '接入成功';
}
}

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

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

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

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

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

@ -4,5 +4,9 @@ namespace App\Service\v3\Interfaces;
interface ExampleServiceInterface interface ExampleServiceInterface
{ {
public function do();
public function check();
public function undo();
} }

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

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

8
app/Service/v3/Interfaces/OrderServiceInterface.php

@ -1,8 +0,0 @@
<?php
namespace App\Service\v3\Interfaces;
interface OrderServiceInterface
{
}

4
config/autoload/dependencies.php

@ -40,5 +40,7 @@ return [
\App\Service\v3\Interfaces\HelperServiceInterface::class => \App\Service\v3\Implementations\HelperService::class, \App\Service\v3\Interfaces\HelperServiceInterface::class => \App\Service\v3\Implementations\HelperService::class,
\App\Service\v3\Interfaces\VerifyCodeServiceInterface::class => \App\Service\v3\Implementations\VerifyCodeService::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\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\OnlineOnlineOrderService::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,
]; ];

5
config/routes.php

@ -79,9 +79,10 @@ Router::addGroup('/wechat/',function () {
Router::addGroup('/v3/', function () { Router::addGroup('/v3/', function () {
Router::post('location/getNearestMarket', 'App\Controller\v3\LocationController@getNearestMarket'); Router::post('location/getNearestMarket', 'App\Controller\v3\LocationController@getNearestMarket');
Router::post('home/appletIndex', 'App\Controller\v3\HomeController@appletIndex'); 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('goodsRecommend/getByTabsForAppletIndex', 'App\Controller\v3\GoodsRecommendController@getByTabsForAppletIndex');
Router::post('Order/detail', 'App\Controller\v3\OrderController@detail');
Router::post('onlineOrder/confirm', 'App\Controller\v3\OnlineOrderController@do');
Router::post('distributionPrice/get', 'App\Controller\v3\DistributionPriceController@do');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);
// 需要登录的路由 // 需要登录的路由

Loading…
Cancel
Save