OrdersNotice.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Facades\Servers\Aliyun\Sms;
  5. use App\Models\OrdersProduct as Model;
  6. class OrdersNotice extends Command
  7. {
  8. /**
  9. * 任务名称
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'orders_notice';
  14. /**
  15. * 任务描述
  16. *
  17. * @var string
  18. */
  19. protected $description = '订单处理通知';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. // 执行任务
  37. $this->run_task();
  38. return 0;
  39. }
  40. /**
  41. * 执行任务
  42. *
  43. * */
  44. public function run_task(){
  45. // 实例化模型
  46. $Model = new Model();
  47. // 获取三天后到期的优惠券->addDays(3)
  48. $phoneList = $Model->query()
  49. ->join('business','orders_product.business_id','=','business.id')
  50. ->join('admin','business.leader_uid','=','admin.uid')
  51. ->whereIn('orders_product.status',['1','2','3','8','9'])
  52. ->groupBy('admin.phone')
  53. ->limit(1000)
  54. ->pluck('admin.phone')
  55. ->toArray();
  56. // 组合数据
  57. $phoneList = implode(',',$phoneList);
  58. // 给这些手机号发送一条阿里云短信
  59. $result = Sms::sendSms($phoneList,'开邻智数','SMS_478160083');
  60. // 返回结果
  61. return $result;
  62. }
  63. }