Files
crm-server/app/process/Task.php
T
2025-07-25 15:31:30 +08:00

44 lines
1.0 KiB
PHP

<?php
namespace app\process;
use app\controller\FeishuController;
use app\model\Customer;
use app\model\CustomerHis;
use app\model\FeishuUser;
use app\model\User;
use support\Log;
use Webman\App;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
// 每小时执行一次
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) {
$item->update(['user_id' => 0, 'deleted_at' => time()]);
CustomerHis::create([
'customer_id' => $item->_id,
'user_his' => $item->user_id,
'user_id' => 0,
]);
}
Log::info('send high seas end',[time()]);
});
}
}