Total.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2018-2020 rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: TABLE ME
  8. // +----------------------------------------------------------------------
  9. // | Date: 2020-11-08 12:56
  10. // +----------------------------------------------------------------------
  11. namespace app\system\controller\v1;
  12. use app\BaseController;
  13. use app\model\system\SiteTotal;
  14. use app\Request;
  15. use library\services\UtilService;
  16. class Total extends BaseController {
  17. /**
  18. * 获取订单数据
  19. * @param Request $request
  20. */
  21. public function index(Request $request){
  22. $pageSize = 50;
  23. $post = UtilService::getMore(
  24. [
  25. ['page',1],
  26. ['start_time',''],
  27. ['end_time','']
  28. ],$request
  29. );
  30. $func = function($val){ return empty($val) ? "0.00" : $val;};
  31. $where = $post;
  32. list($pageCount,$data) = (new \app\model\system\Site)->getList2($post['page'],$where,$pageSize);
  33. $result = UtilService::getParam([
  34. "sassid",
  35. "name",
  36. "user_count",
  37. "order_count",
  38. "sub_order_count",
  39. ["order_money","order_money",$func],
  40. ['recharge_money','recharge_money',$func],
  41. ['commission_money','commission_money',$func]
  42. ],$data);
  43. return app('json')->success([
  44. 'list' => $result,
  45. 'pageCount' => $pageCount,
  46. 'pageSize' => $pageSize,
  47. 'page' => $post['page']
  48. ]);
  49. }
  50. /**
  51. * 业绩total
  52. * @param Request $request
  53. */
  54. public function siteTotal(Request $request) {
  55. $pageSize = 50;
  56. $post = UtilService::getMore(
  57. [
  58. ['page',1],
  59. ['sassid','','empty','参数错误'],
  60. ['start_time',''],
  61. ['end_time','']
  62. ],$request
  63. );
  64. $where['st.sassid'] = $post['sassid'];
  65. if(!empty($post['start_time'])) {
  66. $where['st.time'] = [[strtotime($post['start_time']),strtotime($post['end_time'])],'whereBetween'];
  67. }
  68. list($pageCount,$data) = (new \app\model\system\SiteTotal())->getList($post['page'],$where,$pageSize,'*','time desc');
  69. $func = function($val){ return empty($val) ? "0.00" : $val;};
  70. $data = UtilService::getParam([
  71. "sassid",
  72. "name",
  73. ['time','time','date("Y-m-d",$1)'],
  74. "user_count",
  75. "order_count",
  76. "sub_order_count",
  77. ["order_money","order_money",$func],
  78. ['recharge_money','recharge_money',$func],
  79. ['commission_money','commission_money',$func]
  80. ],$data);
  81. return app('json')->success([
  82. 'list' => $data,
  83. 'pageCount' => $pageCount,
  84. 'pageSize' => $pageSize,
  85. 'page' => $post['page']
  86. ]);
  87. }
  88. }