RoomApply.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. namespace app\api\controller\plus\live;
  3. use app\api\controller\Controller;
  4. use app\api\model\order\Order as OrderModel;
  5. use app\api\model\plus\live\Room as RoomModel;
  6. use app\api\model\plus\live\LiveProduct as LiveProductModel;
  7. use app\api\model\product\Product as ProductModel;
  8. use app\api\model\supplier\Category as CategoryModel;
  9. /**
  10. * 主播直播申请
  11. */
  12. class RoomApply extends Controller
  13. {
  14. // 当前用户
  15. private $user;
  16. /**
  17. * 构造方法
  18. */
  19. public function initialize()
  20. {
  21. $this->user = $this->getUser(); // 用户信息
  22. }
  23. /**
  24. * 微信直播列表
  25. */
  26. public function lists()
  27. {
  28. $model = new RoomModel();
  29. $list = $model->getMyList($this->user, $this->postData(), true);
  30. return $this->renderSuccess('', compact('list'));
  31. }
  32. /**
  33. * 保存
  34. */
  35. public function addlive()
  36. {
  37. $model = new RoomModel;
  38. if ($model->add($this->user, $this->postData())) {
  39. $room_id = $model['room_id'];
  40. return $this->renderSuccess('保存成功', compact('room_id'));
  41. }
  42. return $this->renderError($model->getError() ?: '保存失败');
  43. }
  44. /**
  45. * 预告
  46. */
  47. public function addnotice()
  48. {
  49. $model = new RoomModel;
  50. if ($model->notice($this->user, $this->postData())) {
  51. $room_id = $model['room_id'];
  52. return $this->renderSuccess('保存成功', compact('room_id'));
  53. }
  54. return $this->renderError($model->getError() ?: '保存失败');
  55. }
  56. /**
  57. * 修改查询
  58. */
  59. public function detail($room_id)
  60. {
  61. $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
  62. return $this->renderSuccess('', compact('model'));
  63. }
  64. /**
  65. * 保存
  66. */
  67. public function edit($room_id)
  68. {
  69. $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
  70. if ($model->edit($this->user, $this->postData())) {
  71. return $this->renderSuccess('保存成功');
  72. }
  73. return $this->renderError($model->getError() ?: '保存失败');
  74. }
  75. /**
  76. * 保存商品
  77. */
  78. public function addProduct($productIds)
  79. {
  80. $model = new LiveProductModel();
  81. if($model->add($this->user, $productIds)){
  82. return $this->renderSuccess('保存成功');
  83. }
  84. return $this->renderError($model->getError() ?: '保存失败');
  85. }
  86. /**
  87. * 删除商品
  88. */
  89. public function delProduct($product_id)
  90. {
  91. $model = new LiveProductModel();
  92. if($model->remove($product_id)){
  93. return $this->renderSuccess('删除成功');
  94. }
  95. return $this->renderError($model->getError() ?: '删除失败');
  96. }
  97. /**
  98. * 删除
  99. */
  100. public function delete($room_id)
  101. {
  102. $model = RoomModel::detailByUser($this->user['user_id'], $room_id);
  103. if ($model->setDelete($this->user, $this->postData())) {
  104. return $this->renderSuccess('删除成功');
  105. }
  106. return $this->renderError($model->getError() ?: '删除失败');
  107. }
  108. /**
  109. * 直播商品列表
  110. */
  111. public function liveproduct()
  112. {
  113. $model = new LiveProductModel();
  114. $list = $model->getList($this->postData());
  115. return $this->renderSuccess('', compact('list'));
  116. }
  117. /**
  118. * 订单列表
  119. */
  120. public function orderList(){
  121. $model = new OrderModel();
  122. $list = $model->getLiveOrder($this->postData());
  123. return $this->renderSuccess('', compact('list'));
  124. }
  125. /**
  126. * 供应商商品列表
  127. */
  128. public function product_list()
  129. {
  130. $model = new ProductModel();
  131. //查找商品
  132. $param = $this->postData();
  133. $param['shop_supplier_id'] = $this->user['supplierUser']['shop_supplier_id'];
  134. $param['product_id'] = (new LiveProductModel())->livProduct($param['shop_supplier_id']);
  135. $list = $model->getList($param, $this->getUser());
  136. return $this->renderSuccess('', compact( 'list'));
  137. }
  138. //分类列表
  139. public function category(){
  140. $list = CategoryModel::getALL();
  141. return $this->renderSuccess('', compact('list'));
  142. }
  143. }