TradeController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. * 详情
  38. * @return array|mixed
  39. */
  40. public function info()
  41. {
  42. $id = request()->post('id', 0);
  43. $info = TradeService::make()->getInfo($id);
  44. return message(1010, true, $info);
  45. }
  46. /**
  47. * 统计
  48. * @return array
  49. */
  50. public function counts()
  51. {
  52. $params = request()->all();
  53. $type = isset($params['type'])? $params['type'] : 1;
  54. $status = isset($params['status'])? $params['status'] : 0;
  55. // 我的订单
  56. if($type == 1){
  57. if($status==2){
  58. $params['sell_uid'] = $this->userId;
  59. }else{
  60. $params['user_id'] = $this->userId;
  61. }
  62. }
  63. // 推广订单
  64. else if($type == 2){
  65. $params['parent_id'] = $this->userId;
  66. }
  67. // 店铺订单
  68. else if($type == 3){
  69. $params['shop_id'] = $this->shopId;
  70. }
  71. $params['time'] = strtotime(date('Y-m-d'))-86400*7;
  72. $counts = TradeService::make()->getCounts($params);
  73. return message(1010, true, $counts);
  74. }
  75. /**
  76. * 抢拍
  77. * @return array
  78. */
  79. public function buy()
  80. {
  81. if(TradeService::make()->buy(request()->all(), $this->userId, $this->shopId)){
  82. return message(TradeService::make()->getError(), true);
  83. }else{
  84. return message(TradeService::make()->getError(), false);
  85. }
  86. }
  87. /**
  88. * 付款
  89. * @return array
  90. */
  91. public function pay()
  92. {
  93. if(TradeService::make()->pay(request()->all(), $this->userId, $this->shopId)){
  94. return message(TradeService::make()->getError(), true);
  95. }else{
  96. return message(TradeService::make()->getError(), false);
  97. }
  98. }
  99. /**
  100. * 确认收款
  101. * @return array
  102. */
  103. public function confirm()
  104. {
  105. if(TradeService::make()->confirm(request()->all(), $this->userId)){
  106. return message(TradeService::make()->getError(), true);
  107. }else{
  108. return message(TradeService::make()->getError(), false);
  109. }
  110. }
  111. /**
  112. * 上架
  113. * @return array
  114. */
  115. public function sell()
  116. {
  117. if(TradeService::make()->sell(request()->all(), $this->userId)){
  118. return message(TradeService::make()->getError(), true);
  119. }else{
  120. return message(TradeService::make()->getError(), false);
  121. }
  122. }
  123. /**
  124. * 上架审核
  125. * @return array
  126. */
  127. public function sellConfirm()
  128. {
  129. if(TradeService::make()->sellConfirm(request()->all())){
  130. return message(TradeService::make()->getError(), true);
  131. }else{
  132. return message(TradeService::make()->getError(), false);
  133. }
  134. }
  135. /**
  136. * 修改订单
  137. * @return array
  138. */
  139. public function modify()
  140. {
  141. if(TradeService::make()->modify(request()->all())){
  142. return message(TradeService::make()->getError(), true);
  143. }else{
  144. return message(TradeService::make()->getError(), false);
  145. }
  146. }
  147. }