updateOneDayRechargeInfo(); $this->updateThreeDayRechargeInfo(); } public function updateOneDayRechargeInfo() { $start_time = $date = date('Y-m-d H:i:s', strtotime('-1 day')); $params = ['is_one_day' => 1, 'start_time' => $start_time]; $info = MediaPushDetailRecord::getUnUpdatedInfos($params); $officialChargeAmountArray = []; foreach ($info as $item) { $push_time = $item->push_time; $promotion_id = $item->promotion_id; $end_time = date('Y-m-d H:i:s', strtotime($item->push_time) + 86400); $params = ['start_time' => $push_time, 'end_time' => $end_time, 'promotion_id' => $promotion_id];; $recharge_in_one_day = OrderParam::getChargeAmount($params); $item->recharge_in_one_day = $recharge_in_one_day; $item->save(); //更新dayStats表 $appid = $item->appid; $date = date('Y-m-d', strtotime($item->push_time)); if (isset($officialChargeAmountArray[$date][$appid])) { $officialChargeAmountArray[$date][$appid] = $officialChargeAmountArray[$date][$appid] + $recharge_in_one_day; } else { $officialChargeAmountArray[$date][$appid] = $recharge_in_one_day; } } foreach ($officialChargeAmountArray as $k => $v) { foreach ($v as $index => $value) { $date = $k; $appid = $index; $recharge_in_one_day = $value; $mediaPushDayInfo = MediaPushDayStats::getByAppidAndDate($appid, $date); if ($mediaPushDayInfo) { if (empty($mediaPushDayInfo->recharge_in_one_day)) { $mediaPushDayInfo->recharge_in_one_day = $recharge_in_one_day; } else { $mediaPushDayInfo->recharge_in_one_day += $recharge_in_one_day; } $mediaPushDayInfo->save(); } } } } public function updateThreeDayRechargeInfo() { $start_time = $date = date('Y-m-d H:i:s', strtotime('-3 day')); $params = ['is_three_day' => 1, 'start_time' => $start_time]; $info = MediaPushDetailRecord::getUnUpdatedInfos($params); $officialChargeAmountArray = []; foreach ($info as $item) { $push_time = $item->push_time; $promotion_id = $item->promotion_id; $end_time = date('Y-m-d H:i:s', strtotime($item->push_time) + 3 * 86400); $params = ['start_time' => $push_time, 'end_time' => $end_time, 'promotion_id' => $promotion_id];; $recharge_in_three_days = OrderParam::getChargeAmount($params); $item->recharge_in_three_days = $recharge_in_three_days; $item->save(); //更新dayStats表 $appid = $item->appid; $date = date('Y-m-d', strtotime($item->push_time)); if (isset($officialChargeAmountArray[$date][$appid])) { $officialChargeAmountArray[$date][$appid] = $officialChargeAmountArray[$date][$appid] + $recharge_in_three_days; } else { $officialChargeAmountArray[$date][$appid] = $recharge_in_three_days; } } foreach ($officialChargeAmountArray as $k => $v) { foreach ($v as $index => $value) { $date = $k; $appid = $index; $recharge_in_three_days = $value; $mediaPushDayInfo = MediaPushDayStats::getByAppidAndDate($appid, $date); if ($mediaPushDayInfo) { if (empty($mediaPushDayInfo->recharge_in_three_days)) { $mediaPushDayInfo->recharge_in_three_days = $recharge_in_three_days; } else { $mediaPushDayInfo->recharge_in_three_days = $mediaPushDayInfo->recharge_in_three_days + $recharge_in_three_days; } $mediaPushDayInfo->save(); } } } } }