StoreDiscountsController.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\controller\api\v1\activity;
  3. use app\Request;
  4. use app\services\activity\discounts\StoreDiscountsServices;
  5. /**
  6. * 优惠套餐控制器
  7. * Class StoreDiscountsController
  8. * @package app\controller\api\v1\activity
  9. */
  10. class StoreDiscountsController
  11. {
  12. protected $services;
  13. /**
  14. * StoreDiscountsController constructor.
  15. * @param StoreDiscountsServices $services
  16. */
  17. public function __construct(StoreDiscountsServices $services)
  18. {
  19. $this->services = $services;
  20. }
  21. /**
  22. * 获取优惠商品列表
  23. * @param Request $request
  24. * @return mixed
  25. */
  26. public function index(Request $request)
  27. {
  28. [$product_id] = $request->postMore([
  29. ['product_id', 0]
  30. ], true);
  31. $uid = (int)$request->uid();
  32. if (!$product_id) return app('json')->fail('参数错误');
  33. $list = $this->services->getDiscounts((int)$product_id, $uid);
  34. return $list ? app('json')->successful($list) : app('json')->fail('活动商品已下架');
  35. }
  36. }