This commit is contained in:
2026-01-29 11:34:32 +08:00
parent e5afa43198
commit 7ecbb660d5
2 changed files with 159 additions and 198 deletions
+25
View File
@@ -3,6 +3,9 @@
namespace app\process;
use app\common\model\UsedCar;
use app\common\model\WordpressSite;
use app\common\model\WordpressUsedCar;
use app\common\service\WordpressSiteService;
use support\Db;
use support\Log;
use Workerman\Crontab\Crontab;
@@ -36,6 +39,28 @@ class Task
});
if (getenv('ENVIRONMENT') === 'master') {
// 每三个小时自动归档
new Crontab('0 0 3 * * *', function(){
$sites = WordpressSite::where('status', 1)
->get();
foreach ($sites as $site) {
$used_car_id = WordpressUsedCar::where('wp_site_id', $site['id'])
->where('status', 1)
->max('used_car_id');
$used_cars = Db::table('used_car')
->where('id', '>', $used_car_id)
->get();
foreach ($used_cars as $car) {
WordpressSiteService::createProduct($site['site_url'], $car['id']);
}
}
});
}
}
}