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: # config/routes.phpmaster
25 changed files with 193 additions and 181 deletions
-
14app/Constants/v3/SsdbKeys.php
-
31app/Controller/v3/CollectStoreController.php
-
14app/Controller/v3/GoodsController.php
-
23app/Controller/v3/OrderOnlineController.php
-
14app/Controller/v3/ShopCartController.php
-
27app/Controller/v3/ShopCartUpdateController.php
-
4app/Controller/v3/StoreController.php
-
32app/Controller/v3/UpdateShopCartController.php
-
3app/Service/v3/Implementations/AppointmentTimeService.php
-
45app/Service/v3/Implementations/CollectStoreService.php
-
75app/Service/v3/Implementations/GoodsService.php
-
6app/Service/v3/Implementations/OrderOnlineService.php
-
7app/Service/v3/Implementations/ShopCartService.php
-
8app/Service/v3/Implementations/ShopCartUpdateService.php
-
4app/Service/v3/Implementations/StoreService.php
-
2app/Service/v3/Interfaces/AppointmentTimeServiceInterface.php
-
10app/Service/v3/Interfaces/CollectStoreServiceInterface.php
-
2app/Service/v3/Interfaces/GoodsServiceInterface.php
-
4app/Service/v3/Interfaces/OrderOnlineServiceInterface.php
-
4app/Service/v3/Interfaces/ShopCartServiceInterface.php
-
12app/Service/v3/Interfaces/ShopCartUpdateServiceInterface.php
-
2app/Service/v3/Interfaces/StoreServiceInterface.php
-
12app/Service/v3/Interfaces/UpdateShopCartServiceInterface.php
-
4config/autoload/dependencies.php
-
15config/routes.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); |
||||
|
} |
||||
|
} |
||||
@ -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); |
||||
|
} |
||||
|
} |
||||
@ -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); |
|
||||
} |
|
||||
} |
|
||||
@ -1,35 +1,54 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
|
|
||||
namespace App\Service\v3\Implementations; |
namespace App\Service\v3\Implementations; |
||||
|
|
||||
use App\Service\v3\Interfaces\CollectStoreServiceInterface; |
use App\Service\v3\Interfaces\CollectStoreServiceInterface; |
||||
|
use App\Constants\v3\SsdbKeys; |
||||
|
use App\TaskWorker\SSDBTask; |
||||
|
use Hyperf\Utils\ApplicationContext; |
||||
|
|
||||
class CollectStoreService implements CollectStoreServiceInterface |
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) |
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) |
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; |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface ShopCartUpdateServiceInterface |
||||
|
{ |
||||
|
public function do($params); |
||||
|
|
||||
|
public function check(); |
||||
|
|
||||
|
public function undo($params); |
||||
|
} |
||||
@ -1,12 +0,0 @@ |
|||||
<?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