FinancialSta.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 陈武杰
  5. * Date: 2021/1/14
  6. * Time: 9:37
  7. */
  8. namespace App\Admin\Controllers\DataCenter;
  9. use App\Http\Controllers\Controller;
  10. use App\Models\Order;
  11. use App\Models\User;
  12. class FinancialSta
  13. {
  14. //获取平台的收入总金额
  15. public static function getTotalIncome(){
  16. $data = Order::where('payment_status',2)->pluck('payment_amount')->sum();
  17. $data /=100;
  18. return $data;
  19. }
  20. //获取用户充值总金额
  21. public static function getTotalRecharge(){
  22. $data = Order::where('payment_status',2)->where('product_type',7)->pluck('payment_amount')->sum();
  23. $data /= 100;
  24. return $data;
  25. }
  26. //获取平台用户所有的余额
  27. public static function getTotalUserBalance(){
  28. $data = User::where('is_docter',0)->pluck('balance')->sum();
  29. $data /= 100;
  30. return $data;
  31. }
  32. public static function getTotalRefund(){
  33. $data = Order::where('payment_status',4)->pluck('payment_amount')->sum();
  34. $data /= 100;
  35. return $data;
  36. }
  37. /*
  38. * 充值记录
  39. * */
  40. //获取当日充值金额
  41. public static function getTodayReCharge(){
  42. $data = Order::where('payment_status',2)
  43. ->where('product_type',7)
  44. ->where('created_at','>=',date('Y-m-d 00:00:00',strtotime('today')))
  45. ->pluck('payment_amount')->sum();
  46. $data /= 100;
  47. return $data;
  48. }
  49. //获取最近7天的充值金额
  50. public static function getSevenDayReCharge(){
  51. $data = Order::where('payment_status',2)
  52. ->where('product_type',7)
  53. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-6 days')),date('Y-m-d H:i:s',time())])
  54. ->pluck('payment_amount')->sum();
  55. $data /= 100;
  56. return $data;
  57. }
  58. //获取最近30天的充值金额
  59. public static function getOneMonthReCharge(){
  60. $data = Order::where('payment_status',2)
  61. ->where('product_type',7)
  62. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-29 days')),date('Y-m-d H:i:s',time())])
  63. ->pluck('payment_amount')->sum();
  64. $data /= 100;
  65. return $data;
  66. }
  67. //获取今天的支付金额
  68. public static function getTodayPay(){
  69. $data = Order::where('payment_status',2)
  70. ->where('created_at','>=',date('Y-m-d 00:00:00',strtotime('today')))
  71. ->pluck('payment_amount')->sum();
  72. $data /= 100;
  73. return $data;
  74. }
  75. //获取昨天的支付金额
  76. public static function getYesterdayPay(){
  77. $data = Order::where('payment_status',2)
  78. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-1 days')),date('Y-m-d 23:59:59',strtotime('-1 days'))])
  79. ->pluck('payment_amount')->sum();
  80. $data /= 100;
  81. return $data;
  82. }
  83. //获取近七日的支付金额
  84. public static function getSevenDayPay(){
  85. $data = Order::where('payment_status',2)
  86. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-6 days')),date('Y-m-d H:i:s',time())])
  87. ->pluck('payment_amount')->sum();
  88. $data /= 100;
  89. return $data;
  90. }
  91. //获取三十日的支付金额
  92. public static function getOneMonthPay(){
  93. $data = Order::where('payment_status',2)
  94. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-29 days')),date('Y-m-d H:i:s',time())])
  95. ->pluck('payment_amount')->sum();
  96. $data /= 100;
  97. return $data;
  98. }
  99. }