Files
crm-server/app/process/Task.php
T

44 lines
1.0 KiB
PHP
Raw Normal View History

2025-03-22 10:26:52 +08:00
<?php
2025-03-22 18:30:38 +08:00
namespace app\process;
2025-03-22 10:26:52 +08:00
use app\controller\FeishuController;
use app\model\Customer;
2025-03-31 14:25:38 +08:00
use app\model\CustomerHis;
2025-03-22 10:26:52 +08:00
use app\model\FeishuUser;
use app\model\User;
2025-03-22 20:08:01 +08:00
use support\Log;
2025-03-22 10:26:52 +08:00
use Webman\App;
use Workerman\Crontab\Crontab;
class Task
{
2025-03-22 18:30:38 +08:00
2025-03-22 10:26:52 +08:00
public function onWorkerStart()
{
2025-03-31 14:25:38 +08:00
// 每小时执行一次
new Crontab('0 10 * * * *', function(){
echo date('Y-m-d H:i:s') . "\n";
Log::info('send high seas start',[time()]);
$where = [
['deleted_at', '<=', time() - 3600],
['user_id', '<>', 0],
];
$customer = Customer::where($where)->onlyTrashed()->get();
foreach ($customer as $item) {
2025-04-01 13:50:46 +08:00
$item->update(['user_id' => 0, 'deleted_at' => time()]);
2025-03-31 14:25:38 +08:00
CustomerHis::create([
'customer_id' => $item->_id,
'user_his' => $item->user_id,
'user_id' => 0,
]);
}
2025-04-01 13:50:46 +08:00
Log::info('send high seas end',[time()]);
2025-03-31 14:25:38 +08:00
});
2025-03-22 10:26:52 +08:00
}
}