You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
1.6 KiB

<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use App\Request\v3\UserRequest;
use App\Service\v3\Interfaces\InitialDeliveryServiceInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\ShopCartServiceInterface;
class ShopCartController extends BaseController
{
/**
* @Inject
* @var ShopCartServiceInterface
*/
protected $shopCartService;
/**
* @Inject
* @var InitialDeliveryServiceInterface
*/
protected $intialDeliveryService;
public function detail(UserRequest $request)
{
$userId = $this->request->input('user_id');
$marketId = $this->request->input('market_id');
$shopcart = $this->shopCartService->allForUser($userId, $marketId);
$shopcart['intial_delivery'] = $this->intialDeliveryService->get();
return $this->success($shopcart);
// //获取购物车商品信息
// $res['store_lists'] = $this->shopCartService->do($userId,$marketId);
// //获取购物车失效商品信息
// $res['store_lists_invalid'] = $this->shopCartService->undo($userId,$marketId);
// //计算购物车价格
// $res['total'] = $this->shopCartService->getTotal($userId,$marketId);
// return $this->success($res);
}
public function info(UserRequest $request)
{
$userId = $this->request->input('user_id');
$marketId = $this->request->input('market_id');
$res['shopcart']['count'] = $this->shopCartService->countGoods($userId,$marketId);
$res['shopcart']['total'] = $this->shopCartService->getTotal($userId,$marketId);
return $this->success($res);
}
}