1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Facades\Servers\Aliyun\Sms;
- use App\Models\OrdersProduct as Model;
- class OrdersNotice extends Command
- {
- /**
- * 任务名称
- *
- * @var string
- */
- protected $signature = 'orders_notice';
- /**
- * 任务描述
- *
- * @var string
- */
- protected $description = '订单处理通知';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- // 执行任务
- $this->run_task();
- return 0;
- }
- /**
- * 执行任务
- *
- * */
- public function run_task(){
- // 实例化模型
- $Model = new Model();
- // 获取三天后到期的优惠券->addDays(3)
- $phoneList = $Model->query()
- ->join('business','orders_product.business_id','=','business.id')
- ->join('admin','business.leader_uid','=','admin.uid')
- ->whereIn('orders_product.status',['1','2','3','8','9'])
- ->groupBy('admin.phone')
- ->limit(1000)
- ->pluck('admin.phone')
- ->toArray();
- // 组合数据
- $phoneList = implode(',',$phoneList);
- // 给这些手机号发送一条阿里云短信
- $result = $phoneList ? Sms::sendSms($phoneList,'开邻智数','SMS_478160083') : [];
- // 返回结果
- return $result;
- }
- }
|