run_task(); return 0; } /** * 执行任务 * * */ public function run_task(){ // 实例化模型 $Model = new Model(); // 获取三天后到期的优惠券->addDays(3) $phoneList = $Model->query() ->join('custom','custom_coupon.custom_uid','=','custom.uid') ->where([['custom_coupon.status','=',0],['custom_coupon.exp_time','>',now()->endOfDay()->getTimestamp()],['custom_coupon.exp_time','<',now()->addDays(2)->endOfDay()->getTimestamp()]]) ->groupBy('custom.phone') ->limit(1000) ->pluck('custom.phone') ->toArray(); // 组合数据 $phoneList = implode(',',$phoneList); // 给这些手机号发送一条阿里云短信 $result = Sms::sendSms($phoneList,'开邻智数','SMS_478125029'); // 返回结果 return $result; } }