StoreCombinationController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\v1\activity;
  12. use app\Request;
  13. use app\services\activity\combination\StoreCombinationServices;
  14. use app\services\activity\combination\StorePinkServices;
  15. use app\services\other\QrcodeServices;
  16. /**
  17. * 拼团类
  18. * Class StoreCombinationController
  19. * @package app\api\controller\activity
  20. */
  21. class StoreCombinationController
  22. {
  23. protected $services;
  24. public function __construct(StoreCombinationServices $services)
  25. {
  26. $this->services = $services;
  27. }
  28. /**
  29. * 拼团列表
  30. * @return mixed
  31. */
  32. public function lst()
  33. {
  34. $list = $this->services->getCombinationList();
  35. return app('json')->success(get_thumb_water($list));
  36. }
  37. /**
  38. * 拼团商品详情
  39. * @param Request $request
  40. * @param $id
  41. * @return mixed
  42. */
  43. public function detail(Request $request, $id)
  44. {
  45. $data = $this->services->combinationDetail($request, $id);
  46. return app('json')->success($data);
  47. }
  48. /**
  49. * 拼团 开团
  50. * @param Request $request
  51. * @param $id
  52. * @return mixed
  53. */
  54. public function pink(Request $request, $id)
  55. {
  56. $data = $this->services->getPinkInfo($request, (int)$id);
  57. return app('json')->success($data);
  58. }
  59. /**
  60. * 拼团 取消开团
  61. * @param Request $request
  62. * @return mixed
  63. */
  64. public function remove(Request $request)
  65. {
  66. list($id, $cid) = $request->postMore([
  67. ['id', 0],
  68. ['cid', 0],
  69. ], true);
  70. if (!$id || !$cid) return app('json')->fail(100100);
  71. /** @var StorePinkServices $pinkService */
  72. $pinkService = app()->make(StorePinkServices::class);
  73. $pinkService->removePink($request->uid(), $cid, $id);
  74. return app('json')->success(100010);
  75. }
  76. /**
  77. * 拼团海报
  78. * @param Request $request
  79. * @return mixed
  80. */
  81. public function poster(Request $request)
  82. {
  83. list($pinkId, $from) = $request->postMore([
  84. ['id', 0],
  85. ['from', 'wechat']
  86. ], true);
  87. if (!$pinkId) return app('json')->fail(100100);
  88. $user = $request->user();
  89. /** @var StorePinkServices $pinkService */
  90. $pinkService = app()->make(StorePinkServices::class);
  91. $res = $pinkService->getPinkPoster($pinkId, $from, $user);
  92. return app('json')->success(['url' => $res]);
  93. }
  94. /**
  95. * 获取拼团海报详情
  96. * @param Request $request
  97. * @param StorePinkServices $services
  98. * @param $id
  99. * @return mixed
  100. */
  101. public function posterInfo(Request $request, StorePinkServices $services, $id)
  102. {
  103. return app('json')->success($services->posterInfo((int)$id, $request->user()));
  104. }
  105. /**
  106. * 获取秒杀小程序二维码
  107. * @param Request $request
  108. * @param $id
  109. * @return mixed
  110. */
  111. public function code(Request $request, $id)
  112. {
  113. /** @var QrcodeServices $qrcodeService */
  114. $qrcodeService = app()->make(QrcodeServices::class);
  115. $url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 1);
  116. if ($url) {
  117. return app('json')->success(['code' => $url]);
  118. } else {
  119. return app('json')->success(['code' => '']);
  120. }
  121. }
  122. /**
  123. * 获取拼团列表轮播图
  124. */
  125. public function banner_list()
  126. {
  127. $banner = sys_data('combination_banner') ?? [];
  128. return app('json')->success($banner);
  129. }
  130. }