Browse Source
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
Merge branch 'phoenix' of http://120.24.33.109:11081/hyzjshwo/lanzu_api_hyperf into phoenix
# Conflicts: # app/Constants/v3/SsdbKeys.php # app/Service/v3/Implementations/CollectStoreService.php # app/Service/v3/Implementations/ShopCartService.php # app/Service/v3/Interfaces/CollectStoreServiceInterface.php # app/Service/v3/Interfaces/ShopCartServiceInterface.php # config/autoload/dependencies.phpmaster
32 changed files with 718 additions and 26 deletions
-
25app/Constants/v3/Goods.php
-
20app/Constants/v3/LogLabel.php
-
11app/Constants/v3/SsdbKeys.php
-
44app/Constants/v3/Store.php
-
15app/Constants/v3/Tabs.php
-
106app/Controller/v3/GoodsRecommendController.php
-
57app/Controller/v3/HomeController.php
-
15app/Controller/v3/SearchController.php
-
51app/Controller/v3/StoreController.php
-
16app/Exception/Handler/ErrorCodeExceptionHandler.php
-
12app/Model/v3/Goods.php
-
35app/Model/v3/Store.php
-
3app/Model/v3/User.php
-
1app/Request/v3/SearchGoodsRequest.php
-
42app/Request/v3/SearchStoreRequest.php
-
38app/Request/v3/StoreIndexRequest.php
-
36app/Request/v3/UserIndexRequest.php
-
16app/Service/v3/Implementations/CategoryService.php
-
20app/Service/v3/Implementations/CollectStoreService.php
-
41app/Service/v3/Implementations/CouponService.php
-
38app/Service/v3/Implementations/SearchService.php
-
2app/Service/v3/Implementations/ShopCartService.php
-
37app/Service/v3/Implementations/StoreService.php
-
10app/Service/v3/Implementations/UserInfoService.php
-
1app/Service/v3/Interfaces/CategoryServiceInterface.php
-
31app/Service/v3/Interfaces/CouponServiceInterface.php
-
2app/Service/v3/Interfaces/SearchServiceInterface.php
-
2app/Service/v3/Interfaces/ShopCartServiceInterface.php
-
11app/Service/v3/Interfaces/StoreServiceInterface.php
-
1app/Service/v3/Interfaces/UserInfoServiceInterface.php
-
2config/autoload/dependencies.php
-
3config/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,20 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Constants\v3; |
||||
|
|
||||
|
use Hyperf\Constants\AbstractConstants; |
||||
|
use Hyperf\Constants\Annotation\Constants; |
||||
|
|
||||
|
/** |
||||
|
* @Constants |
||||
|
*/ |
||||
|
class LogLabel extends AbstractConstants |
||||
|
{ |
||||
|
/** |
||||
|
* @Message("Error Code Log") |
||||
|
*/ |
||||
|
const ERROR_CODE_EXCEPTION = 'error_code_exception'; |
||||
|
|
||||
|
} |
||||
@ -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,42 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Request\v3; |
||||
|
|
||||
|
use App\Request\BaseFormRequest; |
||||
|
|
||||
|
class SearchStoreRequest extends BaseFormRequest |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
*/ |
||||
|
public function rules(): array |
||||
|
{ |
||||
|
return [ |
||||
|
'market_id' => 'required|nonempty|integer', |
||||
|
'type_id' => 'nonempty|integer', |
||||
|
'keyword' => 'nonempty', |
||||
|
'order_by' => 'nonempty|in:default,sales', |
||||
|
'sort' => 'nonempty|in:asc,desc', |
||||
|
'page' => 'nonempty|integer', |
||||
|
'pagesize' => 'nonempty|integer', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function messages(): array |
||||
|
{ |
||||
|
return [ |
||||
|
'*.*' => ':attribute无效', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
public function attributes(): array |
||||
|
{ |
||||
|
return parent::attributes(); |
||||
|
} |
||||
|
} |
||||
@ -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,36 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Request\v3; |
||||
|
|
||||
|
use App\Request\BaseFormRequest; |
||||
|
|
||||
|
class UserIndexRequest extends BaseFormRequest |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
*/ |
||||
|
public function rules(): array |
||||
|
{ |
||||
|
return [ |
||||
|
'user_id' => 'required|nonempty|integer', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function messages(): array |
||||
|
{ |
||||
|
return [ |
||||
|
'*.*' => ':attribute无效', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
public function attributes(): array |
||||
|
{ |
||||
|
return parent::attributes(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Implementations; |
||||
|
|
||||
|
use App\Service\v3\Interfaces\CouponServiceInterface; |
||||
|
|
||||
|
class CouponService implements CouponServiceInterface |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function do() |
||||
|
{ |
||||
|
// TODO: Implement do() method.
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function check() |
||||
|
{ |
||||
|
// TODO: Implement check() method.
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function undo() |
||||
|
{ |
||||
|
// TODO: Implement undo() method.
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @inheritDoc |
||||
|
*/ |
||||
|
public function countAvailableByUser($userId) |
||||
|
{ |
||||
|
return mt_rand(0,10); |
||||
|
} |
||||
|
} |
||||
@ -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,31 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Service\v3\Interfaces; |
||||
|
|
||||
|
interface CouponServiceInterface |
||||
|
{ |
||||
|
/** |
||||
|
* 领取 |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function do(); |
||||
|
|
||||
|
/** |
||||
|
* 是否已经领取 |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function check(); |
||||
|
|
||||
|
/** |
||||
|
* 退还优惠券 |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function undo(); |
||||
|
|
||||
|
/** |
||||
|
* 统计用户可使用优惠券数量 |
||||
|
* @param $userId |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function countAvailableByUser($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