TradeController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Common\MemberService;
  5. use App\Services\Common\TradeService;
  6. /**
  7. * 交易
  8. * Class TradeController
  9. * @package App\Http\Controllers\Api
  10. */
  11. class TradeController extends webApp
  12. {
  13. public function index()
  14. {
  15. $params = request()->all();
  16. $pageSize = isset($params['pageSize'])? $params['pageSize'] : 18;
  17. $type = isset($params['type'])? $params['type'] : 1;
  18. $status = isset($params['status'])? $params['status'] : 0;
  19. // 我的订单
  20. if($type == 1){
  21. $params['user_id'] = $this->userId;
  22. $params['sell_uid'] = $this->userId;
  23. }
  24. // 推广订单
  25. else if($type == 2){
  26. $params['parent_id'] = $this->userId;
  27. }
  28. // 店铺订单
  29. else if($type == 3){
  30. $params['shop_id'] = $this->shopId;
  31. }
  32. $params['time'] = strtotime(date('Y-m-d'))-86400*7;
  33. $datas = TradeService::make()->getDataList($params, $pageSize);
  34. return message(1010, true, $datas);
  35. }
  36. // 转商品列表
  37. public function switchGoods()
  38. {
  39. $params = request()->all();
  40. $pageSize = isset($params['pageSize'])? $params['pageSize'] : 18;
  41. $params['shop_id'] = $this->shopId;
  42. $datas = TradeService::make()->getSwitchGoods($params, $pageSize);
  43. return message(1010, true, $datas);
  44. }
  45. /**
  46. * 详情
  47. * @return array|mixed
  48. */
  49. public function info()
  50. {
  51. $id = request()->post('id', 0);
  52. $info = TradeService::make()->getInfo($id);
  53. return message(1010, true, $info);
  54. }
  55. /**
  56. * 统计
  57. * @return array
  58. */
  59. public function counts()
  60. {
  61. $params = request()->all();
  62. $type = isset($params['type'])? $params['type'] : 1;
  63. $status = isset($params['status'])? $params['status'] : 0;
  64. // 我的订单
  65. if($type == 1){
  66. if($status==2){
  67. $params['sell_uid'] = $this->userId;
  68. }else{
  69. $params['user_id'] = $this->userId;
  70. }
  71. }
  72. // 推广订单
  73. else if($type == 2){
  74. $params['parent_id'] = $this->userId;
  75. }
  76. // 店铺订单
  77. else if($type == 3){
  78. $params['shop_id'] = $this->shopId;
  79. }
  80. $params['time'] = strtotime(date('Y-m-d'))-86400*7;
  81. $counts = TradeService::make()->getCounts($params);
  82. return message(1010, true, $counts);
  83. }
  84. /**
  85. * 抢拍
  86. * @return array
  87. */
  88. public function buy()
  89. {
  90. if(TradeService::make()->buy(request()->all(), $this->userId, $this->shopId)){
  91. return message(TradeService::make()->getError(), true);
  92. }else{
  93. return message(TradeService::make()->getError(), false);
  94. }
  95. }
  96. /**
  97. * 付款
  98. * @return array
  99. */
  100. public function pay()
  101. {
  102. if(TradeService::make()->pay(request()->all(), $this->userId, $this->shopId)){
  103. return message(TradeService::make()->getError(), true);
  104. }else{
  105. return message(TradeService::make()->getError(), false);
  106. }
  107. }
  108. /**
  109. * 确认收款
  110. * @return array
  111. */
  112. public function confirm()
  113. {
  114. if(TradeService::make()->confirm(request()->all(), $this->userId)){
  115. return message(TradeService::make()->getError(), true);
  116. }else{
  117. return message(TradeService::make()->getError(), false);
  118. }
  119. }
  120. /**
  121. * 上架
  122. * @return array
  123. */
  124. public function sell()
  125. {
  126. if(TradeService::make()->sell(request()->all(), $this->userId)){
  127. return message(TradeService::make()->getError(), true);
  128. }else{
  129. return message(TradeService::make()->getError(), false);
  130. }
  131. }
  132. /**
  133. * 上架审核
  134. * @return array
  135. */
  136. public function sellConfirm()
  137. {
  138. if(TradeService::make()->sellConfirm(request()->all())){
  139. return message(TradeService::make()->getError(), true);
  140. }else{
  141. return message(TradeService::make()->getError(), false);
  142. }
  143. }
  144. /**
  145. * 修改订单
  146. * @return array
  147. */
  148. public function modify()
  149. {
  150. if(TradeService::make()->modify(request()->all())){
  151. return message(TradeService::make()->getError(), true);
  152. }else{
  153. return message(TradeService::make()->getError(), false);
  154. }
  155. }
  156. /**
  157. * 取消订单
  158. * @return array
  159. */
  160. public function cancel()
  161. {
  162. if(TradeService::make()->cancel(request()->all())){
  163. return message(TradeService::make()->getError(), true);
  164. }else{
  165. return message(TradeService::make()->getError(), false);
  166. }
  167. }
  168. }