AdvertOrderController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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\Models\AdvertModel;
  13. use App\Models\AdvertOrderModel;
  14. use App\Models\TradeOrderModel;
  15. use App\Services\Common\AdvertOrderService;
  16. use App\Services\Common\TradeOrderService;
  17. /**
  18. * 挂单广告订单控制器
  19. * Class AdvertOrderController
  20. * @package App\Http\Controllers\Admin
  21. */
  22. class AdvertOrderController extends Backend
  23. {
  24. /**
  25. * 构造函数
  26. * AdvertOrderController constructor.
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new AdvertOrderModel();
  31. $this->service = new AdvertOrderService();
  32. parent::__construct();
  33. }
  34. /**
  35. * 广告订单
  36. * @return array|mixed
  37. */
  38. public function index()
  39. {
  40. $params = request()->all();
  41. $pageSize = request()->post('limit', 15);
  42. if($this->userInfo['user_type'] == 2){
  43. $params['business_id'] = $this->userInfo['user_id'];
  44. }
  45. $list = AdvertOrderService::make()->getDataList($params,$pageSize);
  46. $message = array(
  47. "msg" => '操作成功',
  48. "code" => 0,
  49. "data" => isset($list['list'])? $list['list']:[],
  50. "count" => isset($list['total'])? $list['total']:0,
  51. );
  52. return $message;
  53. }
  54. /**
  55. * 交易员自己的广告订单
  56. * @return array
  57. */
  58. public function business()
  59. {
  60. $params = request()->all();
  61. $pageSize = request()->post('limit', 15);
  62. $params['user_id'] = $this->userInfo['user_id'];
  63. $list = AdvertOrderService::make()->getDataList($params,$pageSize);
  64. $message = array(
  65. "msg" => '操作成功',
  66. "code" => 0,
  67. "data" => isset($list['list'])? $list['list']:[],
  68. "count" => isset($list['total'])? $list['total']:0,
  69. );
  70. return $message;
  71. }
  72. /**
  73. * 购买广告(交易员)
  74. * @return array
  75. */
  76. public function buy()
  77. {
  78. $params = request()->post();
  79. if(!AdvertOrderService::make()->buy($this->userInfo['user_id'], $params)){
  80. return returnJson(AdvertOrderService::make()->getError(), false);
  81. }else{
  82. return returnJson(AdvertOrderService::make()->getError(), true);
  83. }
  84. }
  85. /**
  86. * 出售广告(交易员)
  87. * @return array
  88. */
  89. public function sell()
  90. {
  91. return returnJson(1002);
  92. }
  93. /**
  94. * 确认付款(交易员的客户订单)
  95. * @return array
  96. */
  97. public function pay()
  98. {
  99. return returnJson(1002);
  100. }
  101. /**
  102. * 确认付款(交易员的个人订单)
  103. * @return array
  104. */
  105. public function businessPay()
  106. {
  107. $params = request()->post();
  108. if(!AdvertOrderService::make()->businessPay($this->userInfo['user_id'], $params)){
  109. return returnJson(AdvertOrderService::make()->getError(), false);
  110. }else{
  111. return returnJson(AdvertOrderService::make()->getError(), true);
  112. }
  113. }
  114. /**
  115. * 确认收款(交易员客户订单)
  116. * @return array
  117. */
  118. public function collection()
  119. {
  120. $params = request()->post();
  121. // 平台处理则无币商参数
  122. $businessId = $this->userInfo['user_id'];
  123. if($this->userInfo['user_type'] == 1){
  124. $params['catch_uid'] = $this->userId;
  125. $businessId = 0;
  126. }
  127. if(!AdvertOrderService::make()->collection($businessId, $params)){
  128. return returnJson(TradeOrderService::make()->getError(), false);
  129. }else{
  130. return returnJson(TradeOrderService::make()->getError(), true);
  131. }
  132. }
  133. /**
  134. * 确认收款(交易员的个人订单)
  135. * @return array
  136. */
  137. public function businessCollection()
  138. {
  139. $params = request()->post();
  140. // 平台处理则无币商参数
  141. $businessId = $this->userInfo['user_id'];
  142. if($this->userInfo['user_type'] == 1){
  143. $params['catch_uid'] = $this->userId;
  144. $businessId = 0;
  145. }
  146. if(!AdvertOrderService::make()->businessCollection($businessId, $params)){
  147. return returnJson(AdvertOrderService::make()->getError(), false);
  148. }else{
  149. return returnJson(AdvertOrderService::make()->getError(), true);
  150. }
  151. }
  152. /**
  153. * 订单异常处理(交易员申请或平台处理)
  154. */
  155. public function exception()
  156. {
  157. return returnJson(1002);
  158. }
  159. /**
  160. * 订单取消(交易员或平台操作)
  161. */
  162. public function businessCancel()
  163. {
  164. $params = request()->post();
  165. // 平台处理则无币商参数
  166. $businessId = $this->userInfo['user_id'];
  167. if($this->userInfo['user_type'] == 1){
  168. $params['catch_uid'] = $this->userId;
  169. $businessId = 0;
  170. }
  171. if(!TradeOrderService::make()->businessCancel($businessId,$params)){
  172. return returnJson(TradeOrderService::make()->getError(), false);
  173. }else{
  174. return returnJson(TradeOrderService::make()->getError(), true);
  175. }
  176. }
  177. }