Просмотр исходного кода

refactor(module): 将团队管理模块更名为推广管理模块

-重命名了多个文件和类名,将 "Team" 替换为 "Promotion"
- 更新了命名空间和路由资源名称
- 调整了部分字段名,如 "team_count" 改为 "promotion_count"
notfff 7 месяцев назад
Родитель
Сommit
23356319bf
88 измененных файлов с 1006 добавлено и 1006 удалено
  1. 2 2
      app/Module/Promotion/AdminControllers/Helper/FilterHelper.php
  2. 9 9
      app/Module/Promotion/AdminControllers/Helper/FilterHelperTrait.php
  3. 2 2
      app/Module/Promotion/AdminControllers/Helper/FormHelper.php
  4. 10 10
      app/Module/Promotion/AdminControllers/Helper/FormHelperTrait.php
  5. 2 2
      app/Module/Promotion/AdminControllers/Helper/GridHelper.php
  6. 9 9
      app/Module/Promotion/AdminControllers/Helper/GridHelperTrait.php
  7. 2 2
      app/Module/Promotion/AdminControllers/Helper/ShowHelper.php
  8. 9 9
      app/Module/Promotion/AdminControllers/Helper/ShowHelperTrait.php
  9. 12 12
      app/Module/Promotion/AdminControllers/TeamInviteRewardController.php
  10. 12 12
      app/Module/Promotion/AdminControllers/TeamProfitController.php
  11. 12 12
      app/Module/Promotion/AdminControllers/TeamProfitRuleController.php
  12. 12 12
      app/Module/Promotion/AdminControllers/TeamReferralChangeController.php
  13. 12 12
      app/Module/Promotion/AdminControllers/TeamReferralCodeController.php
  14. 12 12
      app/Module/Promotion/AdminControllers/TeamReferralCodeUsageController.php
  15. 16 16
      app/Module/Promotion/AdminControllers/TeamTalentConfigController.php
  16. 12 12
      app/Module/Promotion/AdminControllers/TeamUserReferralController.php
  17. 12 12
      app/Module/Promotion/AdminControllers/TeamUserRelationCacheController.php
  18. 16 16
      app/Module/Promotion/AdminControllers/TeamUserTalentController.php
  19. 10 10
      app/Module/Promotion/Commands/CleanExpiredReferralCodesCommand.php
  20. 17 17
      app/Module/Promotion/Commands/RebuildRelationCacheCommand.php
  21. 18 18
      app/Module/Promotion/Commands/UpdateTalentLevelsCommand.php
  22. 0 0
      app/Module/Promotion/Databases/GenerateSql/README.md
  23. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_invite_rewards.sql
  24. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_profit_rules.sql
  25. 5 5
      app/Module/Promotion/Databases/GenerateSql/team_profits.sql
  26. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_referral_changes.sql
  27. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_referral_code_usages.sql
  28. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_referral_codes.sql
  29. 4 4
      app/Module/Promotion/Databases/GenerateSql/team_talent_configs.sql
  30. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_user_referrals.sql
  31. 3 3
      app/Module/Promotion/Databases/GenerateSql/team_user_relation_cache.sql
  32. 4 4
      app/Module/Promotion/Databases/GenerateSql/team_user_talents.sql
  33. 0 0
      app/Module/Promotion/Docs/README.md
  34. 27 27
      app/Module/Promotion/Docs/create.sql
  35. 56 56
      app/Module/Promotion/Docs/与Farm模块集成.md
  36. 48 48
      app/Module/Promotion/Docs/推荐关系系统.md
  37. 64 64
      app/Module/Promotion/Docs/数据库设计.md
  38. 7 7
      app/Module/Promotion/Docs/枚举定义.md
  39. 29 29
      app/Module/Promotion/Docs/模块接口.md
  40. 0 0
      app/Module/Promotion/Docs/直间推收益机制.md
  41. 69 69
      app/Module/Promotion/Docs/缓存策略.md
  42. 6 6
      app/Module/Promotion/Docs/设计概述.md
  43. 1 1
      app/Module/Promotion/Enums/PROFIT_RECORD_STATUS.php
  44. 1 1
      app/Module/Promotion/Enums/PROFIT_SOURCE_TYPE.php
  45. 1 1
      app/Module/Promotion/Enums/REFERRAL_CODE_STATUS.php
  46. 1 1
      app/Module/Promotion/Enums/REFERRAL_LEVEL.php
  47. 1 1
      app/Module/Promotion/Enums/TALENT_LEVEL.php
  48. 1 1
      app/Module/Promotion/Enums/TEAM_TASK_STATUS.php
  49. 1 1
      app/Module/Promotion/Enums/TEAM_TASK_TYPE.php
  50. 6 6
      app/Module/Promotion/Events/ReferralCreatedEvent.php
  51. 9 9
      app/Module/Promotion/Events/ReferralUpdatedEvent.php
  52. 6 6
      app/Module/Promotion/Events/TalentLevelChangedEvent.php
  53. 7 7
      app/Module/Promotion/Events/TeamProfitCreatedEvent.php
  54. 17 17
      app/Module/Promotion/Listeners/DistributeTeamProfitListener.php
  55. 7 7
      app/Module/Promotion/Listeners/UpdateTalentLevelListener.php
  56. 13 13
      app/Module/Promotion/Listeners/UpdateTeamCountsListener.php
  57. 15 15
      app/Module/Promotion/Logics/ReferralCodeLogic.php
  58. 33 33
      app/Module/Promotion/Logics/ReferralLogic.php
  59. 24 24
      app/Module/Promotion/Logics/RelationCacheLogic.php
  60. 70 70
      app/Module/Promotion/Logics/TalentLogic.php
  61. 16 16
      app/Module/Promotion/Logics/TeamProfitLogic.php
  62. 5 5
      app/Module/Promotion/Models/TeamInviteReward.php
  63. 13 13
      app/Module/Promotion/Models/TeamProfit.php
  64. 7 7
      app/Module/Promotion/Models/TeamProfitRule.php
  65. 5 5
      app/Module/Promotion/Models/TeamReferralChange.php
  66. 8 8
      app/Module/Promotion/Models/TeamReferralCode.php
  67. 6 6
      app/Module/Promotion/Models/TeamReferralCodeUsage.php
  68. 10 10
      app/Module/Promotion/Models/TeamTalentConfig.php
  69. 5 5
      app/Module/Promotion/Models/TeamUserReferral.php
  70. 7 7
      app/Module/Promotion/Models/TeamUserRelationCache.php
  71. 10 10
      app/Module/Promotion/Models/TeamUserTalent.php
  72. 22 22
      app/Module/Promotion/Providers/TeamServiceProvider.php
  73. 7 7
      app/Module/Promotion/README.md
  74. 12 12
      app/Module/Promotion/Repositorys/BaseRepository.php
  75. 4 4
      app/Module/Promotion/Repositorys/TeamInviteRewardRepository.php
  76. 4 4
      app/Module/Promotion/Repositorys/TeamProfitRepository.php
  77. 4 4
      app/Module/Promotion/Repositorys/TeamProfitRuleRepository.php
  78. 4 4
      app/Module/Promotion/Repositorys/TeamReferralChangeRepository.php
  79. 4 4
      app/Module/Promotion/Repositorys/TeamReferralCodeRepository.php
  80. 4 4
      app/Module/Promotion/Repositorys/TeamReferralCodeUsageRepository.php
  81. 4 4
      app/Module/Promotion/Repositorys/TeamTalentConfigRepository.php
  82. 4 4
      app/Module/Promotion/Repositorys/TeamUserReferralRepository.php
  83. 4 4
      app/Module/Promotion/Repositorys/TeamUserRelationCacheRepository.php
  84. 4 4
      app/Module/Promotion/Repositorys/TeamUserTalentRepository.php
  85. 7 7
      app/Module/Promotion/Services/ReferralCodeService.php
  86. 13 13
      app/Module/Promotion/Services/ReferralService.php
  87. 23 23
      app/Module/Promotion/Services/TalentService.php
  88. 18 18
      app/Module/Promotion/Services/TeamProfitService.php

+ 2 - 2
app/Module/Team/AdminControllers/Helper/FilterHelper.php → app/Module/Promotion/AdminControllers/Helper/FilterHelper.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
 use UCore\DcatAdmin\FilterHelper as BaseFilterHelper;
 
 /**
  * 筛选器辅助类
- * 
+ *
  * 提供筛选器的辅助方法,如筛选条件的显示、格式化等。
  */
 class FilterHelper extends BaseFilterHelper

+ 9 - 9
app/Module/Team/AdminControllers/Helper/FilterHelperTrait.php → app/Module/Promotion/AdminControllers/Helper/FilterHelperTrait.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_CHANGE_REASON;
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
-use App\Module\Team\Enums\REFERRAL_CODE_USAGE_STATUS;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_CHANGE_REASON;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Enums\REFERRAL_CODE_USAGE_STATUS;
 
 /**
  * 筛选器辅助特性
- * 
+ *
  * 提供筛选器的辅助方法,如筛选条件的显示、格式化等。
  */
 trait FilterHelperTrait
@@ -25,7 +25,7 @@ trait FilterHelperTrait
     {
         return $this->filter->equal($field, $label)->select(REFERRAL_CODE_STATUS::getOptions());
     }
-    
+
     /**
      * 推荐码使用状态筛选
      *
@@ -37,7 +37,7 @@ trait FilterHelperTrait
     {
         return $this->filter->equal($field, $label)->select(REFERRAL_CODE_USAGE_STATUS::getOptions());
     }
-    
+
     /**
      * 推荐关系修改原因筛选
      *
@@ -49,7 +49,7 @@ trait FilterHelperTrait
     {
         return $this->filter->equal($field, $label)->select(REFERRAL_CHANGE_REASON::getOptions());
     }
-    
+
     /**
      * 收益来源类型筛选
      *

+ 2 - 2
app/Module/Team/AdminControllers/Helper/FormHelper.php → app/Module/Promotion/AdminControllers/Helper/FormHelper.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
 use UCore\DcatAdmin\FormHelper as BaseFormHelper;
 
 /**
  * 表单页辅助类
- * 
+ *
  * 提供表单页的辅助方法,如表单项的显示、格式化等。
  */
 class FormHelper extends BaseFormHelper

+ 10 - 10
app/Module/Team/AdminControllers/Helper/FormHelperTrait.php → app/Module/Promotion/AdminControllers/Helper/FormHelperTrait.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_CHANGE_REASON;
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
-use App\Module\Team\Enums\REFERRAL_CODE_USAGE_STATUS;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_CHANGE_REASON;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Enums\REFERRAL_CODE_USAGE_STATUS;
 
 /**
  * 表单页辅助特性
- * 
+ *
  * 提供表单页的辅助方法,如表单项的显示、格式化等。
  */
 trait FormHelperTrait
@@ -25,7 +25,7 @@ trait FormHelperTrait
     {
         return $this->form->select($field, $label)->options(REFERRAL_CODE_STATUS::getOptions());
     }
-    
+
     /**
      * 推荐码使用状态选择
      *
@@ -37,7 +37,7 @@ trait FormHelperTrait
     {
         return $this->form->select($field, $label)->options(REFERRAL_CODE_USAGE_STATUS::getOptions());
     }
-    
+
     /**
      * 推荐关系修改原因选择
      *
@@ -49,7 +49,7 @@ trait FormHelperTrait
     {
         return $this->form->select($field, $label)->options(REFERRAL_CHANGE_REASON::getOptions());
     }
-    
+
     /**
      * 收益来源类型选择
      *
@@ -61,7 +61,7 @@ trait FormHelperTrait
     {
         return $this->form->select($field, $label)->options(PROFIT_SOURCE_TYPE::getOptions());
     }
-    
+
     /**
      * JSON编辑器
      *

+ 2 - 2
app/Module/Team/AdminControllers/Helper/GridHelper.php → app/Module/Promotion/AdminControllers/Helper/GridHelper.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
 use UCore\DcatAdmin\GridHelper as BaseGridHelper;
 
 /**
  * 列表页辅助类
- * 
+ *
  * 提供列表页的辅助方法,如列的显示、格式化等。
  */
 class GridHelper extends BaseGridHelper

+ 9 - 9
app/Module/Team/AdminControllers/Helper/GridHelperTrait.php → app/Module/Promotion/AdminControllers/Helper/GridHelperTrait.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_CHANGE_REASON;
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
-use App\Module\Team\Enums\REFERRAL_CODE_USAGE_STATUS;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_CHANGE_REASON;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Enums\REFERRAL_CODE_USAGE_STATUS;
 
 /**
  * 列表页辅助特性
- * 
+ *
  * 提供列表页的辅助方法,如列的显示、格式化等。
  */
 trait GridHelperTrait
@@ -25,7 +25,7 @@ trait GridHelperTrait
     {
         return $this->grid->column($field, $label)->using(REFERRAL_CODE_STATUS::getOptions());
     }
-    
+
     /**
      * 显示推荐码使用状态
      *
@@ -37,7 +37,7 @@ trait GridHelperTrait
     {
         return $this->grid->column($field, $label)->using(REFERRAL_CODE_USAGE_STATUS::getOptions());
     }
-    
+
     /**
      * 显示推荐关系修改原因
      *
@@ -49,7 +49,7 @@ trait GridHelperTrait
     {
         return $this->grid->column($field, $label)->using(REFERRAL_CHANGE_REASON::getOptions());
     }
-    
+
     /**
      * 显示收益来源类型
      *

+ 2 - 2
app/Module/Team/AdminControllers/Helper/ShowHelper.php → app/Module/Promotion/AdminControllers/Helper/ShowHelper.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
 use UCore\DcatAdmin\ShowHelper as BaseShowHelper;
 
 /**
  * 详情页辅助类
- * 
+ *
  * 提供详情页的辅助方法,如字段的显示、格式化等。
  */
 class ShowHelper extends BaseShowHelper

+ 9 - 9
app/Module/Team/AdminControllers/Helper/ShowHelperTrait.php → app/Module/Promotion/AdminControllers/Helper/ShowHelperTrait.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\AdminControllers\Helper;
+namespace App\Module\Promotion\AdminControllers\Helper;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_CHANGE_REASON;
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
-use App\Module\Team\Enums\REFERRAL_CODE_USAGE_STATUS;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_CHANGE_REASON;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Enums\REFERRAL_CODE_USAGE_STATUS;
 
 /**
  * 详情页辅助特性
- * 
+ *
  * 提供详情页的辅助方法,如字段的显示、格式化等。
  */
 trait ShowHelperTrait
@@ -25,7 +25,7 @@ trait ShowHelperTrait
     {
         return $this->show->field($field, $label)->using(REFERRAL_CODE_STATUS::getOptions());
     }
-    
+
     /**
      * 显示推荐码使用状态
      *
@@ -37,7 +37,7 @@ trait ShowHelperTrait
     {
         return $this->show->field($field, $label)->using(REFERRAL_CODE_USAGE_STATUS::getOptions());
     }
-    
+
     /**
      * 显示推荐关系修改原因
      *
@@ -49,7 +49,7 @@ trait ShowHelperTrait
     {
         return $this->show->field($field, $label)->using(REFERRAL_CHANGE_REASON::getOptions());
     }
-    
+
     /**
      * 显示收益来源类型
      *

+ 12 - 12
app/Module/Team/AdminControllers/TeamInviteRewardController.php → app/Module/Promotion/AdminControllers/TeamInviteRewardController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamInviteRewardRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionInviteRewardRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 邀请奖励记录管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-invite-rewards', names: 'dcat.admin.team-invite-rewards')]
-class TeamInviteRewardController extends AdminController
+#[Resource('promotion-invite-rewards', names: 'dcat.admin.promotion-invite-rewards')]
+class PromotionInviteRewardController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamInviteRewardController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamInviteRewardRepository(['user', 'invitee']), function (Grid $grid) {
+        return Grid::make(new PromotionInviteRewardRepository(['user', 'invitee']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
@@ -83,7 +83,7 @@ class TeamInviteRewardController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamInviteRewardRepository(['user', 'invitee']), function (Show $show) {
+        return Show::make($id, new PromotionInviteRewardRepository(['user', 'invitee']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -114,7 +114,7 @@ class TeamInviteRewardController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamInviteRewardRepository(), function (Form $form) {
+        return Form::make(new PromotionInviteRewardRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamProfitController.php → app/Module/Promotion/AdminControllers/TeamProfitController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamProfitRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionProfitRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 团队收益记录管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-profits', names: 'dcat.admin.team-profits')]
-class TeamProfitController extends AdminController
+#[Resource('promotion-profits', names: 'dcat.admin.promotion-profits')]
+class PromotionProfitController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamProfitController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamProfitRepository(['user', 'fromUser']), function (Grid $grid) {
+        return Grid::make(new PromotionProfitRepository(['user', 'fromUser']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
@@ -86,7 +86,7 @@ class TeamProfitController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamProfitRepository(['user', 'fromUser']), function (Show $show) {
+        return Show::make($id, new PromotionProfitRepository(['user', 'fromUser']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -118,7 +118,7 @@ class TeamProfitController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamProfitRepository(), function (Form $form) {
+        return Form::make(new PromotionProfitRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamProfitRuleController.php → app/Module/Promotion/AdminControllers/TeamProfitRuleController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamProfitRuleRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionProfitRuleRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 收益分成规则管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-profit-rules', names: 'dcat.admin.team-profit-rules')]
-class TeamProfitRuleController extends AdminController
+#[Resource('promotion-profit-rules', names: 'dcat.admin.promotion-profit-rules')]
+class PromotionProfitRuleController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamProfitRuleController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamProfitRuleRepository(), function (Grid $grid) {
+        return Grid::make(new PromotionProfitRuleRepository(), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $helper->columnProfitSourceType();
@@ -71,7 +71,7 @@ class TeamProfitRuleController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamProfitRuleRepository(), function (Show $show) {
+        return Show::make($id, new PromotionProfitRuleRepository(), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $helper->fieldProfitSourceType();
@@ -96,7 +96,7 @@ class TeamProfitRuleController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamProfitRuleRepository(), function (Form $form) {
+        return Form::make(new PromotionProfitRuleRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $helper->selectProfitSourceType()->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamReferralChangeController.php → app/Module/Promotion/AdminControllers/TeamReferralChangeController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamReferralChangeRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionReferralChangeRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 推荐关系修改记录管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-referral-changes', names: 'dcat.admin.team-referral-changes')]
-class TeamReferralChangeController extends AdminController
+#[Resource('promotion-referral-changes', names: 'dcat.admin.promotion-referral-changes')]
+class PromotionReferralChangeController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamReferralChangeController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamReferralChangeRepository(['user', 'oldReferrer', 'newReferrer', 'operator']), function (Grid $grid) {
+        return Grid::make(new PromotionReferralChangeRepository(['user', 'oldReferrer', 'newReferrer', 'operator']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
@@ -78,7 +78,7 @@ class TeamReferralChangeController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamReferralChangeRepository(['user', 'oldReferrer', 'newReferrer', 'operator']), function (Show $show) {
+        return Show::make($id, new PromotionReferralChangeRepository(['user', 'oldReferrer', 'newReferrer', 'operator']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -109,7 +109,7 @@ class TeamReferralChangeController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamReferralChangeRepository(), function (Form $form) {
+        return Form::make(new PromotionReferralChangeRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamReferralCodeController.php → app/Module/Promotion/AdminControllers/TeamReferralCodeController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamReferralCodeRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionReferralCodeRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 推荐码管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-referral-codes', names: 'dcat.admin.team-referral-codes')]
-class TeamReferralCodeController extends AdminController
+#[Resource('promotion-referral-codes', names: 'dcat.admin.promotion-referral-codes')]
+class PromotionReferralCodeController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamReferralCodeController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamReferralCodeRepository(['user']), function (Grid $grid) {
+        return Grid::make(new PromotionReferralCodeRepository(['user']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('code', '推荐码');
@@ -73,7 +73,7 @@ class TeamReferralCodeController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamReferralCodeRepository(['user']), function (Show $show) {
+        return Show::make($id, new PromotionReferralCodeRepository(['user']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('code', '推荐码');
@@ -97,7 +97,7 @@ class TeamReferralCodeController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamReferralCodeRepository(), function (Form $form) {
+        return Form::make(new PromotionReferralCodeRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('code', '推荐码')->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamReferralCodeUsageController.php → app/Module/Promotion/AdminControllers/TeamReferralCodeUsageController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamReferralCodeUsageRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionReferralCodeUsageRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 推荐码使用记录管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-referral-code-usages', names: 'dcat.admin.team-referral-code-usages')]
-class TeamReferralCodeUsageController extends AdminController
+#[Resource('promotion-referral-code-usages', names: 'dcat.admin.promotion-referral-code-usages')]
+class PromotionReferralCodeUsageController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamReferralCodeUsageController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamReferralCodeUsageRepository(['user', 'codeOwner']), function (Grid $grid) {
+        return Grid::make(new PromotionReferralCodeUsageRepository(['user', 'codeOwner']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('code', '推荐码');
@@ -80,7 +80,7 @@ class TeamReferralCodeUsageController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamReferralCodeUsageRepository(['user', 'codeOwner']), function (Show $show) {
+        return Show::make($id, new PromotionReferralCodeUsageRepository(['user', 'codeOwner']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('code', '推荐码');
@@ -109,7 +109,7 @@ class TeamReferralCodeUsageController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamReferralCodeUsageRepository(), function (Form $form) {
+        return Form::make(new PromotionReferralCodeUsageRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('code', '推荐码')->required();

+ 16 - 16
app/Module/Team/AdminControllers/TeamTalentConfigController.php → app/Module/Promotion/AdminControllers/TeamTalentConfigController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamTalentConfigRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionTalentConfigRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 达人等级配置管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-talent-configs', names: 'dcat.admin.team-talent-configs')]
-class TeamTalentConfigController extends AdminController
+#[Resource('promotion-talent-configs', names: 'dcat.admin.promotion-talent-configs')]
+class PromotionTalentConfigController extends AdminController
 {
     /**
      * 标题
@@ -35,13 +35,13 @@ class TeamTalentConfigController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamTalentConfigRepository(), function (Grid $grid) {
+        return Grid::make(new PromotionTalentConfigRepository(), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('level', '等级')->sortable();
             $grid->column('name', '名称');
             $grid->column('direct_count_required', '直推人数要求')->sortable();
-            $grid->column('team_count_required', '团队总人数要求')->sortable();
+            $grid->column('promotion_count_required', '团队总人数要求')->sortable();
             $grid->column('profit_rate', '收益比例')->sortable();
             $grid->column('icon', '图标');
             $grid->column('icon_url', '图标URL');
@@ -56,7 +56,7 @@ class TeamTalentConfigController extends AdminController
                 $filter->equal('level', '等级');
                 $filter->like('name', '名称');
                 $filter->between('direct_count_required', '直推人数要求');
-                $filter->between('team_count_required', '团队总人数要求');
+                $filter->between('promotion_count_required', '团队总人数要求');
                 $filter->between('profit_rate', '收益比例');
                 $filter->equal('status', '状态')->radio([
                     1 => '启用',
@@ -77,13 +77,13 @@ class TeamTalentConfigController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamTalentConfigRepository(), function (Show $show) {
+        return Show::make($id, new PromotionTalentConfigRepository(), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('level', '等级');
             $show->field('name', '名称');
             $show->field('direct_count_required', '直推人数要求');
-            $show->field('team_count_required', '团队总人数要求');
+            $show->field('promotion_count_required', '团队总人数要求');
             $show->field('profit_rate', '收益比例');
             $show->field('icon', '图标');
             $show->field('icon_url', '图标URL');
@@ -106,13 +106,13 @@ class TeamTalentConfigController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamTalentConfigRepository(), function (Form $form) {
+        return Form::make(new PromotionTalentConfigRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->number('level', '等级')->min(1)->required();
             $form->text('name', '名称')->required();
             $form->number('direct_count_required', '直推人数要求')->min(0)->default(0)->required();
-            $form->number('team_count_required', '团队总人数要求')->min(0)->default(0)->required();
+            $form->number('promotion_count_required', '团队总人数要求')->min(0)->default(0)->required();
             $form->rate('profit_rate', '收益比例')->min(0)->max(1)->default(0)->required();
             $form->text('icon', '图标');
             $form->text('icon_url', '图标URL');

+ 12 - 12
app/Module/Team/AdminControllers/TeamUserReferralController.php → app/Module/Promotion/AdminControllers/TeamUserReferralController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamUserReferralRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionUserReferralRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 用户推荐关系管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-user-referrals', names: 'dcat.admin.team-user-referrals')]
-class TeamUserReferralController extends AdminController
+#[Resource('promotion-user-referrals', names: 'dcat.admin.promotion-user-referrals')]
+class PromotionUserReferralController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamUserReferralController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamUserReferralRepository(['user', 'referrer']), function (Grid $grid) {
+        return Grid::make(new PromotionUserReferralRepository(['user', 'referrer']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
@@ -70,7 +70,7 @@ class TeamUserReferralController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamUserReferralRepository(['user', 'referrer']), function (Show $show) {
+        return Show::make($id, new PromotionUserReferralRepository(['user', 'referrer']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -93,7 +93,7 @@ class TeamUserReferralController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamUserReferralRepository(), function (Form $form) {
+        return Form::make(new PromotionUserReferralRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();

+ 12 - 12
app/Module/Team/AdminControllers/TeamUserRelationCacheController.php → app/Module/Promotion/AdminControllers/TeamUserRelationCacheController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamUserRelationCacheRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionUserRelationCacheRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 用户关系缓存管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-user-relation-caches', names: 'dcat.admin.team-user-relation-caches')]
-class TeamUserRelationCacheController extends AdminController
+#[Resource('promotion-user-relation-caches', names: 'dcat.admin.promotion-user-relation-caches')]
+class PromotionUserRelationCacheController extends AdminController
 {
     /**
      * 标题
@@ -35,7 +35,7 @@ class TeamUserRelationCacheController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamUserRelationCacheRepository(['user', 'ancestor']), function (Grid $grid) {
+        return Grid::make(new PromotionUserRelationCacheRepository(['user', 'ancestor']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
@@ -72,7 +72,7 @@ class TeamUserRelationCacheController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamUserRelationCacheRepository(['user', 'ancestor']), function (Show $show) {
+        return Show::make($id, new PromotionUserRelationCacheRepository(['user', 'ancestor']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -96,7 +96,7 @@ class TeamUserRelationCacheController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamUserRelationCacheRepository(), function (Form $form) {
+        return Form::make(new PromotionUserRelationCacheRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();

+ 16 - 16
app/Module/Team/AdminControllers/TeamUserTalentController.php → app/Module/Promotion/AdminControllers/TeamUserTalentController.php

@@ -1,12 +1,12 @@
 <?php
 
-namespace App\Module\Team\AdminControllers;
+namespace App\Module\Promotion\AdminControllers;
 
-use App\Module\Team\AdminControllers\Helper\FilterHelper;
-use App\Module\Team\AdminControllers\Helper\FormHelper;
-use App\Module\Team\AdminControllers\Helper\GridHelper;
-use App\Module\Team\AdminControllers\Helper\ShowHelper;
-use App\Module\Team\Repositorys\TeamUserTalentRepository;
+use App\Module\Promotion\AdminControllers\Helper\FilterHelper;
+use App\Module\Promotion\AdminControllers\Helper\FormHelper;
+use App\Module\Promotion\AdminControllers\Helper\GridHelper;
+use App\Module\Promotion\AdminControllers\Helper\ShowHelper;
+use App\Module\Promotion\Repositorys\PromotionUserTalentRepository;
 use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Show;
@@ -16,10 +16,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 /**
  * 用户达人等级管理控制器
  *
- * @package App\Module\Team\AdminControllers
+ * @package App\Module\Promotion\AdminControllers
  */
-#[Resource('team-user-talents', names: 'dcat.admin.team-user-talents')]
-class TeamUserTalentController extends AdminController
+#[Resource('promotion-user-talents', names: 'dcat.admin.promotion-user-talents')]
+class PromotionUserTalentController extends AdminController
 {
     /**
      * 标题
@@ -35,14 +35,14 @@ class TeamUserTalentController extends AdminController
      */
     protected function grid()
     {
-        return Grid::make(new TeamUserTalentRepository(['user']), function (Grid $grid) {
+        return Grid::make(new PromotionUserTalentRepository(['user']), function (Grid $grid) {
             $helper = new GridHelper($grid, $this);
             $grid->column('id', 'ID')->sortable();
             $grid->column('user.username', '用户名');
             $grid->column('user.nickname', '用户昵称');
             $grid->column('talent_level', '达人等级')->sortable();
             $grid->column('direct_count', '直推人数')->sortable();
-            $grid->column('team_count', '团队总人数')->sortable();
+            $grid->column('promotion_count', '团队总人数')->sortable();
             $grid->column('created_at', '创建时间');
             $grid->column('updated_at', '更新时间');
 
@@ -55,7 +55,7 @@ class TeamUserTalentController extends AdminController
                 $filter->whereLike('user.nickname', '用户昵称');
                 $filter->equal('talent_level', '达人等级');
                 $filter->between('direct_count', '直推人数');
-                $filter->between('team_count', '团队总人数');
+                $filter->between('promotion_count', '团队总人数');
                 $filter->between('created_at', '创建时间')->datetime();
             });
 
@@ -71,7 +71,7 @@ class TeamUserTalentController extends AdminController
      */
     protected function detail($id)
     {
-        return Show::make($id, new TeamUserTalentRepository(['user']), function (Show $show) {
+        return Show::make($id, new PromotionUserTalentRepository(['user']), function (Show $show) {
             $helper = new ShowHelper($show, $this);
             $helper->field('id', 'ID');
             $show->field('user_id', '用户ID');
@@ -79,7 +79,7 @@ class TeamUserTalentController extends AdminController
             $show->field('user.nickname', '用户昵称');
             $show->field('talent_level', '达人等级');
             $show->field('direct_count', '直推人数');
-            $show->field('team_count', '团队总人数');
+            $show->field('promotion_count', '团队总人数');
             $show->field('created_at', '创建时间');
             $show->field('updated_at', '更新时间');
 
@@ -94,13 +94,13 @@ class TeamUserTalentController extends AdminController
      */
     protected function form()
     {
-        return Form::make(new TeamUserTalentRepository(), function (Form $form) {
+        return Form::make(new PromotionUserTalentRepository(), function (Form $form) {
             $helper = new FormHelper($form, $this);
             $form->display('id', 'ID');
             $form->text('user_id', '用户ID')->required();
             $form->number('talent_level', '达人等级')->min(0)->default(0)->required();
             $form->number('direct_count', '直推人数')->min(0)->default(0)->required();
-            $form->number('team_count', '团队总人数')->min(0)->default(0)->required();
+            $form->number('promotion_count', '团队总人数')->min(0)->default(0)->required();
             $form->display('created_at', '创建时间');
             $form->display('updated_at', '更新时间');
 

+ 10 - 10
app/Module/Team/Commands/CleanExpiredReferralCodesCommand.php → app/Module/Promotion/Commands/CleanExpiredReferralCodesCommand.php

@@ -1,13 +1,13 @@
 <?php
 
-namespace App\Module\Team\Commands;
+namespace App\Module\Promotion\Commands;
 
-use App\Module\Team\Services\ReferralCodeService;
+use App\Module\Promotion\Services\ReferralCodeService;
 use Illuminate\Console\Command;
 
 /**
  * 清理过期推荐码命令
- * 
+ *
  * 用于清理过期的推荐码,释放数据库空间。
  */
 class CleanExpiredReferralCodesCommand extends Command
@@ -17,7 +17,7 @@ class CleanExpiredReferralCodesCommand extends Command
      *
      * @var string
      */
-    protected $signature = 'team:clean-expired-referral-codes {--debug-info : 显示详细信息}';
+    protected $signature = 'promotion:clean-expired-referral-codes {--debug-info : 显示详细信息}';
 
     /**
      * 命令描述
@@ -34,26 +34,26 @@ class CleanExpiredReferralCodesCommand extends Command
     public function handle()
     {
         $this->info('开始清理过期推荐码...');
-        
+
         $showDebugInfo = $this->option('debug-info');
-        
+
         try {
             $count = ReferralCodeService::cleanExpiredReferralCodes();
-            
+
             if ($showDebugInfo) {
                 $this->info("共清理了 {$count} 个过期推荐码");
             } else {
                 $this->info("清理完成");
             }
-            
+
             return 0;
         } catch (\Exception $e) {
             $this->error("清理过期推荐码失败: " . $e->getMessage());
-            
+
             if ($showDebugInfo) {
                 $this->error($e->getTraceAsString());
             }
-            
+
             return 1;
         }
     }

+ 17 - 17
app/Module/Team/Commands/RebuildRelationCacheCommand.php → app/Module/Promotion/Commands/RebuildRelationCacheCommand.php

@@ -1,14 +1,14 @@
 <?php
 
-namespace App\Module\Team\Commands;
+namespace App\Module\Promotion\Commands;
 
-use App\Module\Team\Logics\RelationCacheLogic;
-use App\Module\Team\Models\TeamUserReferral;
+use App\Module\Promotion\Logics\RelationCacheLogic;
+use App\Module\Promotion\Models\PromotionUserReferral;
 use Illuminate\Console\Command;
 
 /**
  * 重建关系缓存命令
- * 
+ *
  * 用于重建用户关系缓存,确保缓存数据的准确性。
  */
 class RebuildRelationCacheCommand extends Command
@@ -18,7 +18,7 @@ class RebuildRelationCacheCommand extends Command
      *
      * @var string
      */
-    protected $signature = 'team:rebuild-relation-cache {--user-id= : 指定用户ID} {--debug-info : 显示详细信息}';
+    protected $signature = 'promotion:rebuild-relation-cache {--user-id= : 指定用户ID} {--debug-info : 显示详细信息}';
 
     /**
      * 命令描述
@@ -54,15 +54,15 @@ class RebuildRelationCacheCommand extends Command
     public function handle()
     {
         $this->info('开始重建关系缓存...');
-        
+
         $userId = $this->option('user-id');
         $showDebugInfo = $this->option('debug-info');
-        
+
         try {
             if ($userId) {
                 // 重建指定用户的关系缓存
                 $this->relationCacheLogic->rebuildUserRelationCache($userId);
-                
+
                 if ($showDebugInfo) {
                     $this->info("用户 {$userId} 的关系缓存重建完成");
                 } else {
@@ -71,26 +71,26 @@ class RebuildRelationCacheCommand extends Command
             } else {
                 // 重建所有用户的关系缓存
                 $this->relationCacheLogic->clearAllRelationCache();
-                
-                $users = TeamUserReferral::all();
+
+                $users = PromotionUserReferral::all();
                 $total = $users->count();
                 $current = 0;
-                
+
                 if ($showDebugInfo) {
                     $this->info("共有 {$total} 个用户需要重建关系缓存");
                     $bar = $this->output->createProgressBar($total);
                     $bar->start();
                 }
-                
+
                 foreach ($users as $user) {
                     $this->relationCacheLogic->buildUserRelationCache($user->user_id);
                     $current++;
-                    
+
                     if ($showDebugInfo) {
                         $bar->advance();
                     }
                 }
-                
+
                 if ($showDebugInfo) {
                     $bar->finish();
                     $this->newLine();
@@ -99,15 +99,15 @@ class RebuildRelationCacheCommand extends Command
                     $this->info("重建完成");
                 }
             }
-            
+
             return 0;
         } catch (\Exception $e) {
             $this->error("重建关系缓存失败: " . $e->getMessage());
-            
+
             if ($showDebugInfo) {
                 $this->error($e->getTraceAsString());
             }
-            
+
             return 1;
         }
     }

+ 18 - 18
app/Module/Team/Commands/UpdateTalentLevelsCommand.php → app/Module/Promotion/Commands/UpdateTalentLevelsCommand.php

@@ -1,14 +1,14 @@
 <?php
 
-namespace App\Module\Team\Commands;
+namespace App\Module\Promotion\Commands;
 
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Models\TeamUserTalent;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Models\PromotionUserTalent;
 use Illuminate\Console\Command;
 
 /**
  * 更新达人等级命令
- * 
+ *
  * 用于更新所有用户的达人等级,确保等级数据的准确性。
  */
 class UpdateTalentLevelsCommand extends Command
@@ -18,7 +18,7 @@ class UpdateTalentLevelsCommand extends Command
      *
      * @var string
      */
-    protected $signature = 'team:update-talent-levels {--user-id= : 指定用户ID} {--debug-info : 显示详细信息}';
+    protected $signature = 'promotion:update-talent-levels {--user-id= : 指定用户ID} {--debug-info : 显示详细信息}';
 
     /**
      * 命令描述
@@ -54,18 +54,18 @@ class UpdateTalentLevelsCommand extends Command
     public function handle()
     {
         $this->info('开始更新达人等级...');
-        
+
         $userId = $this->option('user-id');
         $showDebugInfo = $this->option('debug-info');
-        
+
         try {
             if ($userId) {
                 // 更新指定用户的达人等级
                 $result = $this->talentLogic->checkAndUpdateTalentLevel($userId);
-                
+
                 if ($showDebugInfo) {
                     if ($result) {
-                        $talent = TeamUserTalent::where('user_id', $userId)->first();
+                        $talent = PromotionUserTalent::where('user_id', $userId)->first();
                         $this->info("用户 {$userId} 的达人等级更新为 {$talent->talent_level}");
                     } else {
                         $this->info("用户 {$userId} 的达人等级未变更");
@@ -75,28 +75,28 @@ class UpdateTalentLevelsCommand extends Command
                 }
             } else {
                 // 更新所有用户的达人等级
-                $users = TeamUserTalent::all();
+                $users = PromotionUserTalent::all();
                 $total = $users->count();
                 $updated = 0;
-                
+
                 if ($showDebugInfo) {
                     $this->info("共有 {$total} 个用户需要更新达人等级");
                     $bar = $this->output->createProgressBar($total);
                     $bar->start();
                 }
-                
+
                 foreach ($users as $user) {
                     $result = $this->talentLogic->checkAndUpdateTalentLevel($user->user_id);
-                    
+
                     if ($result) {
                         $updated++;
                     }
-                    
+
                     if ($showDebugInfo) {
                         $bar->advance();
                     }
                 }
-                
+
                 if ($showDebugInfo) {
                     $bar->finish();
                     $this->newLine();
@@ -105,15 +105,15 @@ class UpdateTalentLevelsCommand extends Command
                     $this->info("更新完成");
                 }
             }
-            
+
             return 0;
         } catch (\Exception $e) {
             $this->error("更新达人等级失败: " . $e->getMessage());
-            
+
             if ($showDebugInfo) {
                 $this->error($e->getTraceAsString());
             }
-            
+
             return 1;
         }
     }

+ 0 - 0
app/Module/Team/Databases/GenerateSql/README.md → app/Module/Promotion/Databases/GenerateSql/README.md


+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_invite_rewards.sql → app/Module/Promotion/Databases/GenerateSql/team_invite_rewards.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_invite_rewards 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamInviteReward
+-- 表 kku_promotion_invite_rewards 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionInviteReward
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_invite_rewards` (
+CREATE TABLE `kku_promotion_invite_rewards` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '获得奖励的用户ID',
   `invited_user_id` bigint NOT NULL COMMENT '被邀请的用户ID',

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_profit_rules.sql → app/Module/Promotion/Databases/GenerateSql/team_profit_rules.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_profit_rules 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamProfitRule
+-- 表 kku_promotion_profit_rules 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionProfitRule
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_profit_rules` (
+CREATE TABLE `kku_promotion_profit_rules` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `source_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源类型',
   `direct_profit_rate` decimal(5,4) NOT NULL COMMENT '直推分成比例',

+ 5 - 5
app/Module/Team/Databases/GenerateSql/team_profits.sql → app/Module/Promotion/Databases/GenerateSql/team_profits.sql

@@ -1,13 +1,13 @@
 -- ******************************************************************
--- 表 kku_team_profits 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamProfit
+-- 表 kku_promotion_profits 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionProfit
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_profits` (
+CREATE TABLE `kku_promotion_profits` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '获得收益的用户ID',
-  `team_member_id` bigint NOT NULL COMMENT '团队成员ID',
+  `promotion_member_id` bigint NOT NULL COMMENT '团队成员ID',
   `source_id` bigint NOT NULL COMMENT '收益来源ID',
   `source_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收益来源类型',
   `item_id` bigint NOT NULL COMMENT '物品ID',
@@ -17,7 +17,7 @@ CREATE TABLE `kku_team_profits` (
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   PRIMARY KEY (`id`) USING BTREE,
   KEY `idx_user_id` (`user_id`) USING BTREE,
-  KEY `idx_team_member_id` (`team_member_id`) USING BTREE,
+  KEY `idx_promotion_member_id` (`promotion_member_id`) USING BTREE,
   KEY `idx_source` (`source_type`,`source_id`) USING BTREE,
   KEY `idx_relation_type` (`relation_type`) USING BTREE,
   KEY `idx_created_at` (`created_at`) USING BTREE

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_referral_changes.sql → app/Module/Promotion/Databases/GenerateSql/team_referral_changes.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_referral_changes 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamReferralChange
+-- 表 kku_promotion_referral_changes 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionReferralChange
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_referral_changes` (
+CREATE TABLE `kku_promotion_referral_changes` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '用户ID',
   `old_referrer_id` bigint DEFAULT NULL COMMENT '旧推荐人ID',

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_referral_code_usages.sql → app/Module/Promotion/Databases/GenerateSql/team_referral_code_usages.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_referral_code_usages 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamReferralCodeUsage
+-- 表 kku_promotion_referral_code_usages 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionReferralCodeUsage
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_referral_code_usages` (
+CREATE TABLE `kku_promotion_referral_code_usages` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '使用的邀请码',
   `code_owner_id` bigint NOT NULL COMMENT '邀请码所有者用户ID',

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_referral_codes.sql → app/Module/Promotion/Databases/GenerateSql/team_referral_codes.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_referral_codes 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamReferralCode
+-- 表 kku_promotion_referral_codes 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionReferralCode
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_referral_codes` (
+CREATE TABLE `kku_promotion_referral_codes` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '用户ID',
   `code` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '推荐码',

+ 4 - 4
app/Module/Team/Databases/GenerateSql/team_talent_configs.sql → app/Module/Promotion/Databases/GenerateSql/team_talent_configs.sql

@@ -1,15 +1,15 @@
 -- ******************************************************************
--- 表 kku_team_talent_configs 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamTalentConfig
+-- 表 kku_promotion_talent_configs 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionTalentConfig
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_talent_configs` (
+CREATE TABLE `kku_promotion_talent_configs` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `level` tinyint unsigned NOT NULL COMMENT '等级',
   `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '等级名称',
   `direct_count_required` int NOT NULL COMMENT '所需直推人数',
-  `team_count_required` int NOT NULL COMMENT '所需团队总人数',
+  `promotion_count_required` int NOT NULL COMMENT '所需团队总人数',
   `profit_rate` decimal(5,4) NOT NULL COMMENT '间推分成比例',
   `benefits` json DEFAULT NULL COMMENT '等级权益',
   `icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '等级图标',

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_user_referrals.sql → app/Module/Promotion/Databases/GenerateSql/team_user_referrals.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_user_referrals 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamUserReferral
+-- 表 kku_promotion_user_referrals 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionUserReferral
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_user_referrals` (
+CREATE TABLE `kku_promotion_user_referrals` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '用户ID',
   `referrer_id` bigint NOT NULL COMMENT '直接推荐人ID',

+ 3 - 3
app/Module/Team/Databases/GenerateSql/team_user_relation_cache.sql → app/Module/Promotion/Databases/GenerateSql/team_user_relation_cache.sql

@@ -1,10 +1,10 @@
 -- ******************************************************************
--- 表 kku_team_user_relation_cache 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamUserRelationCache
+-- 表 kku_promotion_user_relation_cache 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionUserRelationCache
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_user_relation_cache` (
+CREATE TABLE `kku_promotion_user_relation_cache` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '用户ID',
   `related_user_id` bigint NOT NULL COMMENT '关联用户ID(上级)',

+ 4 - 4
app/Module/Team/Databases/GenerateSql/team_user_talents.sql → app/Module/Promotion/Databases/GenerateSql/team_user_talents.sql

@@ -1,15 +1,15 @@
 -- ******************************************************************
--- 表 kku_team_user_talents 的创建SQL
--- 对应的Model: App\Module\Team\Models\TeamUserTalent
+-- 表 kku_promotion_user_talents 的创建SQL
+-- 对应的Model: App\Module\Promotion\Models\PromotionUserTalent
 -- 警告: 此文件由系统自动生成,禁止修改!
 -- ******************************************************************
 
-CREATE TABLE `kku_team_user_talents` (
+CREATE TABLE `kku_promotion_user_talents` (
   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint NOT NULL COMMENT '用户ID',
   `talent_level` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '达人等级:0无,1初级,2中级,3高级,4资深,5顶级',
   `direct_count` int NOT NULL DEFAULT '0' COMMENT '直推人数',
-  `team_count` int NOT NULL DEFAULT '0' COMMENT '团队总人数',
+  `promotion_count` int NOT NULL DEFAULT '0' COMMENT '团队总人数',
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`) USING BTREE,

+ 0 - 0
app/Module/Team/Docs/README.md → app/Module/Promotion/Docs/README.md


+ 27 - 27
app/Module/Team/Docs/create.sql → app/Module/Promotion/Docs/create.sql

@@ -1,9 +1,9 @@
 -- 团队模块数据库创建脚本
 -- 包含所有团队模块相关表的创建语句
 
--- 1. 用户推荐关系表 (team_user_referrals)
+-- 1. 用户推荐关系表 (promotion_user_referrals)
 -- 存储用户与其直接推荐人(直接上级)的关系
-CREATE TABLE IF NOT EXISTS `kku_team_user_referrals` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_user_referrals` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `referrer_id` bigint(20) NOT NULL COMMENT '直接推荐人ID',
@@ -14,14 +14,14 @@ CREATE TABLE IF NOT EXISTS `kku_team_user_referrals` (
   KEY `idx_referrer_id` (`referrer_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户直接推荐关系表';
 
--- 2. 达人等级表 (team_user_talents)
+-- 2. 达人等级表 (promotion_user_talents)
 -- 存储用户的达人等级信息,包括直推人数和团队总人数
-CREATE TABLE IF NOT EXISTS `kku_team_user_talents` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_user_talents` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `talent_level` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '达人等级:0无,1初级,2中级,3高级,4资深,5顶级',
   `direct_count` int(11) NOT NULL DEFAULT '0' COMMENT '直推人数',
-  `team_count` int(11) NOT NULL DEFAULT '0' COMMENT '团队总人数',
+  `promotion_count` int(11) NOT NULL DEFAULT '0' COMMENT '团队总人数',
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`),
@@ -29,12 +29,12 @@ CREATE TABLE IF NOT EXISTS `kku_team_user_talents` (
   KEY `idx_talent_level` (`talent_level`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='达人等级表';
 
--- 3. 团队收益记录表 (team_profits)
+-- 3. 团队收益记录表 (promotion_profits)
 -- 记录团队成员产生的分成收益
-CREATE TABLE IF NOT EXISTS `kku_team_profits` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_profits` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '获得收益的用户ID',
-  `team_member_id` bigint(20) NOT NULL COMMENT '团队成员ID',
+  `promotion_member_id` bigint(20) NOT NULL COMMENT '团队成员ID',
   `source_id` bigint(20) NOT NULL COMMENT '收益来源ID',
   `source_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收益来源类型',
   `item_id` bigint(20) NOT NULL COMMENT '物品ID',
@@ -44,15 +44,15 @@ CREATE TABLE IF NOT EXISTS `kku_team_profits` (
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   PRIMARY KEY (`id`),
   KEY `idx_user_id` (`user_id`),
-  KEY `idx_team_member_id` (`team_member_id`),
+  KEY `idx_promotion_member_id` (`promotion_member_id`),
   KEY `idx_source` (`source_type`,`source_id`),
   KEY `idx_relation_type` (`relation_type`),
   KEY `idx_created_at` (`created_at`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='团队收益记录表';
 
--- 4. 推荐码表 (team_referral_codes)
+-- 4. 推荐码表 (promotion_referral_codes)
 -- 存储用户的推荐码信息
-CREATE TABLE IF NOT EXISTS `kku_team_referral_codes` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_referral_codes` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '推荐码',
@@ -67,14 +67,14 @@ CREATE TABLE IF NOT EXISTS `kku_team_referral_codes` (
   KEY `idx_status` (`status`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='推荐码表';
 
--- 5. 达人等级配置表 (team_talent_configs)
+-- 5. 达人等级配置表 (promotion_talent_configs)
 -- 存储不同达人等级的配置信息
-CREATE TABLE IF NOT EXISTS `kku_team_talent_configs` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_talent_configs` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `level` tinyint(3) unsigned NOT NULL COMMENT '等级',
   `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '等级名称',
   `direct_count_required` int(11) NOT NULL COMMENT '所需直推人数',
-  `team_count_required` int(11) NOT NULL COMMENT '所需团队总人数',
+  `promotion_count_required` int(11) NOT NULL COMMENT '所需团队总人数',
   `profit_rate` decimal(5,4) NOT NULL COMMENT '间推分成比例',
   `benefits` json DEFAULT NULL COMMENT '等级权益',
   `icon` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '等级图标',
@@ -84,9 +84,9 @@ CREATE TABLE IF NOT EXISTS `kku_team_talent_configs` (
   UNIQUE KEY `idx_level` (`level`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='达人等级配置表';
 
--- 6. 收益分成规则表 (team_profit_rules)
+-- 6. 收益分成规则表 (promotion_profit_rules)
 -- 存储不同来源的收益分成规则
-CREATE TABLE IF NOT EXISTS `kku_team_profit_rules` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_profit_rules` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `source_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源类型',
   `direct_profit_rate` decimal(5,4) NOT NULL COMMENT '直推分成比例',
@@ -100,9 +100,9 @@ CREATE TABLE IF NOT EXISTS `kku_team_profit_rules` (
   KEY `idx_status` (`status`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收益分成规则表';
 
--- 7. 推荐关系修改记录表 (team_referral_changes)
+-- 7. 推荐关系修改记录表 (promotion_referral_changes)
 -- 记录用户推荐关系的修改历史
-CREATE TABLE IF NOT EXISTS `kku_team_referral_changes` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_referral_changes` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `old_referrer_id` bigint(20) DEFAULT NULL COMMENT '旧推荐人ID',
@@ -116,9 +116,9 @@ CREATE TABLE IF NOT EXISTS `kku_team_referral_changes` (
   KEY `idx_change_time` (`change_time`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='推荐关系修改记录表';
 
--- 8. 用户关系缓存表 (team_user_relation_cache)
+-- 8. 用户关系缓存表 (promotion_user_relation_cache)
 -- 用于存储用户之间的所有推荐关系(包括上下级关系)
-CREATE TABLE IF NOT EXISTS `kku_team_user_relation_cache` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_user_relation_cache` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `related_user_id` bigint(20) NOT NULL COMMENT '关联用户ID(上级)',
@@ -135,9 +135,9 @@ CREATE TABLE IF NOT EXISTS `kku_team_user_relation_cache` (
   KEY `idx_depth` (`depth`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户关系缓存表';
 
--- 9. 邀请奖励记录表 (team_invite_rewards)
+-- 9. 邀请奖励记录表 (promotion_invite_rewards)
 -- 用于记录用户邀请他人注册时获得的奖励
-CREATE TABLE IF NOT EXISTS `kku_team_invite_rewards` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_invite_rewards` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '获得奖励的用户ID',
   `invited_user_id` bigint(20) NOT NULL COMMENT '被邀请的用户ID',
@@ -158,9 +158,9 @@ CREATE TABLE IF NOT EXISTS `kku_team_invite_rewards` (
   KEY `idx_created_at` (`created_at`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='邀请奖励记录表';
 
--- 10. 邀请码使用记录表 (team_referral_code_usages)
+-- 10. 邀请码使用记录表 (promotion_referral_code_usages)
 -- 用于详细记录每次邀请码的使用情况
-CREATE TABLE IF NOT EXISTS `kku_team_referral_code_usages` (
+CREATE TABLE IF NOT EXISTS `kku_promotion_referral_code_usages` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '使用的邀请码',
   `code_owner_id` bigint(20) NOT NULL COMMENT '邀请码所有者用户ID',
@@ -183,7 +183,7 @@ CREATE TABLE IF NOT EXISTS `kku_team_referral_code_usages` (
 -- 初始化数据
 
 -- 1. 达人等级配置数据
-INSERT INTO `kku_team_talent_configs` (`level`, `name`, `direct_count_required`, `team_count_required`, `profit_rate`, `benefits`) VALUES
+INSERT INTO `kku_promotion_talent_configs` (`level`, `name`, `direct_count_required`, `promotion_count_required`, `profit_rate`, `benefits`) VALUES
 (1, '初级达人', 5, 10, 0.0100, '{"farm_output_bonus": 0.01}'),
 (2, '中级达人', 10, 30, 0.0150, '{"farm_output_bonus": 0.02}'),
 (3, '高级达人', 20, 50, 0.0200, '{"farm_output_bonus": 0.03, "daily_gift": {"item_id": 1001, "amount": 1}}'),
@@ -191,7 +191,7 @@ INSERT INTO `kku_team_talent_configs` (`level`, `name`, `direct_count_required`,
 (5, '顶级达人', 50, 200, 0.0300, '{"farm_output_bonus": 0.05, "daily_gift": {"item_id": 1001, "amount": 3}, "special_privileges": ["vip_customer_service", "exclusive_avatar_frame"]}');
 
 -- 2. 收益分成规则数据
-INSERT INTO `kku_team_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
+INSERT INTO `kku_promotion_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
 ('farm_harvest', 0.0500, 20, 1, '{"min_amount": 10, "max_amount": 1000}'),
 ('task_complete', 0.0300, 10, 1, '{"min_amount": 5, "max_amount": 500}'),
-('item_sell', 0.0200, 5, 1, '{"min_amount": 1, "max_amount": 100, "excluded_items": [1001, 1002]}');
+('item_sell', 0.0200, 5, 1, '{"min_amount": 1, "max_amount": 100, "excluded_items": [1001, 1002]}');

+ 56 - 56
app/Module/Team/Docs/与Farm模块集成.md → app/Module/Promotion/Docs/与Farm模块集成.md

@@ -62,29 +62,29 @@ class CropHarvestedEvent
 }
 ```
 
-### 3.2 Team模块的事件监听器
+### 3.2 Promotion模块的事件监听器
 
-Team模块监听Farm模块的作物收获事件,计算并分配收益:
+Promotion模块监听Farm模块的作物收获事件,计算并分配收益:
 
 ```php
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
 use App\Module\Farm\Events\CropHarvestedEvent;
-use App\Module\Team\Services\TeamProfitService;
+use App\Module\Promotion\Services\PromotionProfitService;
 
 class CropHarvestedListener
 {
     /**
-     * @var TeamProfitService
+     * @var PromotionProfitService
      */
-    protected $teamProfitService;
+    protected $promotionProfitService;
 
     /**
      * 构造函数
      */
-    public function __construct(TeamProfitService $teamProfitService)
+    public function __construct(PromotionProfitService $promotionProfitService)
     {
-        $this->teamProfitService = $teamProfitService;
+        $this->promotionProfitService = $promotionProfitService;
     }
 
     /**
@@ -93,7 +93,7 @@ class CropHarvestedListener
     public function handle(CropHarvestedEvent $event)
     {
         // 计算团队收益分成
-        $this->teamProfitService->calculateTeamProfit(
+        $this->promotionProfitService->calculatePromotionProfit(
             $event->userId,
             'farm_harvest',
             $event->cropId,
@@ -106,16 +106,16 @@ class CropHarvestedListener
 
 ### 3.3 事件注册
 
-在Team模块的服务提供者中注册事件监听器:
+在Promotion模块的服务提供者中注册事件监听器:
 
 ```php
-namespace App\Module\Team\Providers;
+namespace App\Module\Promotion\Providers;
 
 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
 use App\Module\Farm\Events\CropHarvestedEvent;
-use App\Module\Team\Listeners\CropHarvestedListener;
+use App\Module\Promotion\Listeners\CropHarvestedListener;
 
-class TeamServiceProvider extends ServiceProvider
+class PromotionServiceProvider extends ServiceProvider
 {
     /**
      * 事件到监听器的映射
@@ -154,22 +154,22 @@ class TeamServiceProvider extends ServiceProvider
 
 ### 4.1 分成规则配置
 
-Team模块为Farm模块的收获收益配置专门的分成规则:
+Promotion模块为Farm模块的收获收益配置专门的分成规则:
 
 ```sql
-INSERT INTO `team_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
+INSERT INTO `promotion_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
 ('farm_harvest', 0.0500, 20, 1, '{"min_amount": 10, "max_amount": 1000}');
 ```
 
 ### 4.2 分成计算逻辑
 
-当用户收获作物时,Team模块按以下逻辑计算分成:
+当用户收获作物时,Promotion模块按以下逻辑计算分成:
 
 ```php
 /**
  * 计算团队收益分成
  */
-public function calculateTeamProfit(int $userId, string $sourceType, int $sourceId, int $itemId, int $amount): bool
+public function calculatePromotionProfit(int $userId, string $sourceType, int $sourceId, int $itemId, int $amount): bool
 {
     // 获取分成规则
     $rule = $this->profitRuleRepository->getBySourceType($sourceType);
@@ -209,9 +209,9 @@ public function calculateTeamProfit(int $userId, string $sourceType, int $source
 
         if ($profitAmount > 0) {
             // 记录分成
-            $this->teamProfitRepository->create([
+            $this->promotionProfitRepository->create([
                 'user_id' => $referrer->referrer_id,
-                'team_member_id' => $userId,
+                'promotion_member_id' => $userId,
                 'source_id' => $sourceId,
                 'source_type' => $sourceType,
                 'item_id' => $itemId,
@@ -242,9 +242,9 @@ public function calculateTeamProfit(int $userId, string $sourceType, int $source
 
             if ($profitAmount > 0) {
                 // 记录分成
-                $this->teamProfitRepository->create([
+                $this->promotionProfitRepository->create([
                     'user_id' => $referrer->referrer_id,
-                    'team_member_id' => $userId,
+                    'promotion_member_id' => $userId,
                     'source_id' => $sourceId,
                     'source_type' => $sourceType,
                     'item_id' => $itemId,
@@ -311,7 +311,7 @@ public function calculateTalentOutputBonus(int $userId): float
 }
 ```
 
-Farm模块在计算作物产量时,调用Team模块的接口获取达人加成:
+Farm模块在计算作物产量时,调用Promotion模块的接口获取达人加成:
 
 ```php
 /**
@@ -335,7 +335,7 @@ public function calculateOutput(FarmCrop $crop, FarmLand $land, int $houseLevel)
     $disasterImpact = $this->disasterLogic->calculateDisasterImpact($crop->disasters);
 
     // 计算达人加成
-    $talentBonus = $this->teamService->calculateTalentOutputBonus($crop->user_id);
+    $talentBonus = $this->promotionService->calculateTalentOutputBonus($crop->user_id);
 
     // 计算最终产量
     $finalOutput = $baseOutput * (1 + $landBonus) * (1 + $houseBonus) * (1 - $disasterImpact) * (1 + $talentBonus);
@@ -410,13 +410,13 @@ public function claimTalentDailyGift(int $userId): array
 
 ### 6.1 团队种植任务
 
-Team模块可以创建团队种植任务,鼓励团队成员在Farm模块中种植特定作物:
+Promotion模块可以创建团队种植任务,鼓励团队成员在Farm模块中种植特定作物:
 
 ```php
 /**
  * 创建团队种植任务
  */
-public function createTeamPlantingTask(int $userId, int $seedId, int $targetCount, int $rewardItemId, int $rewardAmount): array
+public function createPromotionPlantingTask(int $userId, int $seedId, int $targetCount, int $rewardItemId, int $rewardAmount): array
 {
     // 验证用户是否是达人
     $talentInfo = $this->talentRepository->getByUserId($userId);
@@ -425,7 +425,7 @@ public function createTeamPlantingTask(int $userId, int $seedId, int $targetCoun
     }
 
     // 创建团队任务
-    $task = $this->teamTaskRepository->create([
+    $task = $this->promotionTaskRepository->create([
         'creator_id' => $userId,
         'task_type' => 'planting',
         'seed_id' => $seedId,
@@ -451,27 +451,27 @@ public function createTeamPlantingTask(int $userId, int $seedId, int $targetCoun
 
 ### 6.2 监听种植事件
 
-Team模块监听Farm模块的种植事件,更新团队任务进度:
+Promotion模块监听Farm模块的种植事件,更新团队任务进度:
 
 ```php
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
 use App\Module\Farm\Events\CropPlantedEvent;
-use App\Module\Team\Services\TeamTaskService;
+use App\Module\Promotion\Services\PromotionTaskService;
 
 class CropPlantedListener
 {
     /**
-     * @var TeamTaskService
+     * @var PromotionTaskService
      */
-    protected $teamTaskService;
+    protected $promotionTaskService;
 
     /**
      * 构造函数
      */
-    public function __construct(TeamTaskService $teamTaskService)
+    public function __construct(PromotionTaskService $promotionTaskService)
     {
-        $this->teamTaskService = $teamTaskService;
+        $this->promotionTaskService = $promotionTaskService;
     }
 
     /**
@@ -480,7 +480,7 @@ class CropPlantedListener
     public function handle(CropPlantedEvent $event)
     {
         // 更新团队种植任务进度
-        $this->teamTaskService->updatePlantingTaskProgress(
+        $this->promotionTaskService->updatePlantingTaskProgress(
             $event->userId,
             $event->seedId
         );
@@ -492,16 +492,16 @@ class CropPlantedListener
 
 ### 7.1 团队农场活跃度
 
-Team模块统计团队在Farm模块中的活跃度:
+Promotion模块统计团队在Farm模块中的活跃度:
 
 ```php
 /**
  * 统计团队农场活跃度
  */
-public function calculateTeamFarmActivity(int $userId, int $days = 7): array
+public function calculatePromotionFarmActivity(int $userId, int $days = 7): array
 {
     // 获取团队成员ID列表
-    $memberIds = $this->referralRepository->getTeamMemberIds($userId);
+    $memberIds = $this->referralRepository->getPromotionMemberIds($userId);
 
     // 统计种植次数
     $plantCount = $this->farmActivityRepository->countPlantings($memberIds, $days);
@@ -532,25 +532,25 @@ public function calculateTeamFarmActivity(int $userId, int $days = 7): array
 
 ### 7.2 团队收益分析
 
-Team模块分析团队在Farm模块中的收益情况:
+Promotion模块分析团队在Farm模块中的收益情况:
 
 ```php
 /**
  * 分析团队农场收益
  */
-public function analyzeTeamFarmProfit(int $userId, string $timeRange = 'month'): array
+public function analyzePromotionFarmProfit(int $userId, string $timeRange = 'month'): array
 {
     // 确定时间范围
     $startTime = $this->getTimeRangeStart($timeRange);
 
     // 获取团队成员ID列表
-    $memberIds = $this->referralRepository->getTeamMemberIds($userId);
+    $memberIds = $this->referralRepository->getPromotionMemberIds($userId);
 
     // 统计总收益
     $totalProfit = $this->farmProfitRepository->sumProfit($memberIds, $startTime);
 
     // 统计直推收益
-    $directProfit = $this->teamProfitRepository->sumProfit(
+    $directProfit = $this->promotionProfitRepository->sumProfit(
         $userId,
         'farm_harvest',
         $startTime,
@@ -558,7 +558,7 @@ public function analyzeTeamFarmProfit(int $userId, string $timeRange = 'month'):
     );
 
     // 统计间推收益
-    $indirectProfit = $this->teamProfitRepository->sumProfit(
+    $indirectProfit = $this->promotionProfitRepository->sumProfit(
         $userId,
         'farm_harvest',
         $startTime,
@@ -583,14 +583,14 @@ public function analyzeTeamFarmProfit(int $userId, string $timeRange = 'month'):
 ### 8.1 前置条件
 
 1. Farm模块已实现作物收获事件
-2. Team模块已实现推荐关系和达人等级系统
+2. Promotion模块已实现推荐关系和达人等级系统
 3. 两个模块都已注册到应用中
 
 ### 8.2 实现步骤
 
-1. **配置事件监听**:在Team模块中注册监听Farm模块的事件
-2. **实现收益分成**:在Team模块中实现Farm收益的分成逻辑
-3. **添加达人权益**:在Farm模块中调用Team模块接口获取达人加成
+1. **配置事件监听**:在Promotion模块中注册监听Farm模块的事件
+2. **实现收益分成**:在Promotion模块中实现Farm收益的分成逻辑
+3. **添加达人权益**:在Farm模块中调用Promotion模块接口获取达人加成
 4. **实现团队任务**:创建和管理与Farm相关的团队任务
 5. **数据统计分析**:实现团队在Farm模块中的活跃度和收益分析
 
@@ -602,7 +602,7 @@ public function analyzeTeamFarmProfit(int $userId, string $timeRange = 'month'):
 'providers' => [
     // ...
     App\Module\Farm\Providers\FarmServiceProvider::class,
-    App\Module\Team\Providers\TeamServiceProvider::class,
+    App\Module\Promotion\Providers\PromotionServiceProvider::class,
 ],
 ```
 
@@ -610,7 +610,7 @@ public function analyzeTeamFarmProfit(int $userId, string $timeRange = 'month'):
 
 ### 9.1 单元测试
 
-为Team模块与Farm模块的集成编写单元测试:
+为Promotion模块与Farm模块的集成编写单元测试:
 
 ```php
 /**
@@ -629,9 +629,9 @@ public function testCropHarvestedEventTriggersProfitSharing()
     event(new CropHarvestedEvent($user2->id, 1, 1, 1, 100));
 
     // 验证收益分成
-    $profit = $this->teamProfitRepository->findByConditions([
+    $profit = $this->promotionProfitRepository->findByConditions([
         'user_id' => $user1->id,
-        'team_member_id' => $user2->id,
+        'promotion_member_id' => $user2->id,
         'source_type' => 'farm_harvest'
     ])->first();
 
@@ -646,9 +646,9 @@ public function testCropHarvestedEventTriggersProfitSharing()
 
 ```php
 /**
- * 测试完整的Farm-Team集成流程
+ * 测试完整的Farm-Promotion集成流程
  */
-public function testFarmTeamIntegrationFlow()
+public function testFarmPromotionIntegrationFlow()
 {
     // 创建测试用户
     $user1 = factory(User::class)->create();
@@ -662,7 +662,7 @@ public function testFarmTeamIntegrationFlow()
         'user_id' => $user1->id,
         'talent_level' => 3,
         'direct_count' => 5,
-        'team_count' => 10
+        'promotion_count' => 10
     ]);
 
     // 用户2种植作物
@@ -677,9 +677,9 @@ public function testFarmTeamIntegrationFlow()
     $harvestResult = $this->farmService->harvestCrop($user2->id, $cropId);
 
     // 验证用户1获得分成
-    $profit = $this->teamProfitRepository->findByConditions([
+    $profit = $this->promotionProfitRepository->findByConditions([
         'user_id' => $user1->id,
-        'team_member_id' => $user2->id,
+        'promotion_member_id' => $user2->id,
         'source_type' => 'farm_harvest'
     ])->first();
 
@@ -694,6 +694,6 @@ public function testFarmTeamIntegrationFlow()
 
 ## 10. 总结
 
-Team模块与Farm模块的集成主要通过事件驱动机制实现,核心功能是收益分成和达人权益。当Farm模块中的用户收获作物时,Team模块会根据用户的推荐关系计算并分配收益给其上级。同时,Team模块的达人等级系统也为Farm模块提供产出加成,提高达人用户的游戏体验。
+Promotion模块与Farm模块的集成主要通过事件驱动机制实现,核心功能是收益分成和达人权益。当Farm模块中的用户收获作物时,Promotion模块会根据用户的推荐关系计算并分配收益给其上级。同时,Promotion模块的达人等级系统也为Farm模块提供产出加成,提高达人用户的游戏体验。
 
 这种集成方式保持了模块间的松耦合,同时提供了灵活的收益分成机制,鼓励用户发展团队,形成良性的社交生态。通过团队任务和数据统计分析,进一步增强了两个模块的协同效应,提升了游戏的社交性和粘性。

+ 48 - 48
app/Module/Team/Docs/推荐关系系统.md → app/Module/Promotion/Docs/推荐关系系统.md

@@ -54,7 +54,7 @@
 
 ## 3. 数据结构设计
 
-### 3.1 用户推荐关系表 (team_user_referrals)
+### 3.1 用户推荐关系表 (promotion_user_referrals)
 
 用户推荐关系表采用简化设计,只存储用户与其直接上级(直推关系)的关系,间接关系通过缓存或实时计算获取。
 
@@ -85,7 +85,7 @@ id | user_id | referrer_id | created_at
 - 用户1间接推荐了用户4(通过用户2和用户3)
 - 用户2间接推荐了用户4(通过用户3)
 
-### 3.2 推荐码表 (team_referral_codes)
+### 3.2 推荐码表 (promotion_referral_codes)
 
 推荐码表存储用户的推荐码信息,用于邀请新用户注册。
 
@@ -141,7 +141,7 @@ public function createReferralRelation(int $userId, int $referrerId): bool
         $this->clearReferralCaches($userId, null, $referrerId);
 
         // 更新推荐人的团队人数
-        $this->updateTeamCounts($referrerId);
+        $this->updatePromotionCounts($referrerId);
 
         // 触发推荐关系创建事件
         event(new ReferralCreatedEvent($userId, $referrerId));
@@ -156,27 +156,27 @@ public function createReferralRelation(int $userId, int $referrerId): bool
 /**
  * 更新用户及其所有上级的团队人数
  */
-private function updateTeamCounts(int $userId): void
+private function updatePromotionCounts(int $userId): void
 {
     // 更新当前用户的团队人数
     $directCount = $this->countDirectReferrals($userId);
-    $teamCount = $this->calculateTeamCount($userId);
-    $this->talentRepository->updateCounts($userId, $directCount, $teamCount);
+    $promotionCount = $this->calculatePromotionCount($userId);
+    $this->talentRepository->updateCounts($userId, $directCount, $promotionCount);
 
     // 递归更新所有上级的团队人数
     $directReferrer = $this->referralRepository->getDirectReferrer($userId);
     if ($directReferrer) {
-        $this->updateTeamCounts($directReferrer->referrer_id);
+        $this->updatePromotionCounts($directReferrer->referrer_id);
     }
 }
 
 /**
  * 计算用户的团队总人数
  */
-private function calculateTeamCount(int $userId): int
+private function calculatePromotionCount(int $userId): int
 {
     // 获取所有团队成员
-    $allMembers = $this->getAllTeamMembers($userId);
+    $allMembers = $this->getAllPromotionMembers($userId);
     return count($allMembers);
 }
 ```
@@ -241,7 +241,7 @@ private function generateUniqueCode(): string
 public function getAllReferrers(int $userId): array
 {
     // 尝试从缓存获取
-    $cacheKey = "team:user:{$userId}:all_referrers";
+    $cacheKey = "promotion:user:{$userId}:all_referrers";
     $cachedReferrers = Redis::get($cacheKey);
 
     if ($cachedReferrers !== null) {
@@ -290,10 +290,10 @@ private function calculateAllReferrers(int $userId, array &$allReferrers, int $l
 /**
  * 获取用户的所有团队成员(包括直接和间接)
  */
-public function getAllTeamMembers(int $userId, int $page = 1, int $pageSize = 20): array
+public function getAllPromotionMembers(int $userId, int $page = 1, int $pageSize = 20): array
 {
     // 尝试从缓存获取
-    $cacheKey = "team:user:{$userId}:all_members";
+    $cacheKey = "promotion:user:{$userId}:all_members";
     $cachedMembers = Redis::get($cacheKey);
 
     $allMembers = [];
@@ -301,7 +301,7 @@ public function getAllTeamMembers(int $userId, int $page = 1, int $pageSize = 20
         $allMembers = json_decode($cachedMembers, true);
     } else {
         // 缓存不存在,计算所有下级
-        $this->calculateAllTeamMembers($userId, $allMembers);
+        $this->calculateAllPromotionMembers($userId, $allMembers);
 
         // 缓存结果
         Redis::setex($cacheKey, 86400, json_encode($allMembers)); // 缓存1天
@@ -342,7 +342,7 @@ public function getAllTeamMembers(int $userId, int $page = 1, int $pageSize = 20
 /**
  * 递归计算用户的所有团队成员
  */
-private function calculateAllTeamMembers(int $userId, array &$allMembers, int $level = 0, int $maxLevel = 20): void
+private function calculateAllPromotionMembers(int $userId, array &$allMembers, int $level = 0, int $maxLevel = 20): void
 {
     // 限制最大层级
     if ($level >= $maxLevel) {
@@ -363,7 +363,7 @@ private function calculateAllTeamMembers(int $userId, array &$allMembers, int $l
         ];
 
         // 递归获取下级的下级
-        $this->calculateAllTeamMembers($memberId, $allMembers, $level + 1, $maxLevel);
+        $this->calculateAllPromotionMembers($memberId, $allMembers, $level + 1, $maxLevel);
     }
 }
 
@@ -373,32 +373,32 @@ private function calculateAllTeamMembers(int $userId, array &$allMembers, int $l
 private function clearReferralCaches(int $userId, ?int $oldReferrerId, int $newReferrerId): void
 {
     // 清除用户自身的缓存
-    Redis::del("team:user:{$userId}:all_referrers");
+    Redis::del("promotion:user:{$userId}:all_referrers");
 
     // 清除旧推荐人相关的缓存
     if ($oldReferrerId) {
-        Redis::del("team:user:{$oldReferrerId}:all_members");
+        Redis::del("promotion:user:{$oldReferrerId}:all_members");
 
         // 获取旧推荐人的所有上级,清除他们的团队成员缓存
         $oldUpperReferrers = $this->getAllReferrers($oldReferrerId);
         foreach ($oldUpperReferrers as $referrer) {
-            Redis::del("team:user:{$referrer['user_id']}:all_members");
+            Redis::del("promotion:user:{$referrer['user_id']}:all_members");
         }
     }
 
     // 清除新推荐人相关的缓存
-    Redis::del("team:user:{$newReferrerId}:all_members");
+    Redis::del("promotion:user:{$newReferrerId}:all_members");
 
     // 获取新推荐人的所有上级,清除他们的团队成员缓存
     $newUpperReferrers = $this->getAllReferrers($newReferrerId);
     foreach ($newUpperReferrers as $referrer) {
-        Redis::del("team:user:{$referrer['user_id']}:all_members");
+        Redis::del("promotion:user:{$referrer['user_id']}:all_members");
     }
 
     // 获取用户的所有下级,清除他们的上级缓存
-    $allMembers = $this->getAllTeamMembers($userId);
+    $allMembers = $this->getAllPromotionMembers($userId);
     foreach ($allMembers['members'] as $member) {
-        Redis::del("team:user:{$member['user_id']}:all_referrers");
+        Redis::del("promotion:user:{$member['user_id']}:all_referrers");
     }
 }
 ```
@@ -514,11 +514,11 @@ private function clearReferralCaches(int $userId, ?int $oldReferrerId, int $newR
 2. **缓存键设计**:
    ```
    // 用户的所有上级
-   key: team:user:{userId}:all_referrers
+   key: promotion:user:{userId}:all_referrers
    value: [referrerId1, referrerId2, ...]
 
    // 用户的所有下级
-   key: team:user:{userId}:all_members
+   key: promotion:user:{userId}:all_members
    value: [memberId1, memberId2, ...]
    ```
 
@@ -535,14 +535,14 @@ private function clearReferralCaches(int $userId, ?int $oldReferrerId, int $newR
 
 为了进一步提高查询效率,特别是在Redis缓存失效或需要复杂查询时,系统引入了用户关系缓存表:
 
-##### 5.3.2.1 用户关系缓存表 (team_user_relation_cache)
+##### 5.3.2.1 用户关系缓存表 (promotion_user_relation_cache)
 
 用户关系缓存表是一个统一的缓存表,用于存储用户之间的所有推荐关系(包括上下级关系)。通过合理设计字段和索引,一张表可以同时满足查询用户上级和下级的需求,减少数据冗余,简化维护。
 
 **表结构设计**:
 
 ```sql
-CREATE TABLE `team_user_relation_cache` (
+CREATE TABLE `promotion_user_relation_cache` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `related_user_id` bigint(20) NOT NULL COMMENT '关联用户ID(上级)',
@@ -602,25 +602,25 @@ id | user_id | related_user_id | level | path      | depth
 
 1. 查询用户4的所有上级:
 ```sql
-SELECT * FROM team_user_relation_cache WHERE user_id = 4;
+SELECT * FROM promotion_user_relation_cache WHERE user_id = 4;
 ```
 
 2. 查询用户1的所有下级:
 ```sql
-SELECT * FROM team_user_relation_cache WHERE related_user_id = 1;
+SELECT * FROM promotion_user_relation_cache WHERE related_user_id = 1;
 ```
 
 3. 查询用户2的直接下级:
 ```sql
 SELECT u.* FROM users u
-JOIN team_user_relation_cache r ON u.id = r.user_id
+JOIN promotion_user_relation_cache r ON u.id = r.user_id
 WHERE r.related_user_id = 2 AND r.level = 1;
 ```
 
 4. 查询用户1的第2代下级:
 ```sql
 SELECT u.* FROM users u
-JOIN team_user_relation_cache r ON u.id = r.user_id
+JOIN promotion_user_relation_cache r ON u.id = r.user_id
 WHERE r.related_user_id = 1 AND r.depth = 2;
 ```
 
@@ -852,7 +852,7 @@ public function getAllReferrers(int $userId, int $level = 0, int $maxDepth = 20)
 /**
  * 获取用户的所有团队成员
  */
-public function getAllTeamMembers(int $userId, int $level = 0, int $maxDepth = 20, int $page = 1, int $pageSize = 20): array
+public function getAllPromotionMembers(int $userId, int $level = 0, int $maxDepth = 20, int $page = 1, int $pageSize = 20): array
 {
     $conditions = ['related_user_id' => $userId];
 
@@ -903,7 +903,7 @@ public function getAllTeamMembers(int $userId, int $level = 0, int $maxDepth = 2
 /**
  * 获取用户特定代数的团队成员
  */
-public function getTeamMembersByDepth(int $userId, int $depth): array
+public function getPromotionMembersByDepth(int $userId, int $depth): array
 {
     $relations = $this->relationCacheRepository->findByConditions([
         'related_user_id' => $userId,
@@ -933,7 +933,7 @@ public function getTeamMembersByDepth(int $userId, int $depth): array
 /**
  * 统计用户的团队规模
  */
-public function countTeamMembers(int $userId, int $level = 0): int
+public function countPromotionMembers(int $userId, int $level = 0): int
 {
     $conditions = ['related_user_id' => $userId];
 
@@ -1031,12 +1031,12 @@ public function updateReferralRelation(int $userId, int $newReferrerId): bool
 
         // 更新旧推荐人的直推人数和团队人数
         if ($oldReferrerId) {
-            $this->updateTeamCounts($oldReferrerId);
+            $this->updatePromotionCounts($oldReferrerId);
             $this->talentService->checkAndUpdateTalentLevel($oldReferrerId);
         }
 
         // 更新新推荐人的直推人数和团队人数
-        $this->updateTeamCounts($newReferrerId);
+        $this->updatePromotionCounts($newReferrerId);
         $this->talentService->checkAndUpdateTalentLevel($newReferrerId);
 
         // 记录修改历史
@@ -1062,7 +1062,7 @@ public function updateReferralRelation(int $userId, int $newReferrerId): bool
 为了记录推荐关系的修改历史,系统使用以下表结构:
 
 ```sql
-CREATE TABLE `team_referral_changes` (
+CREATE TABLE `promotion_referral_changes` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `old_referrer_id` bigint(20) DEFAULT NULL COMMENT '旧推荐人ID',
@@ -1100,8 +1100,8 @@ private function validateReferralChangeEligibility(int $userId): void
     }
 
     // 检查团队规模限制
-    $teamCount = $this->calculateTeamCount($userId);
-    if ($teamCount > 100) {
+    $promotionCount = $this->calculatePromotionCount($userId);
+    if ($promotionCount > 100) {
         throw new ReferralException("团队规模超过100人不能修改推荐关系");
     }
 }
@@ -1133,7 +1133,7 @@ private function checkCircularReferral(int $userId, int $referrerId): bool
     }
 
     // 获取用户的所有下级
-    $allMembers = $this->getAllTeamMembers($userId);
+    $allMembers = $this->getAllPromotionMembers($userId);
 
     // 检查新推荐人是否在用户的下级中
     foreach ($allMembers['members'] as $member) {
@@ -1179,7 +1179,7 @@ public function countDirectReferrals(int $userId): int
 /**
  * 统计用户的团队总人数
  */
-public function countTeamMembers(int $userId): int
+public function countPromotionMembers(int $userId): int
 {
     return $this->referralRepository->countByConditions([
         'referrer_id' => $userId
@@ -1195,10 +1195,10 @@ public function countTeamMembers(int $userId): int
 /**
  * 统计用户团队的活跃度
  */
-public function calculateTeamActivity(int $userId, int $days = 7): array
+public function calculatePromotionActivity(int $userId, int $days = 7): array
 {
     // 获取团队成员ID列表
-    $memberIds = $this->referralRepository->getTeamMemberIds($userId);
+    $memberIds = $this->referralRepository->getPromotionMemberIds($userId);
 
     // 统计活跃用户数
     $activeCount = $this->userActivityRepository->countActiveUsers($memberIds, $days);
@@ -1226,7 +1226,7 @@ public function calculateTeamActivity(int $userId, int $days = 7): array
 /**
  * 生成用户的团队树形图
  */
-public function generateTeamTree(int $userId, int $maxDepth = 3): array
+public function generatePromotionTree(int $userId, int $maxDepth = 3): array
 {
     // 获取用户信息
     $user = $this->userRepository->find($userId);
@@ -1243,7 +1243,7 @@ public function generateTeamTree(int $userId, int $maxDepth = 3): array
     ];
 
     // 递归构建团队树
-    $this->buildTeamTreeNode($root, 1, $maxDepth);
+    $this->buildPromotionTreeNode($root, 1, $maxDepth);
 
     return $root;
 }
@@ -1251,7 +1251,7 @@ public function generateTeamTree(int $userId, int $maxDepth = 3): array
 /**
  * 递归构建团队树节点
  */
-private function buildTeamTreeNode(array &$node, int $currentDepth, int $maxDepth): void
+private function buildPromotionTreeNode(array &$node, int $currentDepth, int $maxDepth): void
 {
     // 达到最大深度,停止递归
     if ($currentDepth >= $maxDepth) {
@@ -1276,7 +1276,7 @@ private function buildTeamTreeNode(array &$node, int $currentDepth, int $maxDept
             ];
 
             // 递归构建子节点
-            $this->buildTeamTreeNode($childNode, $currentDepth + 1, $maxDepth);
+            $this->buildPromotionTreeNode($childNode, $currentDepth + 1, $maxDepth);
 
             // 添加到父节点
             $node['children'][] = $childNode;
@@ -1293,10 +1293,10 @@ private function buildTeamTreeNode(array &$node, int $currentDepth, int $maxDept
 /**
  * 生成用户的团队关系图
  */
-public function generateTeamGraph(int $userId, int $maxMembers = 50): array
+public function generatePromotionGraph(int $userId, int $maxMembers = 50): array
 {
     // 获取团队成员
-    $members = $this->getTeamMembers($userId, 0, 1, $maxMembers)['members'];
+    $members = $this->getPromotionMembers($userId, 0, 1, $maxMembers)['members'];
 
     // 构建节点
     $nodes = [];

+ 64 - 64
app/Module/Team/Docs/数据库设计.md → app/Module/Promotion/Docs/数据库设计.md

@@ -4,25 +4,25 @@
 
 团队模块包含以下核心数据表:
 
-1. **team_user_referrals** - 用户推荐关系表
-2. **team_user_talents** - 达人等级表
-3. **team_profits** - 团队收益记录表
-4. **team_referral_codes** - 推荐码表
-5. **team_talent_configs** - 达人等级配置表
-6. **team_profit_rules** - 收益分成规则表
-7. **team_referral_changes** - 推荐关系修改记录表
-8. **team_user_relation_cache** - 用户关系缓存表
-9. **team_invite_rewards** - 邀请奖励记录表
-10. **team_referral_code_usages** - 邀请码使用记录表
+1. **promotion_user_referrals** - 用户推荐关系表
+2. **promotion_user_talents** - 达人等级表
+3. **promotion_profits** - 团队收益记录表
+4. **promotion_referral_codes** - 推荐码表
+5. **promotion_talent_configs** - 达人等级配置表
+6. **promotion_profit_rules** - 收益分成规则表
+7. **promotion_referral_changes** - 推荐关系修改记录表
+8. **promotion_user_relation_cache** - 用户关系缓存表
+9. **promotion_invite_rewards** - 邀请奖励记录表
+10. **promotion_referral_code_usages** - 邀请码使用记录表
 
 ## 2. 表结构详细设计
 
-### 2.1 用户推荐关系表 (team_user_referrals)
+### 2.1 用户推荐关系表 (promotion_user_referrals)
 
 存储用户与其直接推荐人(直接上级)的关系,间接关系通过缓存或实时计算获取。该表是实现"直间推播种收获贡献百分比农作物收益"功能的基础。
 
 ```sql
-CREATE TABLE `team_user_referrals` (
+CREATE TABLE `promotion_user_referrals` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `referrer_id` bigint(20) NOT NULL COMMENT '直接推荐人ID',
@@ -36,17 +36,17 @@ CREATE TABLE `team_user_referrals` (
 
 > 注意:表中只存储直接推荐关系(直推),间接推荐关系(间推)通过递归查询或缓存获取。这种设计简化了数据结构,同时通过缓存机制保证了查询效率。
 
-### 2.2 达人等级表 (team_user_talents)
+### 2.2 达人等级表 (promotion_user_talents)
 
 存储用户的达人等级信息,包括直推人数和团队总人数。
 
 ```sql
-CREATE TABLE `team_user_talents` (
+CREATE TABLE `promotion_user_talents` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `talent_level` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '达人等级:0无,1初级,2中级,3高级,4资深,5顶级',
   `direct_count` int(11) NOT NULL DEFAULT '0' COMMENT '直推人数',
-  `team_count` int(11) NOT NULL DEFAULT '0' COMMENT '团队总人数',
+  `promotion_count` int(11) NOT NULL DEFAULT '0' COMMENT '团队总人数',
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
   PRIMARY KEY (`id`),
@@ -55,15 +55,15 @@ CREATE TABLE `team_user_talents` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='达人等级表';
 ```
 
-### 2.3 团队收益记录表 (team_profits)
+### 2.3 团队收益记录表 (promotion_profits)
 
 记录团队成员产生的分成收益,是实现"直间推播种收获贡献百分比农作物收益"功能的核心表。
 
 ```sql
-CREATE TABLE `team_profits` (
+CREATE TABLE `promotion_profits` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '获得收益的用户ID',
-  `team_member_id` bigint(20) NOT NULL COMMENT '团队成员ID',
+  `promotion_member_id` bigint(20) NOT NULL COMMENT '团队成员ID',
   `source_id` bigint(20) NOT NULL COMMENT '收益来源ID',
   `source_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '收益来源类型',
   `item_id` bigint(20) NOT NULL COMMENT '物品ID',
@@ -73,7 +73,7 @@ CREATE TABLE `team_profits` (
   `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
   PRIMARY KEY (`id`),
   KEY `idx_user_id` (`user_id`),
-  KEY `idx_team_member_id` (`team_member_id`),
+  KEY `idx_promotion_member_id` (`promotion_member_id`),
   KEY `idx_source` (`source_type`,`source_id`),
   KEY `idx_relation_type` (`relation_type`),
   KEY `idx_created_at` (`created_at`)
@@ -82,12 +82,12 @@ CREATE TABLE `team_profits` (
 
 > 注意:`relation_type`字段用于区分直推和间推收益,便于统计和分析。`source_type`为'farm_harvest'时表示农场收获收益,是团队收益的主要来源。
 
-### 2.4 推荐码表 (team_referral_codes)
+### 2.4 推荐码表 (promotion_referral_codes)
 
 存储用户的推荐码信息。
 
 ```sql
-CREATE TABLE `team_referral_codes` (
+CREATE TABLE `promotion_referral_codes` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '推荐码',
@@ -103,17 +103,17 @@ CREATE TABLE `team_referral_codes` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='推荐码表';
 ```
 
-### 2.5 达人等级配置表 (team_talent_configs)
+### 2.5 达人等级配置表 (promotion_talent_configs)
 
 存储不同达人等级的配置信息。
 
 ```sql
-CREATE TABLE `team_talent_configs` (
+CREATE TABLE `promotion_talent_configs` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `level` tinyint(3) unsigned NOT NULL COMMENT '等级',
   `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '等级名称',
   `direct_count_required` int(11) NOT NULL COMMENT '所需直推人数',
-  `team_count_required` int(11) NOT NULL COMMENT '所需团队总人数',
+  `promotion_count_required` int(11) NOT NULL COMMENT '所需团队总人数',
   `profit_rate` decimal(5,4) NOT NULL COMMENT '间推分成比例',
   `benefits` json DEFAULT NULL COMMENT '等级权益',
   `icon` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '等级图标',
@@ -124,12 +124,12 @@ CREATE TABLE `team_talent_configs` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='达人等级配置表';
 ```
 
-### 2.6 收益分成规则表 (team_profit_rules)
+### 2.6 收益分成规则表 (promotion_profit_rules)
 
 存储不同来源的收益分成规则。
 
 ```sql
-CREATE TABLE `team_profit_rules` (
+CREATE TABLE `promotion_profit_rules` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `source_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '来源类型',
   `direct_profit_rate` decimal(5,4) NOT NULL COMMENT '直推分成比例',
@@ -144,12 +144,12 @@ CREATE TABLE `team_profit_rules` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='收益分成规则表';
 ```
 
-### 2.7 推荐关系修改记录表 (team_referral_changes)
+### 2.7 推荐关系修改记录表 (promotion_referral_changes)
 
 记录用户推荐关系的修改历史。
 
 ```sql
-CREATE TABLE `team_referral_changes` (
+CREATE TABLE `promotion_referral_changes` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `old_referrer_id` bigint(20) DEFAULT NULL COMMENT '旧推荐人ID',
@@ -164,12 +164,12 @@ CREATE TABLE `team_referral_changes` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='推荐关系修改记录表';
 ```
 
-### 2.8 用户关系缓存表 (team_user_relation_cache)
+### 2.8 用户关系缓存表 (promotion_user_relation_cache)
 
 用户关系缓存表是一个统一的缓存表,用于存储用户之间的所有推荐关系(包括上下级关系)。通过合理设计字段和索引,一张表可以同时满足查询用户上级和下级的需求,减少数据冗余,简化维护。
 
 ```sql
-CREATE TABLE `team_user_relation_cache` (
+CREATE TABLE `promotion_user_relation_cache` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '用户ID',
   `related_user_id` bigint(20) NOT NULL COMMENT '关联用户ID(上级)',
@@ -200,12 +200,12 @@ CREATE TABLE `team_user_relation_cache` (
 | created_at | timestamp | 创建时间 |
 | updated_at | timestamp | 更新时间 |
 
-### 2.9 邀请奖励记录表 (team_invite_rewards)
+### 2.9 邀请奖励记录表 (promotion_invite_rewards)
 
 邀请奖励记录表用于记录用户邀请他人注册时获得的奖励,支持多种奖励类型和来源追踪。
 
 ```sql
-CREATE TABLE `team_invite_rewards` (
+CREATE TABLE `promotion_invite_rewards` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `user_id` bigint(20) NOT NULL COMMENT '获得奖励的用户ID',
   `invited_user_id` bigint(20) NOT NULL COMMENT '被邀请的用户ID',
@@ -259,12 +259,12 @@ id | user_id | invited_user_id | reward_type | reward_id | reward_amount | rewar
 - 用户2邀请用户4注册,获得了50点经验值奖励
 - 当用户2升级时,用户1获得了1个ID为1002的物品奖励
 
-### 2.10 邀请码使用记录表 (team_referral_code_usages)
+### 2.10 邀请码使用记录表 (promotion_referral_code_usages)
 
 邀请码使用记录表用于详细记录每次邀请码的使用情况,包括谁使用了哪个邀请码、何时使用、使用结果等信息。
 
 ```sql
-CREATE TABLE `team_referral_code_usages` (
+CREATE TABLE `promotion_referral_code_usages` (
   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `code` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '使用的邀请码',
   `code_owner_id` bigint(20) NOT NULL COMMENT '邀请码所有者用户ID',
@@ -319,29 +319,29 @@ id | code     | code_owner_id | user_id | ip_address    | status | result
 
 1. 查询用户4的所有上级:
 ```sql
-SELECT * FROM team_user_relation_cache WHERE user_id = 4;
+SELECT * FROM promotion_user_relation_cache WHERE user_id = 4;
 ```
 
 2. 查询用户1的所有下级:
 ```sql
-SELECT * FROM team_user_relation_cache WHERE related_user_id = 1;
+SELECT * FROM promotion_user_relation_cache WHERE related_user_id = 1;
 ```
 
 3. 查询用户2的直接下级:
 ```sql
 SELECT u.* FROM users u
-JOIN team_user_relation_cache r ON u.id = r.user_id
+JOIN promotion_user_relation_cache r ON u.id = r.user_id
 WHERE r.related_user_id = 2 AND r.level = 1;
 ```
 
 4. 查询用户1的第2代下级:
 ```sql
 SELECT u.* FROM users u
-JOIN team_user_relation_cache r ON u.id = r.user_id
+JOIN promotion_user_relation_cache r ON u.id = r.user_id
 WHERE r.related_user_id = 1 AND r.depth = 2;
 ```
 
-> 注意:该表是缓存表,其数据可以通过`team_user_referrals`表重新计算生成。使用单一表存储所有关系,减少了数据冗余,简化了维护,同时通过合理的索引设计,保证了查询效率。
+> 注意:该表是缓存表,其数据可以通过`promotion_user_referrals`表重新计算生成。使用单一表存储所有关系,减少了数据冗余,简化了维护,同时通过合理的索引设计,保证了查询效率。
 
 ## 3. 数据关系
 
@@ -349,12 +349,12 @@ WHERE r.related_user_id = 1 AND r.depth = 2;
 
 ```
                                     ┌───────────────────┐
-                                    │team_talent_configs│
+                                    │promotion_talent_configs│
                                     └─────────┬─────────┘
 ┌───────────────────┐            ┌───────────────────┐
-│team_user_referrals│◄───────────┤ team_user_talents │
+│promotion_user_referrals│◄───────────┤ promotion_user_talents │
 └─────────┬─────────┘            └─────────┬─────────┘
           │                                 │
           │                                 │
@@ -362,19 +362,19 @@ WHERE r.related_user_id = 1 AND r.depth = 2;
           │             │                   │
           ▼             ▼                   │
 ┌───────────────────┐  ┌───────────────────┐│
-│team_referral_codes│  │team_user_relation_cache│
+│promotion_referral_codes│  │promotion_user_relation_cache│
 └───────────────────┘  └───────────────────┘│
                                   ┌───────────────────┐
-                                  │   team_profits    │
+                                  │   promotion_profits    │
                                   └─────────┬─────────┘
                                   ┌───────────────────┐
-                                  │ team_profit_rules │
+                                  │ promotion_profit_rules │
                                   └───────────────────┘
 ```
 
@@ -403,25 +403,25 @@ WHERE r.related_user_id = 1 AND r.depth = 2;
 
 ### 4.2 唯一索引
 
-- `team_user_referrals`: `user_id`(确保每个用户只有一个直接推荐人)
-- `team_user_talents`: `user_id`(确保每个用户只有一条达人记录)
-- `team_referral_codes`: `code`(确保推荐码唯一)
-- `team_referral_codes`: `user_id`(确保每个用户只有一个推荐码)
-- `team_talent_configs`: `level`(确保等级唯一)
-- `team_profit_rules`: `source_type`(确保来源类型唯一)
-- `team_user_relation_cache`: `user_id,related_user_id`(确保用户与上级的关系唯一)
+- `promotion_user_referrals`: `user_id`(确保每个用户只有一个直接推荐人)
+- `promotion_user_talents`: `user_id`(确保每个用户只有一条达人记录)
+- `promotion_referral_codes`: `code`(确保推荐码唯一)
+- `promotion_referral_codes`: `user_id`(确保每个用户只有一个推荐码)
+- `promotion_talent_configs`: `level`(确保等级唯一)
+- `promotion_profit_rules`: `source_type`(确保来源类型唯一)
+- `promotion_user_relation_cache`: `user_id,related_user_id`(确保用户与上级的关系唯一)
 
 ### 4.3 普通索引
 
-- `team_user_referrals`: `referrer_id`
-- `team_user_talents`: `talent_level`
-- `team_profits`: `user_id`, `team_member_id`, `source_type,source_id`, `created_at`
-- `team_referral_codes`: `status`
-- `team_profit_rules`: `status`
-- `team_referral_changes`: `user_id`, `change_time`
-- `team_user_relation_cache`: `user_id`, `related_user_id`, `level`, `depth`(支持各种查询场景)
-- `team_invite_rewards`: `user_id`, `invited_user_id`, `reward_type`, `reward_source`, `status`, `created_at`(支持多种查询和统计场景)
-- `team_referral_code_usages`: `code`, `code_owner_id`, `user_id`, `status`, `created_at`(支持邀请码使用记录的多种查询场景)
+- `promotion_user_referrals`: `referrer_id`
+- `promotion_user_talents`: `talent_level`
+- `promotion_profits`: `user_id`, `promotion_member_id`, `source_type,source_id`, `created_at`
+- `promotion_referral_codes`: `status`
+- `promotion_profit_rules`: `status`
+- `promotion_referral_changes`: `user_id`, `change_time`
+- `promotion_user_relation_cache`: `user_id`, `related_user_id`, `level`, `depth`(支持各种查询场景)
+- `promotion_invite_rewards`: `user_id`, `invited_user_id`, `reward_type`, `reward_source`, `status`, `created_at`(支持多种查询和统计场景)
+- `promotion_referral_code_usages`: `code`, `code_owner_id`, `user_id`, `status`, `created_at`(支持邀请码使用记录的多种查询场景)
 
 ## 5. JSON字段结构
 
@@ -461,7 +461,7 @@ WHERE r.related_user_id = 1 AND r.depth = 2;
 初始化5级达人的配置数据:
 
 ```sql
-INSERT INTO `team_talent_configs` (`level`, `name`, `direct_count_required`, `team_count_required`, `profit_rate`, `benefits`) VALUES
+INSERT INTO `promotion_talent_configs` (`level`, `name`, `direct_count_required`, `promotion_count_required`, `profit_rate`, `benefits`) VALUES
 (1, '初级达人', 5, 10, 0.0100, '{"farm_output_bonus": 0.01}'),
 (2, '中级达人', 10, 30, 0.0150, '{"farm_output_bonus": 0.02}'),
 (3, '高级达人', 20, 50, 0.0200, '{"farm_output_bonus": 0.03, "daily_gift": {"item_id": 1001, "amount": 1}}'),
@@ -474,7 +474,7 @@ INSERT INTO `team_talent_configs` (`level`, `name`, `direct_count_required`, `te
 初始化基本的收益分成规则:
 
 ```sql
-INSERT INTO `team_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
+INSERT INTO `promotion_profit_rules` (`source_type`, `direct_profit_rate`, `max_indirect_level`, `status`, `rules`) VALUES
 ('farm_harvest', 0.0500, 20, 1, '{"min_amount": 10, "max_amount": 1000}'),
 ('task_complete', 0.0300, 10, 1, '{"min_amount": 5, "max_amount": 500}'),
 ('item_sell', 0.0200, 5, 1, '{"min_amount": 1, "max_amount": 100, "excluded_items": [1001, 1002]}');
@@ -508,7 +508,7 @@ INSERT INTO `team_profit_rules` (`source_type`, `direct_profit_rate`, `max_indir
 
 ### 8.1 分表策略
 
-当用户数量增长到一定规模时,可以考虑按用户ID范围对`team_user_referrals`和`team_profits`表进行分表。
+当用户数量增长到一定规模时,可以考虑按用户ID范围对`promotion_user_referrals`和`promotion_profits`表进行分表。
 
 ### 8.2 缓存策略
 
@@ -516,7 +516,7 @@ INSERT INTO `team_profit_rules` (`source_type`, `direct_profit_rate`, `max_indir
 2. 缓存用户的推荐关系和达人信息等频繁访问的数据
 3. 使用Redis缓存用户的所有上级(包括直接和间接)
 4. 使用Redis缓存用户的所有下级(包括直接和间接)
-5. 使用数据库缓存表(`team_user_relation_cache`)持久化存储用户的上下级关系
+5. 使用数据库缓存表(`promotion_user_relation_cache`)持久化存储用户的上下级关系
 6. 设置合理的缓存过期时间,如1天
 7. 推荐关系变更时主动更新相关缓存和缓存表
 8. 定期校验和修复缓存表数据,确保与实际推荐关系一致

+ 7 - 7
app/Module/Team/Docs/枚举定义.md → app/Module/Promotion/Docs/枚举定义.md

@@ -11,7 +11,7 @@
 推荐层级枚举定义了用户之间的推荐关系类型。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum REFERRAL_LEVEL: int {
     case DIRECT = 1;     // 直推关系
@@ -33,7 +33,7 @@ enum REFERRAL_LEVEL: int {
 达人等级枚举定义了用户的达人等级。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum TALENT_LEVEL: int {
     case NONE = 0;       // 非达人
@@ -63,7 +63,7 @@ enum TALENT_LEVEL: int {
 收益来源类型枚举定义了团队收益的来源。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum PROFIT_SOURCE_TYPE: string {
     case FARM_HARVEST = 'farm_harvest';   // 农场收获
@@ -85,7 +85,7 @@ enum PROFIT_SOURCE_TYPE: string {
 收益记录状态枚举定义了团队收益记录的状态。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum PROFIT_RECORD_STATUS: int {
     case PENDING = 0;    // 待处理
@@ -109,7 +109,7 @@ enum PROFIT_RECORD_STATUS: int {
 团队任务类型枚举定义了团队可以执行的任务类型。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum TEAM_TASK_TYPE: string {
     case PLANTING = 'planting';       // 种植任务
@@ -133,7 +133,7 @@ enum TEAM_TASK_TYPE: string {
 团队任务状态枚举定义了团队任务的状态。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum TEAM_TASK_STATUS: int {
     case ACTIVE = 1;     // 进行中
@@ -159,7 +159,7 @@ enum TEAM_TASK_STATUS: int {
 推荐码状态枚举定义了推荐码的状态。
 
 ```php
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 enum REFERRAL_CODE_STATUS: int {
     case INACTIVE = 0;   // 未激活

+ 29 - 29
app/Module/Team/Docs/模块接口.md → app/Module/Promotion/Docs/模块接口.md

@@ -113,7 +113,7 @@ $directReferrers = $referralService->getUserReferrers(1001, 1);
  * @param int $pageSize 每页数量
  * @return array 团队成员列表和分页信息
  */
-public function getTeamMembers(int $userId, int $level = 0, int $page = 1, int $pageSize = 20): array;
+public function getPromotionMembers(int $userId, int $level = 0, int $page = 1, int $pageSize = 20): array;
 ```
 
 **功能说明**:
@@ -125,10 +125,10 @@ public function getTeamMembers(int $userId, int $level = 0, int $page = 1, int $
 **调用示例**:
 ```php
 // 获取所有团队成员,第1页,每页20条
-$allMembers = $referralService->getTeamMembers(1000);
+$allMembers = $referralService->getPromotionMembers(1000);
 
 // 只获取直推成员,第1页,每页50条
-$directMembers = $referralService->getTeamMembers(1000, 1, 1, 50);
+$directMembers = $referralService->getPromotionMembers(1000, 1, 1, 50);
 ```
 
 ### 3.4 检查推荐关系
@@ -314,7 +314,7 @@ $rate = $talentService->getTalentProfitRate(3);
 // 返回0.02 (2%)
 ```
 
-## 5. 团队收益服务接口 (TeamProfitService)
+## 5. 团队收益服务接口 (PromotionProfitService)
 
 ### 5.1 计算团队收益分成
 
@@ -329,7 +329,7 @@ $rate = $talentService->getTalentProfitRate(3);
  * @param int $amount 收益数量
  * @return bool 是否成功
  */
-public function calculateTeamProfit(int $userId, string $sourceType, int $sourceId, int $itemId, int $amount): bool;
+public function calculatePromotionProfit(int $userId, string $sourceType, int $sourceId, int $itemId, int $amount): bool;
 ```
 
 **功能说明**:
@@ -341,7 +341,7 @@ public function calculateTeamProfit(int $userId, string $sourceType, int $source
 **调用示例**:
 ```php
 // 用户1001收获农场作物,产生100个物品ID为2001的收益
-$result = $teamProfitService->calculateTeamProfit(1001, 'farm_harvest', 5001, 2001, 100);
+$result = $promotionProfitService->calculatePromotionProfit(1001, 'farm_harvest', 5001, 2001, 100);
 if ($result) {
     // 分成计算成功
 }
@@ -358,7 +358,7 @@ if ($result) {
  * @param string $timeRange 时间范围(today,yesterday,week,month,all)
  * @return array 收益统计
  */
-public function getUserTeamProfitStats(int $userId, string $sourceType = '', string $timeRange = 'all'): array;
+public function getUserPromotionProfitStats(int $userId, string $sourceType = '', string $timeRange = 'all'): array;
 ```
 
 **功能说明**:
@@ -369,10 +369,10 @@ public function getUserTeamProfitStats(int $userId, string $sourceType = '', str
 **调用示例**:
 ```php
 // 获取用户1000的所有团队收益统计
-$allStats = $teamProfitService->getUserTeamProfitStats(1000);
+$allStats = $promotionProfitService->getUserPromotionProfitStats(1000);
 
 // 获取用户1000的本月农场收益统计
-$farmMonthStats = $teamProfitService->getUserTeamProfitStats(1000, 'farm_harvest', 'month');
+$farmMonthStats = $promotionProfitService->getUserPromotionProfitStats(1000, 'farm_harvest', 'month');
 ```
 
 ### 5.3 获取用户团队收益记录
@@ -387,7 +387,7 @@ $farmMonthStats = $teamProfitService->getUserTeamProfitStats(1000, 'farm_harvest
  * @param int $pageSize 每页数量
  * @return array 收益记录和分页信息
  */
-public function getUserTeamProfitRecords(int $userId, string $sourceType = '', int $page = 1, int $pageSize = 20): array;
+public function getUserPromotionProfitRecords(int $userId, string $sourceType = '', int $page = 1, int $pageSize = 20): array;
 ```
 
 **功能说明**:
@@ -399,10 +399,10 @@ public function getUserTeamProfitRecords(int $userId, string $sourceType = '', i
 **调用示例**:
 ```php
 // 获取用户1000的所有团队收益记录,第1页,每页20条
-$allRecords = $teamProfitService->getUserTeamProfitRecords(1000);
+$allRecords = $promotionProfitService->getUserPromotionProfitRecords(1000);
 
 // 获取用户1000的农场收益记录,第1页,每页50条
-$farmRecords = $teamProfitService->getUserTeamProfitRecords(1000, 'farm_harvest', 1, 50);
+$farmRecords = $promotionProfitService->getUserPromotionProfitRecords(1000, 'farm_harvest', 1, 50);
 ```
 
 ### 5.4 获取收益分成规则
@@ -425,7 +425,7 @@ public function getProfitRule(string $sourceType): array;
 **调用示例**:
 ```php
 // 获取农场收益的分成规则
-$farmRule = $teamProfitService->getProfitRule('farm_harvest');
+$farmRule = $promotionProfitService->getProfitRule('farm_harvest');
 ```
 
 ## 6. 事件接口
@@ -476,7 +476,7 @@ class TalentLevelUpEvent
 ```php
 // 在EventServiceProvider中注册监听器
 protected $listen = [
-    'App\Module\Team\Events\TalentLevelUpEvent' => [
+    'App\Module\Promotion\Events\TalentLevelUpEvent' => [
         'App\Module\Task\Listeners\TalentLevelUpListener',
     ],
 ];
@@ -537,7 +537,7 @@ class ReferralCreatedEvent
 ```php
 // 在EventServiceProvider中注册监听器
 protected $listen = [
-    'App\Module\Team\Events\ReferralCreatedEvent' => [
+    'App\Module\Promotion\Events\ReferralCreatedEvent' => [
         'App\Module\Task\Listeners\ReferralCreatedListener',
     ],
 ];
@@ -591,10 +591,10 @@ class UserRegisteredEvent
 
 **监听处理**:
 ```php
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
 use App\Module\User\Events\UserRegisteredEvent;
-use App\Module\Team\Services\ReferralService;
+use App\Module\Promotion\Services\ReferralService;
 
 class UserRegisteredListener
 {
@@ -678,24 +678,24 @@ class CropHarvestedEvent
 
 **监听处理**:
 ```php
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
 use App\Module\Farm\Events\CropHarvestedEvent;
-use App\Module\Team\Services\TeamProfitService;
+use App\Module\Promotion\Services\PromotionProfitService;
 
 class CropHarvestedListener
 {
     /**
-     * @var TeamProfitService
+     * @var PromotionProfitService
      */
-    protected $teamProfitService;
+    protected $promotionProfitService;
     
     /**
      * 构造函数
      */
-    public function __construct(TeamProfitService $teamProfitService)
+    public function __construct(PromotionProfitService $promotionProfitService)
     {
-        $this->teamProfitService = $teamProfitService;
+        $this->promotionProfitService = $promotionProfitService;
     }
     
     /**
@@ -710,7 +710,7 @@ class CropHarvestedListener
         $amount = $event->amount;
         
         // 计算团队收益分成
-        $this->teamProfitService->calculateTeamProfit(
+        $this->promotionProfitService->calculatePromotionProfit(
             $userId,
             'farm_harvest',
             $cropId,
@@ -779,7 +779,7 @@ public function harvestCrop(int $cropId)
         $amount = $result['amount'];
         
         // 计算团队收益分成
-        $this->teamProfitService->calculateTeamProfit(
+        $this->promotionProfitService->calculatePromotionProfit(
             $userId,
             'farm_harvest',
             $cropId,
@@ -799,19 +799,19 @@ public function harvestCrop(int $cropId)
 
 ```php
 // 获取用户团队信息
-public function getUserTeamInfo(int $userId)
+public function getUserPromotionInfo(int $userId)
 {
     // 获取用户达人信息
     $talentInfo = $this->talentService->getUserTalentInfo($userId);
     
     // 获取直推成员
-    $directMembers = $this->referralService->getTeamMembers($userId, 1, 1, 10);
+    $directMembers = $this->referralService->getPromotionMembers($userId, 1, 1, 10);
     
     // 获取团队收益统计
-    $profitStats = $this->teamProfitService->getUserTeamProfitStats($userId);
+    $profitStats = $this->promotionProfitService->getUserPromotionProfitStats($userId);
     
     // 获取最近收益记录
-    $recentProfits = $this->teamProfitService->getUserTeamProfitRecords($userId, '', 1, 5);
+    $recentProfits = $this->promotionProfitService->getUserPromotionProfitRecords($userId, '', 1, 5);
     
     // 返回结果
     return [

+ 0 - 0
app/Module/Team/Docs/直间推收益机制.md → app/Module/Promotion/Docs/直间推收益机制.md


+ 69 - 69
app/Module/Team/Docs/缓存策略.md → app/Module/Promotion/Docs/缓存策略.md

@@ -37,39 +37,39 @@
 
 ```
 // 用户的所有上级(包括直接和间接)
-team:user:{userId}:all_referrers
+promotion:user:{userId}:all_referrers
 
 // 用户的所有下级(包括直接和间接)
-team:user:{userId}:all_members
+promotion:user:{userId}:all_members
 
 // 用户的直推人数
-team:user:{userId}:direct_count
+promotion:user:{userId}:direct_count
 
 // 用户的团队总人数
-team:user:{userId}:team_count
+promotion:user:{userId}:promotion_count
 ```
 
 ### 3.2 达人等级缓存键
 
 ```
 // 用户的达人等级
-team:user:{userId}:talent_level
+promotion:user:{userId}:talent_level
 
 // 达人等级配置
-team:talent_config:{level}
+promotion:talent_config:{level}
 
 // 所有达人等级配置
-team:talent_configs
+promotion:talent_configs
 ```
 
 ### 3.3 收益分成规则缓存键
 
 ```
 // 分成规则
-team:profit_rule:{sourceType}
+promotion:profit_rule:{sourceType}
 
 // 所有分成规则
-team:profit_rules
+promotion:profit_rules
 ```
 
 ## 4. 缓存值结构
@@ -119,7 +119,7 @@ team:profit_rules
 {
   "talent_level": 3,
   "direct_count": 20,
-  "team_count": 50
+  "promotion_count": 50
 }
 
 // 达人等级配置
@@ -127,7 +127,7 @@ team:profit_rules
   "level": 3,
   "name": "高级达人",
   "direct_count_required": 20,
-  "team_count_required": 50,
+  "promotion_count_required": 50,
   "profit_rate": 0.02,
   "benefits": {
     "farm_output_bonus": 0.03,
@@ -168,7 +168,7 @@ team:profit_rules
 public function getAllReferrers(int $userId): array
 {
     // 缓存键
-    $cacheKey = "team:user:{$userId}:all_referrers";
+    $cacheKey = "promotion:user:{$userId}:all_referrers";
     
     // 尝试从缓存获取
     $cachedData = Redis::get($cacheKey);
@@ -214,38 +214,38 @@ public function updateReferralRelation(int $userId, int $newReferrerId): bool
 private function clearReferralCaches(int $userId, ?int $oldReferrerId, int $newReferrerId): void
 {
     // 清除用户自身的缓存
-    Redis::del("team:user:{$userId}:all_referrers");
+    Redis::del("promotion:user:{$userId}:all_referrers");
     
     // 清除旧推荐人相关的缓存
     if ($oldReferrerId) {
-        Redis::del("team:user:{$oldReferrerId}:all_members");
-        Redis::del("team:user:{$oldReferrerId}:direct_count");
-        Redis::del("team:user:{$oldReferrerId}:team_count");
+        Redis::del("promotion:user:{$oldReferrerId}:all_members");
+        Redis::del("promotion:user:{$oldReferrerId}:direct_count");
+        Redis::del("promotion:user:{$oldReferrerId}:promotion_count");
         
         // 清除旧推荐人的所有上级的缓存
         $oldUpperReferrers = $this->getAllReferrers($oldReferrerId);
         foreach ($oldUpperReferrers as $referrer) {
-            Redis::del("team:user:{$referrer['user_id']}:all_members");
-            Redis::del("team:user:{$referrer['user_id']}:team_count");
+            Redis::del("promotion:user:{$referrer['user_id']}:all_members");
+            Redis::del("promotion:user:{$referrer['user_id']}:promotion_count");
         }
     }
     
     // 清除新推荐人相关的缓存
-    Redis::del("team:user:{$newReferrerId}:all_members");
-    Redis::del("team:user:{$newReferrerId}:direct_count");
-    Redis::del("team:user:{$newReferrerId}:team_count");
+    Redis::del("promotion:user:{$newReferrerId}:all_members");
+    Redis::del("promotion:user:{$newReferrerId}:direct_count");
+    Redis::del("promotion:user:{$newReferrerId}:promotion_count");
     
     // 清除新推荐人的所有上级的缓存
     $newUpperReferrers = $this->getAllReferrers($newReferrerId);
     foreach ($newUpperReferrers as $referrer) {
-        Redis::del("team:user:{$referrer['user_id']}:all_members");
-        Redis::del("team:user:{$referrer['user_id']}:team_count");
+        Redis::del("promotion:user:{$referrer['user_id']}:all_members");
+        Redis::del("promotion:user:{$referrer['user_id']}:promotion_count");
     }
     
     // 清除用户的所有下级的缓存
-    $allMembers = $this->getAllTeamMembers($userId);
+    $allMembers = $this->getAllPromotionMembers($userId);
     foreach ($allMembers['members'] as $member) {
-        Redis::del("team:user:{$member['user_id']}:all_referrers");
+        Redis::del("promotion:user:{$member['user_id']}:all_referrers");
     }
 }
 ```
@@ -264,11 +264,11 @@ public function refreshTalentConfigCache(): void
     $configs = $this->talentConfigRepository->getAll();
     
     // 缓存所有配置
-    Redis::setex("team:talent_configs", 86400 * 7, json_encode($configs)); // 缓存7天
+    Redis::setex("promotion:talent_configs", 86400 * 7, json_encode($configs)); // 缓存7天
     
     // 缓存单个配置
     foreach ($configs as $config) {
-        Redis::setex("team:talent_config:{$config->level}", 86400 * 7, json_encode($config));
+        Redis::setex("promotion:talent_config:{$config->level}", 86400 * 7, json_encode($config));
     }
 }
 ```
@@ -306,7 +306,7 @@ public function updateTalentLevel(int $userId, int $newLevel): bool
     
     if ($result) {
         // 清除相关缓存
-        Redis::del("team:user:{$userId}:talent_level");
+        Redis::del("promotion:user:{$userId}:talent_level");
     }
     
     return $result;
@@ -324,10 +324,10 @@ public function updateTalentLevel(int $userId, int $newLevel): bool
 public function batchClearReferralCaches(array $userIds): void
 {
     foreach ($userIds as $userId) {
-        Redis::del("team:user:{$userId}:all_referrers");
-        Redis::del("team:user:{$userId}:all_members");
-        Redis::del("team:user:{$userId}:direct_count");
-        Redis::del("team:user:{$userId}:team_count");
+        Redis::del("promotion:user:{$userId}:all_referrers");
+        Redis::del("promotion:user:{$userId}:all_members");
+        Redis::del("promotion:user:{$userId}:direct_count");
+        Redis::del("promotion:user:{$userId}:promotion_count");
     }
 }
 ```
@@ -368,7 +368,7 @@ public function warmupActiveUserCache(int $days = 7): void
     // 预热用户的推荐关系缓存
     foreach ($activeUsers as $user) {
         $this->getAllReferrers($user->id);
-        $this->getAllTeamMembers($user->id);
+        $this->getAllPromotionMembers($user->id);
     }
 }
 ```
@@ -381,14 +381,14 @@ public function warmupActiveUserCache(int $days = 7): void
 /**
  * 预热大型团队领导者的缓存
  */
-public function warmupLargeTeamCache(int $minTeamSize = 100): void
+public function warmupLargePromotionCache(int $minPromotionSize = 100): void
 {
     // 获取大型团队领导者
-    $leaders = $this->talentRepository->getUsersByMinTeamSize($minTeamSize);
+    $leaders = $this->talentRepository->getUsersByMinPromotionSize($minPromotionSize);
     
     // 预热领导者的团队缓存
     foreach ($leaders as $leader) {
-        $this->getAllTeamMembers($leader->user_id);
+        $this->getAllPromotionMembers($leader->user_id);
     }
 }
 ```
@@ -405,8 +405,8 @@ public function warmupLargeTeamCache(int $minTeamSize = 100): void
  */
 private function recordCacheHit(string $cacheType): void
 {
-    Redis::incr("team:cache:hit:{$cacheType}");
-    Redis::incr("team:cache:total:{$cacheType}");
+    Redis::incr("promotion:cache:hit:{$cacheType}");
+    Redis::incr("promotion:cache:total:{$cacheType}");
 }
 
 /**
@@ -414,8 +414,8 @@ private function recordCacheHit(string $cacheType): void
  */
 private function recordCacheMiss(string $cacheType): void
 {
-    Redis::incr("team:cache:miss:{$cacheType}");
-    Redis::incr("team:cache:total:{$cacheType}");
+    Redis::incr("promotion:cache:miss:{$cacheType}");
+    Redis::incr("promotion:cache:total:{$cacheType}");
 }
 
 /**
@@ -423,8 +423,8 @@ private function recordCacheMiss(string $cacheType): void
  */
 public function getCacheHitRate(string $cacheType): float
 {
-    $hit = (int)Redis::get("team:cache:hit:{$cacheType}") ?: 0;
-    $total = (int)Redis::get("team:cache:total:{$cacheType}") ?: 1;
+    $hit = (int)Redis::get("promotion:cache:hit:{$cacheType}") ?: 0;
+    $total = (int)Redis::get("promotion:cache:total:{$cacheType}") ?: 1;
     
     return $hit / $total;
 }
@@ -443,14 +443,14 @@ public function getCacheSize(): array
     $sizes = [];
     
     // 获取推荐关系缓存大小
-    $sizes['referrers'] = $this->estimateCacheSize("team:user:*:all_referrers");
-    $sizes['members'] = $this->estimateCacheSize("team:user:*:all_members");
+    $sizes['referrers'] = $this->estimateCacheSize("promotion:user:*:all_referrers");
+    $sizes['members'] = $this->estimateCacheSize("promotion:user:*:all_members");
     
     // 获取达人等级缓存大小
-    $sizes['talent'] = $this->estimateCacheSize("team:user:*:talent_level");
+    $sizes['talent'] = $this->estimateCacheSize("promotion:user:*:talent_level");
     
     // 获取配置缓存大小
-    $sizes['config'] = $this->estimateCacheSize("team:talent_config:*");
+    $sizes['config'] = $this->estimateCacheSize("promotion:talent_config:*");
     
     return $sizes;
 }
@@ -481,7 +481,7 @@ private function estimateCacheSize(string $pattern): int
  */
 private function recordCacheException(string $cacheType, string $message): void
 {
-    Redis::incr("team:cache:exception:{$cacheType}");
+    Redis::incr("promotion:cache:exception:{$cacheType}");
     Log::error("Cache exception: {$cacheType} - {$message}");
 }
 ```
@@ -527,7 +527,7 @@ public function getAllReferrers(int $userId): array
     }
     
     // 尝试从Redis缓存获取
-    $cacheKey = "team:user:{$userId}:all_referrers";
+    $cacheKey = "promotion:user:{$userId}:all_referrers";
     $cachedData = Redis::get($cacheKey);
     if ($cachedData !== null) {
         $data = json_decode($cachedData, true);
@@ -555,38 +555,38 @@ public function getAllReferrers(int $userId): array
 /**
  * 获取用户的所有团队成员(预分片)
  */
-public function getAllTeamMembers(int $userId): array
+public function getAllPromotionMembers(int $userId): array
 {
     // 获取团队规模
-    $teamCount = $this->getTeamCount($userId);
+    $promotionCount = $this->getPromotionCount($userId);
     
     // 如果团队规模大于阈值,使用分片缓存
-    if ($teamCount > 1000) {
-        return $this->getAllTeamMembersSharded($userId);
+    if ($promotionCount > 1000) {
+        return $this->getAllPromotionMembersSharded($userId);
     }
     
     // 否则使用普通缓存
-    return $this->getAllTeamMembersNormal($userId);
+    return $this->getAllPromotionMembersNormal($userId);
 }
 
 /**
  * 获取用户的所有团队成员(分片版)
  */
-private function getAllTeamMembersSharded(int $userId): array
+private function getAllPromotionMembersSharded(int $userId): array
 {
     $allMembers = [];
     $shardCount = 10;
     
     // 获取所有分片
     for ($i = 0; $i < $shardCount; $i++) {
-        $cacheKey = "team:user:{$userId}:all_members:shard:{$i}";
+        $cacheKey = "promotion:user:{$userId}:all_members:shard:{$i}";
         $cachedData = Redis::get($cacheKey);
         
         if ($cachedData !== null) {
             $allMembers = array_merge($allMembers, json_decode($cachedData, true));
         } else {
             // 计算该分片的数据
-            $shardMembers = $this->calculateTeamMembersShard($userId, $i, $shardCount);
+            $shardMembers = $this->calculatePromotionMembersShard($userId, $i, $shardCount);
             Redis::setex($cacheKey, 86400, json_encode($shardMembers));
             $allMembers = array_merge($allMembers, $shardMembers);
         }
@@ -641,7 +641,7 @@ public function updateTalentLevel(int $userId, int $newLevel): bool
         
         if ($result) {
             // 清除相关缓存
-            Redis::del("team:user:{$userId}:talent_level");
+            Redis::del("promotion:user:{$userId}:talent_level");
         }
         
         return $result;
@@ -657,29 +657,29 @@ public function updateTalentLevel(int $userId, int $newLevel): bool
 /**
  * 更新用户的团队统计数据(最终一致性)
  */
-public function updateTeamStats(int $userId): void
+public function updatePromotionStats(int $userId): void
 {
     // 将任务加入队列,异步执行
-    dispatch(new UpdateTeamStatsJob($userId));
+    dispatch(new UpdatePromotionStatsJob($userId));
 }
 
 /**
  * 异步更新团队统计数据
  */
-public function handleUpdateTeamStats(int $userId): void
+public function handleUpdatePromotionStats(int $userId): void
 {
     // 计算直推人数
     $directCount = $this->countDirectReferrals($userId);
     
     // 计算团队总人数
-    $teamCount = $this->calculateTeamCount($userId);
+    $promotionCount = $this->calculatePromotionCount($userId);
     
     // 更新数据库
-    $this->talentRepository->updateCounts($userId, $directCount, $teamCount);
+    $this->talentRepository->updateCounts($userId, $directCount, $promotionCount);
     
     // 更新缓存
-    Redis::setex("team:user:{$userId}:direct_count", 86400, $directCount);
-    Redis::setex("team:user:{$userId}:team_count", 86400, $teamCount);
+    Redis::setex("promotion:user:{$userId}:direct_count", 86400, $directCount);
+    Redis::setex("promotion:user:{$userId}:promotion_count", 86400, $promotionCount);
 }
 ```
 
@@ -693,9 +693,9 @@ public function handleUpdateTeamStats(int $userId): void
 /**
  * 获取用户的团队成员(数据脱敏)
  */
-public function getTeamMembersWithMasking(int $userId): array
+public function getPromotionMembersWithMasking(int $userId): array
 {
-    $members = $this->getAllTeamMembers($userId);
+    $members = $this->getAllPromotionMembers($userId);
     
     // 对敏感数据进行脱敏
     foreach ($members as &$member) {
@@ -728,10 +728,10 @@ private function maskUsername(string $username): string
 /**
  * 验证用户是否有权限访问团队数据
  */
-private function validateTeamAccess(int $userId, int $teamLeaderId): bool
+private function validatePromotionAccess(int $userId, int $promotionLeaderId): bool
 {
     // 如果是自己的团队数据,允许访问
-    if ($userId == $teamLeaderId) {
+    if ($userId == $promotionLeaderId) {
         return true;
     }
     
@@ -743,7 +743,7 @@ private function validateTeamAccess(int $userId, int $teamLeaderId): bool
     // 如果是团队成员,允许访问
     $referrers = $this->getAllReferrers($userId);
     foreach ($referrers as $referrer) {
-        if ($referrer['user_id'] == $teamLeaderId) {
+        if ($referrer['user_id'] == $promotionLeaderId) {
             return true;
         }
     }

+ 6 - 6
app/Module/Team/Docs/设计概述.md → app/Module/Promotion/Docs/设计概述.md

@@ -49,7 +49,7 @@
 1. **Service**:对外提供服务接口,是模块的主要入口
    - ReferralService:推荐关系服务
    - TalentService:达人等级服务
-   - TeamProfitService:团队收益服务
+   - PromotionProfitService:团队收益服务
    - ReferralCodeService:推荐码服务
 
 2. **Logic**:实现业务逻辑,处理复杂的业务规则
@@ -60,17 +60,17 @@
 3. **Repository**:数据访问和持久化,封装数据库操作
    - UserReferralRepository:用户推荐关系仓库
    - UserTalentRepository:用户达人等级仓库
-   - TeamProfitRepository:团队收益记录仓库
+   - PromotionProfitRepository:团队收益记录仓库
 
 4. **Model**:数据结构定义,对应数据库表
    - UserReferral:用户推荐关系模型
    - UserTalent:用户达人等级模型
-   - TeamProfit:团队收益记录模型
+   - PromotionProfit:团队收益记录模型
 
 5. **Event**:事件定义,用于模块间通信
    - TalentLevelUpEvent:达人等级提升事件
    - ReferralCreatedEvent:推荐关系创建事件
-   - TeamProfitGeneratedEvent:团队收益生成事件
+   - PromotionProfitGeneratedEvent:团队收益生成事件
 
 ### 3.3 依赖关系
 
@@ -78,7 +78,7 @@
 
 ```
 ┌─────────────┐      ┌─────────────┐      ┌─────────────┐
-│  User模块   │◄────►│  Team模块   │◄────►│  Farm模块   │
+│  User模块   │◄────►│  Promotion模块   │◄────►│  Farm模块   │
 └─────────────┘      └──────┬──────┘      └─────────────┘
@@ -164,7 +164,7 @@
 
 ```
 ┌─────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
-│Farm模块  │     │TeamProfitService│  │ ProfitLogic │    │GameItems模块│
+│Farm模块  │     │PromotionProfitService│  │ ProfitLogic │    │GameItems模块│
 └────┬────┘     └───────┬─────┘     └───────┬─────┘     └───────┬─────┘
      │                  │                   │                   │
      │ 收获事件          │                   │                   │

+ 1 - 1
app/Module/Team/Enums/PROFIT_RECORD_STATUS.php → app/Module/Promotion/Enums/PROFIT_RECORD_STATUS.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 收益记录状态枚举

+ 1 - 1
app/Module/Team/Enums/PROFIT_SOURCE_TYPE.php → app/Module/Promotion/Enums/PROFIT_SOURCE_TYPE.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 收益来源类型枚举

+ 1 - 1
app/Module/Team/Enums/REFERRAL_CODE_STATUS.php → app/Module/Promotion/Enums/REFERRAL_CODE_STATUS.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 推荐码状态枚举

+ 1 - 1
app/Module/Team/Enums/REFERRAL_LEVEL.php → app/Module/Promotion/Enums/REFERRAL_LEVEL.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 推荐层级枚举

+ 1 - 1
app/Module/Team/Enums/TALENT_LEVEL.php → app/Module/Promotion/Enums/TALENT_LEVEL.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 达人等级枚举

+ 1 - 1
app/Module/Team/Enums/TEAM_TASK_STATUS.php → app/Module/Promotion/Enums/TEAM_TASK_STATUS.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 团队任务状态枚举

+ 1 - 1
app/Module/Team/Enums/TEAM_TASK_TYPE.php → app/Module/Promotion/Enums/TEAM_TASK_TYPE.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Enums;
+namespace App\Module\Promotion\Enums;
 
 /**
  * 团队任务类型枚举

+ 6 - 6
app/Module/Team/Events/ReferralCreatedEvent.php → app/Module/Promotion/Events/ReferralCreatedEvent.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\Events;
+namespace App\Module\Promotion\Events;
 
-use App\Module\Team\Models\TeamUserReferral;
+use App\Module\Promotion\Models\PromotionUserReferral;
 use Illuminate\Broadcasting\InteractsWithSockets;
 use Illuminate\Foundation\Events\Dispatchable;
 use Illuminate\Queue\SerializesModels;
 
 /**
  * 推荐关系创建事件
- * 
+ *
  * 当用户的推荐关系被创建时触发此事件。
  * 监听此事件可以执行如下操作:
  * 1. 更新用户的团队统计数据
@@ -23,17 +23,17 @@ class ReferralCreatedEvent
     /**
      * 推荐关系模型
      *
-     * @var TeamUserReferral
+     * @var PromotionUserReferral
      */
     public $referral;
 
     /**
      * 创建一个新的事件实例
      *
-     * @param TeamUserReferral $referral 推荐关系模型
+     * @param PromotionUserReferral $referral 推荐关系模型
      * @return void
      */
-    public function __construct(TeamUserReferral $referral)
+    public function __construct(PromotionUserReferral $referral)
     {
         $this->referral = $referral;
     }

+ 9 - 9
app/Module/Team/Events/ReferralUpdatedEvent.php → app/Module/Promotion/Events/ReferralUpdatedEvent.php

@@ -1,16 +1,16 @@
 <?php
 
-namespace App\Module\Team\Events;
+namespace App\Module\Promotion\Events;
 
-use App\Module\Team\Models\TeamReferralChange;
-use App\Module\Team\Models\TeamUserReferral;
+use App\Module\Promotion\Models\PromotionReferralChange;
+use App\Module\Promotion\Models\PromotionUserReferral;
 use Illuminate\Broadcasting\InteractsWithSockets;
 use Illuminate\Foundation\Events\Dispatchable;
 use Illuminate\Queue\SerializesModels;
 
 /**
  * 推荐关系更新事件
- * 
+ *
  * 当用户的推荐关系被更新时触发此事件。
  * 监听此事件可以执行如下操作:
  * 1. 更新用户的团队统计数据
@@ -24,25 +24,25 @@ class ReferralUpdatedEvent
     /**
      * 推荐关系模型
      *
-     * @var TeamUserReferral
+     * @var PromotionUserReferral
      */
     public $referral;
 
     /**
      * 推荐关系修改记录
      *
-     * @var TeamReferralChange
+     * @var PromotionReferralChange
      */
     public $change;
 
     /**
      * 创建一个新的事件实例
      *
-     * @param TeamUserReferral $referral 推荐关系模型
-     * @param TeamReferralChange $change 推荐关系修改记录
+     * @param PromotionUserReferral $referral 推荐关系模型
+     * @param PromotionReferralChange $change 推荐关系修改记录
      * @return void
      */
-    public function __construct(TeamUserReferral $referral, TeamReferralChange $change)
+    public function __construct(PromotionUserReferral $referral, PromotionReferralChange $change)
     {
         $this->referral = $referral;
         $this->change = $change;

+ 6 - 6
app/Module/Team/Events/TalentLevelChangedEvent.php → app/Module/Promotion/Events/TalentLevelChangedEvent.php

@@ -1,15 +1,15 @@
 <?php
 
-namespace App\Module\Team\Events;
+namespace App\Module\Promotion\Events;
 
-use App\Module\Team\Models\TeamUserTalent;
+use App\Module\Promotion\Models\PromotionUserTalent;
 use Illuminate\Broadcasting\InteractsWithSockets;
 use Illuminate\Foundation\Events\Dispatchable;
 use Illuminate\Queue\SerializesModels;
 
 /**
  * 达人等级变更事件
- * 
+ *
  * 当用户的达人等级发生变化时触发此事件。
  * 监听此事件可以执行如下操作:
  * 1. 更新用户的权益
@@ -23,7 +23,7 @@ class TalentLevelChangedEvent
     /**
      * 达人等级模型
      *
-     * @var TeamUserTalent
+     * @var PromotionUserTalent
      */
     public $talent;
 
@@ -44,12 +44,12 @@ class TalentLevelChangedEvent
     /**
      * 创建一个新的事件实例
      *
-     * @param TeamUserTalent $talent 达人等级模型
+     * @param PromotionUserTalent $talent 达人等级模型
      * @param int $oldLevel 旧的达人等级
      * @param int $newLevel 新的达人等级
      * @return void
      */
-    public function __construct(TeamUserTalent $talent, int $oldLevel, int $newLevel)
+    public function __construct(PromotionUserTalent $talent, int $oldLevel, int $newLevel)
     {
         $this->talent = $talent;
         $this->oldLevel = $oldLevel;

+ 7 - 7
app/Module/Team/Events/TeamProfitCreatedEvent.php → app/Module/Promotion/Events/TeamProfitCreatedEvent.php

@@ -1,39 +1,39 @@
 <?php
 
-namespace App\Module\Team\Events;
+namespace App\Module\Promotion\Events;
 
-use App\Module\Team\Models\TeamProfit;
+use App\Module\Promotion\Models\PromotionProfit;
 use Illuminate\Broadcasting\InteractsWithSockets;
 use Illuminate\Foundation\Events\Dispatchable;
 use Illuminate\Queue\SerializesModels;
 
 /**
  * 团队收益创建事件
- * 
+ *
  * 当团队收益记录被创建时触发此事件。
  * 监听此事件可以执行如下操作:
  * 1. 发送通知
  * 2. 记录收益日志
  * 3. 更新用户的收益统计
  */
-class TeamProfitCreatedEvent
+class PromotionProfitCreatedEvent
 {
     use Dispatchable, InteractsWithSockets, SerializesModels;
 
     /**
      * 团队收益模型
      *
-     * @var TeamProfit
+     * @var PromotionProfit
      */
     public $profit;
 
     /**
      * 创建一个新的事件实例
      *
-     * @param TeamProfit $profit 团队收益模型
+     * @param PromotionProfit $profit 团队收益模型
      * @return void
      */
-    public function __construct(TeamProfit $profit)
+    public function __construct(PromotionProfit $profit)
     {
         $this->profit = $profit;
     }

+ 17 - 17
app/Module/Team/Listeners/DistributeTeamProfitListener.php → app/Module/Promotion/Listeners/DistributeTeamProfitListener.php

@@ -1,24 +1,24 @@
 <?php
 
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
-use App\Module\Team\Events\TeamProfitCreatedEvent;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Logics\TeamProfitLogic;
+use App\Module\Promotion\Events\PromotionProfitCreatedEvent;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Logics\PromotionProfitLogic;
 
 
 use Illuminate\Support\Facades\Log;
 
 /**
  * 分配团队收益监听器
- * 
+ *
  * 监听团队收益创建事件,分配团队收益。
  * 根据用户的推荐关系和达人等级,计算并分配团队收益。
  */
-class DistributeTeamProfitListener
+class DistributePromotionProfitListener
 {
-    
+
 
     /**
      * 推荐关系逻辑类
@@ -37,35 +37,35 @@ class DistributeTeamProfitListener
     /**
      * 团队收益逻辑类
      *
-     * @var TeamProfitLogic
+     * @var PromotionProfitLogic
      */
-    protected $teamProfitLogic;
+    protected $promotionProfitLogic;
 
     /**
      * 创建监听器实例
      *
      * @param ReferralLogic $referralLogic 推荐关系逻辑类
      * @param TalentLogic $talentLogic 达人等级逻辑类
-     * @param TeamProfitLogic $teamProfitLogic 团队收益逻辑类
+     * @param PromotionProfitLogic $promotionProfitLogic 团队收益逻辑类
      * @return void
      */
     public function __construct(
         ReferralLogic $referralLogic,
         TalentLogic $talentLogic,
-        TeamProfitLogic $teamProfitLogic
+        PromotionProfitLogic $promotionProfitLogic
     ) {
         $this->referralLogic = $referralLogic;
         $this->talentLogic = $talentLogic;
-        $this->teamProfitLogic = $teamProfitLogic;
+        $this->promotionProfitLogic = $promotionProfitLogic;
     }
 
     /**
      * 处理团队收益创建事件
      *
-     * @param TeamProfitCreatedEvent $event 团队收益创建事件
+     * @param PromotionProfitCreatedEvent $event 团队收益创建事件
      * @return void
      */
-    public function handle(TeamProfitCreatedEvent $event)
+    public function handle(PromotionProfitCreatedEvent $event)
     {
         try {
             $profit = $event->profit;
@@ -76,7 +76,7 @@ class DistributeTeamProfitListener
             $amount = $profit->amount;
 
             // 分配团队收益
-            $this->teamProfitLogic->distributeTeamProfit(
+            $this->promotionProfitLogic->distributePromotionProfit(
                 $userId,
                 $sourceType,
                 $sourceId,
@@ -94,7 +94,7 @@ class DistributeTeamProfitListener
         } catch (\Exception $e) {
             Log::error("团队收益分配失败", [
                 'error' => $e->getMessage(),
-                'event' => 'TeamProfitCreated'
+                'event' => 'PromotionProfitCreated'
             ]);
         }
     }

+ 7 - 7
app/Module/Team/Listeners/UpdateTalentLevelListener.php → app/Module/Promotion/Listeners/UpdateTalentLevelListener.php

@@ -1,24 +1,24 @@
 <?php
 
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
-use App\Module\Team\Events\ReferralCreatedEvent;
-use App\Module\Team\Events\ReferralUpdatedEvent;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\TalentLogic;
+use App\Module\Promotion\Events\ReferralCreatedEvent;
+use App\Module\Promotion\Events\ReferralUpdatedEvent;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\TalentLogic;
 
 
 use Illuminate\Support\Facades\Log;
 
 /**
  * 更新达人等级监听器
- * 
+ *
  * 监听推荐关系创建和更新事件,更新用户的达人等级。
  * 根据用户的直推人数和团队总人数,计算用户的达人等级。
  */
 class UpdateTalentLevelListener
 {
-    
+
 
     /**
      * 推荐关系逻辑类

+ 13 - 13
app/Module/Team/Listeners/UpdateTeamCountsListener.php → app/Module/Promotion/Listeners/UpdateTeamCountsListener.php

@@ -1,24 +1,24 @@
 <?php
 
-namespace App\Module\Team\Listeners;
+namespace App\Module\Promotion\Listeners;
 
-use App\Module\Team\Events\ReferralCreatedEvent;
-use App\Module\Team\Events\ReferralUpdatedEvent;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\RelationCacheLogic;
+use App\Module\Promotion\Events\ReferralCreatedEvent;
+use App\Module\Promotion\Events\ReferralUpdatedEvent;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\RelationCacheLogic;
 
 
 use Illuminate\Support\Facades\Log;
 
 /**
  * 更新团队统计数据监听器
- * 
+ *
  * 监听推荐关系创建和更新事件,更新团队统计数据。
  * 包括更新直推人数和团队总人数。
  */
-class UpdateTeamCountsListener
+class UpdatePromotionCountsListener
 {
-    
+
 
     /**
      * 推荐关系逻辑类
@@ -67,7 +67,7 @@ class UpdateTeamCountsListener
             $this->relationCacheLogic->buildUserRelationCache($userId);
 
             // 更新团队总人数
-            $this->referralLogic->updateTeamCounts($referrerId);
+            $this->referralLogic->updatePromotionCounts($referrerId);
 
             Log::info("团队统计数据更新成功", [
                 'user_id' => $userId,
@@ -112,12 +112,12 @@ class UpdateTeamCountsListener
 
             // 更新旧推荐人的团队总人数
             if ($oldReferrerId) {
-                $this->referralLogic->updateTeamCounts($oldReferrerId);
+                $this->referralLogic->updatePromotionCounts($oldReferrerId);
             }
 
             // 更新新推荐人的团队总人数
             if ($newReferrerId) {
-                $this->referralLogic->updateTeamCounts($newReferrerId);
+                $this->referralLogic->updatePromotionCounts($newReferrerId);
             }
 
             Log::info("团队统计数据更新成功", [
@@ -144,12 +144,12 @@ class UpdateTeamCountsListener
     {
         $events->listen(
             ReferralCreatedEvent::class,
-            [UpdateTeamCountsListener::class, 'handleReferralCreated']
+            [UpdatePromotionCountsListener::class, 'handleReferralCreated']
         );
 
         $events->listen(
             ReferralUpdatedEvent::class,
-            [UpdateTeamCountsListener::class, 'handleReferralUpdated']
+            [UpdatePromotionCountsListener::class, 'handleReferralUpdated']
         );
     }
 }

+ 15 - 15
app/Module/Team/Logics/ReferralCodeLogic.php → app/Module/Promotion/Logics/ReferralCodeLogic.php

@@ -1,10 +1,10 @@
 <?php
 
-namespace App\Module\Team\Logics;
+namespace App\Module\Promotion\Logics;
 
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
-use App\Module\Team\Models\TeamReferralCode;
-use App\Module\Team\Models\TeamReferralCodeUsage;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Models\PromotionReferralCode;
+use App\Module\Promotion\Models\PromotionReferralCodeUsage;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Str;
 
@@ -52,7 +52,7 @@ class ReferralCodeLogic
             $code = $this->generateUniqueCode();
 
             // 创建推荐码记录
-            $referralCode = new TeamReferralCode();
+            $referralCode = new PromotionReferralCode();
             $referralCode->user_id = $userId;
             $referralCode->code = $code;
             $referralCode->usage_count = 0;
@@ -86,7 +86,7 @@ class ReferralCodeLogic
             $code = strtoupper(Str::random($length));
 
             // 检查是否已存在
-            $exists = TeamReferralCode::where('code', $code)->exists();
+            $exists = PromotionReferralCode::where('code', $code)->exists();
 
             $attempts++;
         } while ($exists && $attempts < $maxAttempts);
@@ -103,11 +103,11 @@ class ReferralCodeLogic
      * 获取用户的有效推荐码
      *
      * @param int $userId 用户ID
-     * @return TeamReferralCode|null
+     * @return PromotionReferralCode|null
      */
-    public function getUserActiveCode(int $userId): ?TeamReferralCode
+    public function getUserActiveCode(int $userId): ?PromotionReferralCode
     {
-        $code = TeamReferralCode::where('user_id', $userId)
+        $code = PromotionReferralCode::where('user_id', $userId)
             ->where('status', REFERRAL_CODE_STATUS::ACTIVE)
             ->where(function ($query) {
                 $query->whereNull('expire_time')
@@ -128,7 +128,7 @@ class ReferralCodeLogic
     {
         try {
             // 查找推荐码
-            $referralCode = TeamReferralCode::where('code', $code)->first();
+            $referralCode = PromotionReferralCode::where('code', $code)->first();
 
             if (!$referralCode) {
                 return [
@@ -223,13 +223,13 @@ class ReferralCodeLogic
             \UCore\Db\Helper::check_tr();
 
             // 记录使用记录
-            $usage = new TeamReferralCodeUsage();
+            $usage = new PromotionReferralCodeUsage();
             $usage->code = $code;
             $usage->code_owner_id = $referralCode->user_id;
             $usage->user_id = $userId;
             $usage->ip_address = $ipAddress;
             $usage->user_agent = $userAgent;
-            $usage->status = TeamReferralCodeUsage::STATUS_SUCCESS;
+            $usage->status = PromotionReferralCodeUsage::STATUS_SUCCESS;
             $usage->result = '成功使用推荐码';
             $usage->save();
 
@@ -242,7 +242,7 @@ class ReferralCodeLogic
 
             if (!$result) {
                 // 如果建立推荐关系失败,更新使用记录状态
-                $usage->status = TeamReferralCodeUsage::STATUS_FAILED;
+                $usage->status = PromotionReferralCodeUsage::STATUS_FAILED;
                 $usage->result = '建立推荐关系失败';
                 $usage->save();
 
@@ -275,7 +275,7 @@ class ReferralCodeLogic
     public function disableReferralCode(string $code): bool
     {
         try {
-            $referralCode = TeamReferralCode::where('code', $code)->first();
+            $referralCode = PromotionReferralCode::where('code', $code)->first();
 
             if (!$referralCode) {
                 return false;
@@ -297,7 +297,7 @@ class ReferralCodeLogic
     public function cleanExpiredReferralCodes(): int
     {
         try {
-            return TeamReferralCode::where('status', REFERRAL_CODE_STATUS::ACTIVE)
+            return PromotionReferralCode::where('status', REFERRAL_CODE_STATUS::ACTIVE)
                 ->whereNotNull('expire_time')
                 ->where('expire_time', '<', now())
                 ->update(['status' => REFERRAL_CODE_STATUS::DISABLED]);

+ 33 - 33
app/Module/Team/Logics/ReferralLogic.php → app/Module/Promotion/Logics/ReferralLogic.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace App\Module\Team\Logics;
+namespace App\Module\Promotion\Logics;
 
-use App\Module\Team\Enums\REFERRAL_LEVEL;
-use App\Module\Team\Models\TeamReferralChange;
-use App\Module\Team\Models\TeamUserReferral;
-use App\Module\Team\Models\TeamUserRelationCache;
+use App\Module\Promotion\Enums\REFERRAL_LEVEL;
+use App\Module\Promotion\Models\PromotionReferralChange;
+use App\Module\Promotion\Models\PromotionUserReferral;
+use App\Module\Promotion\Models\PromotionUserRelationCache;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 
@@ -40,7 +40,7 @@ class ReferralLogic
 
         try {
             // 创建直推关系
-            $referral = new TeamUserReferral();
+            $referral = new PromotionUserReferral();
             $referral->user_id = $userId;
             $referral->referrer_id = $referrerId;
             $result = $referral->save();
@@ -88,18 +88,18 @@ class ReferralLogic
         try {
             // 删除旧的推荐关系
             if ($oldReferrerId) {
-                TeamUserReferral::where('user_id', $userId)->delete();
+                PromotionUserReferral::where('user_id', $userId)->delete();
             }
 
             // 创建新的推荐关系
-            $referral = new TeamUserReferral();
+            $referral = new PromotionUserReferral();
             $referral->user_id = $userId;
             $referral->referrer_id = $newReferrerId;
             $result = $referral->save();
 
             if ($result) {
                 // 记录修改历史
-                $change = new TeamReferralChange();
+                $change = new PromotionReferralChange();
                 $change->user_id = $userId;
                 $change->old_referrer_id = $oldReferrerId;
                 $change->new_referrer_id = $newReferrerId;
@@ -127,7 +127,7 @@ class ReferralLogic
      */
     public function getDirectReferrerId(int $userId): ?int
     {
-        $referral = TeamUserReferral::where('user_id', $userId)->first();
+        $referral = PromotionUserReferral::where('user_id', $userId)->first();
         return $referral ? $referral->referrer_id : null;
     }
 
@@ -139,7 +139,7 @@ class ReferralLogic
      */
     public function hasReferrer(int $userId): bool
     {
-        return TeamUserReferral::where('user_id', $userId)->exists();
+        return PromotionUserReferral::where('user_id', $userId)->exists();
     }
 
     /**
@@ -150,7 +150,7 @@ class ReferralLogic
      */
     public function getDirectMembers(int $userId): array
     {
-        return TeamUserReferral::where('referrer_id', $userId)
+        return PromotionUserReferral::where('referrer_id', $userId)
             ->with('user')
             ->get()
             ->toArray();
@@ -166,7 +166,7 @@ class ReferralLogic
     public function getAllReferrers(int $userId, int $maxLevel = 20): array
     {
         // 尝试从缓存获取
-        $cacheKey = "team:user:{$userId}:all_referrers";
+        $cacheKey = "promotion:user:{$userId}:all_referrers";
         $cachedData = Redis::get($cacheKey);
 
         if ($cachedData !== null) {
@@ -174,7 +174,7 @@ class ReferralLogic
         }
 
         // 从关系缓存表获取
-        $relations = TeamUserRelationCache::where('user_id', $userId)
+        $relations = PromotionUserRelationCache::where('user_id', $userId)
             ->where('depth', '<=', $maxLevel)
             ->orderBy('depth')
             ->get();
@@ -204,10 +204,10 @@ class ReferralLogic
      * @param int $pageSize 每页数量
      * @return array
      */
-    public function getAllTeamMembers(int $userId, int $maxLevel = 20, int $page = 1, int $pageSize = 20): array
+    public function getAllPromotionMembers(int $userId, int $maxLevel = 20, int $page = 1, int $pageSize = 20): array
     {
         // 从关系缓存表获取
-        $query = TeamUserRelationCache::where('related_user_id', $userId)
+        $query = PromotionUserRelationCache::where('related_user_id', $userId)
             ->where('depth', '<=', $maxLevel);
 
         $total = $query->count();
@@ -285,34 +285,34 @@ class ReferralLogic
                 // 1. 删除用户及其所有下级与旧上级及其所有上级的关系缓存
                 if ($oldReferrerId) {
                     // 获取用户的所有下级ID
-                    $downlineIds = TeamUserRelationCache::where('related_user_id', $userId)
+                    $downlineIds = PromotionUserRelationCache::where('related_user_id', $userId)
                         ->pluck('user_id')
                         ->toArray();
                     $downlineIds[] = $userId; // 包括用户自身
 
                     // 获取旧上级的所有上级ID
-                    $upperReferrerIds = TeamUserRelationCache::where('user_id', $oldReferrerId)
+                    $upperReferrerIds = PromotionUserRelationCache::where('user_id', $oldReferrerId)
                         ->pluck('related_user_id')
                         ->toArray();
                     $upperReferrerIds[] = $oldReferrerId; // 包括直接上级
 
                     // 删除关系缓存
-                    TeamUserRelationCache::whereIn('user_id', $downlineIds)
+                    PromotionUserRelationCache::whereIn('user_id', $downlineIds)
                         ->whereIn('related_user_id', $upperReferrerIds)
                         ->delete();
 
                     // 清除Redis缓存
                     foreach ($downlineIds as $downlineId) {
-                        Redis::del("team:user:{$downlineId}:all_referrers");
+                        Redis::del("promotion:user:{$downlineId}:all_referrers");
                     }
 
                     foreach ($upperReferrerIds as $upperReferrerId) {
-                        Redis::del("team:user:{$upperReferrerId}:all_members");
+                        Redis::del("promotion:user:{$upperReferrerId}:all_members");
                     }
                 }
 
                 // 2. 为用户创建与新上级的直接关系缓存
-                $directRelation = new TeamUserRelationCache();
+                $directRelation = new PromotionUserRelationCache();
                 $directRelation->user_id = $userId;
                 $directRelation->related_user_id = $newReferrerId;
                 $directRelation->level = REFERRAL_LEVEL::DIRECT;
@@ -321,11 +321,11 @@ class ReferralLogic
                 $directRelation->save();
 
                 // 3. 获取新上级的所有上级
-                $upperRelations = TeamUserRelationCache::where('user_id', $newReferrerId)->get();
+                $upperRelations = PromotionUserRelationCache::where('user_id', $newReferrerId)->get();
 
                 // 4. 为用户创建与新上级的所有上级的间接关系缓存
                 foreach ($upperRelations as $upperRelation) {
-                    $indirectRelation = new TeamUserRelationCache();
+                    $indirectRelation = new PromotionUserRelationCache();
                     $indirectRelation->user_id = $userId;
                     $indirectRelation->related_user_id = $upperRelation->related_user_id;
                     $indirectRelation->level = REFERRAL_LEVEL::INDIRECT;
@@ -335,12 +335,12 @@ class ReferralLogic
                 }
 
                 // 5. 获取用户的所有下级
-                $downlineRelations = TeamUserRelationCache::where('related_user_id', $userId)->get();
+                $downlineRelations = PromotionUserRelationCache::where('related_user_id', $userId)->get();
 
                 // 6. 为用户的所有下级创建与新上级及其所有上级的关系缓存
                 foreach ($downlineRelations as $downlineRelation) {
                     // 创建下级与新上级的关系
-                    $downlineToReferrer = new TeamUserRelationCache();
+                    $downlineToReferrer = new PromotionUserRelationCache();
                     $downlineToReferrer->user_id = $downlineRelation->user_id;
                     $downlineToReferrer->related_user_id = $newReferrerId;
                     $downlineToReferrer->level = REFERRAL_LEVEL::INDIRECT;
@@ -350,7 +350,7 @@ class ReferralLogic
 
                     // 创建下级与新上级的所有上级的关系
                     foreach ($upperRelations as $upperRelation) {
-                        $downlineToUpper = new TeamUserRelationCache();
+                        $downlineToUpper = new PromotionUserRelationCache();
                         $downlineToUpper->user_id = $downlineRelation->user_id;
                         $downlineToUpper->related_user_id = $upperRelation->related_user_id;
                         $downlineToUpper->level = REFERRAL_LEVEL::INDIRECT;
@@ -360,13 +360,13 @@ class ReferralLogic
                     }
 
                     // 清除下级的Redis缓存
-                    Redis::del("team:user:{$downlineRelation->user_id}:all_referrers");
+                    Redis::del("promotion:user:{$downlineRelation->user_id}:all_referrers");
                 }
 
                 // 7. 清除新上级及其所有上级的Redis缓存
-                Redis::del("team:user:{$newReferrerId}:all_members");
+                Redis::del("promotion:user:{$newReferrerId}:all_members");
                 foreach ($upperRelations as $upperRelation) {
-                    Redis::del("team:user:{$upperRelation->related_user_id}:all_members");
+                    Redis::del("promotion:user:{$upperRelation->related_user_id}:all_members");
                 }
         } catch (\Exception $e) {
             Log::error("更新关系缓存失败: " . $e->getMessage());
@@ -381,7 +381,7 @@ class ReferralLogic
      */
     public function countDirectReferrals(int $userId): int
     {
-        return TeamUserReferral::where('referrer_id', $userId)->count();
+        return PromotionUserReferral::where('referrer_id', $userId)->count();
     }
 
     /**
@@ -390,8 +390,8 @@ class ReferralLogic
      * @param int $userId 用户ID
      * @return int
      */
-    public function countTeamMembers(int $userId): int
+    public function countPromotionMembers(int $userId): int
     {
-        return TeamUserRelationCache::where('related_user_id', $userId)->count();
+        return PromotionUserRelationCache::where('related_user_id', $userId)->count();
     }
 }

+ 24 - 24
app/Module/Team/Logics/RelationCacheLogic.php → app/Module/Promotion/Logics/RelationCacheLogic.php

@@ -1,10 +1,10 @@
 <?php
 
-namespace App\Module\Team\Logics;
+namespace App\Module\Promotion\Logics;
 
-use App\Module\Team\Enums\REFERRAL_LEVEL;
-use App\Module\Team\Models\TeamUserReferral;
-use App\Module\Team\Models\TeamUserRelationCache;
+use App\Module\Promotion\Enums\REFERRAL_LEVEL;
+use App\Module\Promotion\Models\PromotionUserReferral;
+use App\Module\Promotion\Models\PromotionUserRelationCache;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
@@ -30,7 +30,7 @@ class RelationCacheLogic
             $this->clearUserRelationCache($userId);
 
             // 获取用户的直接推荐人
-            $referral = TeamUserReferral::where('user_id', $userId)->first();
+            $referral = PromotionUserReferral::where('user_id', $userId)->first();
 
             if (!$referral) {
                 Log::info("用户 {$userId} 没有推荐人,无需生成关系缓存");
@@ -40,7 +40,7 @@ class RelationCacheLogic
             $referrerId = $referral->referrer_id;
 
             // 创建直接关系缓存
-            $directRelation = new TeamUserRelationCache();
+            $directRelation = new PromotionUserRelationCache();
             $directRelation->user_id = $userId;
             $directRelation->related_user_id = $referrerId;
             $directRelation->level = REFERRAL_LEVEL::DIRECT;
@@ -49,11 +49,11 @@ class RelationCacheLogic
             $directRelation->save();
 
             // 获取推荐人的所有上级
-            $upperRelations = TeamUserRelationCache::where('user_id', $referrerId)->get();
+            $upperRelations = PromotionUserRelationCache::where('user_id', $referrerId)->get();
 
             // 创建间接关系缓存
             foreach ($upperRelations as $upperRelation) {
-                $indirectRelation = new TeamUserRelationCache();
+                $indirectRelation = new PromotionUserRelationCache();
                 $indirectRelation->user_id = $userId;
                 $indirectRelation->related_user_id = $upperRelation->related_user_id;
                 $indirectRelation->level = REFERRAL_LEVEL::INDIRECT;
@@ -63,7 +63,7 @@ class RelationCacheLogic
             }
 
             // 清除Redis缓存
-            Redis::del("team:user:{$userId}:all_referrers");
+            Redis::del("promotion:user:{$userId}:all_referrers");
 
             return true;
         } catch (\Exception $e) {
@@ -82,10 +82,10 @@ class RelationCacheLogic
     {
         try {
             // 删除数据库中的关系缓存
-            TeamUserRelationCache::where('user_id', $userId)->delete();
+            PromotionUserRelationCache::where('user_id', $userId)->delete();
 
             // 清除Redis缓存
-            Redis::del("team:user:{$userId}:all_referrers");
+            Redis::del("promotion:user:{$userId}:all_referrers");
 
             return true;
         } catch (\Exception $e) {
@@ -104,16 +104,16 @@ class RelationCacheLogic
     {
         try {
             // 清空关系缓存表
-            TeamUserRelationCache::truncate();
+            PromotionUserRelationCache::truncate();
 
             // 清除所有Redis缓存
-            $keys = Redis::keys("team:user:*:all_referrers");
+            $keys = Redis::keys("promotion:user:*:all_referrers");
             if (!empty($keys)) {
                 Redis::del($keys);
             }
 
             // 获取所有用户ID
-            $userIds = TeamUserReferral::pluck('user_id')->toArray();
+            $userIds = PromotionUserReferral::pluck('user_id')->toArray();
 
             $successCount = 0;
             $failCount = 0;
@@ -155,21 +155,21 @@ class RelationCacheLogic
     public function checkRelationCacheIntegrity(): array
     {
         try {
-            $totalUsers = TeamUserReferral::count();
-            $usersWithCache = TeamUserRelationCache::distinct('user_id')->count('user_id');
+            $totalUsers = PromotionUserReferral::count();
+            $usersWithCache = PromotionUserRelationCache::distinct('user_id')->count('user_id');
             $missingUsers = $totalUsers - $usersWithCache;
 
             $circularRelations = DB::select("
                 SELECT r1.user_id, r1.referrer_id
-                FROM team_user_referrals r1
-                JOIN team_user_referrals r2 ON r1.referrer_id = r2.user_id
+                FROM promotion_user_referrals r1
+                JOIN promotion_user_referrals r2 ON r1.referrer_id = r2.user_id
                 WHERE r2.referrer_id = r1.user_id
             ");
 
             $orphanedCaches = DB::select("
                 SELECT c.user_id
-                FROM team_user_relation_cache c
-                LEFT JOIN team_user_referrals r ON c.user_id = r.user_id
+                FROM promotion_user_relation_cache c
+                LEFT JOIN promotion_user_referrals r ON c.user_id = r.user_id
                 WHERE r.user_id IS NULL
             ");
 
@@ -206,8 +206,8 @@ class RelationCacheLogic
 
             // 修复缺失的用户缓存
             if ($integrity['missing_users'] > 0) {
-                $usersWithCache = TeamUserRelationCache::distinct('user_id')->pluck('user_id')->toArray();
-                $allUsers = TeamUserReferral::pluck('user_id')->toArray();
+                $usersWithCache = PromotionUserRelationCache::distinct('user_id')->pluck('user_id')->toArray();
+                $allUsers = PromotionUserReferral::pluck('user_id')->toArray();
                 $missingUsers = array_diff($allUsers, $usersWithCache);
 
                 foreach ($missingUsers as $userId) {
@@ -221,8 +221,8 @@ class RelationCacheLogic
             if ($integrity['orphaned_caches'] > 0) {
                 $orphanedCaches = DB::select("
                     SELECT c.user_id
-                    FROM team_user_relation_cache c
-                    LEFT JOIN team_user_referrals r ON c.user_id = r.user_id
+                    FROM promotion_user_relation_cache c
+                    LEFT JOIN promotion_user_referrals r ON c.user_id = r.user_id
                     WHERE r.user_id IS NULL
                 ");
 

+ 70 - 70
app/Module/Team/Logics/TalentLogic.php → app/Module/Promotion/Logics/TalentLogic.php

@@ -1,17 +1,17 @@
 <?php
 
-namespace App\Module\Team\Logics;
+namespace App\Module\Promotion\Logics;
 
-use App\Module\Team\Enums\TALENT_LEVEL;
-use App\Module\Team\Models\TeamTalentConfig;
-use App\Module\Team\Models\TeamUserTalent;
+use App\Module\Promotion\Enums\TALENT_LEVEL;
+use App\Module\Promotion\Models\PromotionTalentConfig;
+use App\Module\Promotion\Models\PromotionUserTalent;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
 use Illuminate\Support\Facades\Redis;
 
 /**
  * 达人等级逻辑类
- * 
+ *
  * 处理用户达人等级的核心业务逻辑,包括计算达人等级、更新达人等级、
  * 获取达人等级配置等功能。该类仅供内部使用,不对外提供服务。
  */
@@ -36,34 +36,34 @@ class TalentLogic
      * 获取用户的达人等级信息
      *
      * @param int $userId 用户ID
-     * @return TeamUserTalent|null
+     * @return PromotionUserTalent|null
      */
-    public function getUserTalent(int $userId): ?TeamUserTalent
+    public function getUserTalent(int $userId): ?PromotionUserTalent
     {
         // 尝试从缓存获取
-        $cacheKey = "team:user:{$userId}:talent";
+        $cacheKey = "promotion:user:{$userId}:talent";
         $cachedData = Redis::get($cacheKey);
-        
+
         if ($cachedData !== null) {
             $talentData = json_decode($cachedData, true);
-            $talent = new TeamUserTalent();
+            $talent = new PromotionUserTalent();
             $talent->fill($talentData);
             return $talent;
         }
-        
+
         // 从数据库获取
-        $talent = TeamUserTalent::where('user_id', $userId)->first();
-        
+        $talent = PromotionUserTalent::where('user_id', $userId)->first();
+
         // 如果不存在,创建一个默认的达人等级记录
         if (!$talent) {
             $talent = $this->createDefaultTalent($userId);
         }
-        
+
         // 缓存结果
         if ($talent) {
             Redis::setex($cacheKey, 86400, json_encode($talent->toArray())); // 缓存1天
         }
-        
+
         return $talent;
     }
 
@@ -71,18 +71,18 @@ class TalentLogic
      * 创建默认的达人等级记录
      *
      * @param int $userId 用户ID
-     * @return TeamUserTalent|null
+     * @return PromotionUserTalent|null
      */
-    public function createDefaultTalent(int $userId): ?TeamUserTalent
+    public function createDefaultTalent(int $userId): ?PromotionUserTalent
     {
         try {
-            $talent = new TeamUserTalent();
+            $talent = new PromotionUserTalent();
             $talent->user_id = $userId;
             $talent->talent_level = TALENT_LEVEL::NONE;
             $talent->direct_count = 0;
-            $talent->team_count = 0;
+            $talent->promotion_count = 0;
             $talent->save();
-            
+
             return $talent;
         } catch (\Exception $e) {
             Log::error("创建默认达人等级记录失败: " . $e->getMessage());
@@ -101,24 +101,24 @@ class TalentLogic
     {
         try {
             $talent = $this->getUserTalent($userId);
-            
+
             if (!$talent) {
                 return false;
             }
-            
+
             // 如果等级没有变化,无需更新
             if ($talent->talent_level == $talentLevel) {
                 return true;
             }
-            
+
             $talent->talent_level = $talentLevel;
             $result = $talent->save();
-            
+
             if ($result) {
                 // 清除缓存
-                Redis::del("team:user:{$userId}:talent");
+                Redis::del("promotion:user:{$userId}:talent");
             }
-            
+
             return $result;
         } catch (\Exception $e) {
             Log::error("更新达人等级失败: " . $e->getMessage());
@@ -132,31 +132,31 @@ class TalentLogic
      * @param int $userId 用户ID
      * @return bool
      */
-    public function updateTeamCounts(int $userId): bool
+    public function updatePromotionCounts(int $userId): bool
     {
         try {
             $talent = $this->getUserTalent($userId);
-            
+
             if (!$talent) {
                 return false;
             }
-            
+
             // 计算直推人数
             $directCount = $this->referralLogic->countDirectReferrals($userId);
-            
+
             // 计算团队总人数
-            $teamCount = $this->referralLogic->countTeamMembers($userId);
-            
+            $promotionCount = $this->referralLogic->countPromotionMembers($userId);
+
             // 更新数据
             $talent->direct_count = $directCount;
-            $talent->team_count = $teamCount;
+            $talent->promotion_count = $promotionCount;
             $result = $talent->save();
-            
+
             if ($result) {
                 // 清除缓存
-                Redis::del("team:user:{$userId}:talent");
+                Redis::del("promotion:user:{$userId}:talent");
             }
-            
+
             return $result;
         } catch (\Exception $e) {
             Log::error("更新团队统计数据失败: " . $e->getMessage());
@@ -174,33 +174,33 @@ class TalentLogic
     {
         try {
             // 更新团队统计数据
-            $this->updateTeamCounts($userId);
-            
+            $this->updatePromotionCounts($userId);
+
             // 获取用户的达人信息
             $talent = $this->getUserTalent($userId);
-            
+
             if (!$talent) {
                 return false;
             }
-            
+
             // 获取所有达人等级配置
             $configs = $this->getAllTalentConfigs();
-            
+
             // 计算应该的达人等级
             $newLevel = TALENT_LEVEL::NONE;
-            
+
             foreach ($configs as $config) {
-                if ($talent->direct_count >= $config->direct_count_required && 
-                    $talent->team_count >= $config->team_count_required) {
+                if ($talent->direct_count >= $config->direct_count_required &&
+                    $talent->promotion_count >= $config->promotion_count_required) {
                     $newLevel = $config->level;
                 }
             }
-            
+
             // 如果等级有变化,更新达人等级
             if ($talent->talent_level != $newLevel) {
                 return $this->updateTalentLevel($userId, $newLevel);
             }
-            
+
             return true;
         } catch (\Exception $e) {
             Log::error("检查并更新达人等级失败: " . $e->getMessage());
@@ -212,29 +212,29 @@ class TalentLogic
      * 获取达人等级配置
      *
      * @param int $level 等级
-     * @return TeamTalentConfig|null
+     * @return PromotionTalentConfig|null
      */
-    public function getTalentConfig(int $level): ?TeamTalentConfig
+    public function getTalentConfig(int $level): ?PromotionTalentConfig
     {
         // 尝试从缓存获取
-        $cacheKey = "team:talent_config:{$level}";
+        $cacheKey = "promotion:talent_config:{$level}";
         $cachedData = Redis::get($cacheKey);
-        
+
         if ($cachedData !== null) {
             $configData = json_decode($cachedData, true);
-            $config = new TeamTalentConfig();
+            $config = new PromotionTalentConfig();
             $config->fill($configData);
             return $config;
         }
-        
+
         // 从数据库获取
-        $config = TeamTalentConfig::where('level', $level)->first();
-        
+        $config = PromotionTalentConfig::where('level', $level)->first();
+
         // 缓存结果
         if ($config) {
             Redis::setex($cacheKey, 86400 * 7, json_encode($config->toArray())); // 缓存7天
         }
-        
+
         return $config;
     }
 
@@ -246,28 +246,28 @@ class TalentLogic
     public function getAllTalentConfigs(): array
     {
         // 尝试从缓存获取
-        $cacheKey = "team:talent_configs";
+        $cacheKey = "promotion:talent_configs";
         $cachedData = Redis::get($cacheKey);
-        
+
         if ($cachedData !== null) {
             $configsData = json_decode($cachedData, true);
             $configs = [];
-            
+
             foreach ($configsData as $configData) {
-                $config = new TeamTalentConfig();
+                $config = new PromotionTalentConfig();
                 $config->fill($configData);
                 $configs[] = $config;
             }
-            
+
             return $configs;
         }
-        
+
         // 从数据库获取
-        $configs = TeamTalentConfig::orderBy('level')->get()->toArray();
-        
+        $configs = PromotionTalentConfig::orderBy('level')->get()->toArray();
+
         // 缓存结果
         Redis::setex($cacheKey, 86400 * 7, json_encode($configs)); // 缓存7天
-        
+
         return $configs;
     }
 
@@ -280,11 +280,11 @@ class TalentLogic
     public function getTalentProfitRate(int $level): float
     {
         $config = $this->getTalentConfig($level);
-        
+
         if (!$config) {
             return 0.0;
         }
-        
+
         return $config->profit_rate;
     }
 
@@ -297,11 +297,11 @@ class TalentLogic
     public function getTalentBenefits(int $level): array
     {
         $config = $this->getTalentConfig($level);
-        
+
         if (!$config || empty($config->benefits)) {
             return [];
         }
-        
+
         return is_array($config->benefits) ? $config->benefits : json_decode($config->benefits, true);
     }
 
@@ -314,13 +314,13 @@ class TalentLogic
     public function batchUpdateTalentLevels(array $userIds): int
     {
         $successCount = 0;
-        
+
         foreach ($userIds as $userId) {
             if ($this->checkAndUpdateTalentLevel($userId)) {
                 $successCount++;
             }
         }
-        
+
         return $successCount;
     }
 }

+ 16 - 16
app/Module/Team/Logics/TeamProfitLogic.php → app/Module/Promotion/Logics/TeamProfitLogic.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace App\Module\Team\Logics;
+namespace App\Module\Promotion\Logics;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_LEVEL;
-use App\Module\Team\Models\TeamProfit;
-use App\Module\Team\Models\TeamProfitRule;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_LEVEL;
+use App\Module\Promotion\Models\PromotionProfit;
+use App\Module\Promotion\Models\PromotionProfitRule;
 use Illuminate\Support\Facades\Log;
 
 /**
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Log;
  * 处理团队收益的核心业务逻辑,包括计算收益分成、记录收益、
  * 获取收益规则等功能。该类仅供内部使用,不对外提供服务。
  */
-class TeamProfitLogic
+class PromotionProfitLogic
 {
     /**
      * @var ReferralLogic
@@ -110,9 +110,9 @@ class TeamProfitLogic
                 }
 
                 // 记录收益
-                $profit = new TeamProfit();
+                $profit = new PromotionProfit();
                 $profit->user_id = $referrerId;
-                $profit->team_member_id = $userId;
+                $profit->promotion_member_id = $userId;
                 $profit->source_id = $sourceId;
                 $profit->source_type = $sourceType;
                 $profit->item_id = $itemId;
@@ -138,10 +138,10 @@ class TeamProfitLogic
      *
      * @param int $level 关系层级
      * @param int $depth 层级深度
-     * @param TeamProfitRule $rule 分成规则
+     * @param PromotionProfitRule $rule 分成规则
      * @return float
      */
-    private function calculateProfitRate(int $level, int $depth, TeamProfitRule $rule): float
+    private function calculateProfitRate(int $level, int $depth, PromotionProfitRule $rule): float
     {
         // 直推关系
         if ($level == REFERRAL_LEVEL::DIRECT) {
@@ -180,11 +180,11 @@ class TeamProfitLogic
      * 获取收益分成规则
      *
      * @param string $sourceType 收益来源类型
-     * @return TeamProfitRule|null
+     * @return PromotionProfitRule|null
      */
-    public function getProfitRule(string $sourceType): ?TeamProfitRule
+    public function getProfitRule(string $sourceType): ?PromotionProfitRule
     {
-        return TeamProfitRule::where('source_type', $sourceType)
+        return PromotionProfitRule::where('source_type', $sourceType)
             ->where('status', 1)
             ->first();
     }
@@ -200,7 +200,7 @@ class TeamProfitLogic
      */
     public function getUserProfits(int $userId, ?string $sourceType = null, int $page = 1, int $pageSize = 20): array
     {
-        $query = TeamProfit::where('user_id', $userId);
+        $query = PromotionProfit::where('user_id', $userId);
 
         if ($sourceType) {
             $query->where('source_type', $sourceType);
@@ -211,7 +211,7 @@ class TeamProfitLogic
         $profits = $query->orderBy('created_at', 'desc')
             ->offset(($page - 1) * $pageSize)
             ->limit($pageSize)
-            ->with(['teamMember', 'item'])
+            ->with(['promotionMember', 'item'])
             ->get();
 
         return [
@@ -233,7 +233,7 @@ class TeamProfitLogic
      */
     public function sumUserProfits(int $userId, ?string $sourceType = null, ?int $itemId = null): array
     {
-        $query = TeamProfit::where('user_id', $userId);
+        $query = PromotionProfit::where('user_id', $userId);
 
         if ($sourceType) {
             $query->where('source_type', $sourceType);

+ 5 - 5
app/Module/Team/Models/TeamInviteReward.php → app/Module/Promotion/Models/TeamInviteReward.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
@@ -8,7 +8,7 @@ use UCore\ModelCore;
 /**
  * 邀请奖励记录
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  获得奖励的用户ID
  * @property  int  $invited_user_id  被邀请的用户ID
@@ -22,14 +22,14 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamInviteReward extends ModelCore
+class PromotionInviteReward extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_invite_rewards';
+    protected $table = 'promotion_invite_rewards';
 
 
 
@@ -54,7 +54,7 @@ class TeamInviteReward extends ModelCore
     const STATUS_ISSUED = 1;
     const STATUS_EXPIRED = 2;
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',

+ 13 - 13
app/Module/Team/Models/TeamProfit.php → app/Module/Promotion/Models/TeamProfit.php

@@ -1,36 +1,36 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Enums\REFERRAL_LEVEL;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\REFERRAL_LEVEL;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
 
 /**
  * 团队收益记录
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  获得收益的用户ID
- * @property  int  $team_member_id  团队成员ID
+ * @property  int  $promotion_member_id  团队成员ID
  * @property  int  $source_id  收益来源ID
- * @property  \App\Module\Team\Enums\PROFIT_SOURCE_TYPE  $source_type  收益来源类型
+ * @property  \App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE  $source_type  收益来源类型
  * @property  int  $item_id  物品ID
  * @property  int  $profit_amount  分成收益数量
  * @property  float  $profit_rate  分成比例
- * @property  \App\Module\Team\Enums\REFERRAL_LEVEL  $relation_type  关系类型:1直推,2间推
+ * @property  \App\Module\Promotion\Enums\REFERRAL_LEVEL  $relation_type  关系类型:1直推,2间推
  * @property  \Carbon\Carbon  $created_at  创建时间
  * field end
  */
-class TeamProfit extends ModelCore
+class PromotionProfit extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_profits';
+    protected $table = 'promotion_profits';
 
 
 
@@ -41,11 +41,11 @@ class TeamProfit extends ModelCore
      */
     public $timestamps = false;
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',
-        'team_member_id',
+        'promotion_member_id',
         'source_id',
         'source_type',
         'item_id',
@@ -81,9 +81,9 @@ class TeamProfit extends ModelCore
      *
      * @return BelongsTo
      */
-    public function teamMember()
+    public function promotionMember()
     {
-        return $this->belongsTo('App\Models\User', 'team_member_id');
+        return $this->belongsTo('App\Models\User', 'promotion_member_id');
     }
 
     /**

+ 7 - 7
app/Module/Team/Models/TeamProfitRule.php → app/Module/Promotion/Models/TeamProfitRule.php

@@ -1,16 +1,16 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
 use UCore\ModelCore;
 
 /**
  * 收益分成规则
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
- * @property  \App\Module\Team\Enums\PROFIT_SOURCE_TYPE  $source_type  来源类型
+ * @property  \App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE  $source_type  来源类型
  * @property  float  $direct_profit_rate  直推分成比例
  * @property  int  $max_indirect_level  最大间推层级
  * @property  bool  $status  状态:1有效,0无效
@@ -19,18 +19,18 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamProfitRule extends ModelCore
+class PromotionProfitRule extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_profit_rules';
+    protected $table = 'promotion_profit_rules';
 
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'source_type',

+ 5 - 5
app/Module/Team/Models/TeamReferralChange.php → app/Module/Promotion/Models/TeamReferralChange.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
@@ -8,7 +8,7 @@ use UCore\ModelCore;
 /**
  * 推荐关系修改记录
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  用户ID
  * @property  int  $old_referrer_id  旧推荐人ID
@@ -19,14 +19,14 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $created_at  创建时间
  * field end
  */
-class TeamReferralChange extends ModelCore
+class PromotionReferralChange extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_referral_changes';
+    protected $table = 'promotion_referral_changes';
 
 
 
@@ -37,7 +37,7 @@ class TeamReferralChange extends ModelCore
      */
     public $timestamps = false;
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',

+ 8 - 8
app/Module/Team/Models/TeamReferralCode.php → app/Module/Promotion/Models/TeamReferralCode.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\REFERRAL_CODE_STATUS;
+use App\Module\Promotion\Enums\REFERRAL_CODE_STATUS;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use Illuminate\Database\Eloquent\Relations\HasMany;
 use UCore\ModelCore;
@@ -10,29 +10,29 @@ use UCore\ModelCore;
 /**
  * 推荐码
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  用户ID
  * @property  string  $code  推荐码
  * @property  int  $usage_count  使用次数
- * @property  \App\Module\Team\Enums\REFERRAL_CODE_STATUS  $status  状态:1有效,0无效
+ * @property  \App\Module\Promotion\Enums\REFERRAL_CODE_STATUS  $status  状态:1有效,0无效
  * @property  string  $expire_time  过期时间,NULL表示永不过期
  * @property  \Carbon\Carbon  $created_at  创建时间
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamReferralCode extends ModelCore
+class PromotionReferralCode extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_referral_codes';
+    protected $table = 'promotion_referral_codes';
 
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',
@@ -80,7 +80,7 @@ class TeamReferralCode extends ModelCore
      */
     public function usages()
     {
-        return $this->hasMany(TeamReferralCodeUsage::class, 'code', 'code');
+        return $this->hasMany(PromotionReferralCodeUsage::class, 'code', 'code');
     }
 
     /**

+ 6 - 6
app/Module/Team/Models/TeamReferralCodeUsage.php → app/Module/Promotion/Models/TeamReferralCodeUsage.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
@@ -8,7 +8,7 @@ use UCore\ModelCore;
 /**
  * 邀请码使用记录
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  string  $code  使用的邀请码
  * @property  int  $code_owner_id  邀请码所有者用户ID
@@ -22,14 +22,14 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamReferralCodeUsage extends ModelCore
+class PromotionReferralCodeUsage extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_referral_code_usages';
+    protected $table = 'promotion_referral_code_usages';
 
 
 
@@ -40,7 +40,7 @@ class TeamReferralCodeUsage extends ModelCore
     const STATUS_SUCCESS = 1;
     const STATUS_REVOKED = 2;
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'code',
@@ -61,7 +61,7 @@ class TeamReferralCodeUsage extends ModelCore
      */
     public function referralCode()
     {
-        return $this->belongsTo(TeamReferralCode::class, 'code', 'code');
+        return $this->belongsTo(PromotionReferralCode::class, 'code', 'code');
     }
 
     /**

+ 10 - 10
app/Module/Team/Models/TeamTalentConfig.php → app/Module/Promotion/Models/TeamTalentConfig.php

@@ -1,20 +1,20 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\TALENT_LEVEL;
+use App\Module\Promotion\Enums\TALENT_LEVEL;
 use Illuminate\Database\Eloquent\Relations\HasMany;
 use UCore\ModelCore;
 
 /**
  * 达人等级配置
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
- * @property  \App\Module\Team\Enums\TALENT_LEVEL  $level  等级
+ * @property  \App\Module\Promotion\Enums\TALENT_LEVEL  $level  等级
  * @property  string  $name  等级名称
  * @property  int  $direct_count_required  所需直推人数
- * @property  int  $team_count_required  所需团队总人数
+ * @property  int  $promotion_count_required  所需团队总人数
  * @property  float  $profit_rate  间推分成比例
  * @property  array  $benefits  等级权益
  * @property  string  $icon  等级图标
@@ -22,24 +22,24 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamTalentConfig extends ModelCore
+class PromotionTalentConfig extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_talent_configs';
+    protected $table = 'promotion_talent_configs';
 
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'level',
         'name',
         'direct_count_required',
-        'team_count_required',
+        'promotion_count_required',
         'profit_rate',
         'benefits',
         'icon',
@@ -64,7 +64,7 @@ class TeamTalentConfig extends ModelCore
      */
     public function users()
     {
-        return $this->hasMany(TeamUserTalent::class, 'talent_level', 'level');
+        return $this->hasMany(PromotionUserTalent::class, 'talent_level', 'level');
     }
 
     /**

+ 5 - 5
app/Module/Team/Models/TeamUserReferral.php → app/Module/Promotion/Models/TeamUserReferral.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
@@ -8,7 +8,7 @@ use UCore\ModelCore;
 /**
  * 用户推荐关系
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  用户ID
  * @property  int  $referrer_id  直接推荐人ID
@@ -16,18 +16,18 @@ use UCore\ModelCore;
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamUserReferral extends ModelCore
+class PromotionUserReferral extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_user_referrals';
+    protected $table = 'promotion_user_referrals';
 
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',

+ 7 - 7
app/Module/Team/Models/TeamUserRelationCache.php → app/Module/Promotion/Models/TeamUserRelationCache.php

@@ -1,37 +1,37 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\REFERRAL_LEVEL;
+use App\Module\Promotion\Enums\REFERRAL_LEVEL;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
 
 /**
  * 用户关系缓存
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  用户ID
  * @property  int  $related_user_id  关联用户ID(上级)
- * @property  \App\Module\Team\Enums\REFERRAL_LEVEL  $level  关系层级:1直接,2间接
+ * @property  \App\Module\Promotion\Enums\REFERRAL_LEVEL  $level  关系层级:1直接,2间接
  * @property  string  $path  关系路径,格式:1,2,3
  * @property  int  $depth  层级深度,从1开始
  * @property  \Carbon\Carbon  $created_at  创建时间
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamUserRelationCache extends ModelCore
+class PromotionUserRelationCache extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_user_relation_cache';
+    protected $table = 'promotion_user_relation_cache';
 
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',

+ 10 - 10
app/Module/Team/Models/TeamUserTalent.php → app/Module/Promotion/Models/TeamUserTalent.php

@@ -1,41 +1,41 @@
 <?php
 
-namespace App\Module\Team\Models;
+namespace App\Module\Promotion\Models;
 
-use App\Module\Team\Enums\TALENT_LEVEL;
+use App\Module\Promotion\Enums\TALENT_LEVEL;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 use UCore\ModelCore;
 
 /**
  * 达人等级
  *
- * field start 
+ * field start
  * @property  int  $id  主键ID
  * @property  int  $user_id  用户ID
- * @property  \App\Module\Team\Enums\TALENT_LEVEL  $talent_level  达人等级:0无,1初级,2中级,3高级,4资深,5顶级
+ * @property  \App\Module\Promotion\Enums\TALENT_LEVEL  $talent_level  达人等级:0无,1初级,2中级,3高级,4资深,5顶级
  * @property  int  $direct_count  直推人数
- * @property  int  $team_count  团队总人数
+ * @property  int  $promotion_count  团队总人数
  * @property  \Carbon\Carbon  $created_at  创建时间
  * @property  \Carbon\Carbon  $updated_at  更新时间
  * field end
  */
-class TeamUserTalent extends ModelCore
+class PromotionUserTalent extends ModelCore
 {
     /**
      * 与模型关联的表名
      *
      * @var string
      */
-    protected $table = 'team_user_talents';
+    protected $table = 'promotion_user_talents';
 
 
-    // attrlist start 
+    // attrlist start
     protected $fillable = [
         'id',
         'user_id',
         'talent_level',
         'direct_count',
-        'team_count',
+        'promotion_count',
     ];
     // attrlist end
 
@@ -65,6 +65,6 @@ class TeamUserTalent extends ModelCore
      */
     public function config()
     {
-        return $this->belongsTo(TeamTalentConfig::class, 'talent_level', 'level');
+        return $this->belongsTo(PromotionTalentConfig::class, 'talent_level', 'level');
     }
 }

+ 22 - 22
app/Module/Team/Providers/TeamServiceProvider.php → app/Module/Promotion/Providers/TeamServiceProvider.php

@@ -1,30 +1,30 @@
 <?php
 
-namespace App\Module\Team\Providers;
+namespace App\Module\Promotion\Providers;
 
-use App\Module\Team\Commands\CleanExpiredReferralCodesCommand;
-use App\Module\Team\Commands\RebuildRelationCacheCommand;
-use App\Module\Team\Commands\UpdateTalentLevelsCommand;
-use App\Module\Team\Events\ReferralCreatedEvent;
-use App\Module\Team\Events\ReferralUpdatedEvent;
-use App\Module\Team\Events\TeamProfitCreatedEvent;
-use App\Module\Team\Listeners\DistributeTeamProfitListener;
-use App\Module\Team\Listeners\UpdateTalentLevelListener;
-use App\Module\Team\Listeners\UpdateTeamCountsListener;
-use App\Module\Team\Logics\ReferralCodeLogic;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\RelationCacheLogic;
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Logics\TeamProfitLogic;
+use App\Module\Promotion\Commands\CleanExpiredReferralCodesCommand;
+use App\Module\Promotion\Commands\RebuildRelationCacheCommand;
+use App\Module\Promotion\Commands\UpdateTalentLevelsCommand;
+use App\Module\Promotion\Events\ReferralCreatedEvent;
+use App\Module\Promotion\Events\ReferralUpdatedEvent;
+use App\Module\Promotion\Events\PromotionProfitCreatedEvent;
+use App\Module\Promotion\Listeners\DistributePromotionProfitListener;
+use App\Module\Promotion\Listeners\UpdateTalentLevelListener;
+use App\Module\Promotion\Listeners\UpdatePromotionCountsListener;
+use App\Module\Promotion\Logics\ReferralCodeLogic;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\RelationCacheLogic;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Logics\PromotionProfitLogic;
 use Illuminate\Support\Facades\Event;
 use Illuminate\Support\ServiceProvider;
 
 /**
  * 团队模块服务提供者
- * 
+ *
  * 注册团队模块的服务、事件、命令等。
  */
-class TeamServiceProvider extends ServiceProvider
+class PromotionServiceProvider extends ServiceProvider
 {
     /**
      * 注册服务
@@ -46,8 +46,8 @@ class TeamServiceProvider extends ServiceProvider
             return new TalentLogic($app->make(ReferralLogic::class));
         });
 
-        $this->app->singleton(TeamProfitLogic::class, function ($app) {
-            return new TeamProfitLogic(
+        $this->app->singleton(PromotionProfitLogic::class, function ($app) {
+            return new PromotionProfitLogic(
                 $app->make(ReferralLogic::class),
                 $app->make(TalentLogic::class)
             );
@@ -66,11 +66,11 @@ class TeamServiceProvider extends ServiceProvider
     public function boot()
     {
         // 注册事件和监听器
-        Event::listen(ReferralCreatedEvent::class, UpdateTeamCountsListener::class);
+        Event::listen(ReferralCreatedEvent::class, UpdatePromotionCountsListener::class);
         Event::listen(ReferralCreatedEvent::class, UpdateTalentLevelListener::class);
-        Event::listen(ReferralUpdatedEvent::class, UpdateTeamCountsListener::class);
+        Event::listen(ReferralUpdatedEvent::class, UpdatePromotionCountsListener::class);
         Event::listen(ReferralUpdatedEvent::class, UpdateTalentLevelListener::class);
-        Event::listen(TeamProfitCreatedEvent::class, DistributeTeamProfitListener::class);
+        Event::listen(PromotionProfitCreatedEvent::class, DistributePromotionProfitListener::class);
 
         // 注册命令
         if ($this->app->runningInConsole()) {

+ 7 - 7
app/Module/Team/README.md → app/Module/Promotion/README.md

@@ -15,7 +15,7 @@
 ## 目录结构
 
 ```
-app/Module/Team/
+app/Module/Promotion/
 ├── AdminControllers/        # 后台管理控制器
 ├── Commands/                # 命令行工具
 ├── Databases/               # 数据库相关文件
@@ -64,7 +64,7 @@ app/Module/Team/
 
 ## 核心数据表
 
-### 1. 用户推荐关系表 (team_user_referrals)
+### 1. 用户推荐关系表 (promotion_user_referrals)
 | 字段名 | 类型 | 说明 |
 |--------|------|------|
 | id | bigint | 主键ID |
@@ -74,23 +74,23 @@ app/Module/Team/
 | created_at | timestamp | 创建时间 |
 | updated_at | timestamp | 更新时间 |
 
-### 2. 达人等级表 (team_user_talents)
+### 2. 达人等级表 (promotion_user_talents)
 | 字段名 | 类型 | 说明 |
 |--------|------|------|
 | id | bigint | 主键ID |
 | user_id | bigint | 用户ID |
 | talent_level | tinyint | 达人等级(0-5) |
 | direct_count | int | 直推人数 |
-| team_count | int | 团队总人数 |
+| promotion_count | int | 团队总人数 |
 | created_at | timestamp | 创建时间 |
 | updated_at | timestamp | 更新时间 |
 
-### 3. 团队收益记录表 (team_profits)
+### 3. 团队收益记录表 (promotion_profits)
 | 字段名 | 类型 | 说明 |
 |--------|------|------|
 | id | bigint | 主键ID |
 | user_id | bigint | 获得收益的用户ID |
-| team_member_id | bigint | 团队成员ID |
+| promotion_member_id | bigint | 团队成员ID |
 | source_id | bigint | 收益来源ID |
 | source_type | varchar | 收益来源类型 |
 | profit_amount | int | 分成收益数量 |
@@ -110,7 +110,7 @@ app/Module/Team/
 - 获取用户的达人信息
 - 获取达人等级权益
 
-### 3. 团队收益服务 (TeamProfitService)
+### 3. 团队收益服务 (PromotionProfitService)
 - 计算团队收益分成
 - 记录收益分成
 - 统计团队收益

+ 12 - 12
app/Module/Team/Repositorys/BaseRepository.php → app/Module/Promotion/Repositorys/BaseRepository.php

@@ -1,13 +1,13 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Facades\DB;
 
 /**
  * 基础仓库类
- * 
+ *
  * 提供基本的数据访问和操作功能,所有具体的仓库类都继承自此类。
  * 该类主要用于后台管理控制器,提供数据的CRUD操作。
  */
@@ -75,11 +75,11 @@ class BaseRepository
     public function findBy(array $conditions, array $columns = ['*'])
     {
         $query = $this->model->query();
-        
+
         foreach ($conditions as $field => $value) {
             $query->where($field, $value);
         }
-        
+
         return $query->first($columns);
     }
 
@@ -93,11 +93,11 @@ class BaseRepository
     public function findAllBy(array $conditions, array $columns = ['*'])
     {
         $query = $this->model->query();
-        
+
         foreach ($conditions as $field => $value) {
             $query->where($field, $value);
         }
-        
+
         return $query->get($columns);
     }
 
@@ -122,11 +122,11 @@ class BaseRepository
     public function update(int $id, array $data)
     {
         $record = $this->find($id);
-        
+
         if (!$record) {
             return false;
         }
-        
+
         return $record->update($data);
     }
 
@@ -139,11 +139,11 @@ class BaseRepository
     public function delete(int $id)
     {
         $record = $this->find($id);
-        
+
         if (!$record) {
             return false;
         }
-        
+
         return $record->delete();
     }
 
@@ -167,11 +167,11 @@ class BaseRepository
     public function count(array $conditions = [])
     {
         $query = $this->model->query();
-        
+
         foreach ($conditions as $field => $value) {
             $query->where($field, $value);
         }
-        
+
         return $query->count();
     }
 

+ 4 - 4
app/Module/Team/Repositorys/TeamInviteRewardRepository.php → app/Module/Promotion/Repositorys/TeamInviteRewardRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamInviteReward;
+use App\Module\Promotion\Models\PromotionInviteReward;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是邀请奖励记录模块与后台管理系统的桥梁,用于处理邀请奖励记录数据的CRUD操作。
  * 邀请奖励记录了用户邀请新用户获得的奖励,包括奖励类型、奖励数量、奖励状态等信息。
  */
-class TeamInviteRewardRepository extends EloquentRepository
+class PromotionInviteRewardRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamInviteReward::class;
+    protected $eloquentClass = PromotionInviteReward::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamProfitRepository.php → app/Module/Promotion/Repositorys/TeamProfitRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamProfit;
+use App\Module\Promotion\Models\PromotionProfit;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是团队收益记录模块与后台管理系统的桥梁,用于处理团队收益记录数据的CRUD操作。
  * 团队收益记录了用户获得的团队收益,包括收益来源、收益数量、分成比例等信息。
  */
-class TeamProfitRepository extends EloquentRepository
+class PromotionProfitRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamProfit::class;
+    protected $eloquentClass = PromotionProfit::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamProfitRuleRepository.php → app/Module/Promotion/Repositorys/TeamProfitRuleRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamProfitRule;
+use App\Module\Promotion\Models\PromotionProfitRule;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是收益分成规则模块与后台管理系统的桥梁,用于处理收益分成规则数据的CRUD操作。
  * 收益分成规则定义了不同来源类型的收益分成比例和规则。
  */
-class TeamProfitRuleRepository extends EloquentRepository
+class PromotionProfitRuleRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamProfitRule::class;
+    protected $eloquentClass = PromotionProfitRule::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamReferralChangeRepository.php → app/Module/Promotion/Repositorys/TeamReferralChangeRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamReferralChange;
+use App\Module\Promotion\Models\PromotionReferralChange;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是推荐关系修改记录模块与后台管理系统的桥梁,用于处理推荐关系修改记录数据的CRUD操作。
  * 推荐关系修改记录了用户推荐关系的变更历史,包括旧推荐人、新推荐人、修改原因等信息。
  */
-class TeamReferralChangeRepository extends EloquentRepository
+class PromotionReferralChangeRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamReferralChange::class;
+    protected $eloquentClass = PromotionReferralChange::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamReferralCodeRepository.php → app/Module/Promotion/Repositorys/TeamReferralCodeRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamReferralCode;
+use App\Module\Promotion\Models\PromotionReferralCode;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是推荐码模块与后台管理系统的桥梁,用于处理推荐码数据的CRUD操作。
  * 推荐码用于用户邀请新用户加入,建立推荐关系。
  */
-class TeamReferralCodeRepository extends EloquentRepository
+class PromotionReferralCodeRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamReferralCode::class;
+    protected $eloquentClass = PromotionReferralCode::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamReferralCodeUsageRepository.php → app/Module/Promotion/Repositorys/TeamReferralCodeUsageRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamReferralCodeUsage;
+use App\Module\Promotion\Models\PromotionReferralCodeUsage;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是邀请码使用记录模块与后台管理系统的桥梁,用于处理邀请码使用记录数据的CRUD操作。
  * 邀请码使用记录了用户使用邀请码的详细信息,包括使用时间、使用结果、IP地址等。
  */
-class TeamReferralCodeUsageRepository extends EloquentRepository
+class PromotionReferralCodeUsageRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamReferralCodeUsage::class;
+    protected $eloquentClass = PromotionReferralCodeUsage::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamTalentConfigRepository.php → app/Module/Promotion/Repositorys/TeamTalentConfigRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamTalentConfig;
+use App\Module\Promotion\Models\PromotionTalentConfig;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是达人等级配置模块与后台管理系统的桥梁,用于处理达人等级配置数据的CRUD操作。
  * 达人等级配置定义了不同达人等级的要求和权益。
  */
-class TeamTalentConfigRepository extends EloquentRepository
+class PromotionTalentConfigRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamTalentConfig::class;
+    protected $eloquentClass = PromotionTalentConfig::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamUserReferralRepository.php → app/Module/Promotion/Repositorys/TeamUserReferralRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamUserReferral;
+use App\Module\Promotion\Models\PromotionUserReferral;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是用户推荐关系模块与后台管理系统的桥梁,用于处理用户推荐关系数据的CRUD操作。
  * 用户推荐关系记录了用户之间的直接推荐关系,是构建团队结构的基础。
  */
-class TeamUserReferralRepository extends EloquentRepository
+class PromotionUserReferralRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamUserReferral::class;
+    protected $eloquentClass = PromotionUserReferral::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamUserRelationCacheRepository.php → app/Module/Promotion/Repositorys/TeamUserRelationCacheRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamUserRelationCache;
+use App\Module\Promotion\Models\PromotionUserRelationCache;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是用户关系缓存模块与后台管理系统的桥梁,用于处理用户关系缓存数据的CRUD操作。
  * 用户关系缓存记录了用户之间的间接推荐关系,用于快速查询用户的团队结构。
  */
-class TeamUserRelationCacheRepository extends EloquentRepository
+class PromotionUserRelationCacheRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamUserRelationCache::class;
+    protected $eloquentClass = PromotionUserRelationCache::class;
 }

+ 4 - 4
app/Module/Team/Repositorys/TeamUserTalentRepository.php → app/Module/Promotion/Repositorys/TeamUserTalentRepository.php

@@ -1,8 +1,8 @@
 <?php
 
-namespace App\Module\Team\Repositorys;
+namespace App\Module\Promotion\Repositorys;
 
-use App\Module\Team\Models\TeamUserTalent;
+use App\Module\Promotion\Models\PromotionUserTalent;
 use Dcat\Admin\Repositories\EloquentRepository;
 
 /**
@@ -12,7 +12,7 @@ use Dcat\Admin\Repositories\EloquentRepository;
  * 该类是用户达人等级模块与后台管理系统的桥梁,用于处理用户达人等级数据的CRUD操作。
  * 用户达人等级记录了用户的达人等级、直推人数和团队总人数等信息。
  */
-class TeamUserTalentRepository extends EloquentRepository
+class PromotionUserTalentRepository extends EloquentRepository
 {
-    protected $eloquentClass = TeamUserTalent::class;
+    protected $eloquentClass = PromotionUserTalent::class;
 }

+ 7 - 7
app/Module/Team/Services/ReferralCodeService.php → app/Module/Promotion/Services/ReferralCodeService.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace App\Module\Team\Services;
+namespace App\Module\Promotion\Services;
 
-use App\Module\Team\Logics\ReferralCodeLogic;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Models\TeamReferralCode;
-use App\Module\Team\Models\TeamReferralCodeUsage;
+use App\Module\Promotion\Logics\ReferralCodeLogic;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Models\PromotionReferralCode;
+use App\Module\Promotion\Models\PromotionReferralCodeUsage;
 use Illuminate\Support\Facades\Log;
 
 /**
@@ -140,7 +140,7 @@ class ReferralCodeService
     public static function getReferralCodeUsages(string $code, int $page = 1, int $pageSize = 20): array
     {
         try {
-            $query = TeamReferralCodeUsage::where('code', $code);
+            $query = PromotionReferralCodeUsage::where('code', $code);
 
             $total = $query->count();
 
@@ -198,7 +198,7 @@ class ReferralCodeService
     public static function getUserAllReferralCodes(int $userId, int $page = 1, int $pageSize = 20): array
     {
         try {
-            $query = TeamReferralCode::where('user_id', $userId);
+            $query = PromotionReferralCode::where('user_id', $userId);
 
             $total = $query->count();
 

+ 13 - 13
app/Module/Team/Services/ReferralService.php → app/Module/Promotion/Services/ReferralService.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace App\Module\Team\Services;
+namespace App\Module\Promotion\Services;
 
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\RelationCacheLogic;
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Models\TeamUserReferral;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\RelationCacheLogic;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Models\PromotionUserReferral;
 use Illuminate\Support\Facades\Log;
 
 /**
@@ -64,7 +64,7 @@ class ReferralService
     public static function getUserDirectReferrals(int $userId, int $page = 1, int $pageSize = 20): array
     {
         try {
-            $query = TeamUserReferral::where('referrer_id', $userId)
+            $query = PromotionUserReferral::where('referrer_id', $userId)
                 ->with('user');
 
             $total = $query->count();
@@ -115,11 +115,11 @@ class ReferralService
      * @param int $maxLevel 最大层级
      * @return array
      */
-    public static function getUserTeamMembers(int $userId, int $page = 1, int $pageSize = 20, int $maxLevel = 20): array
+    public static function getUserPromotionMembers(int $userId, int $page = 1, int $pageSize = 20, int $maxLevel = 20): array
     {
         try {
             $referralLogic = new ReferralLogic();
-            return $referralLogic->getAllTeamMembers($userId, $maxLevel, $page, $pageSize);
+            return $referralLogic->getAllPromotionMembers($userId, $maxLevel, $page, $pageSize);
         } catch (\Exception $e) {
             Log::error("获取用户团队成员列表失败: " . $e->getMessage());
             return [
@@ -192,7 +192,7 @@ class ReferralService
             }
 
             // 更新团队统计和达人等级
-            $talentLogic->updateTeamCounts($referrerId);
+            $talentLogic->updatePromotionCounts($referrerId);
             $talentLogic->checkAndUpdateTalentLevel($referrerId);
 
             return [
@@ -214,7 +214,7 @@ class ReferralService
      * @param int $userId 用户ID
      * @return array
      */
-    public static function getUserTeamStats(int $userId): array
+    public static function getUserPromotionStats(int $userId): array
     {
         try {
             $referralLogic = new ReferralLogic();
@@ -224,21 +224,21 @@ class ReferralService
             if (!$talent) {
                 return [
                     'direct_count' => 0,
-                    'team_count' => 0,
+                    'promotion_count' => 0,
                     'talent_level' => 0
                 ];
             }
 
             return [
                 'direct_count' => $talent->direct_count,
-                'team_count' => $talent->team_count,
+                'promotion_count' => $talent->promotion_count,
                 'talent_level' => $talent->talent_level
             ];
         } catch (\Exception $e) {
             Log::error("获取用户团队统计数据失败: " . $e->getMessage());
             return [
                 'direct_count' => 0,
-                'team_count' => 0,
+                'promotion_count' => 0,
                 'talent_level' => 0
             ];
         }

+ 23 - 23
app/Module/Team/Services/TalentService.php → app/Module/Promotion/Services/TalentService.php

@@ -1,10 +1,10 @@
 <?php
 
-namespace App\Module\Team\Services;
+namespace App\Module\Promotion\Services;
 
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Models\TeamUserTalent;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Models\PromotionUserTalent;
 use Illuminate\Support\Facades\Log;
 
 /**
@@ -41,7 +41,7 @@ class TalentService
                 'talent_level' => $talent->talent_level,
                 'talent_name' => $config ? $config->name : '',
                 'direct_count' => $talent->direct_count,
-                'team_count' => $talent->team_count,
+                'promotion_count' => $talent->promotion_count,
                 'icon' => $config ? $config->icon : '',
                 'icon_url' => $config ? $config->icon_url : '',
                 'benefits' => $config ? (is_array($config->benefits) ? $config->benefits : json_decode($config->benefits, true)) : [],
@@ -73,7 +73,7 @@ class TalentService
                     'level' => $config->level,
                     'name' => $config->name,
                     'direct_count_required' => $config->direct_count_required,
-                    'team_count_required' => $config->team_count_required,
+                    'promotion_count_required' => $config->promotion_count_required,
                     'profit_rate' => $config->profit_rate,
                     'benefits' => is_array($config->benefits) ? $config->benefits : json_decode($config->benefits, true),
                     'icon' => $config->icon,
@@ -136,9 +136,9 @@ class TalentService
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
 
-            $talents = TeamUserTalent::where('talent_level', '>', 0)
+            $talents = PromotionUserTalent::where('talent_level', '>', 0)
                 ->orderBy('talent_level', 'desc')
-                ->orderBy('team_count', 'desc')
+                ->orderBy('promotion_count', 'desc')
                 ->orderBy('direct_count', 'desc')
                 ->limit($limit)
                 ->with('user')
@@ -157,7 +157,7 @@ class TalentService
                         'talent_level' => $talent->talent_level,
                         'talent_name' => $config ? $config->name : '',
                         'direct_count' => $talent->direct_count,
-                        'team_count' => $talent->team_count,
+                        'promotion_count' => $talent->promotion_count,
                         'icon' => $config ? $config->icon : '',
                         'icon_url' => $config ? $config->icon_url : ''
                     ];
@@ -192,9 +192,9 @@ class TalentService
                     'direct_count' => 0,
                     'direct_count_required' => 5,
                     'direct_count_progress' => 0,
-                    'team_count' => 0,
-                    'team_count_required' => 10,
-                    'team_count_progress' => 0
+                    'promotion_count' => 0,
+                    'promotion_count_required' => 10,
+                    'promotion_count_progress' => 0
                 ];
             }
 
@@ -222,9 +222,9 @@ class TalentService
                     'direct_count' => $talent->direct_count,
                     'direct_count_required' => $currentConfig ? $currentConfig->direct_count_required : 0,
                     'direct_count_progress' => 100,
-                    'team_count' => $talent->team_count,
-                    'team_count_required' => $currentConfig ? $currentConfig->team_count_required : 0,
-                    'team_count_progress' => 100
+                    'promotion_count' => $talent->promotion_count,
+                    'promotion_count_required' => $currentConfig ? $currentConfig->promotion_count_required : 0,
+                    'promotion_count_progress' => 100
                 ];
             }
 
@@ -233,8 +233,8 @@ class TalentService
                 ? min(100, ($talent->direct_count / $nextLevelConfig->direct_count_required) * 100)
                 : 0;
 
-            $teamCountProgress = $nextLevelConfig->team_count_required > 0
-                ? min(100, ($talent->team_count / $nextLevelConfig->team_count_required) * 100)
+            $promotionCountProgress = $nextLevelConfig->promotion_count_required > 0
+                ? min(100, ($talent->promotion_count / $nextLevelConfig->promotion_count_required) * 100)
                 : 0;
 
             return [
@@ -243,9 +243,9 @@ class TalentService
                 'direct_count' => $talent->direct_count,
                 'direct_count_required' => $nextLevelConfig->direct_count_required,
                 'direct_count_progress' => $directCountProgress,
-                'team_count' => $talent->team_count,
-                'team_count_required' => $nextLevelConfig->team_count_required,
-                'team_count_progress' => $teamCountProgress
+                'promotion_count' => $talent->promotion_count,
+                'promotion_count_required' => $nextLevelConfig->promotion_count_required,
+                'promotion_count_progress' => $promotionCountProgress
             ];
         } catch (\Exception $e) {
             Log::error("获取用户达人等级进度失败: " . $e->getMessage());
@@ -255,9 +255,9 @@ class TalentService
                 'direct_count' => 0,
                 'direct_count_required' => 5,
                 'direct_count_progress' => 0,
-                'team_count' => 0,
-                'team_count_required' => 10,
-                'team_count_progress' => 0
+                'promotion_count' => 0,
+                'promotion_count_required' => 10,
+                'promotion_count_progress' => 0
             ];
         }
     }

+ 18 - 18
app/Module/Team/Services/TeamProfitService.php → app/Module/Promotion/Services/TeamProfitService.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace App\Module\Team\Services;
+namespace App\Module\Promotion\Services;
 
-use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
-use App\Module\Team\Logics\ReferralLogic;
-use App\Module\Team\Logics\TalentLogic;
-use App\Module\Team\Logics\TeamProfitLogic;
+use App\Module\Promotion\Enums\PROFIT_SOURCE_TYPE;
+use App\Module\Promotion\Logics\ReferralLogic;
+use App\Module\Promotion\Logics\TalentLogic;
+use App\Module\Promotion\Logics\PromotionProfitLogic;
 use Illuminate\Support\Facades\Log;
 
 /**
@@ -14,7 +14,7 @@ use Illuminate\Support\Facades\Log;
  * 对外提供团队收益相关的服务,包括记录收益、获取收益记录、
  * 统计收益等功能。该类对外提供服务,内部调用逻辑层实现。
  */
-class TeamProfitService
+class PromotionProfitService
 {
 
     /**
@@ -31,9 +31,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            return $teamProfitLogic->calculateAndRecordProfit(
+            return $promotionProfitLogic->calculateAndRecordProfit(
                 $userId,
                 PROFIT_SOURCE_TYPE::FARM_HARVEST,
                 $sourceId,
@@ -60,9 +60,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            return $teamProfitLogic->calculateAndRecordProfit(
+            return $promotionProfitLogic->calculateAndRecordProfit(
                 $userId,
                 PROFIT_SOURCE_TYPE::TASK_COMPLETE,
                 $sourceId,
@@ -89,9 +89,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            return $teamProfitLogic->calculateAndRecordProfit(
+            return $promotionProfitLogic->calculateAndRecordProfit(
                 $userId,
                 PROFIT_SOURCE_TYPE::ITEM_SELL,
                 $sourceId,
@@ -118,9 +118,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            return $teamProfitLogic->getUserProfits($userId, $sourceType, $page, $pageSize);
+            return $promotionProfitLogic->getUserProfits($userId, $sourceType, $page, $pageSize);
         } catch (\Exception $e) {
             Log::error("获取用户收益记录失败: " . $e->getMessage());
             return [
@@ -146,9 +146,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            return $teamProfitLogic->sumUserProfits($userId, $sourceType, $itemId);
+            return $promotionProfitLogic->sumUserProfits($userId, $sourceType, $itemId);
         } catch (\Exception $e) {
             Log::error("统计用户收益失败: " . $e->getMessage());
             return [
@@ -170,9 +170,9 @@ class TeamProfitService
         try {
             $referralLogic = new ReferralLogic();
             $talentLogic = new TalentLogic($referralLogic);
-            $teamProfitLogic = new TeamProfitLogic($referralLogic, $talentLogic);
+            $promotionProfitLogic = new PromotionProfitLogic($referralLogic, $talentLogic);
 
-            $rule = $teamProfitLogic->getProfitRule($sourceType);
+            $rule = $promotionProfitLogic->getProfitRule($sourceType);
 
             if (!$rule) {
                 return null;