123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- namespace App\Console;
- use App\Console\Commands\Withdraw;
- use App\Console\Commands\OrderFinishFails;
- use App\Console\Commands\YesIntegral;
- use App\Models\Address;
- use App\Models\Ordertest;
- use App\Models\User;
- use Carbon\Carbon;
- use Illuminate\Console\Scheduling\Schedule;
- use Illuminate\Support\Facades\DB;
- use Laravel\Lumen\Console\Kernel as ConsoleKernel;
- use Illuminate\Support\Facades\Log;
- use mysql_xdevapi\Exception;
- class Kernel extends ConsoleKernel
- {
- /**
- * The Artisan commands provided by your application.
- *
- * @var array
- */
- protected $commands = [
- // Withdraw::class,
- // OrderFinishFails::class,
- // YesIntegral::class,
- ];
- /**
- * Define the application's command schedule.
- *
- * @param \Illuminate\Console\Scheduling\Schedule $schedule
- * @return void
- */
- protected function schedule(Schedule $schedule)
- {
- $schedule->call(function (){
- $data=User::whereNotIn('level',[0,3])->whereIn('status',[3,6])->get();
- $i=0;
- foreach ($data as $k=>$v){
- if ($v->recom_user->level>$v->level){
- if ($v->recom_id!=$v->agent_id){
- $i++;
- Log::error('____上级不正确___'.$v->mobile);
- }
- }elseif ($v->recom_user->level=$v->level){
- if ($v->agent_id!=$v->recom_user->agent_id){
- Log::error('____上级dengji不正确___'.$v->mobile);
- }
- }
- }
- Log::error('{--名称-处理完成----}'.$i);
- })->dailyAt('14:52');
- $schedule->call(function (){
- $address=Address::with(['users'])->get();
- foreach ($address as $k=>$v){
- if ($v->users){
- Address::where('id',$v->id)->update(['level'=>$v->users->level,'nickname'=>$v->users->nickname]);
- }
- if ($k%1000==0){
- Log::error('已经行至-==='.$k);
- }
- }
- Log::error('结束');
- })->everyMinute();
- $schedule->call(function (){
- $order=Ordertest::where('is_deleted',1)->with(['order_detail','get_pay'=>function($q){
- $q->whereIn('type',[1,2,3]);
- }])->get();
- foreach ($order as $k=>$v){
- $money=0;
- $pay=0;
- $pay1=0;
- foreach ($v->order_detail as $ke=>$va){
- $money+=$va->money;
- }
- foreach ($v->get_pay as $ke=>$value){
- if ($value->type==1){
- $pay+=$value->pay_money;
- }else{
- $pay1+=$value->pay_money;
- }
- }
- if ($pay!=0){
- if ($money!=$pay){
- if ($pay!=$v->pay_money){
- $arr[$k]=$v->order_num;
- }
- }
- if ($pay!=$pay1){
- Log::error($v->order_num);
- if (!in_array($v->order_num,$arr)){
- Log::error($v->order_num);
- }
- }
- }
- }
- })->dailyAt('03:07');;
- }
- public function code($phone){
- $data=code($phone);
- $re=DB::table('users')->where('recom_code',$data)->first();
- if ($re){
- $data=$this->code($phone);
- return $data;
- }
- return $data;
- }
- public function auth_code($phone){
- $user=User::where('mobile',$phone)->first();
- $code=auth_code($user->id);
- return $code;
- }
- }
|