WithdrawLogic.php 970 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\admin\logic;
  3. use app\common\model\PaymentModel;
  4. use app\common\model\ShopGoods;
  5. use app\common\model\WithDrawLogModel;
  6. use think\facade\Cache;
  7. /**
  8. * 提现记录
  9. * Class ShopGoodsLogic
  10. * @package app\admin\logic
  11. */
  12. class WithdrawLogic
  13. {
  14. /**
  15. * 提现统计
  16. * @param string $time 时间节点如:2023-03-01
  17. * @return mixed
  18. */
  19. public static function getTotal($time = '0')
  20. {
  21. $cacheKey = "caches:withdraw:total_{$time}";
  22. if(!Cache::has($cacheKey)){
  23. $data = WithDrawLogModel::where('status', 1)
  24. ->where(function($query) use($time){
  25. if($time){
  26. $query->where('create_at','>=', $time);
  27. }
  28. })->sum('practical_money');
  29. if($data){
  30. Cache::set($cacheKey, $data, rand(3,5));
  31. }
  32. return $data;
  33. }
  34. return Cache::get($cacheKey);
  35. }
  36. }