StoreCombination.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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\admin\controller\ump;
  12. use app\admin\controller\AuthController;
  13. use app\admin\model\special\Special;
  14. use app\admin\model\ump\StorePinkFalse;
  15. use traits\CurdControllerTrait;
  16. use service\JsonService as Json;
  17. use think\Request;
  18. use think\Url;
  19. use app\wap\model\store\StorePink;
  20. /**
  21. * 拼团管理
  22. * Class StoreCombination
  23. * @package app\admin\controller\store
  24. */
  25. class StoreCombination extends AuthController
  26. {
  27. use CurdControllerTrait;
  28. /**拼团列表
  29. * @return mixed
  30. */
  31. public function combina_list($cid = 0)
  32. {
  33. $special_type = $this->request->param('special_type');
  34. $this->assign('special_type', $special_type);
  35. $this->assign('cid', $cid);
  36. return $this->fetch();
  37. }
  38. /*
  39. * 获取拼团列表
  40. * @param array $where
  41. * @return json
  42. * */
  43. public function get_pink_list()
  44. {
  45. $where = parent::getMore([
  46. ['status', ''],
  47. ['data', ''],
  48. ['nickname', ''],
  49. ['page', 1],
  50. ['cid', 0],
  51. ['limit', 10],
  52. ], $this->request);
  53. return Json::successlayui(StorePink::getPinkList($where));
  54. }
  55. /*
  56. * 删除虚拟拼团
  57. * @param int $id 拼团id
  58. * @return json
  59. * */
  60. public function delete_pink($id = 0)
  61. {
  62. if (!$id) return Json::fail('缺少参数');
  63. if (StorePink::be(['is_false' => 0, 'id' => $id])) return Json::fail('不是虚拟拼团无法删除');
  64. if (StorePink::where('id', $id)->delete())
  65. return Json::successful('删除成功');
  66. else
  67. return Json::fail('删除失败');
  68. }
  69. /*
  70. * 下架拼团
  71. * @param int $id 拼团id
  72. * @return json
  73. * */
  74. public function down_pink($id = 0)
  75. {
  76. if (!$id) return Json::fail('缺少参数');
  77. $res = StorePink::downPink($id);
  78. if ($res === false)
  79. return Json::fail(StorePink::getErrorInfo());
  80. else
  81. return Json::successful('下架成功');
  82. }
  83. /*
  84. * 助力拼团
  85. * */
  86. public function helpe_pink($id = 0)
  87. {
  88. $this->assign('id', $id);
  89. return $this->fetch();
  90. }
  91. public function save_helpe_pink()
  92. {
  93. list($pink_id, $nickname, $avatar) = parent::postMore([
  94. ['pink_id', 0],
  95. ['nickname', ''],
  96. ['avatar', ''],
  97. ], $this->request, true);
  98. if (!$pink_id) return Json::fail('缺少助力团ID');
  99. if (!$nickname) return Json::fail('请输入助力用户用户名');
  100. if (!$avatar) return Json::fail('请上传助力用户头像');
  101. $res = StorePink::helpePink($pink_id, $nickname, $avatar);
  102. if ($res === false)
  103. return Json::fail(StorePink::getErrorInfo());
  104. else
  105. return Json::successful('助力成功');
  106. }
  107. /**拼团人列表
  108. * @return mixed
  109. */
  110. public function order_pink($id)
  111. {
  112. if (!$id) return $this->failed('数据不存在');
  113. $StorePink = StorePink::getPinkUserOne($id);
  114. if (!$StorePink) return $this->failed('数据不存在!');
  115. $list = StorePink::getPinkMember($id);
  116. $list[] = $StorePink;
  117. if ($id = StorePink::where(['k_id' => $id, 'is_false' => 1])->column('id')) {
  118. $falsePink = count($id) ? StorePinkFalse::where('pink_id', 'in', $id)->select()->toArray() : [];
  119. foreach ($falsePink as $item) {
  120. $item['uid'] = 0;
  121. $item['is_refund'] = 0;
  122. $item['is_false'] = 1;
  123. $item['total_price'] = $StorePink['total_price'];
  124. array_push($list, $item);
  125. }
  126. }
  127. $this->assign('list', $list);
  128. return $this->fetch();
  129. }
  130. /*
  131. * 创建虚拟拼团
  132. *
  133. * */
  134. public function create_pink_false()
  135. {
  136. $this->assign('list', Special::PreWhere()->field('id,title')->select());
  137. return $this->fetch();
  138. }
  139. }