新版订单消耗系统

OrderBackUpController.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Services\OrderBackUpService;
  4. use Illuminate\Http\Request;
  5. use Illuminate\Validation\Rule;
  6. class OrderBackUpController extends Controller
  7. {
  8. /**
  9. * 订单记账备份列表
  10. */
  11. public function index(Request $request)
  12. {
  13. $validator = \Validator::make($request->all(), [
  14. 'page' => 'nullable|int',
  15. 'pagesize' => 'nullable|int',
  16. 'change_month' => 'nullable|string',
  17. 'back_type' => 'nullable|int',
  18. 'task_id' => 'nullable|string',
  19. 'company' => 'nullable|string',
  20. 'customer_name' => 'nullable|string',
  21. 'cost_company_name' => 'nullable|string',
  22. 'mcn_name' => 'nullable|string'
  23. ], [
  24. 'page.required' => '页码必传',
  25. ]);
  26. if ($validator->fails()) {
  27. return self::returnValue($validator->getMessageBag(), 1102);
  28. }
  29. $search = $request->all();
  30. $page = $request->input('page', 1);
  31. $pagesize = $request->input('pagesize', 20);
  32. list($data, $total) = OrderBackUpService::index($page, $pagesize, $search);
  33. return self::returnPageValue($data, $total, $pagesize, $page);
  34. }
  35. public function export(Request $request)
  36. {
  37. $validator = \Validator::make($request->all(), [
  38. 'change_month' => 'nullable|string',
  39. 'back_type' => 'nullable|int',
  40. 'task_id' => 'nullable|string',
  41. 'company' => 'nullable|string'
  42. ]);
  43. if ($validator->fails()) {
  44. return self::returnValue($validator->getMessageBag(), 1102);
  45. }
  46. $search = $request->all();
  47. $page = $request->input('page', 1);
  48. $pagesize = $request->input('pagesize', 20);
  49. $res = OrderBackUpService::export($page, $pagesize, $search);
  50. return self::returnValue([], 0);
  51. }
  52. }