TradeOrderController.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Http\Validator\TradeValidator;
  13. use App\Models\TradeOrderModel;
  14. use App\Services\Api\MemberService;
  15. use App\Services\Common\TradeOrderService;
  16. /**
  17. * 交易订单控制器
  18. * Class TradeOrderController
  19. * @package App\Http\Controllers\Admin
  20. */
  21. class TradeOrderController extends Backend
  22. {
  23. /**
  24. * 构造函数
  25. * TradeOrderController constructor.
  26. */
  27. public function __construct()
  28. {
  29. $this->model = new TradeOrderModel();
  30. $this->service = new TradeOrderService();
  31. parent::__construct();
  32. }
  33. public function index()
  34. {
  35. $params = request()->all();
  36. $pageSize = request()->post('limit', 15);
  37. if($this->userInfo['user_type'] == 2){
  38. $params['business_id'] = $this->userInfo['user_id'];
  39. }
  40. $list = TradeOrderService::make()->getDataList($params,$pageSize);
  41. $message = array(
  42. "msg" => '操作成功',
  43. "code" => 0,
  44. "data" => isset($list['list'])? $list['list']:[],
  45. "count" => isset($list['total'])? $list['total']:0,
  46. );
  47. return $message;
  48. }
  49. public function business()
  50. {
  51. $params = request()->all();
  52. $pageSize = request()->post('pageSize', 15);
  53. $params['business_id'] = $this->userInfo['user_id'];
  54. $list = TradeOrderService::make()->getDataList($params,$pageSize);
  55. $message = array(
  56. "msg" => '操作成功',
  57. "code" => 0,
  58. "data" => isset($list['list'])? $list['list']:[],
  59. "count" => isset($list['total'])? $list['total']:0,
  60. );
  61. return $message;
  62. }
  63. /**
  64. * 获取待处理订单
  65. * @return array
  66. */
  67. public function wait()
  68. {
  69. $params = request()->post();
  70. $params['business_id'] = $this->userInfo['user_id'];
  71. $info = TradeOrderService::make()->getWaitOrder($params);
  72. return returnJson(1002, true, $info);
  73. }
  74. /**
  75. * 确定已打款
  76. * @return array
  77. */
  78. public function pay()
  79. {
  80. $params = request()->post();
  81. if(!TradeOrderService::make()->businessPay($this->userInfo['user_id'], $params)){
  82. return returnJson(TradeOrderService::make()->getError(), false);
  83. }else{
  84. return returnJson(TradeOrderService::make()->getError(), true);
  85. }
  86. }
  87. /**
  88. * 确定已收款
  89. * @return array
  90. */
  91. public function collection()
  92. {
  93. $params = request()->post();
  94. // 平台处理则无币商参数
  95. $businessId = $this->userInfo['user_id'];
  96. if($this->userInfo['user_type'] == 1){
  97. $params['catch_uid'] = $this->userId;
  98. $businessId = 0;
  99. }
  100. if(!TradeOrderService::make()->businessCollection($businessId, $params)){
  101. return returnJson(TradeOrderService::make()->getError(), false);
  102. }else{
  103. return returnJson(TradeOrderService::make()->getError(), true);
  104. }
  105. }
  106. /**
  107. * 重新派单用户列表
  108. * @return array
  109. */
  110. public function reassignList()
  111. {
  112. $keyword = request()->post('keyword','');
  113. $tradeType = request()->post('type',1);
  114. $userId = request()->post('userId',0);
  115. $num = request()->post('num',0);
  116. $datas = MemberService::make()->getTradeMemberOptions($num, $tradeType, $userId, $keyword);
  117. return returnJson(1002, true, $datas);
  118. }
  119. /**
  120. * 重派单
  121. */
  122. public function reassign(TradeValidator $validate)
  123. {
  124. $params = request()->post();
  125. $params = $validate->check($params,'info');
  126. if(!is_array($params)){
  127. return returnJson($params, false,[]);
  128. }
  129. $id = request()->post('id',0);
  130. $businessId = request()->post('business_id',0);
  131. if(!TradeOrderService::make()->reassign($id, $businessId)){
  132. return returnJson(TradeOrderService::make()->getError(), false);
  133. }else{
  134. return returnJson(TradeOrderService::make()->getError(), true);
  135. }
  136. }
  137. /**
  138. * 确定已收款
  139. * @return array
  140. */
  141. public function cancel()
  142. {
  143. $params = request()->post();
  144. // 平台处理则无币商参数
  145. $businessId = $this->userInfo['user_id'];
  146. if($this->userInfo['user_type'] == 1){
  147. $params['catch_uid'] = $this->userId;
  148. $businessId = 0;
  149. }
  150. if(!TradeOrderService::make()->businessCancel($businessId,$params)){
  151. return returnJson(TradeOrderService::make()->getError(), false);
  152. }else{
  153. return returnJson(TradeOrderService::make()->getError(), true);
  154. }
  155. }
  156. }