TipWithdrawDays.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Events\TipSend as TipSends;
  4. use App\Models\Agent\AgentOperationLog;
  5. use App\Http\Controllers\Admin\StoreController as Sc;
  6. use App\Models\Order;
  7. use App\Models\OrderW;
  8. use App\Models\Store;
  9. use App\Models\TipWithdraw;
  10. use App\Models\User;
  11. use App\Models\DwbsUser;
  12. use Carbon\Carbon;
  13. use Illuminate\Console\Command;
  14. use Illuminate\Support\Facades\Cache;
  15. use Illuminate\Support\Facades\Log;
  16. use Illuminate\Support\Facades\DB;
  17. use Overtrue\EasySms\EasySms;
  18. class TipWithdrawDays extends Command
  19. {
  20. /**
  21. * The name and signature of the console command.
  22. *
  23. * @var string
  24. */
  25. protected $signature = 'tip_withdraw_days';
  26. /**
  27. * The console command description.
  28. *
  29. * @var string
  30. */
  31. protected $description = '提醒提现7日';
  32. /**
  33. * Create a new command instance.
  34. *
  35. * @return void
  36. */
  37. public function __construct()
  38. {
  39. parent::__construct();
  40. }
  41. /**
  42. * Execute the console command.
  43. *
  44. * @return mixed
  45. */
  46. public function handle()
  47. {
  48. Log::info('7日后提示提现发送短信');
  49. $tips=TipWithdraw::whereDate('send_at',Carbon::now()->subDays(7))->get();
  50. foreach($tips as $key=>$val){
  51. $store=Store::withTrashed()->where('is_failure',0)->where('user_id',$val->user_id)->first();
  52. if($store){
  53. $total = Order::where('store_id',$store->id)->where('status','<','3')->where('is_pay',1)->whereIn('apply_cancel',[0,1,3])->count();
  54. }else{
  55. $total = 0;
  56. }
  57. $sc=new Sc();
  58. $result=$sc->getAccount($val->user_id);
  59. $account=$result['pending_amount']+$result['available_amount'];
  60. if($account > 0 || $total > 0){
  61. TipWithdraw::where('id',$val->id)->update([
  62. 'send_at'=>Carbon::now(),
  63. 'num'=>$val->num++,
  64. ]);
  65. $phone=DwbsUser::withTrashed()->where('id',$val->user_id)->value('mobile');
  66. $config=config('easysms');
  67. $easySms = new EasySms($config);
  68. $content="您的微店铺账号已被删除,请及时处理订单,并完成提现。点击链接进入微店铺 https://dllzff.cn/U1oTQeNj 如已处理请忽略。";
  69. try{
  70. $easySms->send($phone, ['content' =>$content ]);
  71. Log::info('短信发送成功');
  72. } catch (\Overtrue\EasySms\Exceptions\NoGatewayAvailableException $exception) {
  73. $message = $exception->getException('qcloud')->getMessage();
  74. Log::info($message);
  75. }
  76. }else{
  77. TipWithdraw::where('id',$val->id)->delete();
  78. }
  79. }
  80. }
  81. }