|
@@ -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;
|
|
|
}
|
|
|
-}
|
|
|
+}
|