This commit is contained in:
Default
2025-03-15 20:12:21 +08:00
parent 105ffe11c7
commit eb9035a7ae
134 changed files with 15450 additions and 119 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace app\task\logic;
use app\admin\model\GuangGaoFenZuModel;
use app\admin\model\GuangGaoModel;
use app\admin\model\GuangGaoPeiZhiModel;
use GuzzleHttp\Client;
/**
* @mixin think\Model
*/
class AdTask
{
/**
* Undocumented variable
*
* @var \GuzzleHttp\Client
*/
protected $Client = NULL;
/**
* Undocumented variable
*
* @var \app\task\core\TaskCore
*/
protected $TaskCore = NULL;
protected $arrCaiJiPeiZhi = [];
public function __construct()
{
$this->Client = new Client();
}
public function pullAdBySourceSite()
{
$intOpen = GuangGaoPeiZhiModel::getValByCode('GUANG_GAO_TONG_BU_KAI_GUAN');
if ($intOpen != 1) {
return false;
}
$strUrl = GuangGaoPeiZhiModel::getValByCode('GUANG_GAO_TONG_BU_DI_ZHI');
$strResult = $this->Client->request('GET', $strUrl);
$strResult = (string)$strResult->getBody();
$arrData = json_decode($strResult, true);
if (!is_array($arrData) || empty($arrData)) {
return false;
}
if ($arrData['code'] != 1000) {
return false;
}
GuangGaoModel::where('gg_id', '>', 0)->delete();
GuangGaoFenZuModel::where('ggfz_id', '>', 0)->delete();
GuangGaoFenZuModel::insertAll($arrData['data']['ggfz']);
GuangGaoModel::insertAll($arrData['data']['gg']);
GuangGaoModel::flushCache();
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare (strict_types = 1);
namespace app\task\logic;
use think\Container;
use think\facade\Db;
/**
* @mixin think\Model
*/
class SystemLogic
{
static public function reloadRedis()
{
Container::getInstance()->delete('cache');
}
static public function reloadDb()
{
Db::close();
Container::getInstance()->delete('think\DbManager');
}
static public function destructConnectSource()
{
self::reloadDb();
self::reloadRedis();
}
}