Kernel.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. namespace App\Console;
  3. use App\Console\Commands\ReceivedGoods;
  4. use App\Handlers\ProfitSharing;
  5. use App\Handlers\TradeBill;
  6. use App\Handlers\EcommerceBillHandler;
  7. use App\Models\Address;
  8. use App\Models\AgentNo;
  9. use App\Models\DwbsUser;
  10. use App\Models\Store;
  11. use App\Models\User;
  12. use Illuminate\Console\Scheduling\Schedule;
  13. use Illuminate\Support\Facades\Crypt;
  14. use Illuminate\Support\Facades\Log;
  15. use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  16. class Kernel extends ConsoleKernel
  17. {
  18. /**
  19. * The Artisan commands provided by your application.
  20. *
  21. * @var array
  22. */
  23. protected $commands = [
  24. ReceivedGoods::class,
  25. ];
  26. /**
  27. * Define the application's command schedule.
  28. *
  29. * @param \Illuminate\Console\Scheduling\Schedule $schedule
  30. * @return void
  31. */
  32. protected function schedule(Schedule $schedule)
  33. {
  34. // $schedule->command('tip_send')->withoutOverlapping()->hourly();
  35. // $schedule->command('received_goods')->withoutOverlapping()->everyMinute();
  36. // $schedule->command('withdraw_correction_two')->withoutOverlapping()->hourly();
  37. // $schedule->command('withdraw_correction_three')->withoutOverlapping()->hourly();//->dailyAt('10:00');//
  38. // $schedule->command('withdraw_correction_five')->withoutOverlapping()->twiceDaily(10, 16);//->dailyAt('10:00');
  39. // $schedule->command('withdraw_correction_eight')->withoutOverlapping()->dailyAt('11:00');//->everyMinute();
  40. // $schedule->command('tip_withdraw')->withoutOverlapping()->everyMinute();
  41. // $schedule->command('tip_withdraw_days')->withoutOverlapping()->dailyAt('15:00');
  42. // $schedule->command('fifteen_no_finish')->withoutOverlapping()->dailyAt('10:00');
  43. // $schedule->command('finished_order')->withoutOverlapping()->everyMinute();
  44. $schedule->call(function (){
  45. Log::error('开始处理手机号');
  46. $user=Address::where('id','>','672081')->whereNull('phone_code')->get();
  47. foreach ($user as $k=>$v){
  48. if ($v->phone){
  49. $phone_code=Crypt::encryptString($v->phone);
  50. $phone=mb_substr($v->phone,0,3).'****'.mb_substr($v->phone,'-4');
  51. }else{
  52. $phone=null;
  53. }
  54. if ($v->address){
  55. $address_code=Crypt::encryptString($v->address);
  56. $address='********';
  57. }else{
  58. $address=null;
  59. }
  60. Address::where('id',$v->id)->update([
  61. 'phone'=>$phone,
  62. 'address'=>$address,
  63. 'phone_code'=>$phone_code,
  64. 'address_code'=>$address_code,
  65. ]);
  66. }
  67. Log::error('结束处理手机号');
  68. })->hourly();
  69. $schedule->call(function (){
  70. Log::error('开始处理手机号');
  71. $user=User::where('id','>','909982')->whereNotNull('phone')->whereNull('phone_code')->get();
  72. foreach ($user as $k=>$v){
  73. if ($v->phone){
  74. $phone_code=Crypt::encryptString($v->phone);
  75. $phone=mb_substr($v->phone,0,3).'****'.mb_substr($v->phone,'-4');
  76. }else{
  77. $phone=null;
  78. }
  79. User::where('id',$v->id)->update([
  80. 'phone'=>$phone,
  81. 'phone_code'=>$phone_code,
  82. ]);
  83. }
  84. Log::error('结束处理手机号');
  85. })->hourly();
  86. $schedule->call(function (){
  87. Log::error('开始处理手机号');
  88. $user=AgentNo::whereNotNull('phone')->whereNull('phone_code')->get();
  89. foreach ($user as $k=>$v){
  90. if ($v->phone){
  91. $phone_code=Crypt::encryptString($v->phone);
  92. $phone=mb_substr($v->phone,0,3).'****'.mb_substr($v->phone,'-4');
  93. }else{
  94. $phone=null;
  95. }
  96. AgentNo::where('id',$v->id)->update([
  97. 'phone'=>$phone,
  98. 'phone_code'=>$phone_code,
  99. ]);
  100. }
  101. Log::error('结束处理手机号');
  102. })->hourly();
  103. $schedule->call(function (){
  104. $date= date("Y-m-d",strtotime("-1 day"));
  105. Log::info('下载二级商户资金账单,日期:'.$date);
  106. $eco = new EcommerceBillHandler();
  107. $eco -> getecommercebill($date,'ALL','AEAD_AES_256_GCM');
  108. })->dailyAt('11:00');
  109. // $schedule->call(function (){
  110. // $date= date("Y-m-d",strtotime("-1 day"));
  111. // $trade = new TradeBill();
  112. // $trade -> getDownWithdraw($date);
  113. // })->dailyAt('15:00');
  114. //
  115. // $schedule->call(function (){
  116. // $date= date("Y-m-d",strtotime("-1 day"));
  117. // $trade = new ProfitSharing();
  118. // $trade -> getprofitsharing($date);
  119. // })->dailyAt('15:00');
  120. $schedule->call(function (){
  121. $store=Store::where('is_apply',3)->get();
  122. foreach ($store as $k=>$v){
  123. DwbsUser::where('id',$v->user_id)->update(['province'=>$v->province,'city'=>$v->city,'country'=>$v->area,'address'=>$v->address]);
  124. }
  125. Log::error('地址同步结束');
  126. })->dailyAt('16:15');
  127. }
  128. /**
  129. * Register the commands for the application.
  130. *
  131. * @return void
  132. */
  133. protected function commands()
  134. {
  135. $this->load(__DIR__.'/Commands');
  136. require base_path('routes/console.php');
  137. }
  138. }