16 changed files with 274 additions and 15 deletions
-
25app/Constants/v3/Goods.php
-
44app/Constants/v3/Store.php
-
51app/Controller/v3/StoreController.php
-
6app/Model/v3/Goods.php
-
17app/Model/v3/Store.php
-
1app/Request/v3/SearchGoodsRequest.php
-
38app/Request/v3/StoreIndexRequest.php
-
16app/Service/v3/Implementations/CategoryService.php
-
25app/Service/v3/Implementations/CollectStoreService.php
-
4app/Service/v3/Implementations/SearchService.php
-
37app/Service/v3/Implementations/StoreService.php
-
1app/Service/v3/Interfaces/CategoryServiceInterface.php
-
10app/Service/v3/Interfaces/CollectStoreServiceInterface.php
-
11app/Service/v3/Interfaces/StoreServiceInterface.php
-
2config/autoload/dependencies.php
-
1config/routes.php
@ -0,0 +1,25 @@ |
|||
<?php |
|||
|
|||
namespace App\Constants\v3; |
|||
|
|||
use Hyperf\Constants\AbstractConstants; |
|||
use Hyperf\Constants\Annotation\Constants; |
|||
|
|||
/** |
|||
* @Constants |
|||
*/ |
|||
class Goods extends AbstractConstants |
|||
{ |
|||
|
|||
/** |
|||
* @Message("售卖中") |
|||
*/ |
|||
const ON_SALE_YES = 1; |
|||
|
|||
/** |
|||
* @Message("已下架") |
|||
*/ |
|||
const ON_SALE_NO = 2; |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
<?php |
|||
|
|||
namespace App\Constants\v3; |
|||
|
|||
use Hyperf\Constants\AbstractConstants; |
|||
use Hyperf\Constants\Annotation\Constants; |
|||
|
|||
/** |
|||
* @Constants |
|||
*/ |
|||
class Store extends AbstractConstants |
|||
{ |
|||
|
|||
/** |
|||
* @Message("营业中") |
|||
*/ |
|||
const IS_OPEN_YES = 1; |
|||
|
|||
/** |
|||
* @Message("歇业中") |
|||
*/ |
|||
const IS_OPEN_NO = 2; |
|||
|
|||
/** |
|||
* @Message("入驻审核中") |
|||
*/ |
|||
const STATUS_EXAMINING = 1; |
|||
|
|||
/** |
|||
* @Message("入驻成功") |
|||
*/ |
|||
const STATUS_PASS = 2; |
|||
|
|||
/** |
|||
* @Message("入驻被拒") |
|||
*/ |
|||
const STATUS_REFUSE = 3; |
|||
|
|||
/** |
|||
* @Message("入驻已过期") |
|||
*/ |
|||
const STATUS_EXPIRED = 4; |
|||
|
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
<?php |
|||
|
|||
namespace App\Controller\v3; |
|||
|
|||
use App\Controller\BaseController; |
|||
use App\Request\v3\StoreIndexRequest; |
|||
use App\Service\v3\Interfaces\CategoryServiceInterface; |
|||
use App\Service\v3\Interfaces\CollectStoreServiceInterface; |
|||
use App\Service\v3\Interfaces\StoreServiceInterface; |
|||
use Hyperf\Di\Annotation\Inject; |
|||
use Psr\Http\Message\ResponseInterface; |
|||
|
|||
class StoreController extends BaseController |
|||
{ |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var StoreServiceInterface |
|||
*/ |
|||
protected $storeService; |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var CategoryServiceInterface |
|||
*/ |
|||
protected $categoryService; |
|||
|
|||
/** |
|||
* @Inject |
|||
* @var CollectStoreServiceInterface |
|||
*/ |
|||
protected $collectService; |
|||
|
|||
/** |
|||
* 商户详情页 |
|||
* 1、商户id用来查询的,还要有user_id |
|||
* 2、返回数据,id、logo、name、收藏状态、简介、地址、营业状态、营业时间、联系电话 |
|||
* 3、返回数据,商品推荐的分类,需要经过商户商品反查 |
|||
* 4、分类下的商品,则复用商品搜索接口 |
|||
* @param StoreIndexRequest $request |
|||
* @return ResponseInterface |
|||
*/ |
|||
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['goods_types'] = $this->categoryService->allForStore($params['store_id']); |
|||
return $this->success(['store' => $data]); |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
<?php |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
namespace App\Request\v3; |
|||
|
|||
use App\Request\BaseFormRequest; |
|||
|
|||
class StoreIndexRequest extends BaseFormRequest |
|||
{ |
|||
|
|||
/** |
|||
* Get the validation rules that apply to the request. |
|||
*/ |
|||
public function rules(): array |
|||
{ |
|||
return [ |
|||
'market_id' => 'required|nonempty|integer', |
|||
'store_id' => 'required|nonempty|integer', |
|||
'user_id' => 'nonempty|integer', |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
public function messages(): array |
|||
{ |
|||
return [ |
|||
'*.*' => ':attribute无效', |
|||
]; |
|||
} |
|||
|
|||
public function attributes(): array |
|||
{ |
|||
return parent::attributes(); |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Service\v3\Implementations; |
|||
|
|||
use App\Service\v3\Interfaces\CollectStoreServiceInterface; |
|||
|
|||
class CollectStoreService implements CollectStoreServiceInterface |
|||
{ |
|||
|
|||
public function do($marketId, $storeId, $userId) |
|||
{ |
|||
// TODO: Implement do() method.
|
|||
} |
|||
|
|||
public function check($marketId, $storeId, $userId) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
public function undo($marketId, $storeId, $userId) |
|||
{ |
|||
// TODO: Implement undo() method.
|
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Service\v3\Implementations; |
|||
|
|||
use App\Model\v3\Store; |
|||
use App\Service\v3\Interfaces\StoreServiceInterface; |
|||
|
|||
class StoreService implements StoreServiceInterface |
|||
{ |
|||
|
|||
public function do() |
|||
{ |
|||
// TODO: Implement do() method.
|
|||
} |
|||
|
|||
public function check() |
|||
{ |
|||
// TODO: Implement check() method.
|
|||
} |
|||
|
|||
public function undo() |
|||
{ |
|||
// TODO: Implement undo() method.
|
|||
} |
|||
|
|||
public function detail($storeId, $marketId) |
|||
{ |
|||
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]) |
|||
->first()->toArray(); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
<?php |
|||
|
|||
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); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?php |
|||
|
|||
namespace App\Service\v3\Interfaces; |
|||
|
|||
interface StoreServiceInterface |
|||
{ |
|||
public function do(); |
|||
public function check(); |
|||
public function undo(); |
|||
public function detail($storeId, $marketId); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue