修改私域专题报名同步
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Sytopic extends CI_Controller
|
||||
{
|
||||
private $log_file = 'plan_sytopic.log';
|
||||
private $log_dir = 'market/sytopic';
|
||||
private $options;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('market/Market_sytopic_enroll_model', 'sytopic_enroll_model');
|
||||
$this->load->library("ssApi");
|
||||
}
|
||||
|
||||
//同步私域报名状态
|
||||
public function synEnroll()
|
||||
{
|
||||
$getPage = $this->input->get('page');
|
||||
$redis = &load_cache('redis');
|
||||
$pageCacheKey = "SYTOPIC_SYN_ENROLL_PAGE";
|
||||
if ($getPage) {
|
||||
$page = $getPage;
|
||||
} else {
|
||||
$page = $redis->get($pageCacheKey) ?: 1;
|
||||
}
|
||||
$size = 500;
|
||||
$enrollModel = new Market_sytopic_enroll_model();
|
||||
$enrollDeal = $enrollModel::ENROLL_DEAL_PUSH_CLUE . ',' . $enrollModel::ENROLL_DEAL_PUSH_CUSTOMER;
|
||||
$where = [
|
||||
"enrollDeal in ({$enrollDeal})" => null,
|
||||
"status!=" => $enrollModel::STATUS_INVALID,
|
||||
];
|
||||
$rows = $this->sytopic_enroll_model->select($where, 'id asc', $page, $size, 'id');
|
||||
if ($rows) {
|
||||
$ids = array_column($rows, 'id');
|
||||
$ssApi = new SsApi();
|
||||
$stringIds = implode(',', $ids);
|
||||
debug_log("开始同步,第{$page}页:" . $stringIds, $this->log_file, $this->log_dir);
|
||||
$data = $ssApi->getStatus($stringIds);
|
||||
debug_log("返回结果:" . json_encode($data, JSON_UNESCAPED_UNICODE), $this->log_file, $this->log_dir);
|
||||
if ($data['lists']) {
|
||||
foreach ($data['lists'] as $key => $val) {
|
||||
$this->sytopic_enroll_model->update(['status' => $val['status'], 'status2' => $val['status2']], ['id' => $val['out_id']]);
|
||||
}
|
||||
}
|
||||
$page++;
|
||||
debug_log("同步结束,执行下一页:" . $page, $this->log_file, $this->log_dir);
|
||||
$redis->save($pageCacheKey, $page, 24 * 60 * 60);
|
||||
} else {
|
||||
$redis->delete($pageCacheKey);
|
||||
debug_log("执行结束", $this->log_file, $this->log_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user