推送
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user