|
@@ -120,6 +120,7 @@ class CropLogic
|
|
|
$crop->seed_id = $seedId;
|
|
$crop->seed_id = $seedId;
|
|
|
$crop->plant_time = now();
|
|
$crop->plant_time = now();
|
|
|
$crop->growth_stage = GROWTH_STAGE::SEED->value;
|
|
$crop->growth_stage = GROWTH_STAGE::SEED->value;
|
|
|
|
|
+ $crop->stage_start_time = now(); // 设置当前阶段开始时间
|
|
|
$crop->stage_end_time = now()->addSeconds($seed->seed_time);
|
|
$crop->stage_end_time = now()->addSeconds($seed->seed_time);
|
|
|
$crop->disasters = [];
|
|
$crop->disasters = [];
|
|
|
$crop->fertilized = false;
|
|
$crop->fertilized = false;
|
|
@@ -323,7 +324,8 @@ class CropLogic
|
|
|
'crop_id' => $crop->id,
|
|
'crop_id' => $crop->id,
|
|
|
'reduced_time' => $reducedTime,
|
|
'reduced_time' => $reducedTime,
|
|
|
'original_end_time' => $endTime->toDateTimeString(),
|
|
'original_end_time' => $endTime->toDateTimeString(),
|
|
|
- 'new_end_time' => $crop->stage_end_time->toDateTimeString()
|
|
|
|
|
|
|
+ 'new_end_time' => $crop->stage_end_time->toDateTimeString(),
|
|
|
|
|
+ 'stage_start_time' => $crop->stage_start_time->toDateTimeString()
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -556,6 +558,7 @@ class CropLogic
|
|
|
|
|
|
|
|
// 更新作物信息
|
|
// 更新作物信息
|
|
|
$crop->growth_stage = $newStage;
|
|
$crop->growth_stage = $newStage;
|
|
|
|
|
+ $crop->stage_start_time = now(); // 设置新阶段的开始时间
|
|
|
$crop->stage_end_time = $stageEndTime;
|
|
$crop->stage_end_time = $stageEndTime;
|
|
|
$crop->fertilized = false; // 重置施肥状态
|
|
$crop->fertilized = false; // 重置施肥状态
|
|
|
$crop->save();
|
|
$crop->save();
|
|
@@ -599,8 +602,11 @@ class CropLogic
|
|
|
$matureDuration = 24 * 60 * 60;
|
|
$matureDuration = 24 * 60 * 60;
|
|
|
|
|
|
|
|
// 如果成熟期已经超过指定时间,则进入枯萎期
|
|
// 如果成熟期已经超过指定时间,则进入枯萎期
|
|
|
- if ($crop->stage_end_time && now()->diffInSeconds($crop->stage_end_time->copy()->subSeconds($matureDuration)) > $matureDuration) {
|
|
|
|
|
- return GROWTH_STAGE::WITHERED->value;
|
|
|
|
|
|
|
+ if ($crop->stage_end_time && $crop->stage_end_time instanceof \Carbon\Carbon) {
|
|
|
|
|
+ $endTimeMinusDuration = $crop->stage_end_time->copy()->subSeconds($matureDuration);
|
|
|
|
|
+ if (now()->diffInSeconds($endTimeMinusDuration) > $matureDuration) {
|
|
|
|
|
+ return GROWTH_STAGE::WITHERED->value;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return GROWTH_STAGE::MATURE->value;
|
|
return GROWTH_STAGE::MATURE->value;
|