浏览代码

Merge remote-tracking branch 'origin/master'

notfff 7 月之前
父节点
当前提交
04beed0b70

+ 101 - 0
AiWork/202506/201402-土地升级配置管理列表显示土地名字.md

@@ -0,0 +1,101 @@
+# 土地升级配置管理列表显示土地名字
+
+**任务时间**: 2025年06月20日 14:02  
+**任务状态**: ✅ 已完成  
+**提交哈希**: 8647d5a8
+
+## 任务描述
+
+优化土地升级配置管理后台页面,在列表和详情页面显示土地名字而不是ID,提升用户体验。
+
+## 实现内容
+
+### 1. 修改控制器显示逻辑
+
+**文件**: `app/Module/Farm/AdminControllers/FarmLandUpgradeConfigController.php`
+
+#### 列表页面优化
+- 修改`from_type_id`和`to_type_id`列显示,使用关联的土地类型名字
+- 使用预加载的关系`$this->fromType`和`$this->toType`获取土地名字
+- 对于不存在的土地类型,显示"未知类型 (ID: X)"
+
+#### 详情页面优化  
+- 修改详情页面字段显示,显示土地名字和ID
+- 修复`materials`和`conditions`字段显示问题
+- 移除了错误的`fieldModelCatsJson`调用,改为正确的字段显示
+
+### 2. 优化Repository性能
+
+**文件**: `app/Module/Farm/Repositories/FarmLandUpgradeConfigRepository.php`
+
+- 在构造函数中预加载土地类型关系`['fromType', 'toType']`
+- 提高列表和详情页面的查询性能,避免N+1查询问题
+
+### 3. 数据清理
+
+- 清理了无效的土地升级配置数据
+- 删除了引用不存在土地类型ID(5-15)的配置记录
+- 保留了有效的升级路径:普通土地→红土地→黑土地→金土地
+
+## 技术要点
+
+### 关系预加载
+```php
+public function __construct()
+{
+    parent::__construct(['fromType', 'toType']);
+}
+```
+
+### 列表显示优化
+```php
+$grid->column('from_type_id', '起始土地类型')->display(function ($fromTypeId) {
+    return $this->fromType ? $this->fromType->name : "未知类型 (ID: {$fromTypeId})";
+})->sortable();
+```
+
+### 详情页面显示
+```php
+$show->field('from_type_id', '起始土地类型')->as(function ($fromTypeId) {
+    return $this->fromType ? "{$this->fromType->name} (ID: {$fromTypeId})" : "未知类型 (ID: {$fromTypeId})";
+});
+```
+
+## 测试验证
+
+### 列表页面测试
+- ✅ 访问 `http://kku_laravel.local.gd/admin/farm-land-upgrade-configs`
+- ✅ 确认显示土地名字:普通土地、红土地、黑土地、金土地
+- ✅ 确认排序功能正常
+- ✅ 确认筛选功能正常
+
+### 详情页面测试  
+- ✅ 访问详情页面 `/admin/farm-land-upgrade-configs/1`
+- ✅ 确认显示"普通土地 (ID: 1) → 红土地 (ID: 2)"
+- ✅ 确认消耗组和条件组字段正常显示
+
+## 问题解决
+
+### 1. 详情页面错误
+**问题**: 访问详情页面时出现"materials is not a model casts"错误
+**原因**: 使用了`fieldModelCatsJson`方法处理非JSON字段
+**解决**: 改为使用正确的字段显示方法,处理消耗组和条件组ID
+
+### 2. 关系预加载问题
+**问题**: Repository构造函数中错误使用`$this->with()`方法
+**原因**: EloquentRepository的构造函数参数应该是关系数组
+**解决**: 修改为`parent::__construct(['fromType', 'toType'])`
+
+## 最终效果
+
+- 📋 **列表页面**: 清晰显示土地升级路径,如"普通土地 → 红土地"
+- 📄 **详情页面**: 显示完整信息,如"普通土地 (ID: 1)"
+- ⚡ **性能优化**: 通过预加载关系避免N+1查询
+- 🧹 **数据清理**: 移除无效配置,保持数据一致性
+
+## 相关文件
+
+- `app/Module/Farm/AdminControllers/FarmLandUpgradeConfigController.php`
+- `app/Module/Farm/Repositories/FarmLandUpgradeConfigRepository.php`
+- `app/Module/Farm/Models/FarmLandUpgradeConfig.php`
+- `app/Module/Farm/Models/FarmLandType.php`

+ 4 - 0
app/Module/Farm/AdminControllers/FarmLandTypeController.php

@@ -92,6 +92,10 @@ class FarmLandTypeController extends AdminController
             })->sortable();
             $grid->column('unlock_house_level', '解锁所需房屋等级')->sortable();
             $grid->column('is_special', '特殊土地')->bool()->sortable();
+
+            // 添加产出详情列
+            $helper->columnOutputDetails();
+
             $grid->column('created_at', '创建时间')->sortable();
             $grid->column('updated_at', '更新时间')->sortable();
 

+ 188 - 0
app/Module/Farm/AdminControllers/Helper/GridHelperTrait.php

@@ -89,6 +89,194 @@ trait GridHelperTrait
         ]);
     }
 
+    /**
+     * 添加产出详情列
+     *
+     * 展示该土地类型的作物种类概率和产量
+     *
+     * @param string $field 字段名
+     * @param string $label 标签名
+     * @return Column
+     */
+    public function columnOutputDetails(string $field = 'output_details', string $label = '产出详情'): Column
+    {
+        return $this->grid->column($field, $label)->display(function () {
+            // 获取当前土地类型
+            $landType = $this;
+
+            $html = '<div class="output-details">';
+            $html .= '<div class="mb-2"><strong>' . htmlspecialchars($landType->name) . ' (产量加成:' . ($landType->output_bonus * 100) . '%)</strong></div>';
+
+            // 1. 显示神秘种子的产出概率和产量
+            $html .= self::renderMysterySeeLOutputs($landType);
+
+            // 2. 显示普通种子的产出
+            $html .= self::renderNormalSeeLOutputs($landType);
+
+            $html .= '</div>';
+
+            return $html;
+        })->width(500);
+    }
+
+    /**
+     * 渲染神秘种子的产出详情
+     *
+     * @param \App\Module\Farm\Models\FarmLandType $landType
+     * @return string
+     */
+    private static function renderMysterySeeLOutputs($landType): string
+    {
+        // 获取神秘种子
+        $mysterySeeds = \App\Module\Farm\Models\FarmSeed::where('type', \App\Module\Farm\Enums\SEED_TYPE::MYSTERIOUS->value)->get();
+
+        if ($mysterySeeds->isEmpty()) {
+            return '';
+        }
+
+        $html = '<div class="mb-3">';
+        $html .= '<h6 class="text-info">神秘种子产出概率</h6>';
+
+        foreach ($mysterySeeds as $seed) {
+            try {
+                // 使用神秘种子逻辑计算概率
+                $mysteryLogic = new \App\Module\Farm\Logics\MysterySeeLLogic();
+                $adjustedOutputs = $mysteryLogic->calculateAdjustedProbabilities($seed->id, $landType->id);
+
+                $html .= '<div class="mb-2">';
+                $html .= '<strong>' . htmlspecialchars($seed->name) . ':</strong>';
+                $html .= '<div class="table-responsive">';
+                $html .= '<table class="table table-sm table-bordered">';
+                $html .= '<thead><tr><th>产出物品</th><th>概率</th><th>正常产量</th><th>灾害产量</th><th>应用土地加成后(正常)</th><th>应用土地加成后(灾害)</th></tr></thead>';
+                $html .= '<tbody>';
+
+                foreach ($adjustedOutputs as $output) {
+                    // 跳过概率为0的产出
+                    if ($output['adjusted_probability'] <= 0) {
+                        continue;
+                    }
+
+                    $itemName = self::getItemName($output['item_id']);
+                    $probability = number_format($output['adjusted_probability'], 2) . '%';
+
+                    // 正常产量范围
+                    $normalMin = $output['min_amount'];
+                    $normalMax = $output['max_amount'];
+
+                    // 灾害产量范围
+                    $disasterMin = $output['disaster_min_amount'] ?? $output['min_amount'];
+                    $disasterMax = $output['disaster_max_amount'] ?? $output['max_amount'];
+
+                    // 应用土地加成后的产量
+                    $normalBonusMin = (int)($normalMin * (1 + $landType->output_bonus));
+                    $normalBonusMax = (int)($normalMax * (1 + $landType->output_bonus));
+                    $disasterBonusMin = (int)($disasterMin * (1 + $landType->output_bonus));
+                    $disasterBonusMax = (int)($disasterMax * (1 + $landType->output_bonus));
+
+                    $html .= '<tr>';
+                    $html .= '<td>' . htmlspecialchars($itemName) . '</td>';
+                    $html .= '<td><span class="badge badge-info">' . $probability . '</span></td>';
+                    $html .= '<td>' . $normalMin . '-' . $normalMax . '</td>';
+                    $html .= '<td class="text-warning">' . $disasterMin . '-' . $disasterMax . '</td>';
+                    $html .= '<td class="text-success"><strong>' . $normalBonusMin . '-' . $normalBonusMax . '</strong></td>';
+                    $html .= '<td class="text-danger"><strong>' . $disasterBonusMin . '-' . $disasterBonusMax . '</strong></td>';
+                    $html .= '</tr>';
+                }
+
+                $html .= '</tbody></table>';
+                $html .= '</div>';
+                $html .= '</div>';
+
+            } catch (\Exception $e) {
+                $html .= '<div class="text-danger">计算神秘种子概率失败:' . htmlspecialchars($e->getMessage()) . '</div>';
+            }
+        }
+
+        $html .= '</div>';
+
+        return $html;
+    }
+
+    /**
+     * 渲染普通种子的产出详情
+     *
+     * @param \App\Module\Farm\Models\FarmLandType $landType
+     * @return string
+     */
+    private static function renderNormalSeeLOutputs($landType): string
+    {
+        // 获取普通种子的产出配置
+        $normalOutputs = \App\Module\Farm\Models\FarmSeedOutput::with(['seed', 'item'])
+            ->whereHas('seed', function($query) {
+                $query->where('type', '!=', \App\Module\Farm\Enums\SEED_TYPE::MYSTERIOUS->value);
+            })
+            ->where('is_default', true)
+            ->get();
+
+        if ($normalOutputs->isEmpty()) {
+            return '';
+        }
+
+        $html = '<div class="mb-3">';
+        $html .= '<h6 class="text-success">普通种子产出</h6>';
+        $html .= '<div class="table-responsive">';
+        $html .= '<table class="table table-sm table-bordered">';
+        $html .= '<thead><tr><th>种子</th><th>产出物品</th><th>正常产量</th><th>灾害产量</th><th>应用土地加成后(正常)</th><th>应用土地加成后(灾害)</th></tr></thead>';
+        $html .= '<tbody>';
+
+        foreach ($normalOutputs as $output) {
+            $seedName = $output->seed->name ?? "种子{$output->seed_id}";
+            $itemName = $output->item->name ?? "物品{$output->item_id}";
+
+            // 正常产量范围
+            $normalMin = $output->min_amount;
+            $normalMax = $output->max_amount;
+
+            // 灾害产量范围
+            $disasterMin = $output->disaster_min_amount ?? $output->min_amount;
+            $disasterMax = $output->disaster_max_amount ?? $output->max_amount;
+
+            // 应用土地加成后的产量
+            $normalBonusMin = (int)($normalMin * (1 + $landType->output_bonus));
+            $normalBonusMax = (int)($normalMax * (1 + $landType->output_bonus));
+            $disasterBonusMin = (int)($disasterMin * (1 + $landType->output_bonus));
+            $disasterBonusMax = (int)($disasterMax * (1 + $landType->output_bonus));
+
+            $html .= '<tr>';
+            $html .= '<td>' . htmlspecialchars($seedName) . '</td>';
+            $html .= '<td>' . htmlspecialchars($itemName) . '</td>';
+            $html .= '<td>' . $normalMin . '-' . $normalMax . '</td>';
+            $html .= '<td class="text-warning">' . $disasterMin . '-' . $disasterMax . '</td>';
+            $html .= '<td class="text-success"><strong>' . $normalBonusMin . '-' . $normalBonusMax . '</strong></td>';
+            $html .= '<td class="text-danger"><strong>' . $disasterBonusMin . '-' . $disasterBonusMax . '</strong></td>';
+            $html .= '</tr>';
+        }
+
+        $html .= '</tbody></table>';
+        $html .= '</div>';
+        $html .= '</div>';
+
+        return $html;
+    }
+
+    /**
+     * 获取物品名称
+     *
+     * @param int $itemId
+     * @return string
+     */
+    private static function getItemName(int $itemId): string
+    {
+        try {
+            $item = \App\Module\GameItems\Models\Item::find($itemId);
+            return $item ? $item->name : "物品{$itemId}";
+        } catch (\Exception $e) {
+            return "物品{$itemId}";
+        }
+    }
+
+
+
     /**
      * 添加种子类型列
      *

+ 0 - 62
app/Module/Farm/Repositories/FarmGodBuffRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmGodBuff;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 神灵加持仓库
@@ -21,66 +20,5 @@ class FarmGodBuffRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmGodBuff::class;
 
-    /**
-     * 获取用户的所有神灵加持
-     *
-     * @param int $userId
-     * @return Collection
-     */
-    public function findByUserId(int $userId): Collection
-    {
-        return FarmGodBuff::where('user_id', $userId)->get();
-    }
-
-    /**
-     * 获取用户的有效神灵加持
-     *
-     * @param int $userId
-     * @return Collection
-     */
-    public function findActiveByUserId(int $userId): Collection
-    {
-        return FarmGodBuff::where('user_id', $userId)
-            ->where('expire_time', '>', now())
-            ->get();
-    }
-
-    /**
-     * 获取用户指定类型的神灵加持
-     *
-     * @param int $userId
-     * @param int $buffType
-     * @return FarmGodBuff|null
-     */
-    public function findByUserIdAndType(int $userId, int $buffType): ?FarmGodBuff
-    {
-        return FarmGodBuff::where('user_id', $userId)
-            ->where('buff_type', $buffType)
-            ->first();
-    }
 
-    /**
-     * 获取用户指定类型的有效神灵加持
-     *
-     * @param int $userId
-     * @param int $buffType
-     * @return FarmGodBuff|null
-     */
-    public function findActiveByUserIdAndType(int $userId, int $buffType): ?FarmGodBuff
-    {
-        return FarmGodBuff::where('user_id', $userId)
-            ->where('buff_type', $buffType)
-            ->where('expire_time', '>', now())
-            ->first();
-    }
-
-    /**
-     * 清理过期的神灵加持
-     *
-     * @return int
-     */
-    public function deleteExpired(): int
-    {
-        return FarmGodBuff::where('expire_time', '<', now())->delete();
-    }
 }

+ 0 - 43
app/Module/Farm/Repositories/FarmHouseConfigRepository.php

@@ -20,48 +20,5 @@ class FarmHouseConfigRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmHouseConfig::class;
 
-    /**
-     * 根据等级获取房屋配置
-     *
-     * @param int $level
-     * @return FarmHouseConfig|null
-     */
-    public function findByLevel(int $level): ?FarmHouseConfig
-    {
-        return FarmHouseConfig::where('level', $level)->first();
-    }
-
-    /**
-     * 获取最大房屋等级
-     *
-     * @return int
-     */
-    public function getMaxLevel(): int
-    {
-        return FarmHouseConfig::max('level') ?? 1;
-    }
 
-    /**
-     * 获取需要降级检查的房屋等级配置
-     *
-     * @return array
-     */
-    public function findNeedDowngradeCheck(): array
-    {
-        return FarmHouseConfig::whereNotNull('downgrade_days')
-            ->where('level', '>', 1)
-            ->pluck('downgrade_days', 'level')
-            ->toArray();
-    }
-
-    /**
-     * 获取下一级房屋配置
-     *
-     * @param int $currentLevel
-     * @return FarmHouseConfig|null
-     */
-    public function findNextLevel(int $currentLevel): ?FarmHouseConfig
-    {
-        return FarmHouseConfig::where('level', $currentLevel + 1)->first();
-    }
 }

+ 0 - 46
app/Module/Farm/Repositories/FarmLandRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmLand;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 土地信息仓库
@@ -21,50 +20,5 @@ class FarmLandRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmLand::class;
 
-    /**
-     * 更新数据
-     *
-     * 重写父类方法,确保status字段被正确处理
-     *
-     * @param \Dcat\Admin\Form $form
-     * @return bool
-     */
-    public function update(\Dcat\Admin\Form $form)
-    {
-        $model = $this->model();
-
-        if (!$model->getKey()) {
-            $model->exists = true;
-            $model->setAttribute($model->getKeyName(), $form->getKey());
-        }
-
-        $result = null;
-
-        \Illuminate\Support\Facades\DB::transaction(function () use ($form, $model, &$result) {
-            $updates = $form->updates();
-
-            // 获取关联关系数据,但不处理它们
-            [$relations, $relationKeyMap] = $this->getRelationInputs($model, $updates);
-
-            if ($relations) {
-                $updates = \Illuminate\Support\Arr::except($updates, array_keys($relationKeyMap));
-            }
-
-            // 确保status是整数
-            if (isset($updates['status'])) {
-                $updates['status'] = (int)$updates['status'];
-            }
-
-            foreach ($updates as $column => $value) {
-                $model->setAttribute($column, $value);
-            }
-
-            $result = $model->update();
-
-            // 我们不调用updateRelation方法,因为它可能会导致错误
-            // 土地模型没有复杂的关联关系需要在表单中更新
-        });
 
-        return $result;
-    }
 }

+ 0 - 41
app/Module/Farm/Repositories/FarmLandTypeRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmLandType;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 土地类型配置仓库
@@ -21,45 +20,5 @@ class FarmLandTypeRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmLandType::class;
 
-    /**
-     * 根据编码获取土地类型
-     *
-     * @param string $code
-     * @return FarmLandType|null
-     */
-    public function findByCode(string $code): ?FarmLandType
-    {
-        return FarmLandType::where('code', $code)->first();
-    }
-
-    /**
-     * 获取特殊土地类型
-     *
-     * @return Collection
-     */
-    public function findSpecialTypes(): Collection
-    {
-        return FarmLandType::where('is_special', true)->get();
-    }
 
-    /**
-     * 获取普通土地类型
-     *
-     * @return Collection
-     */
-    public function findNormalTypes(): Collection
-    {
-        return FarmLandType::where('is_special', false)->get();
-    }
-
-    /**
-     * 获取指定房屋等级可解锁的土地类型
-     *
-     * @param int $houseLevel
-     * @return Collection
-     */
-    public function findByHouseLevel(int $houseLevel): Collection
-    {
-        return FarmLandType::where('unlock_house_level', '<=', $houseLevel)->get();
-    }
 }

+ 0 - 53
app/Module/Farm/Repositories/FarmLandUpgradeConfigRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmLandUpgradeConfig;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 土地升级配置仓库
@@ -30,57 +29,5 @@ class FarmLandUpgradeConfigRepository extends EloquentRepository
         parent::__construct(['fromType', 'toType']);
     }
 
-    /**
-     * 获取指定起始类型的升级配置
-     *
-     * @param int $fromTypeId
-     * @return Collection
-     */
-    public function findByFromTypeId(int $fromTypeId): Collection
-    {
-        return FarmLandUpgradeConfig::where('from_type_id', $fromTypeId)->get();
-    }
-
-    /**
-     * 获取指定目标类型的升级配置
-     *
-     * @param int $toTypeId
-     * @return Collection
-     */
-    public function findByToTypeId(int $toTypeId): Collection
-    {
-        return FarmLandUpgradeConfig::where('to_type_id', $toTypeId)->get();
-    }
 
-    /**
-     * 获取指定升级路径的配置
-     *
-     * @param int $fromTypeId
-     * @param int $toTypeId
-     * @return FarmLandUpgradeConfig|null
-     */
-    public function findByFromAndToTypeId(int $fromTypeId, int $toTypeId): ?FarmLandUpgradeConfig
-    {
-        return FarmLandUpgradeConfig::where('from_type_id', $fromTypeId)
-            ->where('to_type_id', $toTypeId)
-            ->first();
-    }
-
-    /**
-     * 获取所有可能的升级路径
-     *
-     * @return array
-     */
-    public function getAllUpgradePaths(): array
-    {
-        return FarmLandUpgradeConfig::select('from_type_id', 'to_type_id')
-            ->get()
-            ->map(function ($item) {
-                return [
-                    'from' => $item->from_type_id,
-                    'to' => $item->to_type_id,
-                ];
-            })
-            ->toArray();
-    }
 }

+ 0 - 47
app/Module/Farm/Repositories/FarmSeedOutputRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmSeedOutput;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 种子产出配置仓库
@@ -21,51 +20,5 @@ class FarmSeedOutputRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmSeedOutput::class;
 
-    /**
-     * 获取种子的所有产出配置
-     *
-     * @param int $seedId
-     * @return Collection
-     */
-    public function findBySeedId(int $seedId): Collection
-    {
-        return FarmSeedOutput::where('seed_id', $seedId)->get();
-    }
-
-    /**
-     * 获取种子的默认产出配置
-     *
-     * @param int $seedId
-     * @return FarmSeedOutput|null
-     */
-    public function findDefaultBySeedId(int $seedId): ?FarmSeedOutput
-    {
-        return FarmSeedOutput::where('seed_id', $seedId)
-            ->where('is_default', true)
-            ->first();
-    }
 
-    /**
-     * 获取指定物品ID的产出配置
-     *
-     * @param int $itemId
-     * @return Collection
-     */
-    public function findByItemId(int $itemId): Collection
-    {
-        return FarmSeedOutput::where('item_id', $itemId)->get();
-    }
-
-    /**
-     * 获取种子的所有产出配置,按概率降序排序
-     *
-     * @param int $seedId
-     * @return Collection
-     */
-    public function findBySeedIdOrderByProbability(int $seedId): Collection
-    {
-        return FarmSeedOutput::where('seed_id', $seedId)
-            ->orderByDesc('probability')
-            ->get();
-    }
 }

+ 0 - 51
app/Module/Farm/Repositories/FarmSeedRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmSeed;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 种子配置仓库
@@ -21,55 +20,5 @@ class FarmSeedRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmSeed::class;
 
-    /**
-     * 获取指定类型的种子
-     *
-     * @param int $type
-     * @return Collection
-     */
-    public function findByType(int $type): Collection
-    {
-        return FarmSeed::where('type', $type)->get();
-    }
-
-    /**
-     * 根据物品ID查找种子
-     *
-     * @param int $itemId
-     * @return FarmSeed|null
-     */
-    public function findByItemId(int $itemId): ?FarmSeed
-    {
-        return FarmSeed::where('item_id', $itemId)->first();
-    }
-
-    /**
-     * 获取所有普通种子
-     *
-     * @return Collection
-     */
-    public function findNormalSeeds(): Collection
-    {
-        return FarmSeed::where('type', 1)->get();
-    }
 
-    /**
-     * 获取所有神秘种子
-     *
-     * @return Collection
-     */
-    public function findMysteriousSeeds(): Collection
-    {
-        return FarmSeed::where('type', 2)->get();
-    }
-
-    /**
-     * 获取所有巨化种子
-     *
-     * @return Collection
-     */
-    public function findGiantSeeds(): Collection
-    {
-        return FarmSeed::where('type', 3)->get();
-    }
 }

+ 0 - 35
app/Module/Farm/Repositories/FarmUserRepository.php

@@ -4,7 +4,6 @@ namespace App\Module\Farm\Repositories;
 
 use App\Module\Farm\Models\FarmUser;
 use Dcat\Admin\Repositories\EloquentRepository;
-use Illuminate\Database\Eloquent\Collection;
 
 /**
  * 用户农场信息仓库
@@ -21,39 +20,5 @@ class FarmUserRepository extends EloquentRepository
      */
     protected $eloquentClass = FarmUser::class;
 
-    /**
-     * 根据用户ID查找农场信息
-     *
-     * @param int $userId
-     * @return FarmUser|null
-     */
-    public function findByUserId(int $userId): ?FarmUser
-    {
-        return FarmUser::where('user_id', $userId)->first();
-    }
-
-    /**
-     * 获取指定房屋等级的用户
-     *
-     * @param int $houseLevel
-     * @return Collection
-     */
-    public function findByHouseLevel(int $houseLevel): Collection
-    {
-        return FarmUser::where('house_level', $houseLevel)->get();
-    }
 
-    /**
-     * 获取需要检查降级的用户
-     *
-     * @param int $days
-     * @return Collection
-     */
-    public function findNeedDowngradeUsers(int $days): Collection
-    {
-        $date = now()->subDays($days);
-        return FarmUser::where('house_level', '>', 1)
-            ->where('last_upgrade_time', '<', $date)
-            ->get();
-    }
 }