86 lines
3.3 KiB
PHP
86 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
use app\common\controller\Api;
|
|
/** 定时任务控制器
|
|
* Class Crontab
|
|
* @package addons\shopro\controller
|
|
*/
|
|
class Crontab extends Api
|
|
{
|
|
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedRight = ['*'];
|
|
|
|
/**
|
|
* 每天执行的任务
|
|
*/
|
|
public function day()
|
|
{
|
|
try{
|
|
$res = MockOrder::timeoutCheck(true);
|
|
MockOrder::cleanTodayCarNum(true);
|
|
}catch (\Exception $e){
|
|
$this->error("执行失败:".$e->getMessage());
|
|
}
|
|
$this->success("执行成功:本次取消的模拟单数量【{$res}】");
|
|
}
|
|
|
|
|
|
/**
|
|
* 每五分钟执行的任务
|
|
*/
|
|
public function minute()
|
|
{
|
|
try{
|
|
$lock = new UrlLock(2,"mock-lock-suffix",5,"您的请求过于频繁,请您稍后再试!");
|
|
$lock->lock();
|
|
var_dump("進入時間:".date("Y-m-d H:i:s "));
|
|
sleep(2);
|
|
$lock->free();
|
|
var_dump("釋放時間:".date("Y-m-d H:i:s "));
|
|
// MockOrder::distributionFailSmsNotice(MockOrder::where("id",438)->find());
|
|
//${name},手机号${phone}有${number}圈已被分配到您的${car_number}号车上,请及时查看!
|
|
// $event = "distribution_success";
|
|
//// $event = "distribution_fail";
|
|
// $config = get_addon_config('alisms');
|
|
// $template_id = $config['template'][$event];
|
|
// $res = Smslib::notice(15090180611, ['name'=>"小绿",'phone'=>"15555555555",'number'=>"3",'car_number'=>"22"], $template_id);
|
|
//// $params = [
|
|
//// 'mobile' => 15090180611,
|
|
//// 'msg' => ['name'=>"小明",'phone'=>"15555555555",'number'=>"3",'car_number'=>"22"],
|
|
//// 'template' => "SMS_275410075"
|
|
//// ];
|
|
//// $result = \think\Hook::listen('sms_notice', $params, null, true);
|
|
// var_dump($res);die;
|
|
//
|
|
// //得到返解析的内容
|
|
// $qrcode = new \Zxing\QrReader( cdnurl("/uploads/20221117/f8c6c1ba12938daf9767719fa022d6b8.png",true)); //绝对路径
|
|
// $common_content = $qrcode->decode(); //返回二维码的内容
|
|
|
|
|
|
// $qrcode = new \Zxing\QrReader(cdnurl("/uploads/20221116/ffcf9f4bd725ec49ebb53d97166a486b.png",true)); //二维码图片路径
|
|
// $text = $qrcode->text(); //返回识别后的文本
|
|
// $ids = AppointmentOrder::where("mock_code_url",'not null')->page(1,500)->column("id");
|
|
// $num = count($ids);
|
|
// foreach ($ids as $id) {
|
|
// //取消模拟资格
|
|
// AppointmentOrder::cancelMockCode($id, true);
|
|
// //插入订单日志
|
|
// OrderAction::log($id, "预约订单取消模拟资格,原小票练车码(如果有)作废", "admin", 1);
|
|
// }
|
|
// $qrcode = new QrReader(cdnurl("/uploads/20221117/f8c6c1ba12938daf9767719fa022d6b8.png",true)); //图片路径
|
|
// $text = $qrcode->decode(); //返回识别后的文本
|
|
|
|
// $res = MockOrder::repairOrders(1000,$trans = false);
|
|
|
|
// $sss = Common::getLinkMiniQrCode(29716);
|
|
// var_dump($sss->toArray());die;
|
|
|
|
}catch (\Exception $e){
|
|
$this->error("执行失败:".$e->getMessage());
|
|
}
|
|
$this->success("执行成功条");
|
|
}
|
|
}
|