Browse Source

Merge branch 'phoenix' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into phoenix

# Conflicts:
#	config/routes.php
master
weigang 5 years ago
parent
commit
665dc6fde5
  1. 14
      app/Constants/v3/SsdbKeys.php
  2. 31
      app/Controller/v3/CollectStoreController.php
  3. 14
      app/Controller/v3/GoodsController.php
  4. 23
      app/Controller/v3/OrderOnlineController.php
  5. 14
      app/Controller/v3/ShopCartController.php
  6. 27
      app/Controller/v3/ShopCartUpdateController.php
  7. 4
      app/Controller/v3/StoreController.php
  8. 32
      app/Controller/v3/UpdateShopCartController.php
  9. 3
      app/Service/v3/Implementations/AppointmentTimeService.php
  10. 45
      app/Service/v3/Implementations/CollectStoreService.php
  11. 75
      app/Service/v3/Implementations/GoodsService.php
  12. 6
      app/Service/v3/Implementations/OrderOnlineService.php
  13. 7
      app/Service/v3/Implementations/ShopCartService.php
  14. 8
      app/Service/v3/Implementations/ShopCartUpdateService.php
  15. 4
      app/Service/v3/Implementations/StoreService.php
  16. 2
      app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php
  17. 10
      app/Service/v3/Interfaces/CollectStoreServiceInterface.php
  18. 2
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  19. 4
      app/Service/v3/Interfaces/OrderOnlineServiceInterface.php
  20. 4
      app/Service/v3/Interfaces/ShopCartServiceInterface.php
  21. 12
      app/Service/v3/Interfaces/ShopCartUpdateServiceInterface.php
  22. 2
      app/Service/v3/Interfaces/StoreServiceInterface.php
  23. 12
      app/Service/v3/Interfaces/UpdateShopCartServiceInterface.php
  24. 4
      config/autoload/dependencies.php
  25. 15
      config/routes.php

14
app/Constants/v3/SsdbKeys.php

@ -29,5 +29,19 @@ class SsdbKeys extends AbstractConstants
* @Message("用户新订单统计")
*/
const USER_ORDER_BADGE = 'user_order_badge_';
/**
* @Message("收藏店铺")
*/
const COLLECT_STORE_USER = 'collect_store_user_';
/**
* @Message("用户收藏店铺数量")
*/
const COUNT_COLLECT_STORE_USER = 'count_collect_store_user_';
/**
* @Message("店铺被收藏数量")
*/
const COUNT_COLLECT_STORE = 'count_collect_store_';
}

31
app/Controller/v3/CollectStoreController.php

@ -0,0 +1,31 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
class CollectStoreController extends BaseController
{
/**
* @Inject
* @var CollectStoreServiceInterface
*/
protected $collectStoreService;
public function update()
{
$params = $this->request->all();
//判断是否已收藏店铺
$exists = $this->collectStoreService->check($params['user_id'],$params['store_id']);
//如果已收藏则删除
if($exists){
$res = $this->collectStoreService->undo($params['user_id'],$params['store_id']);
}else{
$res = $this->collectStoreService->do($params['user_id'],$params['store_id']);
}
return $this->success($res);
}
}

14
app/Controller/v3/GoodsController.php

@ -3,6 +3,7 @@
namespace App\Controller\v3;
use App\Controller\BaseController;
use App\Service\v3\Interfaces\StoreServiceInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\GoodsServiceInterface;
class GoodsController extends BaseController
@ -11,10 +12,19 @@ class GoodsController extends BaseController
* @Inject
* @var GoodsServiceInterface
*/
protected $goods;
protected $goodsService;
/**
* @Inject
* @var StoreServiceInterface
*/
protected $storeService;
public function detail()
{
$res = $this->goods->detail();
$params = $this->request->all();
$res['detail'] = $this->goodsService->do();
$res['banner'] = $this->goodsService->getBanner();
$res['store'] = $this->storeService->detail($params['store_id']);
return $this->success($res);
}
}

23
app/Controller/v3/OnlineOrderController.php → app/Controller/v3/OrderOnlineController.php

@ -7,10 +7,10 @@ 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\OrderOnlineServiceInterface;
use App\Service\v3\Interfaces\UserBindTelServiceInterface;
use App\Service\v3\Interfaces\AppointmentTimeServiceInterface;
class OnlineOrderController extends BaseController
class OrderOnlineController extends BaseController
{
/**
* @Inject
@ -26,7 +26,7 @@ class OnlineOrderController extends BaseController
* @Inject
* @var AppointmentTimeServiceInterface
*/
protected $appointmentTime;
protected $appointmentTimeService;
/*
* 如果没有绑手机号去绑定页面
* 收货地址接口
@ -56,12 +56,7 @@ class OnlineOrderController extends BaseController
'user_id' => '214'
];
//返回预约送达时间 数组
$res['appointment_time'] = [
'08:30 - 09:00',
'09:00 - 09:30',
'09:30 - 10:00',
'10:00 - 10:30'
];
$res['appointment_time'] = $this->appointmentTimeService->do();
//
$res['store_list'] = [
[
@ -118,14 +113,4 @@ class OnlineOrderController extends BaseController
];
return $this->success($res);
}
public function check()
{
}
public function undo()
{
}
}

14
app/Controller/v3/ShopCartController.php

@ -16,21 +16,11 @@ class ShopCartController extends BaseController
public function detail()
{
//获取购物车商品信息
$res['store_goood_lists'] = $this->shopCartService->detail();
$res['store_lists'] = $this->shopCartService->do();
//获取购物车失效商品信息
$res['store_invalid_goood_lists'] = $this->shopCartService->undo();
$res['store_lists_invalid'] = $this->shopCartService->undo();
//计算购物车价格
$res['total'] = '820.00';
return $this->success($res);
}
public function getGoodsNum()
{
}
public function undo()
{
}
}

27
app/Controller/v3/ShopCartUpdateController.php

@ -0,0 +1,27 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\ShopCartUpdateServiceInterface;
class ShopCartUpdateController extends BaseController
{
/**
* @Inject
* @var ShopCartUpdateServiceInterface
*/
protected $shopCarServiceUpdate;
public function update()
{
$res = $this->shopCarServiceUpdate->do($this->request->all());
return $this->success($res);
}
public function delete()
{
$res = $this->shopCarServiceUpdate->undo($this->request->all());
return $this->success($res);
}
}

4
app/Controller/v3/StoreController.php

@ -43,8 +43,8 @@ class StoreController extends BaseController
public function index(StoreIndexRequest $request)
{
$params = $request->validated();
$data = $this->storeService->detail($params['store_id'], $params['market_id']);
$data['is_collected'] = (bool)$this->collectService->check($params['market_id'], $params['store_id'], $params['user_id']);
$data = $this->storeService->detail($params['store_id']);
$data['is_collected'] = (bool)$this->collectService->check($params['user_id'],$params['store_id']);
$data['goods_types'] = $this->categoryService->allForStore($params['store_id']);
return $this->success(['store' => $data]);
}

32
app/Controller/v3/UpdateShopCartController.php

@ -1,32 +0,0 @@
<?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);
}
}

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

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

45
app/Service/v3/Implementations/CollectStoreService.php

@ -1,35 +1,54 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
use App\Constants\v3\SsdbKeys;
use App\TaskWorker\SSDBTask;
use Hyperf\Utils\ApplicationContext;
class CollectStoreService implements CollectStoreServiceInterface
{
public function do($marketId, $storeId, $userId)
public function do($userId,$storeId)
{
// TODO: Implement do() method.
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
//收藏店铺
$userSet = $ssdb->exec('set', SsdbKeys::COLLECT_STORE_USER.$userId.'_store_'.$storeId,time());
//用户收藏数量自增
$userIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE_USER.$userId,1);
//店铺被收藏数自增
$storeIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE.$storeId,1);
return $userSet && $userIncr && $storeIncr;
}
public function check($marketId, $storeId, $userId)
public function check($userId,$storeId)
{
return (bool)mt_rand(0,1);
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
return $ssdb->exec('exists', SsdbKeys::COLLECT_STORE_USER.$userId.'_store_'.$storeId);
}
public function undo($marketId, $storeId, $userId)
public function undo($userId,$storeId)
{
// TODO: Implement undo() method.
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
//取消收藏店铺
$userDel = $ssdb->exec('del', SsdbKeys::COLLECT_STORE_USER.$userId.'_store_'.$storeId,time());
//用户收藏数量自减
$userIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE_USER.$userId,'-1');
//店铺被收藏数自减
$storeIncr = $ssdb->exec('incr', SsdbKeys::COUNT_COLLECT_STORE.$userId,'-1');
return $userDel && $userIncr && $storeIncr;
}
//获取用户收藏店铺数量
public function countByUser($userId)
{
return mt_rand(0,30);
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE_USER.$userId);
return $count;
}
//获取店铺被收藏数量
public function countByStore($storeId)
{
// TODO: Implement countByStore() method.
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE.$storeId);
return $count;
}
}

75
app/Service/v3/Implementations/GoodsService.php

@ -4,54 +4,25 @@ namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\GoodsServiceInterface;
use Hyperf\DbConnection\Db;
use App\Model\v3\Goods;
class GoodsService implements GoodsServiceInterface
{
public function detail()
public function do()
{
$res = Goods::query()->where('id',35)->get();
return $res;
}
public function check($goodsId)
{
// TODO: Implement check() method.
}
public function undo()
{
/*
* 返回商品 封面图
* * 返回商品 轮播图
* 返回商品信息 包括名称 规格 tag等
* 返回店铺信息
* 返回商品规格信息
* 猜你喜欢
* 限时抢购
* 为你推荐
* */
// $goods['detail'] = [
// "id" => 170,
// "market_id" => 2,
// "store_id" => 39,
// "goods_type_id" => 39,
// "on_sale" => 1,
// "sort" => 0,
// "is_infinite" => 2,
// "start_num" => 0,
// "restrict_num" => 0,
// "inventory" => 1000,
// "name" => "冬菜",
// "cover_img" => "https => //store.lanzu.vip/attachment/images/2/2020/06/en2nQYncqN4f44qnA7CwnNOG2WqQ2q.jpg",
// "price" => "2.50",
// "original_price" => "2.50",
// "vip_price" => "0.00",
// "sales" => 0,
// "good_unit" => "",
// "tags" => null,
// "details_imgs" => null,
// "spec" => null,
// "content" => "",
// "details" => "<p><img src=\"https => //store.lanzu.vip/attachment/images/2/2020/06/J1Z5N818NqCt581LF1V1Tqd88151fV.jpg\" _src=\"https => //store.lanzu.vip/attachment/images/2/2020/06/J1Z5N818NqCt581LF1V1Tqd88151fV.jpg\" alt=\"冬菜.jpg\" style=\"max-width => 100%\"></p><p>​<br></p>",
// "created_at" => null,
// "updated_at" => 1598769782,
// "deleted_at" => null,
// '净含量' => '约500G',
// '保存条件' => '常温',
// '保质期' => '10天'
// ];
$goods['detail'] = Db::table('lanzu_goods')->where('id',35)->get();
$goods['banner'] = $this->getBanner();
return $goods;
// TODO: Implement undo() method.
}
public function getBanner()
@ -70,20 +41,4 @@ class GoodsService implements GoodsServiceInterface
];
return $banner;
}
public function do()
{
// TODO: Implement do() method.
}
public function check($goodsId)
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

6
app/Service/v3/Implementations/OnlineOrderService.php → app/Service/v3/Implementations/OrderOnlineService.php

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

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

@ -6,7 +6,7 @@ use App\Service\v3\Interfaces\ShopCartServiceInterface;
class ShopCartService implements ShopCartServiceInterface
{
public function detail()
public function do()
{
$res = [
[
@ -108,4 +108,9 @@ class ShopCartService implements ShopCartServiceInterface
];
return $res;
}
public function countGoods()
{
return mt_rand(1,100);
}
}

8
app/Service/v3/Implementations/UpdateShopCartService.php → app/Service/v3/Implementations/ShopCartUpdateService.php

@ -4,11 +4,11 @@ namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\UpdateShopCartServiceInterface;
use App\Service\v3\Interfaces\ShopCartUpdateServiceInterface;
class UpdateShopCartService implements UpdateShopCartServiceInterface
class ShopCartUpdateService implements ShopCartUpdateServiceInterface
{
public function update($params)
public function do($params)
{
switch ($params['goods_id'])
{
@ -31,7 +31,7 @@ class UpdateShopCartService implements UpdateShopCartServiceInterface
// TODO: Implement check() method.
}
public function delete($params)
public function undo($params)
{
return true;
}

4
app/Service/v3/Implementations/StoreService.php

@ -24,14 +24,14 @@ class StoreService implements StoreServiceInterface
// TODO: Implement undo() method.
}
public function detail($storeId, $marketId)
public function detail($storeId)
{
return Store::query()
->select([
'id', 'name', 'logo', 'introduction', 'announcement', 'address', 'tel', 'stall_info',
'is_rest','time1', 'time2', 'time3', 'time4',
])
->where(['id' => $storeId, 'market_id' => $marketId])
->where('id',$storeId)
->first()->toArray();
}
}

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

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

10
app/Service/v3/Interfaces/CollectStoreServiceInterface.php

@ -4,9 +4,13 @@ namespace App\Service\v3\Interfaces;
interface CollectStoreServiceInterface
{
public function do($marketId, $storeId, $userId);
public function check($marketId, $storeId, $userId);
public function undo($marketId, $storeId, $userId);
public function do($userId,$storeId);
public function check($userId,$storeId);
public function undo($userId,$storeId);
public function countByUser($userId);
public function countByStore($storeId);
}

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

@ -7,5 +7,5 @@ interface GoodsServiceInterface
public function do();
public function check($goodsId);
public function undo();
public function detail();
public function getBanner();
}

4
app/Service/v3/Interfaces/OnlineOrderServiceInterface.php → app/Service/v3/Interfaces/OrderOnlineServiceInterface.php

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

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

@ -4,9 +4,11 @@ namespace App\Service\v3\Interfaces;
interface ShopCartServiceInterface
{
public function detail();
public function do();
public function check($goodsId);
public function undo();
public function countGoods();
}

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

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

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

@ -7,5 +7,5 @@ interface StoreServiceInterface
public function do();
public function check();
public function undo();
public function detail($storeId, $marketId);
public function detail($storeId);
}

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

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

4
config/autoload/dependencies.php

@ -40,11 +40,11 @@ return [
\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\UserBindTelServiceInterface::class => \App\Service\v3\Implementations\UserBindTelService::class,
\App\Service\v3\Interfaces\OnlineOrderServiceInterface::class => \App\Service\v3\Implementations\OnlineOrderService::class,
\App\Service\v3\Interfaces\OrderOnlineServiceInterface::class => \App\Service\v3\Implementations\OrderOnlineService::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\ShopCartUpdateServiceInterface::class => \App\Service\v3\Implementations\ShopCartUpdateService::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,

15
config/routes.php

@ -81,17 +81,10 @@ 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/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');
Router::post('location/getMarketListByLocation', 'App\Controller\v3\LocationController@getMarketListByLocation');
Router::post('userDeliveryAddress/update', 'App\Controller\v3\UserDeliveryAddressController@update');
Router::post('userDeliveryAddress/get', 'App\Controller\v3\UserDeliveryAddressController@get');
Router::post('userDeliveryAddress/delete', 'App\Controller\v3\UserDeliveryAddressController@delete');
Router::post('userDeliveryAddress/getList', 'App\Controller\v3\UserDeliveryAddressController@getList');
Router::post('search/hotKeywords', 'App\Controller\v3\SearchController@hotKeywords');
Router::post('search/goods', 'App\Controller\v3\SearchController@goods');
Router::post('search/stores', 'App\Controller\v3\SearchController@stores');
@ -106,4 +99,12 @@ Router::addGroup('/v3/', function () {
Router::post('user/updateInfo', 'App\Controller\v3\UserController@updateInfo');
Router::post('home/userIndex', 'App\Controller\v3\HomeController@userIndex');
Router::post('user/olOrders', 'App\Controller\v3\OrderListController@onlineForUser');
Router::post('orderOnline/detail', 'App\Controller\v3\OrderOnlineController@detail');
Router::post('userDeliveryAddress/update', 'App\Controller\v3\UserDeliveryAddressController@update');
Router::post('userDeliveryAddress/get', 'App\Controller\v3\UserDeliveryAddressController@get');
Router::post('userDeliveryAddress/delete', 'App\Controller\v3\UserDeliveryAddressController@delete');
Router::post('userDeliveryAddress/getList', 'App\Controller\v3\UserDeliveryAddressController@getList');
Router::post('collectStore/update', 'App\Controller\v3\CollectStoreController@update');
Router::post('shopCartUpdate/update', 'App\Controller\v3\ShopCartUpdateController@update');
Router::post('shopCart/detail', 'App\Controller\v3\ShopCartController@detail');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save