فهرست منبع

fixed:计算订单金额

刘学玺 4 ماه پیش
والد
کامیت
93c5a8b26f
3فایلهای تغییر یافته به همراه16 افزوده شده و 50 حذف شده
  1. 0 32
      app/Http/Controllers/Client/OrderController.php
  2. 15 16
      app/Services/Client/AgentService.php
  3. 1 2
      routes/api.php

+ 0 - 32
app/Http/Controllers/Client/OrderController.php

@@ -234,38 +234,6 @@ class OrderController extends Controller
         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);
-        }
-    }
-
     /**
      * 计算订单金额
      *

+ 15 - 16
app/Services/Client/AgentService.php

@@ -2,10 +2,9 @@
 
 namespace App\Services\Client;
 
-use App\Models\AgentInfo;
 use App\Models\AgentConfig;
+use App\Models\AgentInfo;
 use App\Models\Project;
-use Exception;
 
 class AgentService
 {
@@ -20,13 +19,13 @@ class AgentService
             ->firstOrFail();
 
         // 获取代理商配置
-        $config = AgentConfig::where('agent_id', $agentId)->firstOrFail();
+        // $config = AgentConfig::where('agent_id', $agentId)->firstOrFail();
 
-        return [
-            'min_distance' => $config->min_distance,
-            'min_fee' => $config->min_fee,
-            'per_km_fee' => $config->per_km_fee
-        ];
+        // return [
+        //     'min_distance' => $config->min_distance,
+        //     'min_fee' => $config->min_fee,
+        //     'per_km_fee' => $config->per_km_fee
+        // ];
     }
 
     /**
@@ -39,7 +38,7 @@ class AgentService
             ->where('state', 'enable')
             ->first();
 
-        if (!$agent) {
+        if (! $agent) {
             // 如果找不到,按照市、省、全国逐级查找
             $areaCodeParts = str_split($areaCode, 2);
             foreach ($areaCodeParts as $index => $part) {
@@ -73,9 +72,9 @@ class AgentService
             $query->where('category_id', $categoryId);
         }
 
-        $projects = $query->whereHas('agents', function($q) use ($agentId) {
-                $q->where('agent_id', $agentId);
-            })
+        $projects = $query->whereHas('agents', function ($q) use ($agentId) {
+            $q->where('agent_id', $agentId);
+        })
             ->with(['category:id,name'])
             ->orderBy('sort', 'desc')
             ->paginate(10);
@@ -96,17 +95,17 @@ class AgentService
         // 查询项目
         $project = Project::where('id', $projectId)
             ->where('state', 'enable')
-            ->whereHas('agents', function($q) use ($agentId) {
+            ->whereHas('agents', function ($q) use ($agentId) {
                 $q->where('agent_id', $agentId);
             })
             ->with([
                 'category:id,name',
-                'agents' => function($q) use ($agentId) {
+                'agents' => function ($q) use ($agentId) {
                     $q->where('agent_id', $agentId);
-                }
+                },
             ])
             ->firstOrFail();
 
         return $project;
     }
-} 
+}

+ 1 - 2
routes/api.php

@@ -87,12 +87,11 @@ Route::middleware('auth:sanctum')->group(function () {
         Route::get('list', [OrderController::class, 'list']);
         Route::get('detail/{id}', [OrderController::class, 'detail']);
         Route::post('add-time', [OrderController::class, 'addTime']);
+        Route::post('calculate-order-amount', [OrderController::class, 'calculateOrderAmount']);
         // Route::post('refund/{id}', [OrderController::class, 'refund']);
         // Route::post('get-agent-config', [OrderController::class, 'getAgentConfig']);
         // Route::post('get-coach-config', [OrderController::class, 'getCoachConfig']);
         // Route::post('calculate-delivery-fee', [OrderController::class, 'calculateDeliveryFee']);
-        // Route::post('calculate-order-amount', [OrderController::class, 'calculateOrderAmount']);
-
     });
 
 });