|
|
@@ -29,17 +29,10 @@ class LandTemp
|
|
|
*/
|
|
|
const TEMP_KEY_PREFIX = 'game:land:changes:';
|
|
|
|
|
|
- /**
|
|
|
- * 临时数据键前缀 - 土地变更(向后兼容)
|
|
|
- * @deprecated 使用 TEMP_KEY_PREFIX 替代
|
|
|
- */
|
|
|
- const TEMP_KEY_CHANGED_PREFIX = 'game:land:changes:';
|
|
|
|
|
|
- /**
|
|
|
- * 临时数据键前缀 - 土地状态变更(向后兼容)
|
|
|
- * @deprecated 使用 TEMP_KEY_PREFIX 替代
|
|
|
- */
|
|
|
- const TEMP_KEY_STATUS_PREFIX = 'game:land:changes:';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 临时数据过期时间(秒)
|
|
|
@@ -163,15 +156,14 @@ class LandTemp
|
|
|
|
|
|
|
|
|
// 构建统一的土地变更数据
|
|
|
- $landData = [
|
|
|
- 'land_id' => $event->landId,
|
|
|
- 'old_type' => null,
|
|
|
- 'new_type' => null,
|
|
|
- 'old_status' => $event->oldStatus,
|
|
|
- 'new_status' => $event->newStatus,
|
|
|
- 'change_type' => 'status',
|
|
|
- 'updated_at' => time(),
|
|
|
- ];
|
|
|
+
|
|
|
+
|
|
|
+ $landData = new LandChangeTempDto();
|
|
|
+ $landData->landId = $event->landId;
|
|
|
+ $landData->oldStatus = $event->oldStatus;
|
|
|
+ $landData->newStatus = $event->newStatus;
|
|
|
+ $landData->changeType = 'status';
|
|
|
+ $landData->updatedAt = time();
|
|
|
|
|
|
// 存储到统一的土地变更缓存
|
|
|
self::storeLandChange($event->userId, $event->landId, $landData);
|
|
|
@@ -218,62 +210,8 @@ class LandTemp
|
|
|
return $userLandChanges[$landId] ?? null;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取用户的土地状态变更临时数据(向后兼容)
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @return array 用户的土地状态变更数据
|
|
|
- * @deprecated 使用 getUserLandChanges() 替代,然后过滤 changeType === 'status'
|
|
|
- */
|
|
|
- public static function getUserLandStatusChanges(int $userId): array
|
|
|
- {
|
|
|
- $allChanges = self::getUserLandChanges($userId);
|
|
|
- $statusChanges = [];
|
|
|
-
|
|
|
- foreach ($allChanges as $landId => $change) {
|
|
|
- if ($change->isStatusChange()) {
|
|
|
- // 为了向后兼容,转换为LandStatusTempDto格式
|
|
|
- $statusChanges[$landId] = new LandStatusTempDto([
|
|
|
- 'landId' => $change->landId,
|
|
|
- 'position' => $change->position,
|
|
|
- 'landType' => $change->landType,
|
|
|
- 'oldStatus' => $change->oldStatus,
|
|
|
- 'newStatus' => $change->newStatus,
|
|
|
- 'cropId' => $change->cropId,
|
|
|
- 'seedId' => $change->seedId,
|
|
|
- 'updatedAt' => $change->updatedAt,
|
|
|
- ]);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- return $statusChanges;
|
|
|
- }
|
|
|
|
|
|
- /**
|
|
|
- * 获取用户特定土地的状态变更临时数据(向后兼容)
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @param int $landId 土地ID
|
|
|
- * @return LandStatusTempDto|null 土地状态变更数据,不存在时返回null
|
|
|
- * @deprecated 使用 getUserLandChange() 替代,然后检查 isStatusChange()
|
|
|
- */
|
|
|
- public static function getUserLandStatusChange(int $userId, int $landId): ?LandStatusTempDto
|
|
|
- {
|
|
|
- $change = self::getUserLandChange($userId, $landId);
|
|
|
- if ($change && $change->isStatusChange()) {
|
|
|
- return new LandStatusTempDto([
|
|
|
- 'landId' => $change->landId,
|
|
|
- 'position' => $change->position,
|
|
|
- 'landType' => $change->landType,
|
|
|
- 'oldStatus' => $change->oldStatus,
|
|
|
- 'newStatus' => $change->newStatus,
|
|
|
- 'cropId' => $change->cropId,
|
|
|
- 'seedId' => $change->seedId,
|
|
|
- 'updatedAt' => $change->updatedAt,
|
|
|
- ]);
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 清除用户的所有土地变更临时数据(统一接口)
|
|
|
@@ -287,18 +225,7 @@ class LandTemp
|
|
|
Cache::put($tempKey, [], 0);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 清除用户的土地状态变更临时数据(向后兼容)
|
|
|
- *
|
|
|
- * @param int $userId 用户ID
|
|
|
- * @return void
|
|
|
- * @deprecated 使用 clearUserLandChanges() 替代
|
|
|
- */
|
|
|
- public static function clearUserLandStatusChanges(int $userId): void
|
|
|
- {
|
|
|
- // 现在统一存储,所以清除所有数据
|
|
|
- self::clearUserLandChanges($userId);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 清除用户的所有土地临时数据
|