12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- namespace App\Console\Commands;
- use App\Models\InteLog;
- use App\Models\InteReview;
- use App\Models\InteUser;
- use Carbon\Carbon;
- use Illuminate\Console\Command;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Log;
- class IntegralCommand extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'IntegralCommand';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = 'Command description';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- Log::error('开始翻倍');
- for ($i=0;$i<1;$i++){
- $re=InteReview::where('time','<',Carbon::today()->addDays("-".$i)->timestamp)
- ->where('time','>',Carbon::yesterday()->addDays("-".$i)->timestamp)
- ->select(DB::raw('SUM(integral) as inte_all'),'uid')
- ->groupBy('uid')->get();
- foreach ($re as $k=>$v){
- $total=InteReview::where('time','<',Carbon::today()->addDays("-".$i)->timestamp)
- ->where('time','>',Carbon::yesterday()->addDays("-".$i)->timestamp)
- ->where('uid',$v->uid)->sum('type_jiu');
- if ($total>=6){
- $integral=$total*20;
- $inte=new InteLog();
- $inte->uid=$v->uid;
- $inte->type=2;
- $inte->integral=$integral;
- $inte->time=Carbon::yesterday()->addDays("-".$i)->addHours(2)->timestamp;
- $inte->season=48;
- $inte->save();
- $inteuser=InteUser::where('id',$v->uid)->first();
- $inteuser->integral+=$integral;
- $inteuser->save();
- }
- $inte_other=$v->inte_all-$total*20;
- if ($inte_other>=100){
- $inte=new InteLog();
- $inte->uid=$v->uid;
- $inte->type=2;
- $inte->integral=$inte_other;
- $inte->time=Carbon::yesterday()->addDays("-".$i)->addHours(2)->timestamp;
- $inte->season=48;
- $inte->save();
- $inteuser=InteUser::where('id',$v->uid)->first();
- $inteuser->integral+=$inte_other;
- $inteuser->save();
- }
- }
- }
- Log::error('翻倍结束');
- }
- }
|