Browse Source
Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix
Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix
# Conflicts: # app/Constants/v3/ErrorCode.php # config/autoload/dependencies.php # config/routes.phpmaster
23 changed files with 550 additions and 44 deletions
-
29app/Constants/v3/ErrorCode.php
-
13app/Controller/v3/ExampleController.php
-
3app/Controller/v3/GoodsController.php
-
127app/Controller/v3/OnlineOrderController.php
-
19app/Controller/v3/OrderController.php
-
36app/Controller/v3/ShopCartController.php
-
32app/Controller/v3/UpdateShopCartController.php
-
29app/Service/v3/Implementations/AppointmentTimeService.php
-
25app/Service/v3/Implementations/DistributionPriceService.php
-
13app/Service/v3/Implementations/ExampleService.php
-
22app/Service/v3/Implementations/OnlineOrderService.php
-
12app/Service/v3/Implementations/OrderService.php
-
111app/Service/v3/Implementations/ShopCartService.php
-
38app/Service/v3/Implementations/UpdateShopCartService.php
-
12app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php
-
12app/Service/v3/Interfaces/DistributionPriceServiceInterface.php
-
4app/Service/v3/Interfaces/ExampleServiceInterface.php
-
12app/Service/v3/Interfaces/OnlineOrderServiceInterface.php
-
8app/Service/v3/Interfaces/OrderServiceInterface.php
-
12app/Service/v3/Interfaces/ShopCartServiceInterface.php
-
12app/Service/v3/Interfaces/UpdateShopCartServiceInterface.php
-
6config/autoload/dependencies.php
-
7config/routes.php
@ -0,0 +1,127 @@ |
|||||
|
<?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 detail() |
||||
|
{ |
||||
|
$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() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -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); |
|
||||
} |
|
||||
} |
|
||||
@ -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() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Controller\v3; |
||||
|
|
||||
|
use App\Controller\BaseController; |
||||
|
use Hyperf\Di\Annotation\Inject; |
||||
|
use App\Service\v3\Interfaces\UpdateShopCartServiceInterface; |
||||
|
|
||||
|
class UpdateShopCartController extends BaseController |
||||
|
{ |
||||
|
/** |
||||
|
* @Inject |
||||
|
* @var UpdateShopCartServiceInterface |
||||
|
*/ |
||||
|
protected $updateShopCarService; |
||||
|
public function update() |
||||
|
{ |
||||
|
$res = $this->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); |
||||
|
} |
||||
|
} |
||||
@ -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 get() |
||||
|
{ |
||||
|
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.
|
||||
|
} |
||||
|
} |
||||
@ -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.
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Implementations; |
||||
|
|
||||
|
use Hyperf\Di\Annotation\Inject; |
||||
|
use App\Service\v3\Interfaces\OnlineOrderServiceInterface; |
||||
|
class OnlineOrderService implements OnlineOrderServiceInterface |
||||
|
{ |
||||
|
public function detail($params){ |
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
public function check() |
||||
|
{ |
||||
|
// TODO: Implement check() method.
|
||||
|
} |
||||
|
|
||||
|
public function undo() |
||||
|
{ |
||||
|
// TODO: Implement undo() method.
|
||||
|
} |
||||
|
} |
||||
@ -1,12 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Service\v3\Implementations; |
|
||||
|
|
||||
use App\Service\v3\Interfaces\OrderServiceInterface; |
|
||||
|
|
||||
class OrderService implements OrderServiceInterface |
|
||||
{ |
|
||||
public function detail(){ |
|
||||
return '接入成功'; |
|
||||
} |
|
||||
} |
|
||||
@ -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; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Implementations; |
||||
|
|
||||
|
use App\Constants\v3\ErrorCode; |
||||
|
use App\Exception\ErrorCodeException; |
||||
|
use App\Service\v3\Interfaces\UpdateShopCartServiceInterface; |
||||
|
|
||||
|
class UpdateShopCartService implements UpdateShopCartServiceInterface |
||||
|
{ |
||||
|
public function update($params) |
||||
|
{ |
||||
|
switch ($params['goods_id']) |
||||
|
{ |
||||
|
case 1000: |
||||
|
throw new ErrorCodeException(ErrorCode::GOODS_INVENTORY_ERROR); |
||||
|
break; |
||||
|
case 2000: |
||||
|
throw new ErrorCodeException(ErrorCode::PURCHASE_LIMIT_ERROR); |
||||
|
break; |
||||
|
case 3000: |
||||
|
throw new ErrorCodeException(ErrorCode::SPERCIAL_OFFER_GOODS_ERROR); |
||||
|
break; |
||||
|
default: |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public function check() |
||||
|
{ |
||||
|
// TODO: Implement check() method.
|
||||
|
} |
||||
|
|
||||
|
public function delete($params) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface AppointmentTimeServiceInterface |
||||
|
{ |
||||
|
public function get(); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function undo(); |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface DistributionPriceServiceInterface |
||||
|
{ |
||||
|
public function do(); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function undo(); |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface OnlineOrderServiceInterface |
||||
|
{ |
||||
|
public function detail($params); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function undo(); |
||||
|
} |
||||
@ -1,8 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Service\v3\Interfaces; |
|
||||
|
|
||||
interface OrderServiceInterface |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface ShopCartServiceInterface |
||||
|
{ |
||||
|
public function detail(); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function undo(); |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface UpdateShopCartServiceInterface |
||||
|
{ |
||||
|
public function update($params); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function delete($params); |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue