Jelajahi Sumber

清理Point模块Repository类,移除所有业务方法

参考Fund模块Repository标准,Repository是后台专用的,其内不应有任何业务方法:
- 移除所有CRUD方法(grid、detail、edit、store、update、destroy等)
- 移除所有业务统计方法(getStats、search等)
- 移除所有自定义业务方法
- 只保留属性,符合Fund模块标准
- 清理多余空行,保持代码整洁

修改的Repository类:
- PointRepository
- PointLogRepository
- PointConfigRepository
- PointCurrencyRepository
- PointAdminRepository
- PointCirculationRepository
- PointOrderRepository
- PointTransferRepository
notfff 7 bulan lalu
induk
melakukan
35b941ef5b

+ 3 - 3
app/Module/Point/AdminControllers/PointController.php

@@ -15,10 +15,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 use UCore\DcatAdmin\AdminController;
 
 /**
- * 种植点数管理控制器
+ * 点数管理控制器
  *
  * 路由: /admin/point/point
- * 菜单: 积分管理 -> 种植点数
+ * 菜单: 积分管理 -> 积分账户
  * 功能: 管理用户的种植点数,每种植一个种子增长1点
  */
 #[Resource('point-point', names: 'dcat.admin.point')]
@@ -32,7 +32,7 @@ class PointController extends AdminController
     /**
      * 页面标题
      */
-    protected $title = '种植点数';
+    protected $title = '积分账户';
 
     /**
      * 列表页面

+ 107 - 8
app/Module/Point/AdminControllers/PointDashboardController.php

@@ -10,7 +10,7 @@ use App\Module\Point\Repositorys\PointTransferRepository;
 use App\Module\Point\Repositorys\PointOrderRepository;
 use Dcat\Admin\Layout\Content;
 use Dcat\Admin\Widgets\Card;
-use Dcat\Admin\Widgets\InfoBox;
+
 use Spatie\RouteAttributes\Attributes\Get;
 use UCore\DcatAdmin\AdminController;
 
@@ -67,12 +67,111 @@ class PointDashboardController extends AdminController
         $todayLogs = $logRepo->model()->where('create_time', '>=', $todayStart)->count();
         $todayAdminOps = $adminRepo->model()->where('create_time', '>=', $todayStart)->count();
 
-        return new Card('系统概览', [
-            new InfoBox('积分账户总数', 'users', 'aqua', route('admin.point.index'), $totalAccounts),
-            new InfoBox('积分日志总数', 'file-text-o', 'green', route('admin.point-log.index'), $totalLogs),
-            new InfoBox('管理员操作', 'cog', 'yellow', route('admin.point-admin.index'), $totalAdminOps),
-            new InfoBox('今日日志', 'calendar', 'red', route('admin.point-log.index'), $todayLogs),
-        ]);
+        $content = '
+        <div class="row">
+            <div class="col-lg-3 col-6">
+                <div class="small-box bg-info">
+                    <div class="inner">
+                        <h3>' . $totalAccounts . '</h3>
+                        <p>积分账户总数</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-users"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="col-lg-3 col-6">
+                <div class="small-box bg-success">
+                    <div class="inner">
+                        <h3>' . $totalLogs . '</h3>
+                        <p>积分日志总数</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-file-text-o"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-log.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="col-lg-3 col-6">
+                <div class="small-box bg-warning">
+                    <div class="inner">
+                        <h3>' . $totalAdminOps . '</h3>
+                        <p>管理员操作</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-cog"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-admin.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="col-lg-3 col-6">
+                <div class="small-box bg-danger">
+                    <div class="inner">
+                        <h3>' . $todayLogs . '</h3>
+                        <p>今日日志</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-calendar"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-log.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+        </div>
+        <div class="row">
+            <div class="col-lg-4 col-6">
+                <div class="small-box bg-primary">
+                    <div class="inner">
+                        <h3>' . $totalCirculations . '</h3>
+                        <p>点数流转总数</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-exchange"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-circulation.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="col-lg-4 col-6">
+                <div class="small-box bg-secondary">
+                    <div class="inner">
+                        <h3>' . $totalTransfers . '</h3>
+                        <p>积分转账总数</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-send"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-transfer.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+            <div class="col-lg-4 col-6">
+                <div class="small-box bg-dark">
+                    <div class="inner">
+                        <h3>' . $totalOrders . '</h3>
+                        <p>积分订单总数</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fa fa-shopping-cart"></i>
+                    </div>
+                    <a href="' . route('dcat.admin.point-order.index') . '" class="small-box-footer">
+                        查看详情 <i class="fa fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+        </div>';
+
+        return new Card('Point模块统计仪表板', $content);
     }
 
     /**
@@ -149,7 +248,7 @@ class PointDashboardController extends AdminController
 
         foreach ($recentLogs as $log) {
             $time = date('m-d H:i', $log->create_time);
-            $pointType = $pointTypes[$log->point_id] ?? "积分{$log->point_id}";
+            $pointType = $pointTypes[$log->point_id->value] ?? "积分{$log->point_id->value}";
             $amount = $log->amount > 0 ? "+{$log->amount}" : $log->amount;
             $amountClass = $log->amount > 0 ? 'text-success' : 'text-danger';
             $remark = mb_substr($log->remark, 0, 20) . (mb_strlen($log->remark) > 20 ? '...' : '');

+ 5 - 4
app/Module/Point/AdminControllers/PointLogController.php

@@ -12,10 +12,10 @@ use Spatie\RouteAttributes\Attributes\Resource;
 use UCore\DcatAdmin\AdminController;
 
 /**
- * 种植点数日志控制器
+ * 点数日志控制器
  *
  * 路由: /admin/point/point-log
- * 菜单: 积分管理 -> 种植日志
+ * 菜单: 积分管理 -> 积分日志
  * 功能: 查看用户种植点数的变动记录,包括种植奖励等操作
  */
 #[Resource('point-point-log', names: 'dcat.admin.point-log')]
@@ -29,7 +29,7 @@ class PointLogController extends AdminController
     /**
      * 页面标题
      */
-    protected $title = '种植日志';
+    protected $title = '积分 日志';
 
     /**
      * 列表页面
@@ -40,7 +40,8 @@ class PointLogController extends AdminController
             $gridHelper = new GridHelper($grid,$this);
 
             $grid->column('id', 'ID')->sortable();
-            $gridHelper->columnUserPoint();
+            $grid->column('user_id', '用户ID');
+            $gridHelper->columnPointId();
             $gridHelper->columnAmount();
             $gridHelper->columnOperateType();
             $grid->column('operate_id', '操作ID')->limit(20);

+ 0 - 161
app/Module/Point/Repositorys/PointAdminRepository.php

@@ -16,165 +16,4 @@ class PointAdminRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointAdminModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('create_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取管理员操作统计
-     *
-     * @param int|null $adminId
-     * @return array
-     */
-    public function getAdminStats(?int $adminId = null): array
-    {
-        $query = $this->model();
-        
-        if ($adminId !== null) {
-            $query->where('admin_id', $adminId);
-        }
-
-        $records = $query->get();
-        
-        $stats = [
-            'total_records' => $records->count(),
-            'total_points' => 0,
-            'increase_count' => 0,
-            'decrease_count' => 0,
-            'increase_amount' => 0,
-            'decrease_amount' => 0,
-            'by_status' => [
-                'pending' => 0,
-                'completed' => 0,
-                'failed' => 0,
-            ],
-        ];
-
-        foreach ($records as $record) {
-            $stats['total_points'] += $record->total_points;
-            
-            if ($record->total_points > 0) {
-                $stats['increase_count']++;
-                $stats['increase_amount'] += $record->total_points;
-            } else {
-                $stats['decrease_count']++;
-                $stats['decrease_amount'] += abs($record->total_points);
-            }
-
-            switch ($record->status) {
-                case PointAdminModel::STATUS_PENDING:
-                    $stats['by_status']['pending']++;
-                    break;
-                case PointAdminModel::STATUS_COMPLETED:
-                    $stats['by_status']['completed']++;
-                    break;
-                case PointAdminModel::STATUS_FAILED:
-                    $stats['by_status']['failed']++;
-                    break;
-            }
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 搜索管理员操作记录
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where('user_id', $filters['user_id']);
-        }
-
-        if (isset($filters['admin_id'])) {
-            $query = $query->where('admin_id', $filters['admin_id']);
-        }
-
-        if (isset($filters['point_id'])) {
-            $query = $query->where('point_id', $filters['point_id']);
-        }
-
-        if (isset($filters['status'])) {
-            $query = $query->where('status', $filters['status']);
-        }
-
-        if (isset($filters['start_time']) && isset($filters['end_time'])) {
-            $query = $query->whereBetween('create_time', [$filters['start_time'], $filters['end_time']]);
-        }
-
-        return $query->orderBy('create_time', 'desc');
-    }
 }

+ 0 - 168
app/Module/Point/Repositorys/PointCirculationRepository.php

@@ -16,172 +16,4 @@ class PointCirculationRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointCirculationModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('create_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取流转统计
-     *
-     * @param int|null $userId
-     * @return array
-     */
-    public function getCirculationStats(?int $userId = null): array
-    {
-        $query = $this->model();
-        
-        if ($userId !== null) {
-            $query->where('user_id', $userId);
-        }
-
-        $records = $query->get();
-        
-        $stats = [
-            'total_records' => $records->count(),
-            'total_amount' => 0,
-            'by_status' => [
-                'pending' => 0,
-                'completed' => 0,
-                'failed' => 0,
-            ],
-            'by_point_type' => [],
-        ];
-
-        foreach ($records as $record) {
-            $stats['total_amount'] += $record->amount;
-
-            switch ($record->status) {
-                case PointCirculationModel::STATUS_PENDING:
-                    $stats['by_status']['pending']++;
-                    break;
-                case PointCirculationModel::STATUS_COMPLETED:
-                    $stats['by_status']['completed']++;
-                    break;
-                case PointCirculationModel::STATUS_FAILED:
-                    $stats['by_status']['failed']++;
-                    break;
-            }
-
-            $fromTypeName = $record->getFromPointTypeName();
-            $toTypeName = $record->getToPointTypeName();
-            $flowKey = "{$fromTypeName} → {$toTypeName}";
-            
-            if (!isset($stats['by_point_type'][$flowKey])) {
-                $stats['by_point_type'][$flowKey] = [
-                    'count' => 0,
-                    'amount' => 0,
-                ];
-            }
-            
-            $stats['by_point_type'][$flowKey]['count']++;
-            $stats['by_point_type'][$flowKey]['amount'] += $record->amount;
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 搜索流转记录
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where('user_id', $filters['user_id']);
-        }
-
-        if (isset($filters['from_point_id'])) {
-            $query = $query->where('from_point_id', $filters['from_point_id']);
-        }
-
-        if (isset($filters['to_point_id'])) {
-            $query = $query->where('to_point_id', $filters['to_point_id']);
-        }
-
-        if (isset($filters['status'])) {
-            $query = $query->where('status', $filters['status']);
-        }
-
-        if (isset($filters['re_type'])) {
-            $query = $query->where('re_type', $filters['re_type']);
-        }
-
-        if (isset($filters['start_time']) && isset($filters['end_time'])) {
-            $query = $query->whereBetween('create_time', [$filters['start_time'], $filters['end_time']]);
-        }
-
-        return $query->orderBy('create_time', 'desc');
-    }
 }

+ 0 - 127
app/Module/Point/Repositorys/PointConfigRepository.php

@@ -16,131 +16,4 @@ class PointConfigRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointConfigModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->with(['currency'])
-            ->orderBy('type')
-            ->orderBy('id');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->with(['currency'])->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取积分类型选项
-     *
-     * @return array
-     */
-    public function getPointTypeOptions(): array
-    {
-        return $this->model()
-            ->pluck('name', 'type')
-            ->toArray();
-    }
-
-    /**
-     * 检查积分类型是否已存在
-     *
-     * @param int $type
-     * @param int|null $excludeId
-     * @return bool
-     */
-    public function typeExists(int $type, ?int $excludeId = null): bool
-    {
-        $query = $this->model()->where('type', $type);
-        
-        if ($excludeId !== null) {
-            $query->where('id', '!=', $excludeId);
-        }
-        
-        return $query->exists();
-    }
-
-    /**
-     * 获取积分配置统计
-     *
-     * @return array
-     */
-    public function getConfigStats(): array
-    {
-        $configs = $this->model()->with(['currency'])->get();
-        
-        $stats = [
-            'total_configs' => $configs->count(),
-            'by_currency' => [],
-        ];
-
-        foreach ($configs as $config) {
-            $currencyName = $config->currency ? $config->currency->name : '未知';
-            if (!isset($stats['by_currency'][$currencyName])) {
-                $stats['by_currency'][$currencyName] = 0;
-            }
-            $stats['by_currency'][$currencyName]++;
-        }
-
-        return $stats;
-    }
 }

+ 0 - 146
app/Module/Point/Repositorys/PointCurrencyRepository.php

@@ -16,150 +16,4 @@ class PointCurrencyRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointCurrencyModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('type')
-            ->orderBy('id');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取积分类型选项
-     *
-     * @return array
-     */
-    public function getCurrencyOptions(): array
-    {
-        return $this->model()
-            ->pluck('name', 'id')
-            ->toArray();
-    }
-
-    /**
-     * 检查积分类型是否已存在
-     *
-     * @param int $type
-     * @param int|null $excludeId
-     * @return bool
-     */
-    public function typeExists(int $type, ?int $excludeId = null): bool
-    {
-        $query = $this->model()->where('type', $type);
-        
-        if ($excludeId !== null) {
-            $query->where('id', '!=', $excludeId);
-        }
-        
-        return $query->exists();
-    }
-
-    /**
-     * 检查标识是否已存在
-     *
-     * @param string $identification
-     * @param int|null $excludeId
-     * @return bool
-     */
-    public function identificationExists(string $identification, ?int $excludeId = null): bool
-    {
-        $query = $this->model()->where('identification', $identification);
-        
-        if ($excludeId !== null) {
-            $query->where('id', '!=', $excludeId);
-        }
-        
-        return $query->exists();
-    }
-
-    /**
-     * 获取积分类型统计
-     *
-     * @return array
-     */
-    public function getCurrencyStats(): array
-    {
-        $currencies = $this->model()->get();
-        
-        $stats = [
-            'total_currencies' => $currencies->count(),
-            'by_type' => [],
-        ];
-
-        foreach ($currencies as $currency) {
-            $typeName = $currency->getCurrencyName();
-            $stats['by_type'][$typeName] = [
-                'id' => $currency->id,
-                'identification' => $currency->identification,
-                'icon' => $currency->icon,
-                'create_time' => $currency->create_time,
-            ];
-        }
-
-        return $stats;
-    }
 }

+ 0 - 181
app/Module/Point/Repositorys/PointLogRepository.php

@@ -16,185 +16,4 @@ class PointLogRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointLogModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('create_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取用户积分日志统计
-     *
-     * @param int $userId
-     * @param int|null $pointId
-     * @return array
-     */
-    public function getUserLogStats(int $userId, ?int $pointId = null): array
-    {
-        $query = $this->model()->where('user_id', $userId);
-        
-        if ($pointId !== null) {
-            $query->where('point_id', $pointId);
-        }
-
-        $logs = $query->get();
-        
-        $stats = [
-            'total_logs' => $logs->count(),
-            'total_income' => 0,
-            'total_expense' => 0,
-            'income_count' => 0,
-            'expense_count' => 0,
-        ];
-
-        foreach ($logs as $log) {
-            if ($log->amount > 0) {
-                $stats['total_income'] += $log->amount;
-                $stats['income_count']++;
-            } else {
-                $stats['total_expense'] += abs($log->amount);
-                $stats['expense_count']++;
-            }
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 获取积分操作类型统计
-     *
-     * @return array
-     */
-    public function getOperateTypeStats(): array
-    {
-        $stats = $this->model()
-            ->selectRaw('operate_type, COUNT(*) as count, SUM(amount) as total_amount')
-            ->groupBy('operate_type')
-            ->get()
-            ->toArray();
-
-        return $stats;
-    }
-
-    /**
-     * 搜索积分日志
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where('user_id', $filters['user_id']);
-        }
-
-        if (isset($filters['point_id'])) {
-            $query = $query->where('point_id', $filters['point_id']);
-        }
-
-        if (isset($filters['operate_type'])) {
-            $query = $query->where('operate_type', $filters['operate_type']);
-        }
-
-        if (isset($filters['start_time']) && isset($filters['end_time'])) {
-            $query = $query->whereBetween('create_time', [$filters['start_time'], $filters['end_time']]);
-        }
-
-        if (isset($filters['min_amount'])) {
-            $query = $query->where('amount', '>=', $filters['min_amount']);
-        }
-
-        if (isset($filters['max_amount'])) {
-            $query = $query->where('amount', '<=', $filters['max_amount']);
-        }
-
-        return $query->orderBy('create_time', 'desc');
-    }
-
-    /**
-     * 获取每日积分变化统计
-     *
-     * @param int $days
-     * @return array
-     */
-    public function getDailyStats(int $days = 30): array
-    {
-        $endTime = time();
-        $startTime = $endTime - ($days * 24 * 60 * 60);
-
-        $logs = $this->model()
-            ->whereBetween('create_time', [$startTime, $endTime])
-            ->selectRaw('DATE(FROM_UNIXTIME(create_time)) as date, COUNT(*) as count, SUM(amount) as total_amount')
-            ->groupBy('date')
-            ->orderBy('date')
-            ->get()
-            ->toArray();
-
-        return $logs;
-    }
 }

+ 0 - 184
app/Module/Point/Repositorys/PointOrderRepository.php

@@ -16,188 +16,4 @@ class PointOrderRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointOrderModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('create_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取订单统计
-     *
-     * @param int|null $userId
-     * @return array
-     */
-    public function getOrderStats(?int $userId = null): array
-    {
-        $query = $this->model();
-        
-        if ($userId !== null) {
-            $query->where('user_id', $userId);
-        }
-
-        $orders = $query->get();
-        
-        $stats = [
-            'total_orders' => $orders->count(),
-            'total_amount' => 0,
-            'by_status' => [],
-            'by_order_type' => [],
-            'income_orders' => 0,
-            'expense_orders' => 0,
-            'income_amount' => 0,
-            'expense_amount' => 0,
-        ];
-
-        foreach ($orders as $order) {
-            $stats['total_amount'] += $order->amount;
-
-            // 按状态统计
-            $statusName = $order->getStatusName();
-            if (!isset($stats['by_status'][$statusName])) {
-                $stats['by_status'][$statusName] = 0;
-            }
-            $stats['by_status'][$statusName]++;
-
-            // 按订单类型统计
-            $orderTypeName = $order->getOrderTypeName();
-            if (!isset($stats['by_order_type'][$orderTypeName])) {
-                $stats['by_order_type'][$orderTypeName] = [
-                    'count' => 0,
-                    'amount' => 0,
-                ];
-            }
-            $stats['by_order_type'][$orderTypeName]['count']++;
-            $stats['by_order_type'][$orderTypeName]['amount'] += $order->amount;
-
-            // 收入支出统计
-            if ($order->isIncomeOrder()) {
-                $stats['income_orders']++;
-                $stats['income_amount'] += $order->amount;
-            } elseif ($order->isExpenseOrder()) {
-                $stats['expense_orders']++;
-                $stats['expense_amount'] += $order->amount;
-            }
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 搜索订单记录
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where('user_id', $filters['user_id']);
-        }
-
-        if (isset($filters['point_id'])) {
-            $query = $query->where('point_id', $filters['point_id']);
-        }
-
-        if (isset($filters['order_type'])) {
-            $query = $query->where('order_type', $filters['order_type']);
-        }
-
-        if (isset($filters['status'])) {
-            $query = $query->where('status', $filters['status']);
-        }
-
-        if (isset($filters['order_no'])) {
-            $query = $query->where('order_no', 'like', '%' . $filters['order_no'] . '%');
-        }
-
-        if (isset($filters['title'])) {
-            $query = $query->where('title', 'like', '%' . $filters['title'] . '%');
-        }
-
-        if (isset($filters['start_time']) && isset($filters['end_time'])) {
-            $query = $query->whereBetween('create_time', [$filters['start_time'], $filters['end_time']]);
-        }
-
-        return $query->orderBy('create_time', 'desc');
-    }
-
-    /**
-     * 根据订单号查找订单
-     *
-     * @param string $orderNo
-     * @return \Illuminate\Database\Eloquent\Model|null
-     */
-    public function findByOrderNo(string $orderNo)
-    {
-        return $this->model()->where('order_no', $orderNo)->first();
-    }
 }

+ 0 - 159
app/Module/Point/Repositorys/PointRepository.php

@@ -16,163 +16,4 @@ class PointRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('update_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取用户积分统计
-     *
-     * @param int $userId
-     * @return array
-     */
-    public function getUserPointStats(int $userId): array
-    {
-        $points = $this->model()->where('user_id', $userId)->get();
-        
-        $stats = [
-            'total_types' => $points->count(),
-            'total_balance' => $points->sum('balance'),
-            'details' => []
-        ];
-
-        foreach ($points as $point) {
-            $stats['details'][] = [
-                'point_id' => $point->point_id,
-                'balance' => $point->balance,
-                'create_time' => $point->create_time,
-                'update_time' => $point->update_time,
-            ];
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 获取积分类型统计
-     *
-     * @return array
-     */
-    public function getPointTypeStats(): array
-    {
-        $stats = $this->model()
-            ->selectRaw('point_id, COUNT(*) as user_count, SUM(balance) as total_balance, AVG(balance) as avg_balance')
-            ->groupBy('point_id')
-            ->get()
-            ->toArray();
-
-        return $stats;
-    }
-
-    /**
-     * 获取积分排行榜
-     *
-     * @param int $pointId
-     * @param int $limit
-     * @return array
-     */
-    public function getPointRanking(int $pointId, int $limit = 100): array
-    {
-        return $this->model()
-            ->where('point_id', $pointId)
-            ->where('balance', '>', 0)
-            ->orderBy('balance', 'desc')
-            ->limit($limit)
-            ->get()
-            ->toArray();
-    }
-
-    /**
-     * 搜索用户积分
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where('user_id', $filters['user_id']);
-        }
-
-        if (isset($filters['point_id'])) {
-            $query = $query->where('point_id', $filters['point_id']);
-        }
-
-        if (isset($filters['min_balance'])) {
-            $query = $query->where('balance', '>=', $filters['min_balance']);
-        }
-
-        if (isset($filters['max_balance'])) {
-            $query = $query->where('balance', '<=', $filters['max_balance']);
-        }
-
-        return $query->orderBy('balance', 'desc');
-    }
 }

+ 0 - 172
app/Module/Point/Repositorys/PointTransferRepository.php

@@ -16,176 +16,4 @@ class PointTransferRepository extends EloquentRepository
      * 模型类名
      */
     protected $eloquentClass = PointTransferModel::class;
-
-    /**
-     * 获取表格数据
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function grid()
-    {
-        return $this->model()
-            ->orderBy('create_time', 'desc')
-            ->orderBy('id', 'desc');
-    }
-
-    /**
-     * 获取详情数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function detail($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 获取编辑数据
-     *
-     * @param mixed $key
-     * @return \Illuminate\Database\Eloquent\Model
-     */
-    public function edit($key)
-    {
-        return $this->model()->findOrFail($key);
-    }
-
-    /**
-     * 新增数据
-     *
-     * @param array $data
-     * @return mixed
-     */
-    public function store(array $data)
-    {
-        $data['create_time'] = time();
-        $data['update_time'] = time();
-        return $this->model()->create($data);
-    }
-
-    /**
-     * 更新数据
-     *
-     * @param mixed $key
-     * @param array $data
-     * @return bool
-     */
-    public function update($key, array $data)
-    {
-        $data['update_time'] = time();
-        return $this->model()->findOrFail($key)->update($data);
-    }
-
-    /**
-     * 删除数据
-     *
-     * @param mixed $key
-     * @return bool
-     */
-    public function destroy($key)
-    {
-        return $this->model()->findOrFail($key)->delete();
-    }
-
-    /**
-     * 获取转账统计
-     *
-     * @param int|null $userId
-     * @return array
-     */
-    public function getTransferStats(?int $userId = null): array
-    {
-        $query = $this->model();
-        
-        if ($userId !== null) {
-            $query->where(function($q) use ($userId) {
-                $q->where('from_user_id', $userId)->orWhere('to_user_id', $userId);
-            });
-        }
-
-        $records = $query->get();
-        
-        $stats = [
-            'total_records' => $records->count(),
-            'total_amount' => 0,
-            'transfer_out_count' => 0,
-            'transfer_in_count' => 0,
-            'transfer_out_amount' => 0,
-            'transfer_in_amount' => 0,
-            'by_status' => [
-                'pending' => 0,
-                'completed' => 0,
-                'failed' => 0,
-            ],
-        ];
-
-        foreach ($records as $record) {
-            $stats['total_amount'] += $record->amount;
-
-            if ($userId !== null) {
-                if ($record->from_user_id === $userId) {
-                    $stats['transfer_out_count']++;
-                    $stats['transfer_out_amount'] += $record->amount;
-                } else {
-                    $stats['transfer_in_count']++;
-                    $stats['transfer_in_amount'] += $record->amount;
-                }
-            }
-
-            switch ($record->status) {
-                case PointTransferModel::STATUS_PENDING:
-                    $stats['by_status']['pending']++;
-                    break;
-                case PointTransferModel::STATUS_COMPLETED:
-                    $stats['by_status']['completed']++;
-                    break;
-                case PointTransferModel::STATUS_FAILED:
-                    $stats['by_status']['failed']++;
-                    break;
-            }
-        }
-
-        return $stats;
-    }
-
-    /**
-     * 搜索转账记录
-     *
-     * @param array $filters
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function search(array $filters)
-    {
-        $query = $this->model();
-
-        if (isset($filters['from_user_id'])) {
-            $query = $query->where('from_user_id', $filters['from_user_id']);
-        }
-
-        if (isset($filters['to_user_id'])) {
-            $query = $query->where('to_user_id', $filters['to_user_id']);
-        }
-
-        if (isset($filters['user_id'])) {
-            $query = $query->where(function($q) use ($filters) {
-                $q->where('from_user_id', $filters['user_id'])
-                  ->orWhere('to_user_id', $filters['user_id']);
-            });
-        }
-
-        if (isset($filters['point_id'])) {
-            $query = $query->where('point_id', $filters['point_id']);
-        }
-
-        if (isset($filters['status'])) {
-            $query = $query->where('status', $filters['status']);
-        }
-
-        if (isset($filters['start_time']) && isset($filters['end_time'])) {
-            $query = $query->whereBetween('create_time', [$filters['start_time'], $filters['end_time']]);
-        }
-
-        return $query->orderBy('create_time', 'desc');
-    }
 }