|
|
@@ -100,12 +100,17 @@ if (empty($period)){
|
|
|
}
|
|
|
|
|
|
public static function autoPrePerf(){
|
|
|
- $nowTs = 1669778882;//time();
|
|
|
- $currentPeriod = Period::find()->where('START_TIME< :NOW_TIME',['NOW_TIME'=>$nowTs])->where('END_TIME> :NOW_TIME',['NOW_TIME'=>$nowTs])->asArray()->one();
|
|
|
+ $nowTs = time();
|
|
|
+ $currentPeriod = Period::find()->where('START_TIME< :NOW_TIME',['NOW_TIME'=>$nowTs])->where('END_TIME>= :NOW_TIME',['NOW_TIME'=>$nowTs-6])->asArray()->one();
|
|
|
$periodNum = $currentPeriod['PERIOD_NUM'];
|
|
|
|
|
|
- if($nowTs+86400>$currentPeriod['END_TIME'] && !Period::isProcessing($periodNum)){
|
|
|
- print_r("该预结算".PHP_EOL);
|
|
|
+ if($nowTs+86400>$currentPeriod['END_TIME'] ){
|
|
|
+ $nowMin = date("i", $nowTs);
|
|
|
+ $nowSec = date("s", $nowTs);
|
|
|
+ if(($nowMin!=0 || $nowSec >= 5 ) || Period::isProcessing($periodNum)){ // 当不是整点小时,当计算中,不计算
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ print_r("该预结算".$nowMin.PHP_EOL.$nowSec);
|
|
|
//设置计算进行中标识
|
|
|
Period::updatePeriodIsProcessing($periodNum, Period::IS_PROCESSING);
|
|
|
//设置自动计算标识
|
|
|
@@ -115,19 +120,17 @@ if (empty($period)){
|
|
|
$formModel = new PeriodForm();
|
|
|
$formModel->scenario = 'autoPerf';
|
|
|
|
|
|
- if($formModel->load(['PERIOD_NUM'=>$periodNum], '') && $formModel->autoPerf()) {
|
|
|
- echo('自动计算已开始,请等待');
|
|
|
+ if($formModel->load(['periodNum'=>$periodNum], '') && $formModel->autoPrePerf()) {
|
|
|
+ echo('自动计算已开始,请等待'.PHP_EOL);
|
|
|
+ CalcRecord::record($periodNum, '第' . $periodNum . '期,定时计算开始');
|
|
|
} else {
|
|
|
- echo('自动计算未开始');
|
|
|
-// return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
|
|
|
+ echo('自动计算未开始'.PHP_EOL);
|
|
|
+ CalcRecord::record($periodNum, '第' . $periodNum . '期,定时计算未开始');
|
|
|
}
|
|
|
return;
|
|
|
}else{
|
|
|
return;
|
|
|
}
|
|
|
-// if ($nowTs + 432000 <= $currentPeriodEnd || $currentPeriodEnd < $nowTs) {
|
|
|
-// return static::notice(['user' => [],'team'=>[]]);
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
public static function listenAutoPerfPeriod()
|