Commit 4c23d36f by 杨树贤

优化mysql查询

parent b5e29e55
...@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Filter; ...@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Filter;
use App\Http\Services\AdminUserService; use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService; use App\Http\Services\DepartmentService;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
...@@ -150,12 +151,12 @@ class SupplierFilter ...@@ -150,12 +151,12 @@ class SupplierFilter
//获取没有平台合作协议的数据 //获取没有平台合作协议的数据
if (!empty($map['has_cooperation_agreement'])) { if (!empty($map['has_cooperation_agreement'])) {
if ($map['has_cooperation_agreement'] == 1) { if ($map['has_cooperation_agreement'] == 1) {
$query->whereHas('attachment', function ($query) { $query->whereIn('supplier_id', function ($query) {
$query->where('field_name', 'cooperation_agreement'); $query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
}); });
} else { } else {
$query->whereDoesntHave('attachment', function ($query) { $query->whereNotIn('supplier_id', function ($query) {
$query->where('field_name', 'cooperation_agreement'); $query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
}); });
} }
} }
...@@ -388,9 +389,9 @@ class SupplierFilter ...@@ -388,9 +389,9 @@ class SupplierFilter
})->where('uploaded_sku', 1); })->where('uploaded_sku', 1);
break; break;
case "no_cooperation_agreement": case "no_cooperation_agreement":
$query->whereDoesntHave('attachment', function ($query) { $query->whereNotIn('supplier_id', function ($query) {
$query->where('field_name', 'cooperation_agreement'); $query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
})->where('uploaded_sku', 1); });
break; break;
} }
return $query; return $query;
......
...@@ -115,7 +115,7 @@ class SupplierStatisticsService ...@@ -115,7 +115,7 @@ class SupplierStatisticsService
return $value; return $value;
}, $result); }, $result);
$redis->set($statisticsKey, json_encode($result)); $redis->set($statisticsKey, json_encode($result));
$redis->expire($statisticsKey, 50); $redis->expire($statisticsKey, 600);
return $result; return $result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment