|
|
@@ -3,8 +3,11 @@
|
|
|
namespace common\helpers\bonus\Calc;
|
|
|
|
|
|
|
|
|
+use common\helpers\Form;
|
|
|
use common\models\CalcRecord;
|
|
|
+use common\models\forms\PeriodForm;
|
|
|
use common\models\Period;
|
|
|
+use Yii;
|
|
|
|
|
|
class CalcConsole extends BaseBusiness
|
|
|
{
|
|
|
@@ -96,6 +99,37 @@ if (empty($period)){
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ 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();
|
|
|
+ $periodNum = $currentPeriod['PERIOD_NUM'];
|
|
|
+
|
|
|
+ if($nowTs+86400>$currentPeriod['END_TIME'] && !Period::isProcessing($periodNum)){
|
|
|
+ print_r("该预结算".PHP_EOL);
|
|
|
+ //设置计算进行中标识
|
|
|
+ Period::updatePeriodIsProcessing($periodNum, Period::IS_PROCESSING);
|
|
|
+ //设置自动计算标识
|
|
|
+ Period::updatePeriodIsAutoExec($periodNum, Period::MANUAL_EXEC_CALC);
|
|
|
+ //记录开始计算的时间
|
|
|
+ Period::updateAll(['START_EXEC_TIME' => time()], ['PERIOD_NUM' => $periodNum]);
|
|
|
+ $formModel = new PeriodForm();
|
|
|
+ $formModel->scenario = 'autoPerf';
|
|
|
+
|
|
|
+ if($formModel->load(['PERIOD_NUM'=>$periodNum], '') && $formModel->autoPerf()) {
|
|
|
+ echo('自动计算已开始,请等待');
|
|
|
+ } else {
|
|
|
+ echo('自动计算未开始');
|
|
|
+// return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+// if ($nowTs + 432000 <= $currentPeriodEnd || $currentPeriodEnd < $nowTs) {
|
|
|
+// return static::notice(['user' => [],'team'=>[]]);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
public static function listenAutoPerfPeriod()
|
|
|
{
|
|
|
$db = self::CALC_DB_NAME;
|