PostTrait.php 676 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/6/6
  6. * Time: 18:05
  7. */
  8. namespace App\Traits;
  9. use Illuminate\Support\Facades\Redis;
  10. trait PostTrait
  11. {
  12. //预计可获得彩虹豆数
  13. public function availableBean()
  14. {
  15. $bean = Redis::get('yesterday_post_create_bean');
  16. $count = Redis::get('yesterday_post_count');
  17. $num = 1000;
  18. if($bean && $count){
  19. $num = $bean / $count;
  20. }
  21. $h = date('h');
  22. $H = date('H');
  23. $t = $h * 60 / 720 + 2;
  24. if(in_array(intval($H), [9,10,11,12,17.18,19,20,21])){
  25. $t += 0.5;
  26. }
  27. return intval($num * $t);
  28. }
  29. }