Forráskód Böngészése

feat(pet): 添加宠物配置 JSON 生成功能

- 在 PetConfigController 中添加 generateJson 方法,实现宠物配置 JSON 生成
- 在 PetServiceProvider 中注册 GeneratePetJsonCommand 命令
- 更新 ChestJsonConfig 和 ItemJsonConfig 类的注释
- 在 JSON_CONFIG_NAME 枚举中添加宠物相关配置项
- 更新 GenerateItemsJsonCommand 类的注释
Your Name 8 hónapja
szülő
commit
b093f24ce3
31 módosított fájl, 2206 hozzáadás és 1242 törlés
  1. 3 0
      app/Module/Game/DCache/ChestJsonConfig.php
  2. 3 0
      app/Module/Game/DCache/ItemJsonConfig.php
  3. 3 0
      app/Module/Game/Enums/JSON_CONFIG_NAME.php
  4. 1 1
      app/Module/GameItems/Commands/GenerateItemsJsonCommand.php
  5. 100 0
      app/Module/LCache/Cache.php
  6. 169 0
      app/Module/LCache/CacheItem.php
  7. 54 0
      app/Module/LCache/DQueueJob.php
  8. 24 0
      app/Module/LCache/DQueueJobInterface.php
  9. 12 0
      app/Module/LCache/ItemInterface.php
  10. 104 0
      app/Module/LCache/QueueCache.php
  11. 58 0
      app/Module/LCache/QueueJob.php
  12. 37 0
      app/Module/LCache/QueueJobInterface.php
  13. 1 0
      app/Module/LCache/README.md
  14. 114 0
      app/Module/LCache/SCache.php
  15. 44 2
      app/Module/Pet/AdminControllers/PetConfigController.php
  16. 2 1
      app/Module/Pet/Providers/PetServiceProvider.php
  17. 0 688
      app/Module/Task/Docs/API接口设计.md
  18. 418 0
      app/Module/Task/Docs/Proto设计.md
  19. 1 126
      app/Module/Task/Docs/create.sql
  20. 0 16
      app/Module/Task/Docs/task_user_progress_modified.sql
  21. 321 0
      app/Module/Task/Docs/任务配置表.md
  22. 140 23
      app/Module/Task/Docs/数据库设计.md
  23. 139 0
      app/Module/Task/Docs_Roo_dpv3/Proto设计规范.md
  24. 119 0
      app/Module/Task/Docs_Roo_dpv3/任务配置指南.md
  25. 222 0
      app/Module/Task/Docs_Roo_dpv3/任务配置表.json
  26. 43 2
      app/Module/Task/Docs_Roo_dpv3/数据库设计.md
  27. 63 0
      app/Module/Task/Docs_Roo_dpv3/数据库设计比对报告.md
  28. 11 167
      app/Module/Task/Enums/TARGET_TYPE.php
  29. 0 31
      app/Module/Task/Listeners/BaseTaskEventListener.php
  30. 0 79
      app/Module/Task/Listeners/TaskCompletedListener.php
  31. 0 106
      app/Module/Task/Listeners/TaskRewardClaimedListener.php

+ 3 - 0
app/Module/Game/DCache/ChestJsonConfig.php

@@ -6,6 +6,9 @@ use App\Module\GameItems\Commands\GenerateChestJsonCommand;
 use App\Module\GameItems\Commands\GenerateItemsJsonCommand;
 use App\Module\LCache\DQueueJob;
 
+/**
+ * 宝箱配置表 缓存
+ */
 class ChestJsonConfig extends DQueueJob
 {
 

+ 3 - 0
app/Module/Game/DCache/ItemJsonConfig.php

@@ -5,6 +5,9 @@ namespace App\Module\Game\DCache;
 use App\Module\GameItems\Commands\GenerateItemsJsonCommand;
 use App\Module\LCache\DQueueJob;
 
+/**
+ * 物品配置表 缓存
+ */
 class ItemJsonConfig extends DQueueJob
 {
 

+ 3 - 0
app/Module/Game/Enums/JSON_CONFIG_NAME.php

@@ -6,5 +6,8 @@ enum JSON_CONFIG_NAME: string
 {
 
     case ITEM = 'items';
+    case PET = 'pets';
+    case PET_LEVEL = 'pet_levels';
+    case PET_SKILL = 'pet_skills';
 
 }

+ 1 - 1
app/Module/GameItems/Commands/GenerateItemsJsonCommand.php

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\File;
 use Illuminate\Support\Facades\Log;
 
 /**
- * 生成物品JSON数据命令
+ * 生成物品配置表JSON数据命令
  *
  * 该命令用于从数据库中的物品表生成物品JSON数据文件,供客户端使用。
  * 生成的JSON文件包含物品的基本信息,如ID、名称、描述、售价和显示属性等。

+ 100 - 0
app/Module/LCache/Cache.php

@@ -0,0 +1,100 @@
+<?php
+
+namespace App\Module\LCache;
+
+use UCore\Helper\CacheTag;
+use UCore\Helper\Logger;
+
+
+class Cache
+{
+
+    /**
+     * 回调函数的缓存
+     *
+     * @param $key
+     * @param callable $callable
+     * @param $param_arr
+     * @param $exp
+     * @return mixed
+     *
+     */
+    static public function cacheCall($key2, callable $callable, $param_arr, $exp = 60, $tags = [])
+    {
+        $key = self::getKey($key2);
+        $old = \Illuminate\Support\Facades\Cache::get($key);
+        if (!is_null($old)) {
+            return $old;
+        }
+        $new = call_user_func_array($callable, $param_arr);
+        \Illuminate\Support\Facades\Cache::put($key, $new, $exp);
+        if ($tags) {
+            CacheTag::key_tags($key, $tags, null);
+        }
+        return $new;
+    }
+
+
+    /**
+     * 设置数据
+     *
+     * @param $key
+     * @param $data
+     * @param $exp
+     * @param $tags
+     * @return void
+     */
+    static public function put($key, $data, $exp = 60, $tags = [])
+    {
+        $key = self::getKey($key);
+        \Illuminate\Support\Facades\Cache::put($key, $data, $exp);
+        if ($tags) {
+            CacheTag::key_tags($key, $tags, null);
+        }
+
+    }
+
+    /**
+     * 获取数据
+     *
+     * @param $key
+     * @param $default
+     * @return mixed
+     */
+    static public function get($key, $default = null)
+    {
+        $key = self::getKey($key);
+        Logger::debug("Cache-get".$key);
+        return \Illuminate\Support\Facades\Cache::get($key,$default);
+    }
+
+
+    /**
+     * has数据
+     * @param $key
+     * @return bool
+     */
+    static public function has($key)
+    {
+        $key = self::getKey($key);
+
+        return \Illuminate\Support\Facades\Cache::has($key);
+    }
+
+    static public function getTags($key)
+    {
+        $key = self::getKey($key);
+
+    }
+    /**
+     * 获取键名
+     * @param $data
+     * @return string
+     */
+    static public function getKey($data)
+    {
+        return md5(serialize($data));
+    }
+
+
+}

+ 169 - 0
app/Module/LCache/CacheItem.php

@@ -0,0 +1,169 @@
+<?php
+
+namespace App\Module\LCache;
+
+use Psr\Cache\CacheItemInterface;
+use \DateTimeInterface;
+
+class CacheItem implements CacheItemInterface
+{
+
+    public int $ttl;
+    public int $create_ts;
+    public int $expire_ts = 0;
+
+    public string $key;
+
+
+    public mixed $value;
+
+    public $isHit;
+
+
+    public function __construct(string $key, mixed $value = null, int $create_ts = 0, int $ttl = 0)
+    {
+        $this->key   = $key;
+        $this->value = $value;
+        if ($create_ts) {
+            $this->create_ts = time();
+        } else {
+            $this->create_ts = $create_ts;
+        }
+
+        if ($ttl) {
+            $this->expire_ts = $this->create_ts + $ttl;
+            $this->ttl       = $ttl;
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getKey(): string
+    {
+        return $this->key;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function get(): mixed
+    {
+        if (!$this->isHit()) {
+            return null;
+        }
+
+        return $this->value;
+    }
+
+    public function getValue()
+    {
+        return $this->value;
+    }
+
+    /**
+     * A cache hit occurs when a Calling Library requests an Item by key
+     * and a matching value is found for that key, and that value has
+     * not expired, and the value is not invalid for some other reason.
+     *
+     * Calling Libraries SHOULD make sure to verify isHit() on all get() calls.
+     *
+     * {@inheritdoc}
+     */
+    public function isHit($force = false): bool
+    {
+        if (isset($this->isHit) && $force === false) {
+            return $this->isHit;
+        }
+        if ($this->expire_ts) {
+            if ($this->expire_ts < time()) {
+                $this->isHit = false;
+
+                return false;
+            }
+        }
+        $this->isHit = true;
+
+        return true;
+    }
+
+    public function setHit($hit)
+    {
+        $this->isHit = $hit;
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function set(mixed $value): static
+    {
+        $this->value = $value;
+
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function expiresAt(?\DateTimeInterface $expires): static
+    {
+        if ($expires instanceof DateTimeInterface && !$expires instanceof \DateTimeImmutable) {
+            $timezone = $expires->getTimezone();
+            $expires  = \DateTimeImmutable::createFromFormat('U', (string)$expires->getTimestamp(), $timezone);
+            if ($expires) {
+                $expires = $expires->setTimezone($timezone);
+            }
+        }
+
+        if ($expires instanceof DateTimeInterface) {
+            $this->expires = $expires;
+            $this->expire_ts = $expires->getTimestamp();
+        } else {
+            $this->expires = null;
+        }
+
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function expiresAfter(int|\DateInterval|null $time): static
+    {
+        if ($time === null) {
+            $this->expires = null;
+
+            return $this;
+        }
+
+        $this->expires = new \DateTimeImmutable();
+
+        if (!$time instanceof \DateInterval) {
+            $time2 = new \DateInterval(sprintf('PT%sS', abs($time)));
+        }
+        if($time > 0){
+            $this->expires   = $this->expires->add($time2);
+        }else{
+            $this->expires   = $this->expires->sub($time2);
+        }
+
+        $this->expire_ts = $this->expires->getTimestamp();
+
+        return $this;
+    }
+
+    public function getExpiresAt(): DateTimeInterface
+    {
+        if (!$this->expires) {
+            $this->expires = new \DateTimeImmutable();
+            $time          = new \DateInterval(sprintf('PT%sS', $this->ttl));
+
+            $this->expires->add($time);
+        }
+
+        return $this->expires;
+    }
+
+
+}

+ 54 - 0
app/Module/LCache/DQueueJob.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace App\Module\LCache;
+
+
+use App\Module\DelayQueue\Redis;
+use UCore\Helper\Logger;
+
+abstract class DQueueJob  implements QueueJobInterface,DQueueJobInterface
+{
+    use QueueCache;
+
+
+    static public function getDelay(): int
+    {
+        return 2;
+    }
+
+    /**
+     * 事件监听
+     * @param  $user
+     *
+     */
+    static public function eventListen($user)
+    {
+        $arg2   = [];
+        $indexs = static::getRequiredArgIndex();
+        foreach ($indexs as $index) {
+            if (!isset($user->$index)) {
+                Logger::error("Cache-error", [ $user, $indexs, $index ]);
+                throw new \InvalidArgumentException("参数错误");
+            }
+            $arg2[$index] = $user->$index;
+        }
+
+        static::jobUpdate($arg2);
+    }
+
+    /**
+     * 使用任务更新
+     *
+     * @param $arg
+     * @return void
+     */
+    static protected function jobUpdate($parameter)
+    {
+
+        Redis::addQueue([static::class, 'updateSync'], $parameter, static::getDelay());
+
+    }
+
+
+
+}

+ 24 - 0
app/Module/LCache/DQueueJobInterface.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Module\LCache;
+
+interface DQueueJobInterface
+{
+
+
+
+
+    /**
+     * 获取延迟时间
+     *
+     * @return int
+     */
+    static public function getDelay(): int;
+
+
+
+
+
+
+
+}

+ 12 - 0
app/Module/LCache/ItemInterface.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Module\LCache;
+
+use Psr\Cache\CacheItemInterface;
+
+interface ItemInterface
+{
+    public function get();
+
+    public function update($data,$ttl=60):CacheItemInterface;
+}

+ 104 - 0
app/Module/LCache/QueueCache.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace App\Module\LCache;
+
+use UCore\Helper\Logger;
+
+use function Laravel\Prompts\select;
+
+trait QueueCache
+{
+
+    public function run(): bool
+    {
+        $indexs = static::getRequiredArgIndex();
+        foreach ($indexs as $index) {
+            if (!isset($this->arg[$index])) {
+                Logger::error("Cache-error", [ $this->arg, $indexs, $index ]);
+
+                return false;
+            }
+        }
+//        dump($this->arg);
+        $key  = self::getKey($this->arg);
+        $key2 = $key . '_PD';// 防止重复执行
+        $pd   = SCache::get($key2);
+        if ($pd->isHit()) {
+            // 重复执行
+            return true;
+        }
+        $d = static::getNewData($this->arg);
+        self::updateData($key, $d);
+
+        return true;
+    }
+
+    public static function updateData($key, $d)
+    {
+        $key2 = $key . '_PD';// 防止重复执行
+//        dump($key,$d);
+        $data = new CacheItem($key, $d, 0, static::getTtl());
+        SCache::put($key, $data, null);
+        SCache::put($key2, 1, static::getPreventDuplication());
+
+        return $data;
+    }
+
+    /**
+     * 更新数据,同步,强制
+     *
+     * @param $arg
+     * @return void
+     */
+    static public function updateSync($parameter)
+    {
+        $key  = static::getKey($parameter);
+        $d    = static::getNewData($parameter);
+        $data = new CacheItem($key, $d, time(), static::getTtl());
+        SCache::put($key, $data, null);
+
+        return $key;
+    }
+
+
+    /**
+     * 获取缓存key
+     *
+     * @param $parameter
+     * @return string
+     */
+    static protected function getKey($parameter)
+    {
+        return md5(serialize([ static::class, $parameter ]));
+    }
+
+
+    /**
+     * 获取数据
+     *
+     * @return mixed|null
+     */
+    static public function getData($parameter = [], $force = false)
+    {
+        $key = static::getKey($parameter);
+
+
+        $item = SCache::get($key);
+//        var_dump($key);
+        // 3ee2d37c91b4abcf418bd24c0c0e1dea
+        // 3ee2d37c91b4abcf418bd24c0c0e1dea
+//        dump($key,$parameter);
+
+        if (!$item->isHit()) {
+            $force = true;
+        }
+        if ($force) {
+            $d    = static::getNewData($parameter);
+            $item = self::updateData($key, $d);
+        }
+
+        return $item->getValue();
+    }
+
+
+}

+ 58 - 0
app/Module/LCache/QueueJob.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Module\LCache;
+
+
+use UCore\Helper\Logger;
+
+abstract class QueueJob extends \UCore\Queue\QueueJob implements QueueJobInterface
+{
+
+    use QueueCache;
+
+    public function __construct(public array $arg = [])
+    {
+        Logger::info('队列任务创建', [
+            'job_class' => static::class,
+            'args' => $arg
+        ]);
+    }
+
+
+
+
+    public function payload()
+    {
+        Logger::info('队列任务准备执行', [
+            'job_class' => static::class,
+            'payload' => $this->arg
+        ]);
+        return $this->arg;
+    }
+
+
+    /**
+     * 使用任务更新
+     *
+     * @param $arg
+     * @return void
+     */
+    static protected function jobUpdate($parameter)
+    {
+        Logger::info('队列任务更新', [
+            'job_class' => static::class,
+            'parameter' => $parameter
+        ]);
+
+        $queue = env('CACHE_QUEUE', null);
+        if ($queue) {
+            self::dispatch($parameter)->delay(2)->onQueue($queue);
+        } else {
+            self::dispatch($parameter)->delay(2);
+        }
+    }
+
+
+
+
+}

+ 37 - 0
app/Module/LCache/QueueJobInterface.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Module\LCache;
+
+interface QueueJobInterface
+{
+
+    /**
+     * 获取数据
+     *
+     * @param $parameter
+     * @return mixed
+     */
+    static public function getNewData(array $parameter = []);
+
+    /**
+     * 缓存时间
+     *
+     * @return int
+     */
+    static public function getTtl(): int;
+
+    /**
+     * 缓存时间,防止重复执行
+     *
+     * @return int
+     */
+    static public function getPreventDuplication(): int;
+
+    /**
+     * 获取必填参数索引
+     * @return array
+     */
+    static public function getRequiredArgIndex(): array;
+
+
+}

+ 1 - 0
app/Module/LCache/README.md

@@ -0,0 +1 @@
+

+ 114 - 0
app/Module/LCache/SCache.php

@@ -0,0 +1,114 @@
+<?php
+
+namespace App\Module\LCache;
+
+
+use UCore\Helper\CacheTag;
+use UCore\Helper\Logger;
+
+/**
+ * symfony/cache使用laravel的配置的封装
+ *
+ *
+ */
+class SCache
+{
+
+
+    /**
+     * 设置数据
+     *
+     * @param $key
+     * @param $data
+     * @param $exp
+     * @param $tags
+     * @return void
+     */
+    static public function put($key, $data, $exp = 60, $tags = [])
+    {
+        $key = self::getKey($key);
+        if ($data instanceof CacheItem) {
+            $d2 = $data;
+        } else {
+            $d2 = new CacheItem($key, $data, 0, $exp);
+        }
+
+        \Illuminate\Support\Facades\Cache::put($key, $d2, $exp);
+        if ($tags) {
+            CacheTag::key_tags($key, $tags, null);
+        }
+
+        return $d2;
+
+    }
+
+    /**
+     * 获取数据
+     *
+     * @param $key
+     * @param $default
+     * @return CacheItem
+     */
+    static public function get($key, $default = null)
+    {
+
+        $key = self::getKey($key);
+        Logger::debug("Cache-get" . $key);
+        $res = \Illuminate\Support\Facades\Cache::get($key, $default);
+        if ($res instanceof CacheItem) {
+            return $res;
+        }
+        $res = new CacheItem($key, $default, 0);
+        $res->setHit(false)->expiresAfter(-1);
+        return $res;
+    }
+
+
+    /**
+     * 获取数据
+     * @param $key
+     * @param $default
+     * @return mixed|null
+     */
+    static public function getValue($key, $default = null)
+    {
+        $item = self::get($key, $default);
+
+        return $item->getValue();
+    }
+
+    /**
+     * has数据
+     *
+     * @param $key
+     * @return bool
+     */
+    static public function has($key)
+    {
+        $key = self::getKey($key);
+
+        return \Illuminate\Support\Facades\Cache::has($key);
+    }
+
+    static public function getTags($key)
+    {
+        $key = self::getKey($key);
+
+    }
+
+    /**
+     * 获取键名
+     *
+     * @param $data
+     * @return string
+     */
+    static public function getKey($data)
+    {
+        if(is_string($data)){
+            return $data;
+        }
+        return md5(serialize($data));
+    }
+
+
+}

+ 44 - 2
app/Module/Pet/AdminControllers/PetConfigController.php

@@ -2,13 +2,16 @@
 
 namespace App\Module\Pet\AdminControllers;
 
+use App\Module\Game\DCache\PetJsonConfig;
 use App\Module\Pet\Models\PetConfig;
 use App\Module\Pet\Repositorys\PetConfigRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
+use Illuminate\Http\Request;
 use UCore\DcatAdmin\AdminController;
 use Spatie\RouteAttributes\Attributes\Resource;
+use Spatie\RouteAttributes\Attributes\Get;
 use App\Module\Pet\AdminControllers\Helper\FilterHelper;
 use App\Module\Pet\AdminControllers\Helper\FormHelper;
 use App\Module\Pet\AdminControllers\Helper\GridHelper;
@@ -22,6 +25,20 @@ use App\Module\Pet\AdminControllers\Helper\ShowHelper;
 #[Resource('pet-configs', names: 'dcat.admin.pet-configs')]
 class PetConfigController extends AdminController
 {
+    /**
+     * 生成宠物JSON数据
+     */
+    #[Get('pet-configs/generate-json')]
+    public function generateJson()
+    {
+        $result = PetJsonConfig::getData([], true);
+
+        return response()->json([
+            'status' => $result['success'] ? 'success' : 'error',
+            'message' => $result['success'] ? 'JSON生成成功' : 'JSON生成失败: ' . ($result['error'] ?? '')
+        ]);
+    }
+
     /**
      * 标题
      *
@@ -51,6 +68,31 @@ class PetConfigController extends AdminController
             $grid->column('created_at', '创建时间');
             $grid->column('updated_at', '更新时间');
 
+            // 添加生成JSON配置按钮
+            $grid->tools(function ($tools) {
+                $tools->append('<a class="btn btn-primary btn-sm" href="javascript:void(0);" onclick="generatePetJson()">生成宠物配置JSON</a>');
+
+                // 添加JavaScript代码
+                admin_script(<<<JS
+                function generatePetJson() {
+                    $.ajax({
+                        method: 'GET',
+                        url: '/admin/pet-configs/generate-json',
+                        success: function (data) {
+                            if (data.status === 'success') {
+                                Dcat.success(data.message);
+                            } else {
+                                Dcat.error(data.message);
+                            }
+                        },
+                        error: function (xhr) {
+                            Dcat.error('生成JSON失败: ' + xhr.statusText);
+                        }
+                    });
+                }
+                JS);
+            });
+
             // 筛选
             $grid->filter(function ($filter) {
                 $helper = new FilterHelper($filter, $this);
@@ -105,8 +147,8 @@ class PetConfigController extends AdminController
             $helper->embedsCats('grade_probability', '品阶概率配置')
                 ->help('各品阶的概率配置,如:{"FIRST":0.6,"SECOND":0.25,"THIRD":0.1,"FOURTH":0.05}');
 
-                
-    
+
+
 
             $helper->embedsCats('display_attributes', '显示属性配置')
                 ->help('宠物的显示属性配置');

+ 2 - 1
app/Module/Pet/Providers/PetServiceProvider.php

@@ -2,6 +2,7 @@
 
 namespace App\Module\Pet\Providers;
 
+use App\Module\Pet\Commands\GeneratePetJsonCommand;
 use App\Module\Pet\Events\PetBattleEvent;
 use App\Module\Pet\Events\PetCreatedEvent;
 use App\Module\Pet\Events\PetLevelUpEvent;
@@ -58,7 +59,7 @@ class PetServiceProvider extends ServiceProvider
         // 注册命令
         if ($this->app->runningInConsole()) {
             $this->commands([
-                // 可以在这里添加宠物模块的命令
+                \App\Module\Pet\Commands\GeneratePetJsonCommand::class, // 生成宠物配置JSON数据命令
             ]);
         }
     }

+ 0 - 688
app/Module/Task/Docs/API接口设计.md

@@ -1,688 +0,0 @@
-# 任务模块API接口设计
-
-## 1. 接口概述
-
-任务模块提供以下主要API接口:
-
-1. 获取任务列表
-2. 获取任务详情
-3. 接取任务
-4. 放弃任务
-5. 完成任务
-6. 领取任务奖励
-7. 获取任务进度
-
-## 2. 接口详细说明
-
-### 2.1 获取任务列表
-
-#### 请求
-
-```
-GET /api/task/list
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| type | string | 否 | 任务类型(daily, weekly, achievement, event, tutorial, team) |
-| status | int | 否 | 任务状态(0:未接取, 1:进行中, 2:已完成, 3:已领取奖励, 4:已失败, 5:已过期) |
-| category_id | int | 否 | 任务分类ID |
-| page | int | 否 | 页码,默认1 |
-| page_size | int | 否 | 每页数量,默认20 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "success",
-  "data": {
-    "total": 100,
-    "page": 1,
-    "page_size": 20,
-    "list": [
-      {
-        "id": 1,
-        "name": "每日登录",
-        "description": "完成每日登录任务",
-        "type": "daily",
-        "category": {
-          "id": 1,
-          "name": "日常任务"
-        },
-        "target_type": "login",
-        "target_count": 1,
-        "current_progress": 0,
-        "status": 0,
-        "rewards": [
-          {
-            "item_id": 1001,
-            "item_name": "金币",
-            "quantity": 100,
-            "icon": "coin.png"
-          }
-        ],
-        "time_limit": 86400,
-        "expire_at": "2023-06-01 00:00:00",
-        "is_available": true
-      }
-    ]
-  }
-}
-```
-
-### 2.2 获取任务详情
-
-#### 请求
-
-```
-GET /api/task/detail
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "success",
-  "data": {
-    "id": 1,
-    "name": "每日登录",
-    "description": "完成每日登录任务",
-    "type": "daily",
-    "category": {
-      "id": 1,
-      "name": "日常任务"
-    },
-    "target_type": "login",
-    "target_params": {
-      "specific_id": null
-    },
-    "target_count": 1,
-    "current_progress": 0,
-    "status": 0,
-    "rewards": [
-      {
-        "item_id": 1001,
-        "item_name": "金币",
-        "quantity": 100,
-        "icon": "coin.png"
-      }
-    ],
-    "prerequisite_tasks": [
-      {
-        "id": 101,
-        "name": "新手引导",
-        "is_completed": true
-      }
-    ],
-    "level_required": 1,
-    "time_limit": 86400,
-    "expire_at": "2023-06-01 00:00:00",
-    "is_available": true,
-    "unavailable_reason": null
-  }
-}
-```
-
-### 2.3 接取任务
-
-#### 请求
-
-```
-POST /api/task/accept
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务接取成功",
-  "data": {
-    "task_id": 1,
-    "status": 1,
-    "progress": 0,
-    "expire_at": "2023-06-01 00:00:00"
-  }
-}
-```
-
-#### 错误码
-
-| 错误码 | 说明 |
-|-------|------|
-| 1001 | 任务不存在 |
-| 1002 | 任务已接取 |
-| 1003 | 任务已过期 |
-| 1004 | 等级不足 |
-| 1005 | 前置任务未完成 |
-
-### 2.4 放弃任务
-
-#### 请求
-
-```
-POST /api/task/abandon
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务已放弃",
-  "data": {
-    "task_id": 1
-  }
-}
-```
-
-#### 错误码
-
-| 错误码 | 说明 |
-|-------|------|
-| 1001 | 任务不存在 |
-| 1006 | 任务未接取 |
-| 1007 | 任务已完成,无法放弃 |
-
-### 2.5 完成任务
-
-#### 请求
-
-```
-POST /api/task/complete
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务完成成功",
-  "data": {
-    "task_id": 1,
-    "status": 2,
-    "rewards": [
-      {
-        "item_id": 1001,
-        "item_name": "金币",
-        "quantity": 100,
-        "icon": "coin.png"
-      }
-    ],
-    "can_claim_now": true
-  }
-}
-```
-
-#### 错误码
-
-| 错误码 | 说明 |
-|-------|------|
-| 1001 | 任务不存在 |
-| 1006 | 任务未接取 |
-| 1008 | 任务进度不足,无法完成 |
-| 1009 | 任务已过期 |
-
-### 2.6 领取任务奖励
-
-#### 请求
-
-```
-POST /api/task/claim-reward
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "奖励领取成功",
-  "data": {
-    "task_id": 1,
-    "status": 3,
-    "rewards": [
-      {
-        "item_id": 1001,
-        "item_name": "金币",
-        "quantity": 100,
-        "icon": "coin.png"
-      }
-    ]
-  }
-}
-```
-
-#### 错误码
-
-| 错误码 | 说明 |
-|-------|------|
-| 1001 | 任务不存在 |
-| 1010 | 任务未完成,无法领取奖励 |
-| 1011 | 奖励已领取 |
-
-### 2.7 获取任务进度
-
-#### 请求
-
-```
-GET /api/task/progress
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "success",
-  "data": {
-    "task_id": 1,
-    "target_count": 10,
-    "current_progress": 5,
-    "percentage": 50,
-    "status": 1,
-    "details": [
-      {
-        "target_id": "1001",
-        "target_name": "种植萝卜",
-        "current_count": 5,
-        "required_count": 10
-      }
-    ],
-    "expire_at": "2023-06-01 00:00:00",
-    "time_remaining": 3600
-  }
-}
-```
-
-## 3. 事件通知接口
-
-### 3.1 任务进度更新通知
-
-当任务进度更新时,系统会向客户端推送通知。
-
-#### 通知内容
-
-```json
-{
-  "event": "task_progress_updated",
-  "data": {
-    "task_id": 1,
-    "old_progress": 4,
-    "new_progress": 5,
-    "target_count": 10,
-    "percentage": 50,
-    "is_completed": false
-  }
-}
-```
-
-### 3.2 任务完成通知
-
-当任务完成时,系统会向客户端推送通知。
-
-#### 通知内容
-
-```json
-{
-  "event": "task_completed",
-  "data": {
-    "task_id": 1,
-    "task_name": "每日登录",
-    "rewards": [
-      {
-        "item_id": 1001,
-        "item_name": "金币",
-        "quantity": 100,
-        "icon": "coin.png"
-      }
-    ],
-    "completed_at": "2023-05-31 15:30:45"
-  }
-}
-```
-
-### 3.3 任务过期通知
-
-当任务即将过期时,系统会向客户端推送通知。
-
-#### 通知内容
-
-```json
-{
-  "event": "task_expiring",
-  "data": {
-    "task_id": 1,
-    "task_name": "每日登录",
-    "expire_at": "2023-06-01 00:00:00",
-    "time_remaining": 3600
-  }
-}
-```
-
-## 4. 批量操作接口
-
-### 4.1 批量接取任务
-
-#### 请求
-
-```
-POST /api/task/batch-accept
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_ids | array | 是 | 任务ID数组 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "批量接取任务成功",
-  "data": {
-    "success_count": 2,
-    "failed_count": 1,
-    "results": [
-      {
-        "task_id": 1,
-        "success": true,
-        "message": "接取成功"
-      },
-      {
-        "task_id": 2,
-        "success": true,
-        "message": "接取成功"
-      },
-      {
-        "task_id": 3,
-        "success": false,
-        "message": "任务已接取",
-        "error_code": 1002
-      }
-    ]
-  }
-}
-```
-
-### 4.2 批量领取奖励
-
-#### 请求
-
-```
-POST /api/task/batch-claim-reward
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| task_ids | array | 是 | 任务ID数组 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "批量领取奖励成功",
-  "data": {
-    "success_count": 2,
-    "failed_count": 1,
-    "results": [
-      {
-        "task_id": 1,
-        "success": true,
-        "rewards": [
-          {
-            "item_id": 1001,
-            "item_name": "金币",
-            "quantity": 100
-          }
-        ]
-      },
-      {
-        "task_id": 2,
-        "success": true,
-        "rewards": [
-          {
-            "item_id": 1002,
-            "item_name": "钻石",
-            "quantity": 10
-          }
-        ]
-      },
-      {
-        "task_id": 3,
-        "success": false,
-        "message": "任务未完成",
-        "error_code": 1010
-      }
-    ],
-    "total_rewards": [
-      {
-        "item_id": 1001,
-        "item_name": "金币",
-        "quantity": 100
-      },
-      {
-        "item_id": 1002,
-        "item_name": "钻石",
-        "quantity": 10
-      }
-    ]
-  }
-}
-```
-
-## 5. 管理接口
-
-### 5.1 创建任务
-
-#### 请求
-
-```
-POST /api/admin/task/create
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| name | string | 是 | 任务名称 |
-| description | string | 否 | 任务描述 |
-| category_id | int | 是 | 任务分类ID |
-| type | string | 是 | 任务类型 |
-| target_type | string | 是 | 目标类型 |
-| target_params | object | 否 | 目标参数 |
-| target_count | int | 是 | 目标数量 |
-| rewards | array | 是 | 奖励内容 |
-| prerequisite_tasks | array | 否 | 前置任务 |
-| level_required | int | 否 | 所需等级 |
-| time_limit | int | 否 | 时间限制(秒) |
-| reset_type | string | 否 | 重置类型 |
-| is_active | boolean | 否 | 是否激活 |
-| start_time | string | 否 | 开始时间 |
-| end_time | string | 否 | 结束时间 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务创建成功",
-  "data": {
-    "id": 10,
-    "name": "新任务",
-    "type": "daily",
-    "created_at": "2023-05-31 16:00:00"
-  }
-}
-```
-
-### 5.2 更新任务
-
-#### 请求
-
-```
-POST /api/admin/task/update
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| id | int | 是 | 任务ID |
-| name | string | 否 | 任务名称 |
-| description | string | 否 | 任务描述 |
-| category_id | int | 否 | 任务分类ID |
-| type | string | 否 | 任务类型 |
-| target_type | string | 否 | 目标类型 |
-| target_params | object | 否 | 目标参数 |
-| target_count | int | 否 | 目标数量 |
-| rewards | array | 否 | 奖励内容 |
-| prerequisite_tasks | array | 否 | 前置任务 |
-| level_required | int | 否 | 所需等级 |
-| time_limit | int | 否 | 时间限制(秒) |
-| reset_type | string | 否 | 重置类型 |
-| is_active | boolean | 否 | 是否激活 |
-| start_time | string | 否 | 开始时间 |
-| end_time | string | 否 | 结束时间 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务更新成功",
-  "data": {
-    "id": 10,
-    "updated_at": "2023-05-31 16:30:00"
-  }
-}
-```
-
-### 5.3 删除任务
-
-#### 请求
-
-```
-POST /api/admin/task/delete
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| id | int | 是 | 任务ID |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务删除成功",
-  "data": {
-    "id": 10
-  }
-}
-```
-
-### 5.4 手动重置任务
-
-#### 请求
-
-```
-POST /api/admin/task/reset
-```
-
-#### 请求参数
-
-| 参数名 | 类型 | 必填 | 说明 |
-|-------|------|------|------|
-| reset_type | string | 是 | 重置类型(daily, weekly, monthly) |
-| task_ids | array | 否 | 指定任务ID数组,为空则重置所有符合类型的任务 |
-
-#### 响应
-
-```json
-{
-  "code": 0,
-  "message": "任务重置成功",
-  "data": {
-    "reset_type": "daily",
-    "affected_count": 15,
-    "reset_time": "2023-05-31 00:00:00"
-  }
-}
-```
-
-## 6. 错误码汇总
-
-| 错误码 | 说明 |
-|-------|------|
-| 1001 | 任务不存在 |
-| 1002 | 任务已接取 |
-| 1003 | 任务已过期 |
-| 1004 | 等级不足 |
-| 1005 | 前置任务未完成 |
-| 1006 | 任务未接取 |
-| 1007 | 任务已完成,无法放弃 |
-| 1008 | 任务进度不足,无法完成 |
-| 1009 | 任务已过期 |
-| 1010 | 任务未完成,无法领取奖励 |
-| 1011 | 奖励已领取 |
-| 1012 | 任务不可用 |
-| 1013 | 任务已失败 |
-| 1014 | 批量操作部分失败 |
-| 1015 | 参数错误 |
-| 1016 | 操作频率限制 |
-| 1017 | 系统错误 |
-
-## 7. 接口安全性
-
-1. 所有接口都需要进行用户身份验证
-2. 敏感操作(如领取奖励)需要进行额外的安全验证
-3. 接口访问频率限制,防止恶意请求
-4. 服务端验证所有请求参数,防止非法数据
-5. 记录关键操作日志,用于审计和问题排查

+ 418 - 0
app/Module/Task/Docs/Proto设计.md

@@ -0,0 +1,418 @@
+# 任务模块Proto设计
+
+## 1. 概述
+
+本文档描述了任务模块的Protocol Buffers (proto) 设计,包括请求和响应消息的定义、字段说明以及与现有系统的集成方式。任务模块的proto设计遵循系统现有的proto通信模式,提供标准化的数据交换格式。
+
+## 2. Proto文件结构
+
+任务模块的proto定义建议添加到系统的主proto文件(`proto/game.proto`)中,或者创建独立的`task.proto`文件并在主文件中导入。
+
+### 2.1 建议的文件结构
+
+```protobuf
+// task.proto
+syntax = "proto3";
+
+package uraus.kku;
+
+// 导入公共定义
+import "common.proto";
+
+// 任务相关请求消息
+
+// RequestTaskList: 获取任务列表的请求
+// 用于获取符合条件的任务列表,支持分页和多种过滤条件
+// 可根据分类、类型和状态进行过滤,并支持分页显示
+// 客户端可以使用该接口实现任务列表页面的数据加载
+// 对应响应:ResponseTaskList
+message RequestTaskList {
+  int32 category_id = 1;        // 任务分类ID,可选
+  string type = 2;              // 任务类型,可选
+  int32 status = 3;             // 任务状态,可选
+  int32 page = 4;               // 页码,默认1
+  int32 page_size = 5;          // 每页数量,默认20
+}
+
+// RequestTaskDetail: 获取任务详情的请求
+// 用于获取指定任务的详细信息,包括任务基本信息、条件和进度
+// 客户端可以使用该接口实现任务详情页面的数据加载
+// 对应响应:ResponseTaskDetail
+message RequestTaskDetail {
+  int32 task_id = 1;            // 任务ID,必填
+}
+
+// RequestTaskAccept: 接取任务的请求
+// 用于接取指定的任务,将任务添加到用户的任务列表中
+// 接取任务后,用户可以开始完成任务并获得进度跟踪
+// 对应响应:ResponseTaskAccept
+message RequestTaskAccept {
+  int32 task_id = 1;            // 任务ID,必填
+}
+
+// RequestTaskAbandon: 放弃任务的请求
+// 用于放弃已接取但尚未完成的任务
+// 放弃任务后,任务进度将被重置,需要重新接取才能继续
+// 对应响应:ResponseTaskAbandon
+message RequestTaskAbandon {
+  int32 task_id = 1;            // 任务ID,必填
+}
+
+
+
+
+// 任务相关响应消息
+
+// ResponseTaskList: 任务列表查询的响应
+// 返回符合条件的任务列表,包含分页信息和任务基本数据
+// 客户端可以使用该响应渲染任务列表页面
+// 对应请求:RequestTaskList
+message ResponseTaskList {
+  int32 total = 1;                      // 总任务数
+  int32 page = 2;                       // 当前页码
+  int32 page_size = 3;                  // 每页数量
+  repeated TaskInfo tasks = 4;          // 任务列表
+}
+
+// ResponseTaskDetail: 任务详情查询的响应
+// 返回指定任务的详细信息,包括任务基本信息、条件和当前进度
+// 客户端可以使用该响应渲染任务详情页面
+// 对应请求:RequestTaskDetail
+message ResponseTaskDetail {
+  TaskInfo task = 1;                    // 任务详情
+  repeated TaskConditionInfo conditions = 2;  // 任务条件详情
+  TaskProgressInfo progress = 3;        // 任务进度
+}
+
+// ResponseTaskAccept: 接取任务的响应
+// 返回任务接取的结果,包括成功标志、提示消息、任务信息和消耗信息
+// 如果接取成功,返回任务的详细信息和消耗的资源;如果失败,返回错误消息
+// 对应请求:RequestTaskAccept
+message ResponseTaskAccept {
+  bool success = 1;                     // 是否成功
+  string message = 2;                   // 消息
+  TaskInfo task = 3;                    // 接取的任务信息
+  repeated CostInfo costs = 4;          // 消耗的资源
+}
+
+// ResponseTaskAbandon: 放弃任务的响应
+// 返回任务放弃的结果,包括成功标志和提示消息
+// 如果放弃成功,任务将从用户的任务列表中移除
+// 对应请求:RequestTaskAbandon
+message ResponseTaskAbandon {
+  bool success = 1;                     // 是否成功
+  string message = 2;                   // 消息
+}
+
+// ResponseTaskComplete: 完成任务的响应
+// 返回任务完成的结果,包括成功标志、提示消息和可领取的奖励
+// 如果完成成功,返回可领取的奖励列表;如果失败,返回错误消息
+// 对应请求:RequestTaskComplete
+message ResponseTaskComplete {
+  bool success = 1;                     // 是否成功
+  string message = 2;                   // 消息
+  repeated RewardInfo rewards = 3;      // 可领取的奖励
+}
+
+// ResponseTaskClaimReward: 领取任务奖励的响应
+// 返回奖励领取的结果,包括成功标志、提示消息和已领取的奖励
+// 如果领取成功,返回已领取的奖励列表;如果失败,返回错误消息
+// 对应请求:RequestTaskClaimReward
+message ResponseTaskClaimReward {
+  bool success = 1;                     // 是否成功
+  string message = 2;                   // 消息
+  repeated RewardInfo rewards = 3;      // 已领取的奖励
+}
+
+// ResponseTaskProgress: 任务进度查询的响应
+// 返回用户当前的任务进度情况,包含一个或多个任务的进度信息
+// 客户端可以使用该响应更新任务进度显示
+// 对应请求:RequestTaskProgress
+message ResponseTaskProgress {
+  repeated TaskProgressInfo progress_list = 1;  // 任务进度列表
+}
+
+// 任务信息
+// TaskInfo: 任务的基本信息
+// 包含任务的完整属性,用于在客户端显示任务信息和状态
+// 在任务列表、任务详情和任务接取等响应中使用
+message TaskInfo {
+  int32 id = 1;                         // 任务ID
+  string name = 2;                      // 任务名称
+  string description = 3;               // 任务描述
+  string type = 4;                      // 任务类型
+  CategoryInfo category = 5;            // 任务分类
+  string target_type = 6;               // 目标类型
+  int32 target_count = 7;               // 目标数量
+  int32 current_progress = 8;           // 当前进度
+  int32 status = 9;                     // 任务状态
+  repeated RewardInfo rewards = 10;     // 奖励列表
+  repeated CostInfo costs = 11;         // 接取消耗列表
+  int32 time_limit = 12;                // 时间限制(秒)
+  string expire_at = 13;                // 过期时间
+  bool is_available = 14;               // 是否可用
+  int32 level_required = 15;            // 所需等级
+  string reset_type = 16;               // 重置类型
+  string display_params = 17;           // 显示参数(JSON字符串)
+  int32 max_completions = 18;           // 最大完成次数
+  int32 sort_order = 19;                // 排序权重
+}
+
+// 任务分类信息
+// CategoryInfo: 任务分类的基本信息
+// 包含任务分类的ID、名称和编码,用于在客户端对任务进行分类显示
+// 在TaskInfo中作为子字段使用
+message CategoryInfo {
+  int32 id = 1;                         // 分类ID
+  string name = 2;                      // 分类名称
+  string code = 3;                      // 分类编码
+}
+
+// 任务条件信息
+// TaskConditionInfo: 任务完成条件的信息
+// 包含任务条件的完整属性,用于在客户端显示任务条件和进度
+// 在ResponseTaskDetail响应中作为条件列表使用
+message TaskConditionInfo {
+  int32 id = 1;                         // 条件ID
+  string condition_type = 2;            // 条件类型
+  int32 target_value = 3;               // 目标值
+  string operator = 4;                  // 运算符
+  bool is_required = 5;                 // 是否必须
+  string params_json = 6;               // 条件参数(JSON字符串)
+}
+
+// 任务进度信息
+// TaskProgressInfo: 任务完成进度的信息
+// 包含任务的当前进度和目标值,以及各条件的进度详情
+// 在ResponseTaskProgress响应和ResponseTaskDetail响应中使用
+message TaskProgressInfo {
+  int32 task_id = 1;                    // 任务ID
+  int32 current_value = 2;              // 当前值
+  int32 target_value = 3;               // 目标值
+  int32 percentage = 4;                 // 完成百分比
+  bool is_completed = 5;                // 是否已完成
+  repeated ConditionProgressInfo condition_progress = 6;  // 条件进度
+}
+
+// 条件进度信息
+// ConditionProgressInfo: 单个条件的进度信息
+// 包含条件的当前进度和目标值,以及完成状态
+// 在TaskProgressInfo中作为条件进度列表使用
+message ConditionProgressInfo {
+  int32 condition_id = 1;               // 条件ID
+  int32 current_value = 2;              // 当前值
+  int32 target_value = 3;               // 目标值
+  bool is_completed = 4;                // 是否已完成
+}
+
+// 奖励信息
+// RewardInfo: 任务奖励的信息
+// 包含奖励的类型、参数、名称、数量和图标等信息
+// 在TaskInfo中作为奖励列表使用,以及在奖励相关响应中使用
+message RewardInfo {
+  string reward_type = 1;               // 奖励类型
+  string reward_param1 = 2;             // 奖励参数1
+  string reward_param2 = 3;             // 奖励参数2
+  string reward_name = 4;               // 奖励名称
+  int32 quantity = 5;                   // 数量
+  string icon = 6;                      // 图标
+  int32 sort_order = 7;                 // 排序权重
+}
+
+// 消耗信息
+// CostInfo: 任务接取消耗的信息
+// 包含消耗的类型、参数、名称、数量和图标等信息
+// 在TaskInfo中作为消耗列表使用,以及在任务接取相关响应中使用
+message CostInfo {
+  string cost_type = 1;                 // 消耗类型
+  string cost_param1 = 2;               // 消耗参数1
+  string cost_param2 = 3;               // 消耗参数2
+  string cost_name = 4;                 // 消耗名称
+  int32 quantity = 5;                   // 数量
+  string icon = 6;                      // 图标
+  int32 sort_order = 7;                 // 排序权重
+}
+```
+
+## 3. 与现有系统集成
+
+### 3.1 在主proto文件中添加任务模块
+
+在`proto/game.proto`文件中,需要在Request和Response消息中添加任务模块的字段:
+
+```protobuf
+// 在Request消息中添加
+message Request {
+  // 现有字段...
+
+  RequestTaskList task_list = 500;
+  RequestTaskDetail task_detail = 501;
+  RequestTaskAccept task_accept = 502;
+  RequestTaskAbandon task_abandon = 503;
+  RequestTaskComplete task_complete = 504;
+  RequestTaskClaimReward task_claim_reward = 505;
+  RequestTaskProgress task_progress = 506;
+}
+
+// 在Response消息中添加
+message Response {
+  // 现有字段...
+
+  ResponseTaskList task_list = 500;
+  ResponseTaskDetail task_detail = 501;
+  ResponseTaskAccept task_accept = 502;
+  ResponseTaskAbandon task_abandon = 503;
+  ResponseTaskComplete task_complete = 504;
+  ResponseTaskClaimReward task_claim_reward = 505;
+  ResponseTaskProgress task_progress = 506;
+}
+```
+
+### 3.2 更新proto路由配置
+
+在`config/proto_route.php`文件中添加任务模块的路由配置:
+
+```php
+'task' => [
+    'list',
+    'detail',
+    'accept',
+    'abandon',
+    'complete',
+    'claim_reward',
+    'progress',
+],
+```
+
+## 4. 处理器实现
+
+为了处理任务模块的proto请求,需要在`App\Module\AppGame\Handler\Task`目录下创建相应的处理器类:
+
+```
+app/Module/AppGame/Handler/Task/
+├── ListHandler.php
+├── DetailHandler.php
+├── AcceptHandler.php
+├── AbandonHandler.php
+├── CompleteHandler.php
+├── ClaimRewardHandler.php
+└── ProgressHandler.php
+```
+
+每个处理器类需要实现相应的处理逻辑,并返回对应的响应消息。
+
+### 4.1 处理器示例
+
+```php
+<?php
+
+namespace App\Module\AppGame\Handler\Task;
+
+use App\Module\AppGame\Handler\BaseHandler;
+use App\Module\Task\Services\TaskService;
+use Uraus\Kku\Request\RequestTaskList;
+use Uraus\Kku\Response\ResponseTaskList;
+
+class ListHandler extends BaseHandler
+{
+    protected $taskService;
+
+    public function __construct(TaskService $taskService)
+    {
+        $this->taskService = $taskService;
+    }
+
+    public function handle(RequestTaskList $request)
+    {
+        // 获取请求参数
+        $categoryId = $request->getCategoryId();
+        $type = $request->getType();
+        $status = $request->getStatus();
+        $page = $request->getPage() ?: 1;
+        $pageSize = $request->getPageSize() ?: 20;
+
+        // 调用服务获取任务列表
+        $result = $this->taskService->getTaskList(
+            $this->userId,
+            $categoryId,
+            $type,
+            $status,
+            $page,
+            $pageSize
+        );
+
+        // 构建响应
+        $response = new ResponseTaskList();
+        $response->setTotal($result['total']);
+        $response->setPage($page);
+        $response->setPageSize($pageSize);
+
+        // 添加任务列表
+        foreach ($result['list'] as $task) {
+            $taskInfo = $this->buildTaskInfo($task);
+            $response->addTasks($taskInfo);
+        }
+
+        return $response;
+    }
+
+    protected function buildTaskInfo($task)
+    {
+        // 构建TaskInfo对象
+        // ...
+    }
+}
+```
+
+## 5. 事件通知
+
+任务模块可以通过WebSocket或其他实时通信方式向客户端推送事件通知。以下是建议的事件通知proto定义:
+
+```protobuf
+// 任务进度更新通知
+// TaskProgressUpdatedEvent: 任务进度更新的事件通知
+// 当任务进度发生变化时,服务器向客户端推送该事件
+// 客户端可以根据该事件实时更新任务进度显示
+message TaskProgressUpdatedEvent {
+  int32 task_id = 1;                // 任务ID
+  int32 old_progress = 2;           // 旧进度
+  int32 new_progress = 3;           // 新进度
+  int32 target_count = 4;           // 目标数量
+  int32 percentage = 5;             // 完成百分比
+  bool is_completed = 6;            // 是否已完成
+}
+
+// 任务完成通知
+// TaskCompletedEvent: 任务完成的事件通知
+// 当任务完成时,服务器向客户端推送该事件
+// 客户端可以根据该事件显示任务完成提示和奖励信息
+message TaskCompletedEvent {
+  int32 task_id = 1;                // 任务ID
+  string task_name = 2;             // 任务名称
+  repeated RewardInfo rewards = 3;  // 奖励列表
+  string completed_at = 4;          // 完成时间
+}
+
+// 任务过期通知
+// TaskExpiringEvent: 任务即将过期的事件通知
+// 当任务即将过期时,服务器向客户端推送该事件
+// 客户端可以根据该事件显示任务即将过期的提示,提醒用户尽快完成
+message TaskExpiringEvent {
+  int32 task_id = 1;                // 任务ID
+  string task_name = 2;             // 任务名称
+  string expire_at = 3;             // 过期时间
+  int32 time_remaining = 4;         // 剩余时间(秒)
+}
+
+// 任务消耗通知
+// TaskCostEvent: 任务接取消耗的事件通知
+// 当用户接取需要消耗资源的任务时,服务器向客户端推送该事件
+// 客户端可以根据该事件显示资源消耗提示,并更新用户资源显示
+message TaskCostEvent {
+  int32 task_id = 1;                // 任务ID
+  string task_name = 2;             // 任务名称
+  repeated CostInfo costs = 3;      // 消耗资源列表
+  string cost_at = 4;               // 消耗时间
+}
+```
+

+ 1 - 126
app/Module/Task/Docs/create.sql

@@ -1,126 +1 @@
--- 任务分类表
-DROP TABLE IF EXISTS `kku_task_categories`;
-CREATE TABLE `kku_task_categories` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '分类ID,主键',
-  `name` varchar(100) NOT NULL COMMENT '分类名称',
-  `code` varchar(50) NOT NULL COMMENT '分类编码(唯一)',
-  `description` varchar(255) DEFAULT NULL COMMENT '分类描述',
-  `sort_order` int NOT NULL DEFAULT '0' COMMENT '排序顺序',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `idx_code` (`code`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务分类表';
-
--- 任务定义表
-DROP TABLE IF EXISTS `kku_task_tasks`;
-CREATE TABLE `kku_task_tasks` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '任务ID,主键',
-  `category_id` int NOT NULL COMMENT '任务分类ID,外键关联kku_task_categories表',
-  `name` varchar(100) NOT NULL COMMENT '任务名称',
-  `description` varchar(500) DEFAULT NULL COMMENT '任务描述',
-  `type` varchar(20) NOT NULL COMMENT '任务类型(daily, weekly, achievement, event, tutorial, team)',
-  `target_type` varchar(30) NOT NULL COMMENT '目标类型(plant, harvest, upgrade_land等)',
-  `target_params` json DEFAULT NULL COMMENT '目标参数(JSON格式,如特定作物ID)',
-  `target_count` int NOT NULL DEFAULT '1' COMMENT '目标数量',
-  `rewards` json NOT NULL COMMENT '奖励内容(JSON格式)',
-  `prerequisite_tasks` json DEFAULT NULL COMMENT '前置任务ID(JSON格式)',
-  `level_required` int NOT NULL DEFAULT '0' COMMENT '所需等级',
-  `time_limit` int DEFAULT NULL COMMENT '时间限制(秒,NULL表示无限制)',
-  `reset_type` varchar(20) NOT NULL DEFAULT 'none' COMMENT '重置类型(none, daily, weekly, monthly)',
-  `is_active` tinyint NOT NULL DEFAULT '1' COMMENT '是否激活(0:否, 1:是)',
-  `start_time` timestamp NULL DEFAULT NULL COMMENT '开始时间(NULL表示立即开始)',
-  `end_time` timestamp NULL DEFAULT NULL COMMENT '结束时间(NULL表示永不结束)',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`),
-  KEY `idx_category` (`category_id`),
-  KEY `idx_type` (`type`),
-  KEY `idx_target_type` (`target_type`),
-  KEY `idx_active_time` (`is_active`, `start_time`, `end_time`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务定义表';
-
--- 用户任务关联表
-DROP TABLE IF EXISTS `kku_task_user_tasks`;
-CREATE TABLE `kku_task_user_tasks` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `user_id` int NOT NULL COMMENT '用户ID',
-  `task_id` int NOT NULL COMMENT '任务ID,外键关联kku_task_tasks表',
-  `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态(0:未接取, 1:进行中, 2:已完成, 3:已领取奖励, 4:已失败, 5:已过期)',
-  `progress` int NOT NULL DEFAULT '0' COMMENT '当前进度',
-  `completed_at` timestamp NULL DEFAULT NULL COMMENT '完成时间',
-  `rewarded_at` timestamp NULL DEFAULT NULL COMMENT '奖励发放时间',
-  `expire_at` timestamp NULL DEFAULT NULL COMMENT '过期时间',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `idx_user_task` (`user_id`, `task_id`),
-  KEY `idx_user_status` (`user_id`, `status`),
-  KEY `idx_task` (`task_id`),
-  KEY `idx_expire` (`expire_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户任务关联表';
-
--- 用户任务进度表
-DROP TABLE IF EXISTS `kku_task_user_progress`;
-CREATE TABLE `kku_task_user_progress` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `user_id` int NOT NULL COMMENT '用户ID',
-  `task_id` int NOT NULL COMMENT '任务ID,外键关联kku_task_tasks表',
-  `target_id` varchar(100) NOT NULL COMMENT '目标ID(如特定作物ID、物品ID等)',
-  `current_count` int NOT NULL DEFAULT '0' COMMENT '当前计数',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `idx_user_task_target` (`user_id`, `task_id`, `target_id`),
-  KEY `idx_user_task` (`user_id`, `task_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户任务进度表';
-
--- 任务完成日志表
-DROP TABLE IF EXISTS `kku_task_completion_logs`;
-CREATE TABLE `kku_task_completion_logs` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `user_id` int NOT NULL COMMENT '用户ID',
-  `task_id` int NOT NULL COMMENT '任务ID,外键关联kku_task_tasks表',
-  `completed_at` timestamp NOT NULL COMMENT '完成时间',
-  `time_spent` int DEFAULT NULL COMMENT '完成耗时(秒)',
-  `ip_address` varchar(45) DEFAULT NULL COMMENT 'IP地址',
-  `device_info` varchar(255) DEFAULT NULL COMMENT '设备信息',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  PRIMARY KEY (`id`),
-  KEY `idx_user` (`user_id`),
-  KEY `idx_task` (`task_id`),
-  KEY `idx_completed_at` (`completed_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务完成日志表';
-
--- 任务奖励发放日志表
-DROP TABLE IF EXISTS `kku_task_reward_logs`;
-CREATE TABLE `kku_task_reward_logs` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `user_id` int NOT NULL COMMENT '用户ID',
-  `task_id` int NOT NULL COMMENT '任务ID,外键关联kku_task_tasks表',
-  `user_task_id` int NOT NULL COMMENT '用户任务ID,外键关联kku_task_user_tasks表',
-  `rewards` json NOT NULL COMMENT '奖励内容(JSON格式)',
-  `rewarded_at` timestamp NOT NULL COMMENT '奖励发放时间',
-  `ip_address` varchar(45) DEFAULT NULL COMMENT 'IP地址',
-  `device_info` varchar(255) DEFAULT NULL COMMENT '设备信息',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  PRIMARY KEY (`id`),
-  KEY `idx_user` (`user_id`),
-  KEY `idx_task` (`task_id`),
-  KEY `idx_user_task` (`user_task_id`),
-  KEY `idx_rewarded_at` (`rewarded_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务奖励发放日志表';
-
--- 任务重置日志表
-DROP TABLE IF EXISTS `kku_task_reset_logs`;
-CREATE TABLE `kku_task_reset_logs` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `reset_type` varchar(20) NOT NULL COMMENT '重置类型(daily, weekly, monthly)',
-  `reset_time` timestamp NOT NULL COMMENT '重置时间',
-  `affected_tasks` json DEFAULT NULL COMMENT '受影响的任务ID列表(JSON格式)',
-  `affected_count` int NOT NULL DEFAULT '0' COMMENT '受影响的任务数量',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  PRIMARY KEY (`id`),
-  KEY `idx_reset_type` (`reset_type`),
-  KEY `idx_reset_time` (`reset_time`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='任务重置日志表';
+# 任务模块数据库创建脚本

+ 0 - 16
app/Module/Task/Docs/task_user_progress_modified.sql

@@ -1,16 +0,0 @@
--- 修改后的用户任务进度表(关联到任务达成条件)
-DROP TABLE IF EXISTS `kku_task_user_progress`;
-CREATE TABLE `kku_task_user_progress` (
-  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
-  `user_id` int NOT NULL COMMENT '用户ID',
-  `task_id` int NOT NULL COMMENT '任务ID,外键关联kku_task_tasks表',
-  `achievement_condition_id` int NOT NULL COMMENT '达成条件ID,外键关联kku_task_achievement_conditions表',
-  `current_value` int NOT NULL DEFAULT '0' COMMENT '当前值',
-  `last_update_time` timestamp NULL DEFAULT NULL COMMENT '最后更新时间',
-  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
-  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
-  PRIMARY KEY (`id`),
-  UNIQUE KEY `idx_user_task_condition` (`user_id`, `task_id`, `achievement_condition_id`),
-  KEY `idx_user_task` (`user_id`, `task_id`),
-  KEY `idx_achievement_condition` (`achievement_condition_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户任务进度表';

+ 321 - 0
app/Module/Task/Docs/任务配置表.md

@@ -0,0 +1,321 @@
+# 任务配置表设计
+
+## 1. 概述
+
+本文档描述了任务模块的配置表设计,包括配置表的结构、字段说明和示例。任务配置表用于服务端和客户端之间的数据交换,确保双方对任务的理解一致。
+
+任务配置表采用单一配置文件设计,包含以下主要内容:
+
+1. **任务基础信息**:定义任务的基本属性
+2. **完成条件**:定义任务的完成条件
+3. **奖励内容**:定义任务的奖励内容
+
+## 2. 配置表结构
+
+### 2.1 任务配置表(tasks.json)
+
+任务配置表采用单一JSON文件设计,包含任务的基本信息、完成条件和奖励内容。
+
+#### 2.1.1 任务基础信息字段
+
+| 字段名 | 类型 | 必填 | 说明 |
+|-------|------|------|------|
+| id | int | 是 | 任务ID,唯一标识 |
+| name | string | 是 | 任务名称 |
+| description | string | 是 | 任务描述 |
+| category_id | int | 是 | 任务分类ID(服务端使用,客户端仅作参考) |
+| type | string | 是 | 任务类型(daily, weekly, achievement, event, tutorial, team) |
+| level_required | int | 是 | 所需等级 |
+| time_limit | int | 否 | 时间限制(秒,0表示无限制) |
+| max_completions | int | 是 | 最大完成次数 |
+| reset_type | string | 是 | 重置类型(none, daily, weekly, monthly) |
+| is_active | bool | 是 | 是否激活 |
+| sort_order | int | 是 | 排序权重(数值越大越靠前) |
+| start_time | string | 否 | 开始时间(格式:YYYY-MM-DD HH:MM:SS,空字符串表示立即开始) |
+| end_time | string | 否 | 结束时间(格式:YYYY-MM-DD HH:MM:SS,空字符串表示永不结束) |
+| display_params | object | 是 | 显示参数,详见下方说明 |
+| conditions | array | 是 | 任务完成条件数组 |
+| rewards | array | 是 | 任务奖励数组 |
+
+#### 2.1.2 display_params字段说明
+
+| 字段名 | 类型 | 必填 | 说明 |
+|-------|------|------|------|
+| icon | string | 是 | 任务图标路径 |
+| background | string | 否 | 任务背景图路径 |
+| color_theme | string | 否 | 颜色主题(blue, green, red, yellow等) |
+| priority | int | 否 | 显示优先级 |
+| ui_group | string | 否 | UI分组(main, farm, pet等) |
+| show_progress | bool | 是 | 是否显示进度 |
+| progress_style | string | 否 | 进度条样式(percentage, bar, step等) |
+| show_timer | bool | 否 | 是否显示计时器 |
+| timer_style | string | 否 | 计时器样式(countdown, clock等) |
+| animation | string | 否 | 动画效果(pulse, grow, fade等) |
+| jump_target | string | 否 | 跳转目标(点击任务后跳转的场景) |
+| tags | array | 否 | 标签列表 |
+| client_custom | object | 否 | 客户端自定义参数 |
+
+#### 2.1.3 conditions字段说明
+
+每个条件对象包含以下字段:
+
+| 字段名 | 类型 | 必填 | 说明 |
+|-------|------|------|------|
+| id | int | 是 | 条件ID,唯一标识 |
+| condition_type | string | 是 | 条件类型(login, plant, harvest等) |
+| target_value | int | 是 | 目标值 |
+| operator | string | 是 | 运算符(=, >, >=, <, <=) |
+| params | object | 否 | 条件参数 |
+| is_required | bool | 是 | 是否必须满足 |
+| sort_order | int | 是 | 排序权重 |
+| client_display | object | 是 | 客户端显示参数 |
+
+client_display字段说明:
+
+| 字段名 | 类型 | 必填 | 说明 |
+|-------|------|------|------|
+| text | string | 是 | 条件文本描述,可包含{target_value}等占位符 |
+| icon | string | 否 | 条件图标路径 |
+
+#### 2.1.4 rewards字段说明
+
+每个奖励对象包含以下字段:
+
+| 字段名 | 类型 | 必填 | 说明 |
+|-------|------|------|------|
+| id | int | 是 | 奖励ID,唯一标识 |
+| reward_type | string | 是 | 奖励类型(item, currency, experience等) |
+| reward_param1 | string | 是 | 奖励参数1(如物品类型、货币类型等) |
+| reward_param2 | string | 是 | 奖励参数2(如物品ID、货币ID等) |
+| quantity | int | 是 | 奖励数量 |
+
+#### 2.1.5 示例
+
+```json
+[
+  {
+    "id": 1001,
+    "name": "每日登录",
+    "description": "完成每日登录任务",
+    "category_id": 1,
+    "type": "daily",
+    "level_required": 1,
+    "time_limit": 86400,
+    "max_completions": 1,
+    "reset_type": "daily",
+    "is_active": true,
+    "sort_order": 100,
+    "start_time": "",
+    "end_time": "",
+    "display_params": {
+      "icon": "task_daily_login.png",
+      "background": "task_bg_blue.jpg",
+      "color_theme": "blue",
+      "priority": 100,
+      "ui_group": "main",
+      "show_progress": true,
+      "progress_style": "percentage",
+      "show_timer": true,
+      "timer_style": "countdown",
+      "animation": "pulse",
+      "jump_target": "",
+      "tags": ["new", "daily"],
+      "client_custom": {
+        "show_in_dashboard": true,
+        "notification_enabled": true
+      }
+    },
+    "conditions": [
+      {
+        "id": 1,
+        "condition_type": "login",
+        "target_value": 1,
+        "operator": "=",
+        "params": {},
+        "is_required": true,
+        "sort_order": 1,
+        "client_display": {
+          "text": "登录游戏",
+          "icon": "login_icon.png"
+        }
+      }
+    ],
+    "rewards": [
+      {
+        "id": 1,
+        "reward_type": "currency",
+        "reward_param1": "gold",
+        "reward_param2": "1",
+        "quantity": 100
+      }
+    ]
+  },
+  {
+    "id": 1002,
+    "name": "种植5次作物",
+    "description": "在农场中种植5次任意作物",
+    "category_id": 1,
+    "type": "daily",
+    "level_required": 2,
+    "time_limit": 86400,
+    "max_completions": 3,
+    "reset_type": "daily",
+    "is_active": true,
+    "sort_order": 200,
+    "start_time": "",
+    "end_time": "",
+    "display_params": {
+      "icon": "task_plant.png",
+      "background": "task_bg_green.jpg",
+      "color_theme": "green",
+      "priority": 200,
+      "ui_group": "farm",
+      "show_progress": true,
+      "progress_style": "bar",
+      "show_timer": true,
+      "timer_style": "countdown",
+      "animation": "grow",
+      "jump_target": "farm",
+      "tags": ["farm", "daily"],
+      "client_custom": {
+        "show_in_dashboard": true,
+        "notification_enabled": true
+      }
+    },
+    "conditions": [
+      {
+        "id": 2,
+        "condition_type": "plant",
+        "target_value": 5,
+        "operator": ">=",
+        "params": {},
+        "is_required": true,
+        "sort_order": 1,
+        "client_display": {
+          "text": "种植{target_value}次作物",
+          "icon": "plant_icon.png"
+        }
+      }
+    ],
+    "rewards": [
+      {
+        "id": 2,
+        "reward_type": "item",
+        "reward_param1": "fertilizer",
+        "reward_param2": "premium",
+        "quantity": 2
+      },
+      {
+        "id": 3,
+        "reward_type": "experience",
+        "reward_param1": "player",
+        "reward_param2": "level",
+        "quantity": 50
+      }
+    ]
+  }
+]
+```
+
+## 3. 配置表生成与更新
+
+任务配置表的生成与更新可通过以下方式实现:
+
+1. **后台管理导出**:通过后台管理界面导出当前的任务配置
+2. **数据库导出工具**:使用工具从数据库中导出任务配置
+3. **手动维护**:直接编辑JSON配置文件
+
+### 3.1 配置生成思路
+
+配置生成工具的基本思路如下:
+
+```
+1. 从数据库中获取所有激活的任务
+2. 对每个任务,获取其相关的条件和奖励
+3. 将任务、条件和奖励数据组装成统一的JSON结构
+4. 将生成的JSON数据写入配置文件
+5. 更新配置版本信息
+```
+
+### 3.2 版本控制
+
+为确保客户端使用最新的配置,可以实现版本控制机制:
+
+```
+{
+  "task_config": {
+    "version": "1.0.5",
+    "last_updated": "2023-06-01 10:30:00",
+    "files": ["tasks.json"]
+  }
+}
+```
+
+客户端可以定期检查配置版本,如果发现新版本,则下载更新。
+
+## 4. 客户端使用配置表
+
+客户端可以在启动时或需要时从服务器下载最新的配置表,并缓存到本地。这样可以确保客户端和服务端使用相同的任务定义。
+
+客户端可以使用配置表来:
+
+1. **显示任务列表**:根据配置表显示可用的任务
+2. **呈现任务详情**:显示任务的描述、条件和奖励
+3. **跟踪任务进度**:根据配置的条件显示当前进度
+4. **实现客户端预校验**:在提交到服务器前进行初步校验
+
+## 5. 配置表使用示例
+
+### 5.1 显示任务列表
+
+```
+1. 加载任务配置文件
+2. 根据任务类型和激活状态过滤任务
+3. 按排序权重对任务进行排序
+4. 渲染任务列表到界面
+```
+
+
+### 5.2 显示任务详情
+
+```
+1. 根据任务ID从配置中查找对应任务
+2. 获取任务的条件和奖励信息
+3. 对条件和奖励进行排序
+4. 渲染任务标题、条件和奖励信息
+```
+
+
+### 5.3 更新任务进度
+
+```
+1. 根据任务ID从配置中查找对应任务
+2. 获取任务的条件信息
+3. 遍历所有必要条件,计算已完成的条件数量
+   - 比较当前进度值与目标值
+   - 根据运算符判断条件是否完成
+4. 计算总体完成百分比
+5. 更新任务进度显示
+```
+
+
+## 6. 总结
+
+任务配置表是任务模块的重要组成部分,它定义了任务的基本信息、条件和奖励,确保服务端和客户端对任务的理解一致。通过合理设计和使用配置表,可以实现任务系统的灵活配置和高效管理。
+
+采用单一配置表的设计有以下优势:
+
+1. **简化管理**:只需维护一个配置文件,减少了管理复杂性
+2. **减少请求数**:客户端只需下载一个文件,减少了网络请求
+3. **数据一致性**:所有任务相关数据在一个文件中,确保了数据的一致性
+4. **客户端效率**:无需进行多表关联查询,提高了客户端处理效率
+
+配置表的设计考虑了以下几个方面:
+
+1. **完整性**:包含任务所需的所有信息
+2. **灵活性**:支持多种任务类型和条件组合
+3. **可扩展性**:可以方便地添加新的任务、条件和奖励
+4. **易用性**:结构清晰,易于理解和使用
+5. **性能**:合理的数据结构,便于客户端高效处理
+
+通过这个配置表,开发人员可以轻松地定义和管理任务,而无需修改代码,提高了系统的可维护性和扩展性。

+ 140 - 23
app/Module/Task/Docs/数据库设计.md

@@ -9,19 +9,21 @@
 1. **task_categories** - 任务分类表:存储任务的分类信息,用于对任务进行分组和管理。
 2. **task_tasks** - 任务定义表:存储任务的基本定义信息,包括任务名称、描述、类型等。
 3. **task_rewards** - 任务奖励定义表:存储任务的奖励内容,与任务定义表一对多关联。
-4. **task_conditions** - 任务条件表:定义系统中所有可用的条件类型,每种条件类型对应一个处理器类。
-5. **task_achievement_conditions** - 任务达成条件表:关联任务和具体的条件,定义了完成任务需要满足的条件。
+4. **task_costs** - 任务接取消耗表:存储接取任务所需的消耗资源,与任务定义表一对多关联。
+5. **task_conditions** - 任务条件表:定义系统中所有可用的条件类型,每种条件类型对应一个处理器类。
+6. **task_achievement_conditions** - 任务达成条件表:关联任务和具体的条件,定义了完成任务需要满足的条件。
 
 ### 1.2 任务完成相关表
 
-6. **task_user_tasks** - 用户任务关联表:存储用户与任务的关联信息,包括任务状态、进度、完成时间等。
-7. **task_user_progress** - 用户任务进度表:存储用户任务的详细进度信息,关联到具体的任务达成条件。
+7. **task_user_tasks** - 用户任务关联表:存储用户与任务的关联信息,包括任务状态、进度、完成时间等。
+8. **task_user_progress** - 用户任务进度表:存储用户任务的详细进度信息,关联到具体的任务达成条件。
 
 ### 1.3 日志记录相关表
 
-8. **task_completion_logs** - 任务完成日志表:记录用户完成任务的详细信息,用于审计和数据分析。
-9. **task_reward_logs** - 任务奖励发放日志表:记录任务奖励的发放情况,包括奖励内容、发放时间等。
-10. **task_reset_logs** - 任务重置日志表:记录任务重置的情况,包括重置类型、重置时间、影响的任务数等。
+9. **task_completion_logs** - 任务完成日志表:记录用户完成任务的详细信息,用于审计和数据分析。
+10. **task_reward_logs** - 任务奖励发放日志表:记录任务奖励的发放情况,包括奖励内容、发放时间等。
+11. **task_cost_logs** - 任务消耗日志表:记录用户接取任务时的资源消耗情况,包括消耗类型、数量、时间等。
+12. **task_reset_logs** - 任务重置日志表:记录任务重置的情况,包括重置类型、重置时间、影响的任务数等。
 
 ## 2. 表结构详细设计
 
@@ -59,7 +61,10 @@
 | prerequisite_tasks | json | 是 | NULL | 前置任务ID(JSON格式) |
 | level_required | int | 否 | 0 | 所需等级 |
 | time_limit | int | 是 | NULL | 时间限制(秒,NULL表示无限制) |
+| max_completions | int | 否 | 1 | 最大完成次数(用于限制任务可完成的次数) |
 | reset_type | varchar(20) | 否 | 'none' | 重置类型(none, daily, weekly, monthly) |
+| display_params | json | 是 | NULL | 显示参数(JSON格式,存储与任务显示相关的参数) |
+| sort_order | int | 否 | 0 | 排序权重(数值越大越靠前) |
 | is_active | tinyint | 否 | 1 | 是否激活(0:否, 1:是) |
 | start_time | timestamp | 是 | NULL | 开始时间(NULL表示立即开始) |
 | end_time | timestamp | 是 | NULL | 结束时间(NULL表示永不结束) |
@@ -71,19 +76,22 @@
 - KEY `idx_category` (`category_id`)
 - KEY `idx_type` (`type`)
 - KEY `idx_active_time` (`is_active`, `start_time`, `end_time`)
+- KEY `idx_sort` (`sort_order`)
 
 ### 2.1.3 任务奖励定义表 (task_rewards)
 
-存储任务的奖励内容,一个任务可以有多个不同类型的奖励。
+存储任务的奖励内容,一个任务可以有多个不同类型的奖励。每个奖励需要两个参数:reward_param1和reward_param2,用于更精确地定义奖励。
 
 | 字段名 | 类型 | 允许空 | 默认值 | 说明 |
 |-------|------|-------|-------|------|
 | id | int | 否 | 自增 | 主键 |
 | task_id | int | 否 | - | 任务ID,外键关联task_tasks表 |
 | reward_type | varchar(50) | 否 | - | 奖励类型(item, currency, experience, feature_unlock等) |
-| reward_id | int | 是 | NULL | 奖励ID(如物品ID、功能ID等) |
+| reward_param1 | varchar(100) | 否 | - | 奖励参数1(如物品类型、货币类型等) |
+| reward_param2 | varchar(100) | 否 | - | 奖励参数2(如物品ID、货币ID等) |
 | quantity | int | 否 | 1 | 奖励数量 |
 | extra_data | json | 是 | NULL | 额外数据(JSON格式) |
+| sort_order | int | 否 | 0 | 排序权重(数值越大越靠前) |
 | created_at | timestamp | 是 | NULL | 创建时间 |
 | updated_at | timestamp | 是 | NULL | 更新时间 |
 
@@ -91,8 +99,34 @@
 - PRIMARY KEY (`id`)
 - KEY `idx_task_id` (`task_id`)
 - KEY `idx_reward_type` (`reward_type`)
+- KEY `idx_reward_params` (`reward_param1`, `reward_param2`)
+- KEY `idx_sort` (`sort_order`)
 
-### 2.1.4 任务条件表 (task_conditions)
+### 2.1.4 任务接取消耗表 (task_costs)
+
+存储接取任务所需的消耗资源,一个任务可以有多种不同类型的消耗资源。
+
+| 字段名 | 类型 | 允许空 | 默认值 | 说明 |
+|-------|------|-------|-------|------|
+| id | int | 否 | 自增 | 主键 |
+| task_id | int | 否 | - | 任务ID,外键关联task_tasks表 |
+| cost_type | varchar(50) | 否 | - | 消耗类型(currency, item, energy, ticket等) |
+| cost_param1 | varchar(100) | 否 | - | 消耗参数1(如货币类型、物品类型等) |
+| cost_param2 | varchar(100) | 否 | - | 消耗参数2(如货币ID、物品ID等) |
+| quantity | int | 否 | 1 | 消耗数量 |
+| extra_data | json | 是 | NULL | 额外数据(JSON格式) |
+| sort_order | int | 否 | 0 | 排序权重(数值越大越靠前) |
+| created_at | timestamp | 是 | NULL | 创建时间 |
+| updated_at | timestamp | 是 | NULL | 更新时间 |
+
+**索引:**
+- PRIMARY KEY (`id`)
+- KEY `idx_task_id` (`task_id`)
+- KEY `idx_cost_type` (`cost_type`)
+- KEY `idx_cost_params` (`cost_param1`, `cost_param2`)
+- KEY `idx_sort` (`sort_order`)
+
+### 2.1.5 任务条件表 (task_conditions)
 
 定义系统中所有可用的条件类型,每种条件类型对应一个处理器类,负责验证和更新该类型条件的进度。
 
@@ -112,7 +146,7 @@
 - PRIMARY KEY (`id`)
 - UNIQUE KEY `idx_code` (`code`)
 
-### 2.1.5 任务达成条件表 (task_achievement_conditions)
+### 2.1.6 任务达成条件表 (task_achievement_conditions)
 
 关联任务和具体的条件,定义了完成任务需要满足的条件。一个任务可以有多个条件,通过这个表可以实现复杂的任务逻辑。条件分为两种类型:前置条件和进度条件。
 
@@ -230,7 +264,32 @@
 - KEY `idx_user_task` (`user_task_id`)
 - KEY `idx_rewarded_at` (`rewarded_at`)
 
-### 2.3.3 任务重置日志表 (task_reset_logs)
+### 2.3.3 任务消耗日志表 (task_cost_logs)
+
+记录用户接取任务时的资源消耗情况,包括消耗类型、数量、时间等。
+
+| 字段名 | 类型 | 允许空 | 默认值 | 说明 |
+|-------|------|-------|-------|------|
+| id | int | 否 | 自增 | 主键 |
+| user_id | int | 否 | - | 用户ID |
+| task_id | int | 否 | - | 任务ID,外键关联task_tasks表 |
+| cost_type | varchar(50) | 否 | - | 消耗类型(currency, item, energy, ticket等) |
+| cost_param1 | varchar(100) | 否 | - | 消耗参数1(如货币类型、物品类型等) |
+| cost_param2 | varchar(100) | 否 | - | 消耗参数2(如货币ID、物品ID等) |
+| quantity | int | 否 | 1 | 消耗数量 |
+| cost_at | timestamp | 否 | - | 消耗时间 |
+| ip_address | varchar(45) | 是 | NULL | IP地址 |
+| device_info | varchar(255) | 是 | NULL | 设备信息 |
+| created_at | timestamp | 是 | NULL | 创建时间 |
+
+**索引:**
+- PRIMARY KEY (`id`)
+- KEY `idx_user` (`user_id`)
+- KEY `idx_task` (`task_id`)
+- KEY `idx_cost_type` (`cost_type`)
+- KEY `idx_cost_at` (`cost_at`)
+
+### 2.3.4 任务重置日志表 (task_reset_logs)
 
 记录任务重置的情况,包括重置类型、重置时间、影响的任务数等。
 
@@ -255,13 +314,15 @@
 ```mermaid
 erDiagram
     task_categories ||--o{ task_tasks : "包含"
-    task_tasks ||--o{ task_rewards : "定义"
+    task_tasks ||--o{ task_rewards : "定义奖励"
+    task_tasks ||--o{ task_costs : "定义消耗"
     task_tasks ||--o{ task_achievement_conditions : "设置"
     task_conditions ||--o{ task_achievement_conditions : "使用"
     task_tasks ||--o{ task_user_tasks : "接取"
     task_achievement_conditions ||--o{ task_user_progress : "进度"
     task_user_tasks ||--o{ task_completion_logs : "记录完成"
     task_user_tasks ||--o{ task_reward_logs : "记录奖励"
+    task_user_tasks ||--o{ task_cost_logs : "记录消耗"
     task_reset_logs ||--o{ task_tasks : "重置"
 
     task_categories {
@@ -276,14 +337,29 @@ erDiagram
         varchar name "任务名称"
         varchar type "任务类型"
         json prerequisite_tasks "前置任务"
+        int max_completions "最大完成次数"
+        json display_params "显示参数"
+        int sort_order "排序权重"
     }
 
     task_rewards {
         int id PK "主键"
         int task_id FK "任务ID"
         varchar reward_type "奖励类型"
-        int reward_id "奖励ID"
+        varchar reward_param1 "奖励参数1"
+        varchar reward_param2 "奖励参数2"
+        int quantity "数量"
+        int sort_order "排序权重"
+    }
+
+    task_costs {
+        int id PK "主键"
+        int task_id FK "任务ID"
+        varchar cost_type "消耗类型"
+        varchar cost_param1 "消耗参数1"
+        varchar cost_param2 "消耗参数2"
         int quantity "数量"
+        int sort_order "排序权重"
     }
 
     task_conditions {
@@ -332,6 +408,17 @@ erDiagram
         json rewards "奖励内容"
     }
 
+    task_cost_logs {
+        int id PK "主键"
+        int user_id "用户ID"
+        int task_id FK "任务ID"
+        varchar cost_type "消耗类型"
+        varchar cost_param1 "消耗参数1"
+        varchar cost_param2 "消耗参数2"
+        int quantity "数量"
+        timestamp cost_at "消耗时间"
+    }
+
     task_reset_logs {
         int id PK "主键"
         varchar reset_type "重置类型"
@@ -345,25 +432,29 @@ erDiagram
 ```
 task_categories 1 --< task_tasks
 task_tasks 1 --< task_rewards
+task_tasks 1 --< task_costs
 task_conditions 1 --< task_achievement_conditions
 task_tasks 1 --< task_achievement_conditions
 task_tasks 1 --< task_user_tasks
 task_achievement_conditions 1 --< task_user_progress
 task_user_tasks 1 --< task_completion_logs
 task_user_tasks 1 --< task_reward_logs
+task_user_tasks 1 --< task_cost_logs
 ```
 
 ### 3.3 关系说明
 
 1. 一个任务分类可以包含多个任务
 2. 一个任务可以有多个奖励定义
-3. 一个条件类型可以用于多个任务达成条件
-4. 一个任务可以有多个达成条件
-5. 一个任务可以被多个用户接取
-6. 一个任务达成条件可以有多个用户进度记录
-7. 一个用户任务完成后会生成一条完成日志
-8. 一个用户任务领取奖励后会生成一条奖励发放日志
-9. 任务重置日志记录系统定期重置任务的情况
+3. 一个任务可以有多个接取消耗定义
+4. 一个条件类型可以用于多个任务达成条件
+5. 一个任务可以有多个达成条件
+6. 一个任务可以被多个用户接取
+7. 一个任务达成条件可以有多个用户进度记录
+8. 一个用户任务完成后会生成一条完成日志
+9. 一个用户任务领取奖励后会生成一条奖励发放日志
+10. 一个用户任务接取时会生成一条消耗日志
+11. 任务重置日志记录系统定期重置任务的情况
 
 ## 4. JSON字段结构
 
@@ -389,7 +480,33 @@ task_user_tasks 1 --< task_reward_logs
 }
 ```
 
-### 4.2 奖励内容 (extra_data)
+### 4.2 显示参数 (display_params)
+
+任务定义表中的display_params字段用于存储与任务显示相关的参数,例如:
+
+```json
+{
+  "icon": "task_daily_login.png",
+  "background": "task_bg_blue.jpg",
+  "color_theme": "blue",
+  "priority": 100,
+  "ui_group": "main",
+  "show_progress": true,
+  "progress_style": "percentage",
+  "show_timer": true,
+  "timer_style": "countdown",
+  "animation": "pulse",
+  "jump_target": "farm",
+  "tags": ["new", "hot", "limited"],
+  "client_custom": {
+    "show_in_dashboard": true,
+    "notification_enabled": true,
+    "highlight_effect": "glow"
+  }
+}
+```
+
+### 4.3 奖励内容 (extra_data)
 
 任务奖励定义表中的extra_data字段可以存储额外的奖励信息,例如:
 
@@ -405,7 +522,7 @@ task_user_tasks 1 --< task_reward_logs
 }
 ```
 
-### 4.3 前置任务 (prerequisite_tasks)
+### 4.4 前置任务 (prerequisite_tasks)
 
 ```json
 {

+ 139 - 0
app/Module/Task/Docs_Roo_dpv3/Proto设计规范.md

@@ -0,0 +1,139 @@
+# 任务模块 Proto 定义
+
+## 1. 服务定义 (task_service.proto)
+
+```protobuf
+syntax = "proto3";
+package task.module.v1;
+
+import "google/protobuf/timestamp.proto";
+
+// 任务服务
+service TaskService {
+    // 创建任务
+    rpc CreateTask (CreateTaskRequest) returns (Task);
+    // 获取任务列表
+    rpc ListTasks (ListTasksRequest) returns (ListTasksResponse);
+    // 更新任务状态
+    rpc UpdateTaskStatus (UpdateTaskStatusRequest) returns (Task);
+}
+
+// 任务类型枚举
+enum TaskType {
+    TASK_TYPE_UNSPECIFIED = 0;
+    TASK_TYPE_DAILY = 1;    // 日常任务
+    TASK_TYPE_WEEKLY = 2;   // 周常任务
+    TASK_TYPE_ACHIEVEMENT = 3; // 成就任务
+}
+
+// 任务状态枚举
+enum TaskStatus {
+    TASK_STATUS_UNSPECIFIED = 0;
+    TASK_STATUS_IN_PROGRESS = 1; // 进行中
+    TASK_STATUS_COMPLETED = 2;   // 已完成
+    TASK_STATUS_REWARDED = 3;    // 已领奖
+}
+
+// 创建任务请求
+message CreateTaskRequest {
+    string name = 1;          // 任务名称
+    string description = 2;   // 任务描述
+    TaskType type = 3;        // 任务类型
+    repeated Condition conditions = 4; // 完成条件
+    repeated Reward rewards = 5;      // 任务奖励
+}
+
+// 任务条件
+message Condition {
+    string condition_type = 1; // 条件类型
+    string target_value = 2;   // 目标值
+    string operator = 3;       // 比较运算符
+}
+
+// 任务奖励
+message Reward {
+    string reward_type = 1;    // 奖励类型
+    string reward_id = 2;      // 奖励ID
+    int32 amount = 3;          // 奖励数量
+}
+
+// 任务实体
+message Task {
+    string task_id = 1;        // 任务ID
+    string name = 2;           // 任务名称
+    TaskStatus status = 3;     // 任务状态
+    google.protobuf.Timestamp created_at = 4; // 创建时间
+    google.protobuf.Timestamp updated_at = 5; // 更新时间
+}
+
+// 分页查询请求
+message ListTasksRequest {
+    int32 page_size = 1;       // 每页数量
+    string page_token = 2;     // 分页token
+    TaskType filter_type = 3;  // 筛选类型
+}
+
+// 分页响应
+message ListTasksResponse {
+    repeated Task tasks = 1;   // 任务列表
+    string next_page_token = 2;// 下一页token
+}
+
+// 更新状态请求
+message UpdateTaskStatusRequest {
+    string task_id = 1;        // 任务ID
+    TaskStatus status = 2;     // 新状态
+}
+```
+
+## 2. 事件定义 (task_event.proto)
+
+```protobuf
+syntax = "proto3";
+package task.module.v1;
+
+import "google/protobuf/timestamp.proto";
+
+// 任务完成事件
+message TaskCompletedEvent {
+    string user_id = 1;        // 用户ID
+    string task_id = 2;        // 任务ID
+    google.protobuf.Timestamp completed_at = 3; // 完成时间
+    repeated string condition_ids = 4; // 完成的条件ID列表
+}
+
+// 奖励发放事件
+message RewardGrantedEvent {
+    string user_id = 1;        // 用户ID
+    string task_id = 2;        // 任务ID
+    repeated Reward rewards = 3; // 发放的奖励
+    google.protobuf.Timestamp granted_at = 4; // 发放时间
+}
+```
+
+## 3. 数据结构关系
+
+```mermaid
+classDiagram
+    class Task {
+        +string task_id
+        +string name
+        +TaskStatus status
+        +Condition[] conditions
+        +Reward[] rewards
+    }
+    
+    class Condition {
+        +string condition_type
+        +string target_value
+        +string operator
+    }
+    
+    class Reward {
+        +string reward_type
+        +string reward_id
+        +int32 amount
+    }
+    
+    Task "1" *-- "*" Condition
+    Task "1" *-- "*" Reward

+ 119 - 0
app/Module/Task/Docs_Roo_dpv3/任务配置指南.md

@@ -0,0 +1,119 @@
+# 任务配置指南
+
+## 1. 配置表结构说明
+
+### 1.1 基础配置字段
+
+| 字段名 | 类型 | 必填 | 说明 | 示例 |
+|-------|------|------|------|------|
+| taskId | 整数 | 是 | 任务唯一ID | 1001 |
+| name | 字符串 | 是 | 任务名称 | "每日登录" |
+| description | 字符串 | 否 | 任务描述 | "每天登录游戏领取奖励" |
+| type | 枚举 | 是 | 任务类型(DAILY,WEEKLY,ACHIEVEMENT,EVENT) | "DAILY" |
+| category | 字符串 | 否 | 任务分类 | "daily" |
+
+## 2. 显示配置
+
+### 2.1 显示配置字段
+
+```json
+"displayConfig": {
+  "icon": "assets/tasks/daily_login.png",
+  "colorTheme": "blue",
+  "priority": 10,
+  "showProgress": true,
+  "progressStyle": "STEPS"
+}
+```
+
+### 2.2 字段说明
+
+- `icon`: 任务图标路径
+- `colorTheme`: 颜色主题(blue/green/red等)
+- `priority`: 显示优先级(数字越大优先级越高)
+- `showProgress`: 是否显示进度条
+- `progressStyle`: 进度显示样式(STEPS/FRACTION/PERCENTAGE)
+
+## 3. 条件配置
+
+### 3.1 条件配置示例
+
+```json
+"conditions": [
+  {
+    "type": "LOGIN",
+    "target": 1,
+    "current": 0,
+    "params": {}
+  }
+]
+```
+
+### 3.2 常用条件类型
+
+1. **LOGIN**: 登录游戏
+   - 参数: 无
+2. **HARVEST**: 收获作物
+   - 参数: `{"cropTypes": ["wheat","corn"]}`
+3. **PLANT**: 种植作物
+   - 参数: `{"seedTypes": [101,102]}`
+
+## 4. 奖励配置
+
+### 4.1 奖励配置示例
+
+```json
+"rewards": [
+  {
+    "type": "CURRENCY",
+    "id": "gold",
+    "amount": 100,
+    "icon": "assets/currency/gold.png"
+  }
+]
+```
+
+### 4.2 奖励类型
+
+1. **CURRENCY**: 游戏货币
+   - id: 货币类型(gold/silver等)
+2. **ITEM**: 游戏物品
+   - id: 物品ID
+3. **EXPERIENCE**: 经验值
+   - id: 经验类型(farming/mining等)
+
+## 5. 完整配置示例
+
+```json
+{
+  "taskId": 1001,
+  "name": "每日登录",
+  "type": "DAILY",
+  "displayConfig": {
+    "icon": "assets/tasks/daily_login.png",
+    "priority": 5
+  },
+  "conditions": [
+    {
+      "type": "LOGIN",
+      "target": 1
+    }
+  ],
+  "rewards": [
+    {
+      "type": "CURRENCY",
+      "id": "gold",
+      "amount": 100
+    }
+  ]
+}
+```
+
+## 6. 配置流程
+
+1. 确定任务类型和基础信息
+2. 配置显示参数
+3. 设置任务条件
+4. 配置任务奖励
+5. 保存为JSON文件
+6. 导入到任务系统

+ 222 - 0
app/Module/Task/Docs_Roo_dpv3/任务配置表.json

@@ -0,0 +1,222 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "title": "任务配置表",
+  "description": "用于服务端与客户端通信的任务配置数据格式",
+  "type": "object",
+  "definitions": {
+    "task": {
+      "type": "object",
+      "properties": {
+        "taskId": {
+          "type": "integer",
+          "description": "任务唯一ID"
+        },
+        "name": {
+          "type": "string",
+          "description": "任务名称"
+        },
+        "description": {
+          "type": "string",
+          "description": "任务描述"
+        },
+        "type": {
+          "type": "string",
+          "enum": ["DAILY", "WEEKLY", "ACHIEVEMENT", "EVENT"],
+          "description": "任务类型"
+        },
+        "category": {
+          "type": "string",
+          "description": "任务分类"
+        },
+        "displayConfig": {
+          "$ref": "#/definitions/displayConfig"
+        },
+        "conditions": {
+          "type": "array",
+          "items": {
+            "$ref": "#/definitions/condition"
+          },
+          "description": "任务条件列表"
+        },
+        "rewards": {
+          "type": "array",
+          "items": {
+            "$ref": "#/definitions/reward"
+          },
+          "description": "任务奖励列表"
+        },
+        "timeConfig": {
+          "$ref": "#/definitions/timeConfig"
+        }
+      },
+      "required": ["taskId", "name", "type"]
+    },
+    "displayConfig": {
+      "type": "object",
+      "properties": {
+        "icon": {
+          "type": "string",
+          "description": "任务图标资源路径"
+        },
+        "colorTheme": {
+          "type": "string",
+          "description": "颜色主题"
+        },
+        "priority": {
+          "type": "integer",
+          "description": "显示优先级"
+        },
+        "showProgress": {
+          "type": "boolean",
+          "description": "是否显示进度"
+        },
+        "progressStyle": {
+          "type": "string",
+          "enum": ["PERCENTAGE", "FRACTION", "STEPS"],
+          "description": "进度显示样式"
+        }
+      }
+    },
+    "condition": {
+      "type": "object",
+      "properties": {
+        "type": {
+          "type": "string",
+          "description": "条件类型"
+        },
+        "target": {
+          "type": "integer",
+          "description": "目标值"
+        },
+        "current": {
+          "type": "integer",
+          "description": "当前进度值"
+        },
+        "params": {
+          "type": "object",
+          "description": "条件参数"
+        }
+      },
+      "required": ["type", "target"]
+    },
+    "reward": {
+      "type": "object",
+      "properties": {
+        "type": {
+          "type": "string",
+          "enum": ["ITEM", "CURRENCY", "EXPERIENCE"],
+          "description": "奖励类型"
+        },
+        "id": {
+          "type": "string",
+          "description": "奖励物品/货币ID"
+        },
+        "amount": {
+          "type": "integer",
+          "description": "奖励数量"
+        },
+        "icon": {
+          "type": "string",
+          "description": "奖励图标"
+        }
+      },
+      "required": ["type", "id", "amount"]
+    },
+    "timeConfig": {
+      "type": "object",
+      "properties": {
+        "startTime": {
+          "type": "string",
+          "format": "date-time",
+          "description": "开始时间"
+        },
+        "endTime": {
+          "type": "string",
+          "format": "date-time",
+          "description": "结束时间"
+        },
+        "resetType": {
+          "type": "string",
+          "enum": ["NONE", "DAILY", "WEEKLY", "MONTHLY"],
+          "description": "重置类型"
+        }
+      }
+    }
+  },
+  "examples": [
+    {
+      "taskId": 1001,
+      "name": "每日登录",
+      "description": "每日登录游戏领取奖励",
+      "type": "DAILY",
+      "category": "daily",
+      "displayConfig": {
+        "icon": "assets/tasks/daily_login.png",
+        "colorTheme": "blue",
+        "priority": 10,
+        "showProgress": true,
+        "progressStyle": "STEPS"
+      },
+      "conditions": [
+        {
+          "type": "LOGIN",
+          "target": 1,
+          "current": 0,
+          "params": {}
+        }
+      ],
+      "rewards": [
+        {
+          "type": "CURRENCY",
+          "id": "gold",
+          "amount": 100,
+          "icon": "assets/currency/gold.png"
+        }
+      ],
+      "timeConfig": {
+        "resetType": "DAILY"
+      }
+    },
+    {
+      "taskId": 2001,
+      "name": "收获专家",
+      "description": "收获10次作物",
+      "type": "ACHIEVEMENT",
+      "category": "farming",
+      "displayConfig": {
+        "icon": "assets/tasks/harvest_expert.png",
+        "colorTheme": "green",
+        "priority": 5,
+        "showProgress": true,
+        "progressStyle": "FRACTION"
+      },
+      "conditions": [
+        {
+          "type": "HARVEST",
+          "target": 10,
+          "current": 0,
+          "params": {
+            "cropTypes": ["wheat", "corn"]
+          }
+        }
+      ],
+      "rewards": [
+        {
+          "type": "ITEM",
+          "id": "premium_fertilizer",
+          "amount": 3,
+          "icon": "assets/items/fertilizer.png"
+        },
+        {
+          "type": "CURRENCY",
+          "id": "gold",
+          "amount": 500,
+          "icon": "assets/currency/gold.png"
+        }
+      ],
+      "timeConfig": {
+        "resetType": "NONE"
+      }
+    }
+  ]
+}

+ 43 - 2
app/Module/Task/Docs_Roo_dpv3/数据库设计.md

@@ -1,5 +1,15 @@
 # 任务模块数据库设计
 
+## 目录
+1. [数据库表概览](#1-数据库表概览)
+2. [表结构定义](#2-表结构定义)
+   - [基础配置表](#21-基础配置表)
+   - [任务定义表](#22-任务定义表)
+   - [任务执行表](#23-任务执行表)
+   - [日志记录表](#24-日志记录表)
+3. [数据关系](#3-数据关系)
+4. [设计说明](#4-设计说明)
+
 ## 1. 数据库表概览
 
 1. **基础配置表**
@@ -13,15 +23,45 @@
 
 3. **任务完成相关表**
    - task_user_tasks - 用户任务关联表:记录用户与任务的关联关系及完成状态
+   - task_user_progress - 用户任务进度表:记录用户任务各项条件的完成进度
 
 4. **日志记录相关表**
    - task_completion_logs - 任务完成日志表:记录任务完成事件及完成时的条件状态
    - task_reward_logs - 奖励发放日志表:记录奖励发放详情及操作信息
    - task_reset_logs - 进度重置日志表:记录任务进度重置事件及重置前后状态
 
-## 2. 任务定义
+## 2. 表结构定义
+
+### 2.1 基础配置表
+
+#### 任务条件类型表 (task_condition_types)
+
+| 字段名 | 类型 | 允许空 | 默认值 | 说明 |
+|-------|------|-------|-------|------|
+| id | int | 否 | 自增 | 主键 |
+| type_key | varchar(50) | 否 | - | 条件类型键名(唯一标识) |
+| name | varchar(100) | 否 | - | 条件类型显示名称 |
+| description | varchar(255) | 是 | NULL | 条件类型描述 |
+| value_format | varchar(100) | 否 | - | 目标值格式说明(如"level:10", "item:1001:5") |
+| operator_options | varchar(255) | 是 | NULL | 支持的运算符(如">,>=,==,<,<=") |
+| status | tinyint | 否 | 1 | 状态(0禁用,1启用) |
+| created_at | timestamp | 否 | CURRENT_TIMESTAMP | 创建时间 |
+| updated_at | timestamp | 否 | CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP | 更新时间 |
+
+**索引:**
+- PRIMARY KEY (`id`)
+- UNIQUE KEY `uniq_type_key` (`type_key`)
+
+**预置条件类型示例:**
+1. level - 等级要求
+2. item - 道具持有
+3. quest - 任务完成
+4. time - 时间限制
+5. vip - VIP等级
+
+### 2.2 任务定义表
 
-### 2.1 任务分类表 (task_categories)
+#### 2.2.1 任务分类表 (task_categories)
 
 | 字段名 | 类型 | 允许空 | 默认值 | 说明 |
 |-------|------|-------|-------|------|
@@ -48,6 +88,7 @@
 | name | varchar(100) | 否 | - | 任务名称 |
 | description | text | 是 | NULL | 任务描述 |
 | task_type | varchar(50) | 否 | - | 任务类型 |
+| display_params | json | 是 | NULL | 显示参数(JSON格式) |
 | status | tinyint | 否 | 1 | 状态(0禁用,1启用) |
 | start_time | timestamp | 是 | NULL | 开始时间 |
 | end_time | timestamp | 是 | NULL | 结束时间 |

+ 63 - 0
app/Module/Task/Docs_Roo_dpv3/数据库设计比对报告.md

@@ -0,0 +1,63 @@
+# 数据库设计比对报告
+
+## 1. 表结构差异
+
+### 1.1 新增表
+- `task_condition_types` (任务条件类型表)
+  - 在我们的方案中新增,用于集中管理条件类型
+  - 原始设计中条件类型直接定义在`task_conditions`表中
+
+### 1.2 表名变更
+- 原始设计中的`task_achievement_conditions`表
+  - 在我们的方案中简化为`task_conditions`
+
+## 2. 字段差异
+
+### 2.1 task_tasks表
+| 字段 | 原始设计 | 我们的方案 | 差异说明 |
+|------|----------|------------|----------|
+| display_params | 存在 | 新增 | 原始设计已有此字段 |
+| prerequisite_tasks | 存在 | 无 | 我们的方案未包含此字段 |
+| level_required | 存在 | 无 | 我们的方案未包含此字段 |
+| time_limit | 存在 | 无 | 我们的方案未包含此字段 |
+
+### 2.2 task_conditions表
+| 字段 | 原始设计 | 我们的方案 | 差异说明 |
+|------|----------|------------|----------|
+| param_schema | 存在 | 无 | 我们的方案未包含此字段 |
+| handler_class | 存在 | 无 | 我们的方案未包含此字段 |
+| condition_type | 无 | 新增 | 我们的方案新增此字段 |
+
+## 3. 数据关系差异
+
+### 3.1 原始设计关系
+```
+task_conditions 1 --< task_achievement_conditions
+task_tasks 1 --< task_achievement_conditions
+```
+
+### 3.2 我们的方案关系
+```
+task_condition_types 1 --< task_conditions
+task_tasks 1 --< task_conditions
+```
+
+## 4. 主要改进点
+
+1. **条件类型集中管理**:
+   - 新增`task_condition_types`表专门管理条件类型
+   - 避免条件类型信息重复存储
+
+2. **简化任务条件关系**:
+   - 合并`task_achievement_conditions`到`task_conditions`
+   - 减少表数量,简化数据模型
+
+3. **字段优化**:
+   - 移除了部分不常用字段
+   - 保持核心字段不变
+
+## 5. 建议
+
+1. 保留原始设计中的`display_params`字段实现
+2. 采用我们的条件类型集中管理方案
+3. 合并两种设计的优点形成最终方案

+ 11 - 167
app/Module/Task/Enums/TARGET_TYPE.php

@@ -14,7 +14,7 @@ enum TARGET_TYPE: string {
     case ACTIVATE_VIP = 'activate_vip';       // 激活VIP
     case BIND_PHONE = 'bind_phone';           // 绑定手机
     case REAL_NAME_AUTH = 'real_name_auth';   // 实名认证
-    
+
     // 农场相关
     case PLANT = 'plant';                     // 种植作物
     case HARVEST = 'harvest';                 // 收获作物
@@ -25,7 +25,7 @@ enum TARGET_TYPE: string {
     case USE_PESTICIDE = 'use_pesticide';     // 使用农药
     case USE_WATERING_CAN = 'use_watering_can'; // 使用洒水壶
     case USE_WEED_REMOVER = 'use_weed_remover'; // 使用除草剂
-    
+
     // 物品相关
     case ACQUIRE_ITEM = 'acquire_item';       // 获取物品
     case USE_ITEM = 'use_item';               // 使用物品
@@ -34,7 +34,7 @@ enum TARGET_TYPE: string {
     case OPEN_CHEST = 'open_chest';           // 开启宝箱
     case SELL_ITEM = 'sell_item';             // 出售物品
     case TRADE_ITEM = 'trade_item';           // 交易物品
-    
+
     // 宠物相关
     case FEED_PET = 'feed_pet';               // 喂养宠物
     case PET_LEVEL_UP = 'pet_level_up';       // 宠物升级
@@ -42,190 +42,34 @@ enum TARGET_TYPE: string {
     case PET_REMOULD = 'pet_remould';         // 宠物洗髓
     case PET_VEGETEAL = 'pet_vegeteal';       // 宠物偷菜
     case PET_BATTLE = 'pet_battle';           // 宠物战斗
-    
+
     // 团队相关
     case INVITE = 'invite';                   // 邀请好友
     case TEAM_PROFIT = 'team_profit';         // 团队收益
     case TALENT_LEVEL_UP = 'talent_level_up'; // 达人等级提升
     case TEAM_TASK_COMPLETE = 'team_task_complete'; // 完成团队任务
     case TEAM_RANK_CHANGE = 'team_rank_change'; // 团队排名变化
-    
+
     // 社交相关
     case ADD_FRIEND = 'add_friend';           // 添加好友
     case VISIT_FRIEND = 'visit_friend';       // 访问好友
     case SEND_MESSAGE = 'send_message';       // 发送消息
     case SEND_GIFT = 'send_gift';             // 发送礼物
     case SOCIAL_SHARE = 'social_share';       // 社交分享
-    
+
     // 商店相关
     case SHOP_PURCHASE = 'shop_purchase';     // 商店购买
     case SPECIAL_OFFER_PURCHASE = 'special_offer_purchase'; // 特价商品购买
     case VIP_SHOP_PURCHASE = 'vip_shop_purchase'; // VIP商店购买
     case FIRST_PURCHASE = 'first_purchase';   // 首次购买
-    
+
     // 活动相关
     case PARTICIPATE_EVENT = 'participate_event'; // 参与活动
     case EVENT_RANKING_CHANGE = 'event_ranking_change'; // 活动排名变化
     case EVENT_REWARD_CLAIM = 'event_reward_claim'; // 活动奖励领取
     case SEASONAL_EVENT_COMPLETE = 'seasonal_event_complete'; // 季节性活动完成
-    
-    /**
-     * 获取所有目标类型的选项,用于表单选择
-     *
-     * @return array
-     */
-    public static function getOptions(): array
-    {
-        $options = [];
-        foreach (self::cases() as $case) {
-            $options[$case->value] = self::getDescription($case);
-        }
-        return $options;
-    }
-    
-    /**
-     * 获取目标类型的描述
-     *
-     * @param TARGET_TYPE $type
-     * @return string
-     */
-    public static function getDescription(self $type): string
-    {
-        return match($type) {
-            // 用户相关
-            self::LOGIN => '登录游戏',
-            self::LEVEL_UP => '等级提升',
-            self::UPDATE_PROFILE => '更新个人资料',
-            self::ACTIVATE_VIP => '激活VIP',
-            self::BIND_PHONE => '绑定手机',
-            self::REAL_NAME_AUTH => '实名认证',
-            
-            // 农场相关
-            self::PLANT => '种植作物',
-            self::HARVEST => '收获作物',
-            self::UPGRADE_LAND => '升级土地',
-            self::UPGRADE_HOUSE => '升级房屋',
-            self::CLEAR_DISASTER => '清除灾害',
-            self::USE_FERTILIZER => '使用化肥',
-            self::USE_PESTICIDE => '使用农药',
-            self::USE_WATERING_CAN => '使用洒水壶',
-            self::USE_WEED_REMOVER => '使用除草剂',
-            
-            // 物品相关
-            self::ACQUIRE_ITEM => '获取物品',
-            self::USE_ITEM => '使用物品',
-            self::CRAFT_ITEM => '合成物品',
-            self::DISMANTLE_ITEM => '分解物品',
-            self::OPEN_CHEST => '开启宝箱',
-            self::SELL_ITEM => '出售物品',
-            self::TRADE_ITEM => '交易物品',
-            
-            // 宠物相关
-            self::FEED_PET => '喂养宠物',
-            self::PET_LEVEL_UP => '宠物升级',
-            self::USE_PET_SKILL => '使用宠物技能',
-            self::PET_REMOULD => '宠物洗髓',
-            self::PET_VEGETEAL => '宠物偷菜',
-            self::PET_BATTLE => '宠物战斗',
-            
-            // 团队相关
-            self::INVITE => '邀请好友',
-            self::TEAM_PROFIT => '团队收益',
-            self::TALENT_LEVEL_UP => '达人等级提升',
-            self::TEAM_TASK_COMPLETE => '完成团队任务',
-            self::TEAM_RANK_CHANGE => '团队排名变化',
-            
-            // 社交相关
-            self::ADD_FRIEND => '添加好友',
-            self::VISIT_FRIEND => '访问好友',
-            self::SEND_MESSAGE => '发送消息',
-            self::SEND_GIFT => '发送礼物',
-            self::SOCIAL_SHARE => '社交分享',
-            
-            // 商店相关
-            self::SHOP_PURCHASE => '商店购买',
-            self::SPECIAL_OFFER_PURCHASE => '特价商品购买',
-            self::VIP_SHOP_PURCHASE => 'VIP商店购买',
-            self::FIRST_PURCHASE => '首次购买',
-            
-            // 活动相关
-            self::PARTICIPATE_EVENT => '参与活动',
-            self::EVENT_RANKING_CHANGE => '活动排名变化',
-            self::EVENT_REWARD_CLAIM => '活动奖励领取',
-            self::SEASONAL_EVENT_COMPLETE => '季节性活动完成',
-        };
-    }
-    
-    /**
-     * 获取目标类型的分组
-     *
-     * @return array
-     */
-    public static function getGroups(): array
-    {
-        return [
-            '用户相关' => [
-                self::LOGIN->value,
-                self::LEVEL_UP->value,
-                self::UPDATE_PROFILE->value,
-                self::ACTIVATE_VIP->value,
-                self::BIND_PHONE->value,
-                self::REAL_NAME_AUTH->value,
-            ],
-            '农场相关' => [
-                self::PLANT->value,
-                self::HARVEST->value,
-                self::UPGRADE_LAND->value,
-                self::UPGRADE_HOUSE->value,
-                self::CLEAR_DISASTER->value,
-                self::USE_FERTILIZER->value,
-                self::USE_PESTICIDE->value,
-                self::USE_WATERING_CAN->value,
-                self::USE_WEED_REMOVER->value,
-            ],
-            '物品相关' => [
-                self::ACQUIRE_ITEM->value,
-                self::USE_ITEM->value,
-                self::CRAFT_ITEM->value,
-                self::DISMANTLE_ITEM->value,
-                self::OPEN_CHEST->value,
-                self::SELL_ITEM->value,
-                self::TRADE_ITEM->value,
-            ],
-            '宠物相关' => [
-                self::FEED_PET->value,
-                self::PET_LEVEL_UP->value,
-                self::USE_PET_SKILL->value,
-                self::PET_REMOULD->value,
-                self::PET_VEGETEAL->value,
-                self::PET_BATTLE->value,
-            ],
-            '团队相关' => [
-                self::INVITE->value,
-                self::TEAM_PROFIT->value,
-                self::TALENT_LEVEL_UP->value,
-                self::TEAM_TASK_COMPLETE->value,
-                self::TEAM_RANK_CHANGE->value,
-            ],
-            '社交相关' => [
-                self::ADD_FRIEND->value,
-                self::VISIT_FRIEND->value,
-                self::SEND_MESSAGE->value,
-                self::SEND_GIFT->value,
-                self::SOCIAL_SHARE->value,
-            ],
-            '商店相关' => [
-                self::SHOP_PURCHASE->value,
-                self::SPECIAL_OFFER_PURCHASE->value,
-                self::VIP_SHOP_PURCHASE->value,
-                self::FIRST_PURCHASE->value,
-            ],
-            '活动相关' => [
-                self::PARTICIPATE_EVENT->value,
-                self::EVENT_RANKING_CHANGE->value,
-                self::EVENT_REWARD_CLAIM->value,
-                self::SEASONAL_EVENT_COMPLETE->value,
-            ],
-        ];
-    }
+
+
+
+
 }

+ 0 - 31
app/Module/Task/Listeners/BaseTaskEventListener.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace App\Module\Task\Listeners;
-
-use Illuminate\Support\Facades\Log;
-
-/**
- * 任务事件监听器基类
- */
-abstract class BaseTaskEventListener
-{
-    /**
-     * 处理事件
-     *
-     * @param mixed $event 事件对象
-     * @return void
-     */
-    abstract public function handle($event): void;
-    
-    /**
-     * 记录事件日志
-     *
-     * @param string $message 日志消息
-     * @param array $context 上下文数据
-     * @return void
-     */
-    protected function logEvent(string $message, array $context = []): void
-    {
-        Log::info($message, $context);
-    }
-}

+ 0 - 79
app/Module/Task/Listeners/TaskCompletedListener.php

@@ -1,79 +0,0 @@
-<?php
-
-namespace App\Module\Task\Listeners;
-
-use App\Module\Task\Events\TaskCompletedEvent;
-use App\Module\User\Services\UserService;
-use App\Module\GameItems\Services\ItemService;
-
-/**
- * 任务完成事件监听器
- */
-class TaskCompletedListener extends BaseTaskEventListener
-{
-    /**
-     * 用户服务
-     *
-     * @var UserService
-     */
-    protected UserService $userService;
-    
-    /**
-     * 物品服务
-     *
-     * @var ItemService
-     */
-    protected ItemService $itemService;
-    
-    /**
-     * 构造函数
-     *
-     * @param UserService $userService
-     * @param ItemService $itemService
-     */
-    public function __construct(UserService $userService, ItemService $itemService)
-    {
-        $this->userService = $userService;
-        $this->itemService = $itemService;
-    }
-    
-    /**
-     * 处理任务完成事件
-     *
-     * @param TaskCompletedEvent $event
-     * @return void
-     */
-    public function handle($event): void
-    {
-        // 记录日志
-        $this->logEvent("用户 {$event->userId} 完成了任务 {$event->taskName}", [
-            'user_id' => $event->userId,
-            'task_id' => $event->taskId,
-            'task_type' => $event->taskType,
-            'completed_at' => $event->completedAt
-        ]);
-        
-        // 更新用户统计数据
-        // 注意:需要确保UserService中有此方法
-        if (method_exists($this->userService, 'incrementTaskCompletionCount')) {
-            $this->userService->incrementTaskCompletionCount($event->userId, $event->taskType);
-        }
-        
-        // 发送通知
-        $this->sendTaskCompletionNotification($event->userId, $event->taskName);
-    }
-    
-    /**
-     * 发送任务完成通知
-     *
-     * @param int $userId 用户ID
-     * @param string $taskName 任务名称
-     * @return void
-     */
-    private function sendTaskCompletionNotification(int $userId, string $taskName): void
-    {
-        // 发送通知逻辑
-        // 如果有通知服务,可以调用通知模块的服务
-        // 例如:$this->notificationService->send($userId, 'task_completed', [...]);
-    }
-}

+ 0 - 106
app/Module/Task/Listeners/TaskRewardClaimedListener.php

@@ -1,106 +0,0 @@
-<?php
-
-namespace App\Module\Task\Listeners;
-
-use App\Module\Task\Events\TaskRewardClaimedEvent;
-use App\Module\GameItems\Services\ItemService;
-use App\Module\Team\Services\TeamProfitService;
-
-/**
- * 任务奖励领取事件监听器
- */
-class TaskRewardClaimedListener extends BaseTaskEventListener
-{
-    /**
-     * 物品服务
-     *
-     * @var ItemService
-     */
-    protected ItemService $itemService;
-    
-    /**
-     * 团队收益服务
-     *
-     * @var TeamProfitService
-     */
-    protected TeamProfitService $teamProfitService;
-    
-    /**
-     * 构造函数
-     *
-     * @param ItemService $itemService
-     * @param TeamProfitService $teamProfitService
-     */
-    public function __construct(ItemService $itemService, TeamProfitService $teamProfitService)
-    {
-        $this->itemService = $itemService;
-        $this->teamProfitService = $teamProfitService;
-    }
-    
-    /**
-     * 处理任务奖励领取事件
-     *
-     * @param TaskRewardClaimedEvent $event
-     * @return void
-     */
-    public function handle($event): void
-    {
-        // 记录日志
-        $this->logEvent("用户 {$event->userId} 领取了任务 {$event->taskName} 的奖励", [
-            'user_id' => $event->userId,
-            'task_id' => $event->taskId,
-            'rewards' => $event->rewards,
-            'claimed_at' => $event->claimedAt,
-            'is_success' => $event->isSuccess
-        ]);
-        
-        // 如果奖励发放成功
-        if ($event->isSuccess) {
-            // 处理团队收益分成
-            $this->processTeamProfit($event);
-            
-            // 发送奖励领取通知
-            $this->sendRewardNotification($event->userId, $event->taskName, $event->rewards);
-        }
-    }
-    
-    /**
-     * 处理团队收益分成
-     *
-     * @param TaskRewardClaimedEvent $event
-     * @return void
-     */
-    private function processTeamProfit(TaskRewardClaimedEvent $event): void
-    {
-        // 遍历奖励
-        foreach ($event->rewards as $reward) {
-            if (isset($reward['item_id']) && isset($reward['quantity'])) {
-                // 记录任务完成收益
-                // 注意:需要确保TeamProfitService中有此方法
-                if (method_exists($this->teamProfitService, 'recordTaskCompleteProfit')) {
-                    $this->teamProfitService->recordTaskCompleteProfit(
-                        $event->userId,
-                        $event->taskId,
-                        $reward['item_id'],
-                        $reward['quantity']
-                    );
-                }
-            }
-        }
-    }
-    
-    /**
-     * 发送奖励领取通知
-     *
-     * @param int $userId 用户ID
-     * @param string $taskName 任务名称
-     * @param array $rewards 奖励内容
-     * @return void
-     */
-    private function sendRewardNotification(int $userId, string $taskName, array $rewards): void
-    {
-        // 发送通知逻辑
-        // 如果有通知服务,可以调用通知模块的服务
-        // 例如:$this->notificationService->send($userId, 'task_reward_claimed', [...]);
-    }
-}