Kernel.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. namespace App\Console;
  3. use App\Console\Commands\Withdraw;
  4. use App\Console\Commands\OrderFinishFails;
  5. use App\Console\Commands\YesIntegral;
  6. use App\Models\Address;
  7. use App\Models\Ordertest;
  8. use App\Models\User;
  9. use Carbon\Carbon;
  10. use Illuminate\Console\Scheduling\Schedule;
  11. use Illuminate\Support\Facades\DB;
  12. use Laravel\Lumen\Console\Kernel as ConsoleKernel;
  13. use Illuminate\Support\Facades\Log;
  14. use mysql_xdevapi\Exception;
  15. class Kernel extends ConsoleKernel
  16. {
  17. /**
  18. * The Artisan commands provided by your application.
  19. *
  20. * @var array
  21. */
  22. protected $commands = [
  23. // Withdraw::class,
  24. // OrderFinishFails::class,
  25. // YesIntegral::class,
  26. ];
  27. /**
  28. * Define the application's command schedule.
  29. *
  30. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  31. * @return void
  32. */
  33. protected function schedule(Schedule $schedule)
  34. {
  35. $schedule->call(function (){
  36. $data=User::whereNotIn('level',[0,3])->whereIn('status',[3,6])->get();
  37. $i=0;
  38. foreach ($data as $k=>$v){
  39. if ($v->recom_user->level>$v->level){
  40. if ($v->recom_id!=$v->agent_id){
  41. $i++;
  42. Log::error('____上级不正确___'.$v->mobile);
  43. }
  44. }elseif ($v->recom_user->level=$v->level){
  45. if ($v->agent_id!=$v->recom_user->agent_id){
  46. Log::error('____上级dengji不正确___'.$v->mobile);
  47. }
  48. }
  49. }
  50. Log::error('{--名称-处理完成----}'.$i);
  51. })->dailyAt('14:52');
  52. $schedule->call(function (){
  53. $address=Address::with(['users'])->get();
  54. foreach ($address as $k=>$v){
  55. if ($v->users){
  56. Address::where('id',$v->id)->update(['level'=>$v->users->level,'nickname'=>$v->users->nickname]);
  57. }
  58. if ($k%1000==0){
  59. Log::error('已经行至-==='.$k);
  60. }
  61. }
  62. Log::error('结束');
  63. })->everyMinute();
  64. $schedule->call(function (){
  65. $order=Ordertest::where('is_deleted',1)->with(['order_detail','get_pay'=>function($q){
  66. $q->whereIn('type',[1,2,3]);
  67. }])->get();
  68. foreach ($order as $k=>$v){
  69. $money=0;
  70. $pay=0;
  71. $pay1=0;
  72. foreach ($v->order_detail as $ke=>$va){
  73. $money+=$va->money;
  74. }
  75. foreach ($v->get_pay as $ke=>$value){
  76. if ($value->type==1){
  77. $pay+=$value->pay_money;
  78. }else{
  79. $pay1+=$value->pay_money;
  80. }
  81. }
  82. if ($pay!=0){
  83. if ($money!=$pay){
  84. if ($pay!=$v->pay_money){
  85. $arr[$k]=$v->order_num;
  86. }
  87. }
  88. if ($pay!=$pay1){
  89. Log::error($v->order_num);
  90. if (!in_array($v->order_num,$arr)){
  91. Log::error($v->order_num);
  92. }
  93. }
  94. }
  95. }
  96. })->dailyAt('03:07');;
  97. }
  98. public function code($phone){
  99. $data=code($phone);
  100. $re=DB::table('users')->where('recom_code',$data)->first();
  101. if ($re){
  102. $data=$this->code($phone);
  103. return $data;
  104. }
  105. return $data;
  106. }
  107. public function auth_code($phone){
  108. $user=User::where('mobile',$phone)->first();
  109. $code=auth_code($user->id);
  110. return $code;
  111. }
  112. }