Commit 4c23d36f by 杨树贤

优化mysql查询

parent b5e29e55
......@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Filter;
use App\Http\Services\AdminUserService;
use App\Http\Services\DepartmentService;
use App\Model\SupplierAttachmentsModel;
use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
......@@ -150,12 +151,12 @@ class SupplierFilter
//获取没有平台合作协议的数据
if (!empty($map['has_cooperation_agreement'])) {
if ($map['has_cooperation_agreement'] == 1) {
$query->whereHas('attachment', function ($query) {
$query->where('field_name', 'cooperation_agreement');
$query->whereIn('supplier_id', function ($query) {
$query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
});
} else {
$query->whereDoesntHave('attachment', function ($query) {
$query->where('field_name', 'cooperation_agreement');
$query->whereNotIn('supplier_id', function ($query) {
$query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
});
}
}
......@@ -388,9 +389,9 @@ class SupplierFilter
})->where('uploaded_sku', 1);
break;
case "no_cooperation_agreement":
$query->whereDoesntHave('attachment', function ($query) {
$query->where('field_name', 'cooperation_agreement');
})->where('uploaded_sku', 1);
$query->whereNotIn('supplier_id', function ($query) {
$query->select('supplier_id')->from(with(new SupplierAttachmentsModel())->getTable())->where('field_name','cooperation_agreement');
});
break;
}
return $query;
......
......@@ -115,7 +115,7 @@ class SupplierStatisticsService
return $value;
}, $result);
$redis->set($statisticsKey, json_encode($result));
$redis->expire($statisticsKey, 50);
$redis->expire($statisticsKey, 600);
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