StoreCombinationController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\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\controller\api\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')->successful(get_thumb_water($list, 'mid'));
  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')->successful($data);
  47. }
  48. /**
  49. * 获取商品海报二维码
  50. * @param Request $request
  51. * @return mixed
  52. * @throws \think\db\exception\DataNotFoundException
  53. * @throws \think\db\exception\DbException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @author 等风来
  56. * @email 136327134@qq.com
  57. * @date 2022/11/14
  58. */
  59. public function detailCode(Request $request)
  60. {
  61. $id = $request->get('id/d', 0);
  62. $uid = $request->uid();
  63. /** @var QrcodeServices $qrcodeService */
  64. $qrcodeService = app()->make(QrcodeServices::class);
  65. if (($configData['share_qrcode'] ?? 0) && request()->isWechat()) {
  66. $storeInfo['code_base'] = $qrcodeService->getTemporaryQrcode('combination-' . $id, $uid)->url;
  67. } else {
  68. $storeInfo['code_base'] = $qrcodeService->getWechatQrcodePath($id . '_product_combination_detail_wap.jpg', '/pages/activity/goods_combination_details/index?id=' . $id);
  69. }
  70. return app('json')->success($storeInfo);
  71. }
  72. /**
  73. * 拼团 开团
  74. * @param Request $request
  75. * @param $id
  76. * @return mixed
  77. */
  78. public function pink(Request $request, $id)
  79. {
  80. $uid = (int)$request->uid();
  81. $user = $request->user();
  82. $data = $this->services->getPinkInfo($uid, (int)$id, $user->toArray());
  83. return app('json')->successful($data);
  84. }
  85. /**
  86. * 拼团 取消开团
  87. * @param Request $request
  88. * @return mixed
  89. */
  90. public function remove(Request $request)
  91. {
  92. [$id, $cid] = $request->postMore([
  93. ['id', 0],
  94. ['cid', 0],
  95. ], true);
  96. if (!$id || !$cid) return app('json')->fail('缺少参数');
  97. /** @var StorePinkServices $pinkService */
  98. $pinkService = app()->make(StorePinkServices::class);
  99. $pinkService->removePink($request->uid(), $cid, $id);
  100. return app('json')->successful('取消成功');
  101. }
  102. /**
  103. * 获取拼团海报详情
  104. * @param Request $request
  105. * @param StorePinkServices $services
  106. * @param $id
  107. * @return mixed
  108. */
  109. public function posterInfo(Request $request, StorePinkServices $services, $id)
  110. {
  111. return app('json')->success($services->posterInfo((int)$id, $request->user()));
  112. }
  113. /**
  114. * 获取秒杀小程序二维码
  115. * @param Request $request
  116. * @param $id
  117. * @return mixed
  118. */
  119. public function code(Request $request, $id)
  120. {
  121. /** @var QrcodeServices $qrcodeService */
  122. $qrcodeService = app()->make(QrcodeServices::class);
  123. $url = $qrcodeService->getRoutineQrcodePath($id, $request->uid(), 1);
  124. if ($url) {
  125. return app('json')->success(['code' => $url]);
  126. } else {
  127. return app('json')->success(['code' => '']);
  128. }
  129. }
  130. /**
  131. * 获取拼团列表轮播图
  132. */
  133. public function banner_list()
  134. {
  135. $banner = sys_data('combination_banner') ?? [];
  136. return app('json')->success($banner);
  137. }
  138. }