TradeController.php 3.7 KB

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