소스 검색

fixed:清理无用代码

刘学玺 4 달 전
부모
커밋
f6d1822682

+ 0 - 4
app/Http/Controllers/Client/AccountController.php

@@ -7,11 +7,7 @@ use App\Services\Client\AccountService;
 use Illuminate\Http\Request;
 
 /**
-<<<<<<< HEAD
- * @group 账户管理
-=======
  * @group 用户端
->>>>>>> 70ed7591819346761bf23d2dd8032db40c2cf57e
  *
  * 包含登录、注册、账户管理等基础功能
  */

+ 0 - 84
app/Http/Controllers/Client/CommentController.php

@@ -1,84 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Client;
-
-use App\Http\Controllers\Controller;
-use App\Services\Client\CommentService;
-use Illuminate\Http\Request;
-
-/**
- * @group 用户端
- *
- * 评论相关的API接口
- */
-class CommentController extends Controller
-{
-    protected CommentService $service;
-
-    public function __construct(CommentService $service)
-    {
-        $this->service = $service;
-    }
-
-    /**
-     * 发表评价
-     *
-     * 发表评价
-     *
-     * @authenticated
-     *
-     * @bodyParam coach_id int required 技师ID. Example: 1
-     * @bodyParam content string required 评价内容. Example: 很棒的服务!
-     * @bodyParam rating int required 评分. Example: 5
-     *
-     * @response {
-     *   "code": 200,
-     *   "message": "评价成功",
-     *   "data": {
-     *     "id": 1,
-     *     "coach_id": 1,
-     *     "content": "很棒的服务!",
-     *     "rating": 5,
-     *     "created_at": "2024-01-01 10:00:00"
-     *   }
-     * }
-     */
-    public function create(Request $request)
-    {
-        $coachId = $request->input('coach_id');
-        $content = $request->input('content');
-        $rating = $request->input('rating');
-
-        return $this->service->createComment($coachId, $content, $rating);
-    }
-
-    /**
-     * 评价列表
-     *
-     * 获取评价列表
-     *
-     * @authenticated
-     *
-     * @queryParam coach_id int required 技师ID. Example: 1
-     *
-     * @response {
-     *   "code": 200,
-     *   "message": "获取成功",
-     *   "data": [
-     *     {
-     *       "id": 1,
-     *       "coach_id": 1,
-     *       "content": "很棒的服务!",
-     *       "rating": 5,
-     *       "created_at": "2024-01-01 10:00:00"
-     *     }
-     *   ]
-     * }
-     */
-    public function list(Request $request)
-    {
-        $coachId = $request->input('coach_id');
-
-        return $this->service->getCommentList($coachId);
-    }
-}

+ 0 - 97
app/Http/Controllers/Client/CommonController.php

@@ -1,97 +0,0 @@
-<?php
-
-namespace App\Http\Controllers\Client;
-
-use App\Http\Controllers\Controller;
-use App\Services\Client\CommonService;
-use Illuminate\Http\Request;
-
-/**
- * @group 用户端
- *
- * 公共相关的API接口
- */
-class CommonController extends Controller
-{
-    protected CommonService $service;
-
-    public function __construct(CommonService $service)
-    {
-        $this->service = $service;
-    }
-
-    /**
-     * 获取代理商配置
-     *
-     * 获取指定代理商的配置信息
-     *
-     * @authenticated
-     *
-     * @bodyParam agent_id int required 代理商ID. Example: 1
-     *
-     * @response {
-     *   "min_distance": 0,
-     *   "min_fee": 0,
-     *   "per_km_fee": 0
-     * }
-     */
-    public function getConfig(Request $request)
-    {
-        $agentId = $request->input('agent_id');
-
-        return $this->service->getAgentConfig($agentId);
-    }
-
-    /**
-     * 获取技师配置
-     *
-     * 获取指定技师的配置信息
-     *
-     * @authenticated
-     *
-     * @bodyParam coach_id int required 技师ID. Example: 1
-     *
-     * @response {
-     *   "delivery_fee_type": "round_trip",
-     *   "charge_delivery_fee": true
-     * }
-     */
-    public function getCoachConfig(Request $request)
-    {
-        $coachId = $request->input('coach_id');
-
-        return $this->service->getCoachConfig($coachId);
-    }
-
-    /**
-     * 计算路费金额
-     *
-     * 根据距离和其他参数计算路费
-     *
-     * @authenticated
-     *
-     * @bodyParam coach_id int required 技师ID. Example: 1
-     * @bodyParam agent_id int 可选 代理商ID. Example: 1
-     * @bodyParam distance float required 距离. Example: 10.5
-     * @bodyParam latitude float 纬度. Example: 34.0522
-     * @bodyParam longitude float 经度. Example: -118.2437
-     *
-     * @response {
-     *   "fee": 15.75
-     * }
-     */
-    public function calculateDeliveryFee(Request $request)
-    {
-        $coachId = $request->input('coach_id');
-        $agentId = $request->input('agent_id');
-        $distance = $request->input('distance');
-        $latitude = $request->input('latitude');
-        $longitude = $request->input('longitude');
-
-        if ($agentId) {
-            return $this->service->calculateDeliveryFee($coachId, $agentId, $distance);
-        } else {
-            return $this->service->calculateDeliveryFeeByLocation($coachId, $latitude, $longitude, $distance);
-        }
-    }
-}

+ 2 - 1
app/Http/Controllers/Client/ExtendOrderController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Client;
 use App\Http\Controllers\Controller;
 use App\Services\Client\ExtendOrderService;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
 
 /**
  * @group 用户端
@@ -37,6 +38,6 @@ class ExtendOrderController extends Controller
     {
         $orderId = $request->route('order_id');
 
-        return $this->service->extend($orderId);
+        return $this->service->extend(Auth::user()->id, $orderId);
     }
 }

+ 0 - 64
app/Services/Client/CommentService.php

@@ -1,64 +0,0 @@
-<?php
-
-namespace App\Services\Client;
-
-use App\Models\OrderComment;
-use App\Models\CoachUser;
-use App\Models\MemberUser;
-use Illuminate\Support\Facades\Auth;
-
-class CommentService
-{
-    /**
-     * 创建评价
-     */
-    public function createComment(int $coachId, string $content, int $rating)
-    {
-        // 获取当前用户
-        $userId = Auth::id();
-        $user = MemberUser::findOrFail($userId);
-        
-        // 检查用户状态
-        if ($user->state !== 'enable') {
-            throw new \Exception('用户状态异常');
-        }
-        
-        // 检查技师是否存在
-        $coach = CoachUser::findOrFail($coachId);
-        
-        // 创建评价
-        $comment = new OrderComment();
-        $comment->user_id = $userId;
-        $comment->coach_id = $coachId;
-        $comment->content = $content;
-        $comment->rating = $rating;
-        $comment->state = 'enable';
-        $comment->save();
-        
-        return ['message' => '评价成功'];
-    }
-    
-    /**
-     * 获取评价列表
-     */
-    public function getCommentList(int $coachId)
-    {
-        // 获取当前用户
-        $userId = Auth::id();
-        $user = MemberUser::findOrFail($userId);
-        
-        // 检查用户状态
-        if ($user->state !== 'enable') {
-            throw new \Exception('用户状态异常');
-        }
-        
-        // 获取评价列表
-        $comments = OrderComment::where('coach_id', $coachId)
-            ->where('state', 'enable')
-            ->orderBy('created_at', 'desc')
-            ->with(['user:id,nickname,avatar'])
-            ->paginate(10);
-            
-        return $comments;
-    }
-} 

+ 0 - 125
app/Services/Client/CommonService.php

@@ -1,125 +0,0 @@
-<?php
-
-namespace App\Services\Client;
-
-use App\Models\AgentInfo;
-use App\Models\AgentConfig;
-use App\Models\CoachConfig;
-use Exception;
-
-class CommonService
-{
-    /**
-     * 获取代理商配置
-     *
-     * @param int $agentId 代理商编号
-     * @return array
-     * @throws Exception
-     */
-    public function getAgentConfig($agentId)
-    {
-        // 检查代理商是否存在
-        $agent = AgentInfo::find($agentId);
-        if (!$agent) {
-            throw new Exception('代理商不存在');
-        }
-
-        // 获取代理商配置
-        $config = AgentConfig::where('agent_id', $agentId)->first();
-        if (!$config) {
-            throw new Exception('代理商配置不存在');
-        }
-
-        return [
-            'agent_id' => $config->agent_id,
-            'min_distance' => $config->min_distance, // 最小路程
-            'min_fee' => $config->min_fee, // 最小路费金额  
-            'per_km_fee' => $config->per_km_fee, // 每公里路程单价
-            'commission_rate' => $config->commission_rate, // 佣金比例
-            'created_at' => $config->created_at,
-            'updated_at' => $config->updated_at
-        ];
-    }
-
-    /**
-     * 获取技师配置
-     * 
-     * @param int $coachId 技师编号
-     * @return array
-     * @throws Exception
-     */
-    public function getCoachConfig($coachId) 
-    {
-        $config = CoachConfig::where('coach_id', $coachId)->first();
-        if (!$config) {
-            throw new Exception('技师配置不存在');
-        }
-
-        return [
-            'coach_id' => $config->coach_id,
-            'delivery_fee_enabled' => $config->delivery_fee_enabled, // 是否收取路费
-            'delivery_fee_type' => $config->delivery_fee_type, // 路费类型:单程/往返
-            'created_at' => $config->created_at,
-            'updated_at' => $config->updated_at
-        ];
-    }
-
-    /**
-     * 根据代理商ID计算路费
-     */
-    public function calculateDeliveryFee($coachId, $agentId, $distance)
-    {
-        // 获取技师配置
-        $coachConfig = $this->getCoachConfig($coachId);
-        
-        // 如果技师不收取路费
-        if (!$coachConfig['delivery_fee_enabled']) {
-            return 0;
-        }
-
-        // 获取代理商配置
-        $agentConfig = $this->getAgentConfig($agentId);
-        
-        // 计算单程路费
-        $onewayFee = $this->calculateOnewayFee($distance, $agentConfig);
-
-        // 根据技师配置返回单程或往返路费
-        return $coachConfig['delivery_fee_type'] == 'round_trip' ? $onewayFee * 2 : $onewayFee;
-    }
-
-    /**
-     * 根据位置计算路费
-     */
-    public function calculateDeliveryFeeByLocation($coachId, $latitude, $longitude, $distance)
-    {
-        // 根据经纬度查询代理商
-        $agent = AgentInfo::whereRaw("ST_Contains(business_area_polygon, ST_GeomFromText('POINT($longitude $latitude)'))")
-            ->first();
-            
-        if (!$agent) {
-            throw new Exception('该区域暂无代理商');
-        }
-
-        return $this->calculateDeliveryFee($coachId, $agent->id, $distance);
-    }
-
-    /**
-     * 计算单程路费
-     */
-    private function calculateOnewayFee($distance, $agentConfig)
-    {
-        // 如果路程小于等于最小路程
-        if ($distance <= $agentConfig['min_distance']) {
-            return $agentConfig['min_fee'];
-        }
-
-        // 超出的路程
-        $extraDistance = $distance - $agentConfig['min_distance'];
-        
-        // 计算超出部分的费用
-        $extraFee = $extraDistance * $agentConfig['per_km_fee'];
-        
-        // 返回总费用
-        return $agentConfig['min_fee'] + $extraFee;
-    }
-} 

+ 7 - 8
app/Services/Client/ExtendOrderService.php

@@ -2,9 +2,8 @@
 
 namespace App\Services\Client;
 
-use App\Models\Order;
+use App\Models\MemberUser;
 use App\Models\Project;
-use Exception;
 
 class ExtendOrderService
 {
@@ -15,7 +14,7 @@ class ExtendOrderService
     {
         // 查询项目
         $project = Project::findOrFail($projectId);
-        
+
         // 查询加钟分类的项目列表
         $projects = Project::where('state', 'enable')
             ->where('type', 'extend')
@@ -30,15 +29,15 @@ class ExtendOrderService
     /**
      * 加钟
      */
-    public function extend($orderId)
+    public function extend($userId, $orderId)
     {
+        $user = MemberUser::findOrFail($userId);
         // 查询原订单
-        $order = Order::where('id', $orderId)
-            ->where('user_id', auth()->id())
-            ->firstOrFail();
+        $order = $user->orders()->where('id', $orderId)->firstOrFail();
 
         // 创建加钟订单
         $orderService = app(OrderService::class);
+
         return $orderService->createOrder(
             $order->address_id,
             $order->coach_id,
@@ -48,4 +47,4 @@ class ExtendOrderService
             $orderId
         );
     }
-} 
+}