575 lines
25 KiB
PHP
575 lines
25 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Score extends HD_Controller
|
|
{
|
|
private $log_dir = 'receiver_score';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('receiver/receiver_score_log_model');
|
|
$this->load->model('receiver/receiver_score_config_model');
|
|
$this->load->model('app/licheb/app_licheb_users_model');
|
|
$this->load->library('receiver/score_entity');
|
|
$this->load->model('receiver/receiver_score_day_model');
|
|
$this->load->model('receiver/receiver_score_month_model');
|
|
$this->load->model('receiver/receiver_score_avg_day_model');
|
|
$this->load->model("biz/biz_model");
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$biz_id = $this->input->get('biz_id');
|
|
$uid = $this->input->get('uid');
|
|
$getPage = $this->input->get('page');
|
|
$t_limit = $this->input->get('time_limit');
|
|
$h = date('H');
|
|
if (!$t_limit && $h > 5) {
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_PLAN_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 20;
|
|
$groups_string = implode(',', [App_licheb_users_model::GROUP_BIZ, App_licheb_users_model::GROUP_MANAGER]);
|
|
$where = [
|
|
"group_id in ({$groups_string})" => null,
|
|
'status' => 1
|
|
];
|
|
$biz_id && $where['biz_id'] = $biz_id;
|
|
$uid && $where['id'] = $uid;
|
|
$rows = $this->app_licheb_users_model->select($where, "id desc", $page, $size, 'id, uname, biz_id, group_id');
|
|
if ($rows) {
|
|
$day = date('Y-m-d', strtotime("-1 day"));
|
|
foreach ($rows as $item) {
|
|
$result = Score_entity::init($day, $item['id'], $item['group_id'], $item['biz_id']);
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
} else {
|
|
$msg = '执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
//每日统计
|
|
public function scoreDay()
|
|
{
|
|
$t_limit = $this->input->get('time_limit');
|
|
$h = date('H');
|
|
if (!$t_limit && $h > 5) {
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$getPage = $this->input->get('page');
|
|
$day = date('Y-m-d', strtotime("-1 day"));
|
|
$scoreLogModel = new Receiver_score_log_model();
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_DAY_USER_PLAN_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$where = [
|
|
'day' => $day,
|
|
];
|
|
$rows = $scoreLogModel->select($where, "id desc", $page, $size, 'DISTINCT biz_id,uid,day');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'uid' => $item['uid'],
|
|
'day' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$scoreDayRow = $receiverScoreDayModel->get($where);
|
|
$scoreSum = $scoreLogModel->sum('score', ['uid' => $item['uid'], 'day' => $day]);
|
|
$score = $scoreSum ? $scoreSum['score'] : 0;
|
|
//获取上一天数据
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'uid' => $item['uid'],
|
|
'day<' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$dayRow = $receiverScoreDayModel->select($where, 'day desc', 1, 1, 'score');
|
|
$change_score = $dayRow[0]['score'] ? $score - $dayRow[0]['score'] : $score;
|
|
if ($scoreDayRow) {
|
|
$receiverScoreDayModel->update(['score' => $score, 'change_score' => $change_score], ['id' => $scoreDayRow['id']]);
|
|
} else {
|
|
$biz = $this->biz_model->get(['id' => $item['biz_id']]);
|
|
$addData = [
|
|
'biz_id' => $item['biz_id'], 'uid' => $item['uid'],
|
|
'score' => $score, 'day' => $day, 'type' => Receiver_score_day_model::TYPE_USER,
|
|
'change_score' => $change_score, 'c_time' => time(),
|
|
'province_id' => $biz['province_id'] ?: 0,
|
|
];
|
|
$receiverScoreDayModel->add($addData);
|
|
}
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
} else { //合并门店数据
|
|
$finishCacheKey = "RECEIVER_SCORE_DAY_USER_FINISH";
|
|
if ($redis->get($finishCacheKey)) {
|
|
$msg = '用户合并统计数据执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
echo "开始执行店铺合并数据";
|
|
$redis->set($finishCacheKey, 1, 6 * 60 * 60);
|
|
}
|
|
$this->scoreBizDay($day);
|
|
}
|
|
}
|
|
|
|
public function scoreBizDay($day)
|
|
{
|
|
$getPage = $this->input->get('biz_page');
|
|
!$day && $day = date('Y-m-d', strtotime("-1 day"));
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_DAY_BIZ_PLAN_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$where = [
|
|
'day' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$rows = $receiverScoreDayModel->select($where, "id desc", $page, $size, 'DISTINCT biz_id,day');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'day' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$scoreDayRow = $receiverScoreDayModel->get($where);
|
|
$total_num = $receiverScoreDayModel->count(['biz_id' => $item['biz_id'], 'day' => $day]);
|
|
$scoreSum = $receiverScoreDayModel->sum('score', ['biz_id' => $item['biz_id'], 'day' => $day]);
|
|
$total_score = $scoreSum ? $scoreSum['score'] : 0;
|
|
$score = $total_num > 0 ? $total_score / $total_num : 0;
|
|
//获取上一天数据
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'day<' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$dayRow = $receiverScoreDayModel->select($where, 'day desc', 1, 1, 'score');
|
|
$change_score = $dayRow[0]['score'] ? $score - $dayRow[0]['score'] : $score;
|
|
if ($scoreDayRow) {
|
|
$receiverScoreDayModel->update([
|
|
'score' => $score, 'total_score' => $total_score,
|
|
'total_num' => $total_num, 'change_score' => $change_score
|
|
], ['id' => $scoreDayRow['id']]);
|
|
} else {
|
|
$biz = $this->biz_model->get(['id' => $item['biz_id']]);
|
|
$addData = [
|
|
'biz_id' => $item['biz_id'],
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'day' => $day,
|
|
'type' => Receiver_score_day_model::TYPE_BIZ,
|
|
'change_score' => $change_score, 'c_time' => time(),
|
|
'province_id' => $biz['province_id'] ?: 0,
|
|
];
|
|
$receiverScoreDayModel->add($addData);
|
|
}
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
} else {
|
|
$msg = '店铺合并统计数据执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
public function mergeUser()
|
|
{
|
|
$t_limit = $this->input->get('time_limit');
|
|
$m = date('d');
|
|
if (!$t_limit && $m != 1) { //每月1号执行
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$getPage = $this->input->get('page');
|
|
$year = date('Y', strtotime('last month'));
|
|
$month = date('m', strtotime('last month'));
|
|
$firstDayOfLastMonth = date('Y-m-01', strtotime('last month'));
|
|
$lastDayOfLastMonth = date('Y-m-t', strtotime('last month'));
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_MONTH_PLAN_USER_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$receiverScoreMonthModel = new Receiver_score_month_model();
|
|
$where = [
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
];
|
|
$rows = $receiverScoreDayModel->select($where, '', $page, $size, 'DISTINCT biz_id,uid,province_id');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$total_sum = $receiverScoreDayModel->sum('score', [
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'uid' => $item['uid'],
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
]);
|
|
$total_score = $total_sum['score'] ? $total_sum['score'] : 0;
|
|
$total_num = $receiverScoreDayModel->count([
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'uid' => $item['uid'],
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
]);
|
|
$score = $total_num > 0 ? $total_score / $total_num : 0;
|
|
$where = [
|
|
'uid' => $item['uid'],
|
|
'year' => $year,
|
|
'month' => $month,
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$monthRow = $receiverScoreMonthModel->get($where);
|
|
//获取上一个月数据
|
|
$where = [
|
|
'uid' => $item['uid'],
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$monthRow && $where['id<'] = $monthRow['id'];
|
|
$lastRow = $receiverScoreMonthModel->select($where, 'c_time desc', 1, 1, 'score');
|
|
$change_score = $lastRow[0]['score'] ? $score - $lastRow[0]['score'] : $score;
|
|
if ($monthRow) {
|
|
$update = [
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
];
|
|
$receiverScoreMonthModel->update($update, ['id' => $monthRow['id']]);
|
|
} else {
|
|
$add = [
|
|
'biz_id' => $item['biz_id'],
|
|
'uid' => $item['uid'],
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
'year' => $year,
|
|
'month' => $month,
|
|
'type' => Receiver_score_month_model::TYPE_USER,
|
|
'province_id' => $item['province_id'],
|
|
'c_time' => time(),
|
|
];
|
|
$receiverScoreMonthModel->add($add);
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
}
|
|
} else {
|
|
$msg = '执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
public function mergeBiz()
|
|
{
|
|
$t_limit = $this->input->get('time_limit');
|
|
$m = date('d');
|
|
if (!$t_limit && $m != 1) { //每月1号执行
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$getPage = $this->input->get('page');
|
|
$year = date('Y', strtotime('last month'));
|
|
$month = date('m', strtotime('last month'));
|
|
$firstDayOfLastMonth = date('Y-m-01', strtotime('last month'));
|
|
$lastDayOfLastMonth = date('Y-m-t', strtotime('last month'));
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_MONTH_PLAN_BIZ_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$receiverScoreMonthModel = new Receiver_score_month_model();
|
|
$where = [
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
];
|
|
$rows = $receiverScoreDayModel->select($where, '', $page, $size, 'DISTINCT biz_id,province_id');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$total_sum = $receiverScoreDayModel->sum('score', [
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'biz_id' => $item['biz_id'],
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
]);
|
|
$total_score = $total_sum['score'] ? $total_sum['score'] : 0;
|
|
$total_num = $receiverScoreDayModel->count([
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'biz_id' => $item['biz_id'],
|
|
'day>=' => $firstDayOfLastMonth,
|
|
'day<=' => $lastDayOfLastMonth,
|
|
]);
|
|
$score = $total_num > 0 ? $total_score / $total_num : 0;
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'year' => $year,
|
|
'month' => $month,
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$monthRow = $receiverScoreMonthModel->get($where);
|
|
//获取上一个月数据
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$monthRow && $where['id<'] = $monthRow['id'];
|
|
$lastRow = $receiverScoreMonthModel->select($where, 'c_time desc', 1, 1, 'score');
|
|
$change_score = $lastRow[0]['score'] ? $score - $lastRow[0]['score'] : $score;
|
|
if ($monthRow) {
|
|
$update = [
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
];
|
|
$receiverScoreMonthModel->update($update, ['id' => $monthRow['id']]);
|
|
} else {
|
|
$add = [
|
|
'biz_id' => $item['biz_id'],
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
'year' => $year,
|
|
'month' => $month,
|
|
'type' => Receiver_score_month_model::TYPE_BIZ,
|
|
'province_id' => $item['province_id'],
|
|
'c_time' => time(),
|
|
];
|
|
$receiverScoreMonthModel->add($add);
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
}
|
|
} else {
|
|
$msg = '执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
public function mergeAvgUser()
|
|
{
|
|
$t_limit = $this->input->get('time_limit');
|
|
$h = date('H');
|
|
if (!$t_limit && $h > 5) {
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$getPage = $this->input->get('page');
|
|
$s_time = date('Y-m-01');
|
|
$e_time = date('Y-m-t');
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_AGV_PLAN_USER_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$receiverScoreAvgDayModel = new Receiver_score_avg_day_model();
|
|
$where = [
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
];
|
|
$rows = $receiverScoreDayModel->select($where, '', $page, $size, 'DISTINCT biz_id,uid,province_id');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$total_sum = $receiverScoreDayModel->sum('score', [
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'uid' => $item['uid'],
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
]);
|
|
$total_score = $total_sum['score'] ? $total_sum['score'] : 0;
|
|
$total_num = $receiverScoreDayModel->count([
|
|
'type' => $receiverScoreDayModel::TYPE_USER,
|
|
'uid' => $item['uid'],
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
]);
|
|
$score = $total_num > 0 ? $total_score / $total_num : 0;
|
|
$where = [
|
|
'uid' => $item['uid'],
|
|
'day' => date('Y-m-d'),
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$monthRow = $receiverScoreAvgDayModel->get($where);
|
|
//获取最后一条数据
|
|
$where = [
|
|
'uid' => $item['uid'],
|
|
'type' => Receiver_score_day_model::TYPE_USER
|
|
];
|
|
$monthRow && $where['id<'] = $monthRow['id'];
|
|
$lastRow = $receiverScoreAvgDayModel->select($where, 'c_time desc', 1, 1, 'score');
|
|
$change_score = $lastRow[0]['score'] ? $score - $lastRow[0]['score'] : $score;
|
|
if ($monthRow) {
|
|
$update = [
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
];
|
|
$receiverScoreAvgDayModel->update($update, ['id' => $monthRow['id']]);
|
|
} else {
|
|
$add = [
|
|
'biz_id' => $item['biz_id'],
|
|
'uid' => $item['uid'],
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
'day' => date('Y-m-d'),
|
|
'type' => Receiver_score_month_model::TYPE_USER,
|
|
'province_id' => $item['province_id'],
|
|
'c_time' => time(),
|
|
];
|
|
$receiverScoreAvgDayModel->add($add);
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
}
|
|
} else {
|
|
$msg = '执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
public function mergeAvgBiz()
|
|
{
|
|
$t_limit = $this->input->get('time_limit');
|
|
$h = date('H');
|
|
if (!$t_limit && $h > 5) {
|
|
echo '当前时间段不可执行';
|
|
exit;
|
|
}
|
|
$getPage = $this->input->get('page');
|
|
$s_time = date('Y-m-01');
|
|
$e_time = date('Y-m-t');
|
|
$redis = &load_cache('redis');
|
|
$pageCacheKey = "RECEIVER_SCORE_AGV_PLAN_BIZ_PAGE";
|
|
if ($getPage) {
|
|
$page = $getPage;
|
|
} else {
|
|
$page = $redis->get($pageCacheKey) ?: 1;
|
|
}
|
|
$size = 50;
|
|
$receiverScoreDayModel = new Receiver_score_day_model();
|
|
$receiverScoreAvgDayModel = new Receiver_score_avg_day_model();
|
|
$where = [
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
];
|
|
$rows = $receiverScoreDayModel->select($where, '', $page, $size, 'DISTINCT biz_id,province_id');
|
|
if ($rows) {
|
|
foreach ($rows as $item) {
|
|
$total_sum = $receiverScoreDayModel->sum('score', [
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'biz_id' => $item['biz_id'],
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
]);
|
|
$total_score = $total_sum['score'] ? $total_sum['score'] : 0;
|
|
$total_num = $receiverScoreDayModel->count([
|
|
'type' => $receiverScoreDayModel::TYPE_BIZ,
|
|
'biz_id' => $item['biz_id'],
|
|
'day>=' => $s_time,
|
|
'day<=' => $e_time,
|
|
]);
|
|
$score = $total_num > 0 ? $total_score / $total_num : 0;
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'day' => date('Y-m-d'),
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$monthRow = $receiverScoreAvgDayModel->get($where);
|
|
//获取上一个月数据
|
|
$where = [
|
|
'biz_id' => $item['biz_id'],
|
|
'type' => Receiver_score_day_model::TYPE_BIZ
|
|
];
|
|
$monthRow && $where['id<'] = $monthRow['id'];
|
|
$lastRow = $receiverScoreAvgDayModel->select($where, 'c_time desc', 1, 1, 'score');
|
|
$change_score = $lastRow[0]['score'] ? $score - $lastRow[0]['score'] : $score;
|
|
if ($monthRow) {
|
|
$update = [
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
];
|
|
$receiverScoreAvgDayModel->update($update, ['id' => $monthRow['id']]);
|
|
} else {
|
|
$add = [
|
|
'biz_id' => $item['biz_id'],
|
|
'score' => $score,
|
|
'total_score' => $total_score,
|
|
'total_num' => $total_num,
|
|
'change_score' => $change_score,
|
|
'day' => date('Y-m-d'),
|
|
'type' => Receiver_score_month_model::TYPE_BIZ,
|
|
'province_id' => $item['province_id'],
|
|
'c_time' => time(),
|
|
];
|
|
$receiverScoreAvgDayModel->add($add);
|
|
}
|
|
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
|
|
$page++;
|
|
$redis->save($pageCacheKey, $page, 60 * 60);
|
|
}
|
|
} else {
|
|
$msg = '执行完成';
|
|
echo $msg;
|
|
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
|
|
}
|
|
}
|
|
|
|
} |