FinancialSta.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. /*
  33. * 充值记录
  34. * */
  35. //获取当日充值金额
  36. public static function getTodayReCharge(){
  37. $data = Order::where('payment_status',2)
  38. ->where('product_type',7)
  39. ->where('created_at','>=',date('Y-m-d 00:00:00',strtotime('today')))
  40. ->pluck('payment_amount')->sum();
  41. $data /= 100;
  42. return $data;
  43. }
  44. //获取最近7天的充值金额
  45. public static function getSevenDayReCharge(){
  46. $data = Order::where('payment_status',2)
  47. ->where('product_type',7)
  48. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-6 days')),date('Y-m-d H:i:s',time())])
  49. ->pluck('payment_amount')->sum();
  50. $data /= 100;
  51. return $data;
  52. }
  53. //获取最近30天的充值金额
  54. public static function getOneMonthReCharge(){
  55. $data = Order::where('payment_status',2)
  56. ->where('product_type',7)
  57. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-29 days')),date('Y-m-d H:i:s',time())])
  58. ->pluck('payment_amount')->sum();
  59. $data /= 100;
  60. return $data;
  61. }
  62. //获取今天的支付金额
  63. public static function getTodayPay(){
  64. $data = Order::where('payment_status',2)
  65. ->where('created_at','>=',date('Y-m-d 00:00:00',strtotime('today')))
  66. ->pluck('payment_amount')->sum();
  67. $data /= 100;
  68. return $data;
  69. }
  70. //获取昨天的支付金额
  71. public static function getYesterdayPay(){
  72. $data = Order::where('payment_status',2)
  73. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-1 days')),date('Y-m-d 23:59:59',strtotime('-1 days'))])
  74. ->pluck('payment_amount')->sum();
  75. $data /= 100;
  76. return $data;
  77. }
  78. //获取近七日的支付金额
  79. public static function getSevenDayPay(){
  80. $data = Order::where('payment_status',2)
  81. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-6 days')),date('Y-m-d H:i:s',time())])
  82. ->pluck('payment_amount')->sum();
  83. $data /= 100;
  84. return $data;
  85. }
  86. //获取三十日的支付金额
  87. public static function getOneMonthPay(){
  88. $data = Order::where('payment_status',2)
  89. ->whereBetween('created_at',[date('Y-m-d 00:00:00',strtotime('-29 days')),date('Y-m-d H:i:s',time())])
  90. ->pluck('payment_amount')->sum();
  91. $data /= 100;
  92. return $data;
  93. }
  94. }