Kernel.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\Events\RegisterApplyEvent;
  7. use App\Http\Controllers\QYInfo\QYInfoController;
  8. use App\Models\Address;
  9. use App\Models\Ordertest;
  10. use App\Models\Store;
  11. use App\Models\User;
  12. use Carbon\Carbon;
  13. use Illuminate\Console\Scheduling\Schedule;
  14. use Illuminate\Support\Facades\DB;
  15. use Laravel\Lumen\Console\Kernel as ConsoleKernel;
  16. use Illuminate\Support\Facades\Log;
  17. use mysql_xdevapi\Exception;
  18. use Qiniu\Auth as Auths;
  19. use Qiniu\Storage\UploadManager;
  20. use Qiniu\Storage\BucketManager;
  21. class Kernel extends ConsoleKernel
  22. {
  23. /**
  24. * The Artisan commands provided by your application.
  25. *
  26. * @var array
  27. */
  28. protected $commands = [
  29. ];
  30. /**
  31. * Define the application's command schedule.
  32. *
  33. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  34. * @return void
  35. */
  36. protected function schedule(Schedule $schedule)
  37. {
  38. //没审核的3天后提醒一次
  39. $schedule->call(function (){
  40. $dayTime1=date("Y-m-d 00:00:00",strtotime("-3 days"));
  41. $dayTime2=date("Y-m-d 23:59:59",strtotime("-3 days"));
  42. $users = User::where('cert_status',2)->whereBetween('created_at',[$dayTime1,$dayTime2])->get();
  43. foreach($users as $key=>$val){
  44. $agent=User::where('id',$val->agent_id)->first();
  45. if($agent->openid){
  46. Log::info('-----'.$val->mobile.'------审核提醒1-----------'.$agent->openid);
  47. $mes['openid']=$agent->openid;
  48. $mes['data']=[
  49. 'first' => '注册信息已提交,请您及时审核',
  50. 'keyword1' => $val->nickname,
  51. 'keyword2' => $val->mobile,
  52. 'keyword3' => date("Y-m-d H:i"),
  53. 'remark' => '点击链接进入系统,查看详情',
  54. ];
  55. event(new RegisterApplyEvent($mes));
  56. }
  57. }
  58. })->dailyAt('10:00');
  59. }
  60. public function code($phone){
  61. $data=code($phone);
  62. $re=DB::table('users')->where('recom_code',$data)->first();
  63. if ($re){
  64. $data=$this->code($phone);
  65. return $data;
  66. }
  67. return $data;
  68. }
  69. public function auth_code($phone){
  70. $code_1=str_pad(random_int(1, 999), 3, 0, STR_PAD_LEFT);
  71. $code_2=mb_substr($phone,1,3);
  72. $code_3=str_pad(random_int(100, 99999), 6, 0, STR_PAD_LEFT);
  73. $code_4=mb_substr(time(),8,2);
  74. $code='DWBS00'.$code_1.date('ymd',time()).$code_2.$code_3.$code_4;
  75. $re=DB::table('users')->where('auth_code',$code)->first();
  76. if ($re){
  77. $code=$this->auth_code($phone);
  78. return $code;
  79. }
  80. return $code;
  81. }
  82. }