|
|
@@ -336,16 +336,19 @@ class Product extends Controller
|
|
|
->where(function ($query) use ($Product, $sampling_start_time, $sampling_end_time) {
|
|
|
// 新增记录有完整的时间段
|
|
|
if ($sampling_start_time > 0 && $sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($sampling_start_time,$sampling_end_time ) {
|
|
|
+ $query->orwhere(function ($q) use ($sampling_end_time,$sampling_start_time ) {
|
|
|
$q->where('sampling_start_time', '<=', $sampling_end_time)
|
|
|
->where('sampling_end_time', '>=', $sampling_start_time);
|
|
|
+ })->orwhere(function ($q) use ($sampling_start_time ) {
|
|
|
+ $q->where('sampling_start_time', '<=', $sampling_start_time)
|
|
|
+ ->where('sampling_end_time', '=', 0);
|
|
|
});
|
|
|
}
|
|
|
// 新增记录只有开始时间(没有结束时间,表示从开始时间到无限)
|
|
|
elseif ($sampling_start_time > 0 && $sampling_end_time == 0) {
|
|
|
$query->where(function ($q) use ($sampling_start_time) {
|
|
|
// 已存在记录的开始时间 <= 新增记录的开始时间
|
|
|
- $q->where('sampling_end_time', '>=', $sampling_start_time);
|
|
|
+ $q->where('sampling_start_time', '<=', $sampling_start_time);
|
|
|
});
|
|
|
}
|
|
|
// 新增记录只有结束时间
|
|
|
@@ -354,12 +357,6 @@ class Product extends Controller
|
|
|
$q->where('sampling_start_time', '<=', $Product->sampling_end_time);
|
|
|
});
|
|
|
}
|
|
|
- // 新增记录有完整的时间段,数据库有开始时间结束时间未设置
|
|
|
- elseif ($sampling_start_time > 0 && $sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($sampling_start_time ) {
|
|
|
- $q->where('sampling_start_time', '<=', $sampling_start_time);
|
|
|
- });
|
|
|
- }
|
|
|
})
|
|
|
->first();
|
|
|
|
|
|
@@ -489,9 +486,12 @@ class Product extends Controller
|
|
|
->where(function ($query) use ($Product, $sampling_start_time, $sampling_end_time) {
|
|
|
// 新增记录有完整的时间段
|
|
|
if ($sampling_start_time > 0 && $sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($sampling_start_time,$sampling_end_time ) {
|
|
|
+ $query->orwhere(function ($q) use ($sampling_end_time,$sampling_start_time ) {
|
|
|
$q->where('sampling_start_time', '<=', $sampling_end_time)
|
|
|
->where('sampling_end_time', '>=', $sampling_start_time);
|
|
|
+ })->orwhere(function ($q) use ($sampling_start_time ) {
|
|
|
+ $q->where('sampling_start_time', '<=', $sampling_start_time)
|
|
|
+ ->where('sampling_end_time', '=', 0);
|
|
|
});
|
|
|
}
|
|
|
// 新增记录只有开始时间(没有结束时间,表示从开始时间到无限)
|
|
|
@@ -507,12 +507,6 @@ class Product extends Controller
|
|
|
$q->where('sampling_start_time', '<=', $Product->sampling_end_time);
|
|
|
});
|
|
|
}
|
|
|
- // 新增记录有完整的时间段,数据库有开始时间结束时间未设置
|
|
|
- elseif ($Product->sampling_start_time > 0 && $Product->sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($Product ) {
|
|
|
- $q->where('sampling_start_time', '<=', $Product->sampling_start_time);
|
|
|
- });
|
|
|
- }
|
|
|
})
|
|
|
->first();
|
|
|
|
|
|
@@ -619,9 +613,12 @@ class Product extends Controller
|
|
|
->where(function ($query) use ($Product) {
|
|
|
// 新增记录有完整的时间段
|
|
|
if ($Product->sampling_start_time > 0 && $Product->sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($Product ) {
|
|
|
+ $query->orwhere(function ($q) use ($Product ) {
|
|
|
$q->where('sampling_start_time', '<=', $Product->sampling_end_time)
|
|
|
->where('sampling_end_time', '>=', $Product->sampling_start_time);
|
|
|
+ })->orwhere(function ($q) use ($Product ) {
|
|
|
+ $q->where('sampling_start_time', '<=', $Product->sampling_start_time)
|
|
|
+ ->where('sampling_end_time', '=', 0);
|
|
|
});
|
|
|
}
|
|
|
// 新增记录只有开始时间(没有结束时间,表示从开始时间到无限)
|
|
|
@@ -637,12 +634,6 @@ class Product extends Controller
|
|
|
$q->where('sampling_start_time', '<=', $Product->sampling_end_time);
|
|
|
});
|
|
|
}
|
|
|
- // 新增记录有完整的时间段,数据库有开始时间结束时间未设置
|
|
|
- elseif ($Product->sampling_start_time > 0 && $Product->sampling_end_time > 0) {
|
|
|
- $query->where(function ($q) use ($Product ) {
|
|
|
- $q->where('sampling_start_time', '<=', $Product->sampling_start_time);
|
|
|
- });
|
|
|
- }
|
|
|
})
|
|
|
->first();
|
|
|
|