Browse Source

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

master
weigang 5 years ago
parent
commit
46815f286d
  1. 6
      app/Constants/v3/ErrorCode.php
  2. 3
      app/Controller/v3/GoodsController.php
  3. 39
      app/Controller/v3/HomeController.php
  4. 14
      app/Controller/v3/OrderListController.php
  5. 25
      app/Controller/v3/StoreLoginController.php
  6. 15
      app/Model/v3/Order.php
  7. 5
      app/Model/v3/OrderMain.php
  8. 4
      app/Service/v3/Implementations/GoodsService.php
  9. 72
      app/Service/v3/Implementations/OrderListService.php
  10. 30
      app/Service/v3/Implementations/StoreInfoService.php
  11. 29
      app/Service/v3/Implementations/StoreLoginService.php
  12. 2
      app/Service/v3/Interfaces/GoodsServiceInterface.php
  13. 2
      app/Service/v3/Interfaces/OrderListServiceInterface.php
  14. 16
      app/Service/v3/Interfaces/StoreInfoServiceInterface.php
  15. 12
      app/Service/v3/Interfaces/StoreLoginServiceInterface.php
  16. 2
      config/autoload/dependencies.php
  17. 4
      config/routes.php

6
app/Constants/v3/ErrorCode.php

@ -66,6 +66,12 @@ class ErrorCode extends AbstractConstants
* @Message("更新失败")
*/
const USER_INFO_UPDATE_ERROR = 705;
/**
* 商户账户密码不匹配
* @Message("账号密码错误")
*/
const STORE_LOGIN_ERROR = 706;
/************************************/
/* 定位相关 751-800 */
/************************************/

3
app/Controller/v3/GoodsController.php

@ -22,9 +22,8 @@ class GoodsController extends BaseController
public function detail()
{
$params = $this->request->all();
$res['detail'] = $this->goodsService->do();
$res['detail'] = $this->goodsService->do(35);
$res['banner'] = $this->goodsService->getBanner();
$res['store'] = $this->storeService->detail($params['store_id']);
return $this->success($res);
}
}

39
app/Controller/v3/HomeController.php

@ -13,6 +13,7 @@ use App\Service\v3\Interfaces\BannerServiceInterface;
use App\Service\v3\Interfaces\CategoryServiceInterface;
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
use App\Service\v3\Interfaces\CouponServiceInterface;
use App\Service\v3\Interfaces\StoreInfoServiceInterface;
use App\Service\v3\Interfaces\UserCenterBlockServiceInterface;
use App\Service\v3\Interfaces\UserInfoServiceInterface;
use App\TaskWorker\SSDBTask;
@ -52,6 +53,12 @@ class HomeController extends BaseController
*/
protected $userCenterBlockService;
/**
* @Inject
* @var StoreInfoServiceInterface
*/
protected $storeInfoService;
/**
* @Inject
* @var BannerServiceInterface
@ -77,6 +84,7 @@ class HomeController extends BaseController
* 3.活动数据(秒杀、团购、新品、无)
* 4.tabs数据
*/
public function appletIndex()
{
$marketId = $this->request->input('market_id', 0);
@ -131,4 +139,35 @@ class HomeController extends BaseController
return $this->success($data);
}
/**
* 商家入口详情
*/
public function storeIndex()
{
$data['detail'] = $this->storeInfoService->detail();
$data['order_online'] = [
'count' => 6549,
'total' => 12654.12
];
$data['order_offline'] = [
'count' => 3639,
'total' => 89563.12
];
$data['new_user'] = [
'day' => 10,
'week' => 15,
'month' => 25,
'all' => 50
];
$data['badge'] = [
'unpaid' => 0,
'receiving' => 0,
'completed' => 0,
'refund' => 0,
];
return $this->success($data);
}
}

14
app/Controller/v3/OrderListController.php

@ -37,4 +37,18 @@ class OrderListController extends BaseController
$list = $this->orderListService->onlineByUser($params['user_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list);
}
public function onlineForStore()
{
$params = $this->request->all();
$list = $this->orderListService->onlineByStore($params['store_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list);
}
public function offlineForStore()
{
$params = $this->request->all();
$list = $this->orderListService->offlineByStore($params['store_id'], $params['tab'], $params['page'], $params['pagesize']);
return $this->success($list);
}
}

25
app/Controller/v3/StoreLoginController.php

@ -0,0 +1,25 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use App\Service\v3\Interfaces\StoreLoginServiceInterface;
use Hyperf\Di\Annotation\Inject;
class StoreLoginController extends BaseController
{
/**
* @Inject
* @var StoreLoginServiceInterface
*/
protected $storeLoginServicce;
public function login()
{
$params = $this->request->all();
$res = $this->storeLoginServicce->do($params['account'],$params['password']);
return $this->success($res);
}
}

15
app/Model/v3/Order.php

@ -12,4 +12,19 @@ class Order extends Model
{
return $this->hasMany(OrderGoods::class, 'order_id', 'id');
}
public function market()
{
return $this->belongsTo(Market::class, 'market_id', 'id');
}
public function orderMain()
{
return $this->belongsTo(OrderMain::class, 'order_main_id', 'id');
}
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
}

5
app/Model/v3/OrderMain.php

@ -66,4 +66,9 @@ class OrderMain extends Model
'id'
);
}
public function user()
{
return $this->belongsTo(User::class, 'user_id', 'id');
}
}

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

@ -8,9 +8,9 @@ use App\Model\v3\Goods;
class GoodsService implements GoodsServiceInterface
{
public function do()
public function do($goodsId)
{
$res = Goods::query()->where('id',35)->get();
$res = Goods::query()->with('store')->where('id',$goodsId)->first();
return $res;
}

72
app/Service/v3/Implementations/OrderListService.php

@ -4,6 +4,7 @@ namespace App\Service\v3\Implementations;
use App\Constants\v3\OrderState;
use App\Model\v3\OrderMain;
use App\Model\v3\Order;
use App\Service\v3\Interfaces\OrderListServiceInterface;
use Hyperf\Paginator\Paginator;
@ -35,7 +36,76 @@ class OrderListService implements OrderListServiceInterface
->with(['market' => function($query) {
$query->select(['lanzu_market.id', 'lanzu_market.name', 'lanzu_market.tel']);
}])
->where(['user_id' => $userId]);
->where([
['user_id','=',$userId],
['type','=',1]
]);
switch ($tab) {
case 'all':
break;
case 'completed':
$builder->whereIn('state', OrderState::FINISH);
break;
case 'unpaid':
$builder->where(['state' => OrderState::UNPAID]);
break;
case 'receiving':
$builder->whereIn('state', OrderState::RECEIVING);
break;
case 'refund':
$builder->whereIn('state', OrderState::REFUND);
break;
}
$paginate = $builder->paginate($pagesize);
$orders = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
}
public function onlineByStore($storeId, $tab, $page=1, $pagesize=10)
{
$builder = OrderMain::query()
->select('id','global_order_id', 'money', 'state', 'market_id', 'created_at')
->with(['orders' => function($query) use ($storeId) {
$query->where('store_id',$storeId)->with('orderGoods');
}])
->where([
'type' => 1
]);
switch ($tab) {
case 'all':
break;
case 'completed':
$builder->whereIn('state', OrderState::FINISH);
break;
case 'unpaid':
$builder->where(['state' => OrderState::UNPAID]);
break;
case 'receiving':
$builder->whereIn('state', OrderState::RECEIVING);
break;
case 'refund':
$builder->whereIn('state', OrderState::REFUND);
break;
}
$paginate = $builder->paginate($pagesize);
$orders = $paginate->toArray();
return ['has_more_pages' => $paginate->hasMorePages(), 'orders' => $orders['data']];
}
public function offlineByStore($storeId, $tab, $page=1, $pagesize=10)
{
$builder = Order::query()
->with(['orderMain' => function($query) {
$query->where('lanzu_order_main.type',4);
}])
->with(['user' => function($query) {
$query->select(['lanzu_user.id', 'lanzu_user.nick_name']);
}])
->where([
'store_id' => $storeId
]);
switch ($tab) {
case 'all':
break;

30
app/Service/v3/Implementations/StoreInfoService.php

@ -0,0 +1,30 @@
<?php
namespace App\Service\v3\Implementations;
use App\Service\v3\Interfaces\StoreInfoServiceInterface;
use App\Model\v3\Store;
class StoreInfoService implements StoreInfoServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check()
{
}
public function undo()
{
// TODO: Implement undo() method.
}
public function detail()
{
return Store::query()->where('id',1)->first()->toArray();
}
}

29
app/Service/v3/Implementations/StoreLoginService.php

@ -0,0 +1,29 @@
<?php
namespace App\Service\v3\Implementations;
use App\Constants\v3\ErrorCode;
use App\Exception\ErrorCodeException;
use App\Service\v3\Interfaces\StoreLoginServiceInterface;
class StoreLoginService implements StoreLoginServiceInterface
{
public function do($account,$password)
{
if($account == $password){
return true;
}else{
throw new ErrorCodeException(ErrorCode::STORE_LOGIN_ERROR);
}
}
public function check()
{
// TODO: Implement check() method.
}
public function undo()
{
// TODO: Implement undo() method.
}
}

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

@ -4,7 +4,7 @@ namespace App\Service\v3\Interfaces;
interface GoodsServiceInterface
{
public function do();
public function do($goodsId);
public function check($goodsId);
public function undo();
public function getBanner();

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

@ -8,4 +8,6 @@ interface OrderListServiceInterface
public function check();
public function undo();
public function onlineByUser($userId, $tab, $page=1, $pagesize=10);
public function onlineByStore($userId, $tab, $page, $pagesize);
public function offlineByStore($userId, $tab, $page, $pagesize);
}

16
app/Service/v3/Interfaces/StoreInfoServiceInterface.php

@ -0,0 +1,16 @@
<?php
namespace App\Service\v3\Interfaces;
interface StoreInfoServiceInterface
{
public function do();
public function check();
public function undo();
public function detail();
}

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

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

2
config/autoload/dependencies.php

@ -54,6 +54,8 @@ return [
\App\Service\v3\Interfaces\CouponServiceInterface::class => \App\Service\v3\Implementations\CouponService::class,
\App\Service\v3\Interfaces\OrderListServiceInterface::class => \App\Service\v3\Implementations\OrderListService::class,
\App\Service\v3\Interfaces\UserCenterBlockServiceInterface::class => \App\Service\v3\Implementations\UserCenterBlockService::class,
\App\Service\v3\Interfaces\StoreLoginServiceInterface::class => \App\Service\v3\Implementations\StoreLoginService::class,
\App\Service\v3\Interfaces\StoreInfoServiceInterface::class => \App\Service\v3\Implementations\StoreInfoService::class,
\App\Service\v3\Interfaces\BannerServiceInterface::class => \App\Service\v3\Implementations\BannerService::class,
\App\Service\v3\Interfaces\ActivityServiceInterface::class => \App\Service\v3\Implementations\ActivityService::class,
];

4
config/routes.php

@ -108,4 +108,8 @@ Router::addGroup('/v3/', function () {
Router::post('shopCartUpdate/update', 'App\Controller\v3\ShopCartUpdateController@update');
Router::post('shopCart/detail', 'App\Controller\v3\ShopCartController@detail');
Router::post('orderOnline/review', 'App\Controller\v3\OrderOnlineController@review');
Router::post('storeLogin/login', 'App\Controller\v3\StoreLoginController@login');
Router::post('home/storeIndex', 'App\Controller\v3\HomeController@storeIndex');
Router::post('orderList/onlineForStore', 'App\Controller\v3\OrderListController@onlineForStore');
Router::post('orderList/offlineForStore', 'App\Controller\v3\OrderListController@offlineForStore');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save