企微短剧业务系统

OrderController.php 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Service\OrderService;
  4. use Illuminate\Http\Request;
  5. use App\Http\Controllers\Controller;
  6. class OrderController extends Controller
  7. {
  8. /**
  9. * 获取订单数据统计
  10. * */
  11. public function dataStat(Request $request)
  12. {
  13. $validator = \Validator::make($request->all(),[
  14. 'corpid' => 'nullable|string',
  15. 'start_date' => 'nullable|date_format:Y-m-d',
  16. 'end_date' => 'nullable|date_format:Y-m-d',
  17. 'type' => 'nullable|in:1,2'
  18. ]);
  19. if ($validator->fails()) {
  20. return self::returnValue($validator->getMessageBag(), 1102);
  21. }
  22. $params['corpid'] = $request->input('corpid');
  23. $params['order_id'] = $request->input('order_id');
  24. $params['unionid'] = $request->input('unionid');
  25. $params['pay_status'] = $request->input('pay_status');
  26. $params['order_source'] = $request->input('order_source');
  27. $params['start_date'] = $request->input('start_date');
  28. $params['end_date'] = $request->input('end_date');
  29. $params['user_reg_st'] = $request->input('user_reg_st'); // 用户注册起始时间
  30. $params['user_reg_et'] = $request->input('user_reg_et'); // 用户注册截止时间
  31. $params['appid'] = $request->input('appid');
  32. $params['order_type'] = $request->input('order_type'); // 订单类型 1mp投放订单 2adq投放订单
  33. $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
  34. $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
  35. $params['sys_group_id'] = $request->input('sys_group_id');
  36. $params['account_id'] = $request->input('account_id');
  37. $params['order_pay_type'] = $request->input('order_pay_type'); // 订单支付类型 1小程序虚拟支付 2其他支付
  38. $params['ad_report_action_type'] = $request->input('ad_report_action_type');// 1下单 2付费 0全部
  39. $params['corp_id'] = $request->input('corp_id');
  40. # 获取订单数据统计
  41. $data = OrderService::dataStatSecond($params);
  42. return self::returnValue(['data' => $data]);
  43. }
  44. /**
  45. * 订单列表
  46. * */
  47. public function lists(Request $request)
  48. {
  49. $validator = \Validator::make($request->all(),[
  50. 'corpid' => 'required|string',
  51. 'start_date' => 'nullable|date_format:Y-m-d',
  52. 'end_date' => 'nullable|date_format:Y-m-d',
  53. ]);
  54. if ($validator->fails()) {
  55. return self::returnValue($validator->getMessageBag(), 1102);
  56. }
  57. $params['corpid'] = $request->input('corpid');
  58. $params['order_id'] = $request->input('order_id');
  59. $params['unionid'] = $request->input('unionid');
  60. $params['pay_status'] = $request->input('pay_status');
  61. $params['order_source'] = $request->input('order_source');
  62. $params['start_date'] = $request->input('start_date');
  63. $params['end_date'] = $request->input('end_date');
  64. $params['user_reg_st'] = $request->input('user_reg_st'); // 用户注册起始时间
  65. $params['user_reg_et'] = $request->input('user_reg_et'); // 用户注册截止时间
  66. $params['appid'] = $request->input('appid');
  67. $params['order_type'] = $request->input('order_type'); // 订单类型 1mp投放订单 2adq投放订单
  68. $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
  69. $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
  70. $params['account_id'] = $request->input('account_id');
  71. $params['sys_group_id'] = $request->input('sys_group_id');
  72. $params['order_pay_type'] = $request->input('order_pay_type');
  73. $params['ad_report_action_type'] = $request->input('ad_report_action_type');// 1下单 2付费 0全部
  74. $params['corp_id'] = $request->input('corp_id');
  75. $page = $request->input('page', 1);
  76. $pageSize = $request->input('page_size', 20);
  77. # 获取订单数据统计
  78. list($list, $count) = OrderService::getOrderList($params, $params['corpid'], $page, $pageSize);
  79. return self::returnPageValue($list, $count, $pageSize, $page);
  80. }
  81. public function actionUpload(Request $request)
  82. {
  83. $validator = \Validator::make($request->all(),[
  84. 'order_id' => 'required'
  85. ]);
  86. if ($validator->fails()) {
  87. return self::returnValue($validator->getMessageBag(), 1102);
  88. }
  89. $orderId = $request->input('order_id');
  90. $orderDataId = $request->input('order_data_id');
  91. $errcode = 0;
  92. OrderService::actionUpload($orderId, $orderDataId, $errcode);
  93. return self::returnValue([], $errcode);
  94. }
  95. public function orderExport(Request $request)
  96. {
  97. $validator = \Validator::make($request->all(),[
  98. 'corpid' => 'nullable|string',
  99. 'start_date' => 'nullable|date_format:Y-m-d',
  100. 'end_date' => 'nullable|date_format:Y-m-d',
  101. ]);
  102. if ($validator->fails()) {
  103. return self::returnValue($validator->getMessageBag(), 1102);
  104. }
  105. $params['corpid'] = $request->input('corpid');
  106. $params['order_id'] = $request->input('order_id');
  107. $params['order_source'] = $request->input('order_source');
  108. $params['start_date'] = $request->input('start_date');
  109. $params['end_date'] = $request->input('end_date');
  110. $params['appid'] = $request->input('appid');
  111. $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
  112. $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
  113. $params['sys_group_id'] = $request->input('sys_group_id');
  114. $params['account_id'] = $request->input('account_id');
  115. $errcode = 0;
  116. OrderService::orderExport($params, $errcode);
  117. }
  118. // 数据看板订单列表
  119. public function orderList(Request $request)
  120. {
  121. $validator = \Validator::make($request->all(),[
  122. 'corpid' => 'nullable|string',
  123. 'start_date' => 'nullable|date_format:Y-m-d',
  124. 'end_date' => 'nullable|date_format:Y-m-d',
  125. ]);
  126. if ($validator->fails()) {
  127. return self::returnValue($validator->getMessageBag(), 1102);
  128. }
  129. $params['corpid'] = $request->input('corpid');
  130. $params['order_id'] = $request->input('order_id');
  131. $params['order_source'] = $request->input('order_source');
  132. $params['start_date'] = $request->input('start_date');
  133. $params['end_date'] = $request->input('end_date');
  134. $params['appid'] = $request->input('appid');
  135. $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
  136. $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
  137. $params['sys_group_id'] = $request->input('sys_group_id');
  138. $params['account_id'] = $request->input('account_id');
  139. $params['order_pay_type'] = $request->input('order_pay_type');
  140. $page = $request->input('page', 1);
  141. $pageSize = $request->input('page_size', 20);
  142. list($list, $count) = OrderService::orderList($params, $page, $pageSize);
  143. return self::returnPageValue($list, $count, $pageSize, $page);
  144. }
  145. public function platformList()
  146. {
  147. $list = config('platform.base');
  148. $data = [];
  149. foreach ($list as $k => $v) {
  150. $data[] = [
  151. 'platform_id' => $k,
  152. 'platform_title' => $v,
  153. ];
  154. }
  155. return self::returnValue($data);
  156. }
  157. public function orderExportOffline(Request $request)
  158. {
  159. $validator = \Validator::make($request->all(),[
  160. 'corpid' => 'nullable|string',
  161. 'start_date' => 'nullable|date_format:Y-m-d',
  162. 'end_date' => 'nullable|date_format:Y-m-d',
  163. ]);
  164. if ($validator->fails()) {
  165. return self::returnValue($validator->getMessageBag(), 1102);
  166. }
  167. $params['corpid'] = $request->input('corpid');
  168. $params['order_id'] = $request->input('order_id');
  169. $params['order_source'] = $request->input('order_source');
  170. $params['start_date'] = $request->input('start_date');
  171. $params['end_date'] = $request->input('end_date');
  172. $params['appid'] = $request->input('appid');
  173. $params['plat_order_type'] = $request->input('plat_order_type'); // 订单来源 0小程序 1H5
  174. $params['is_ad_user'] = $request->input('is_ad_user'); // 收入来源 0运营 1投放
  175. $params['sys_group_id'] = $request->input('sys_group_id');
  176. $params['account_id'] = $request->input('account_id');
  177. $params['order_pay_type'] = $request->input('order_pay_type');
  178. $errcode = 0;
  179. OrderService::orderExportOffline($params, $errcode);
  180. return self::returnValue([], $errcode);
  181. }
  182. public function orderExportList(Request $request)
  183. {
  184. $page = $request->input('page', 1);
  185. $pageSize = $request->input('page_size', 20);
  186. $sysGroupId = $request->input('sys_group_id');
  187. list($res, $count) = OrderService::orderExportList($sysGroupId, $page, $pageSize);
  188. return self::returnPageValue($res, $count, $pageSize, $page);
  189. }
  190. # 设置第三方平台订单金额分成比例
  191. public function setShareInProportionConf(Request $request) {
  192. $validator = \Validator::make($request->all(),[
  193. 'sys_group_id' => 'required|numeric|in:1,2,3,4,5,6,7,9',
  194. 'order_source' => 'required|numeric|in:1,2,3,4,5,6,7,8,9',
  195. 'android_percent' => 'required',
  196. 'ios_percent' => 'required',
  197. ]);
  198. if ($validator->fails()) {
  199. return self::returnValue($validator->getMessageBag(), 1102);
  200. }
  201. $sysGroupId = $request->input('sys_group_id');
  202. $orderSource = $request->input('order_source');
  203. $androidPercent = $request->input('android_percent');
  204. $iosPercent = $request->input('ios_percent');
  205. $errcode = 0;
  206. OrderService::setShareInProportionConf($sysGroupId, $orderSource, $androidPercent, $iosPercent, $errcode);
  207. return self::returnValue('', $errcode);
  208. }
  209. # 获取第三方平台订单金额分成比例
  210. public function getShareInProportionConf(Request $request) {
  211. $validator = \Validator::make($request->all(),[
  212. 'sys_group_id' => 'required|numeric',
  213. ]);
  214. if ($validator->fails()) {
  215. return self::returnValue($validator->getMessageBag(), 1102);
  216. }
  217. $sysGroupId = $request->input('sys_group_id');
  218. $data = OrderService::getShareInProportionConf($sysGroupId);
  219. return self::returnValue($data);
  220. }
  221. }