|
|
@@ -8714,35 +8714,40 @@ class NewsService implements NewsServiceInterface
|
|
|
{
|
|
|
$page = $data['page'] ?? 1;
|
|
|
$page_size = $data['page_size'] ?? 10;
|
|
|
+ $where = [];
|
|
|
if(isset($data['zwname']) && !empty($data['zwname'])){
|
|
|
- $where = ['zwname', 'like', '%' . $data['zwname'] . '%'];
|
|
|
- }else{
|
|
|
- $where = [];
|
|
|
- }
|
|
|
- if($data['is_pid'] == 0){
|
|
|
$zwids = JobPosition::where('zwpid', 0)
|
|
|
- ->when(!empty($where), function ($query) use ($where) {
|
|
|
- $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
+ ->when(!empty($data['zwname']), function ($query) use ($data) {
|
|
|
+ $query->where('zwname', 'like', '%' . $data['zwname'] . '%');
|
|
|
})
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
- ->pluck('zwid');
|
|
|
- }else{
|
|
|
- $zwids = JobPosition::where('zwpid', '!=', 0)
|
|
|
- ->when(!empty($where), function ($query) use ($where) {
|
|
|
- $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
+ ->pluck('zwid')
|
|
|
+ // ->get()
|
|
|
+ ->toArray();
|
|
|
+ }
|
|
|
+ if(isset($data['childname']) && !empty($data['childname']))
|
|
|
+ {
|
|
|
+ $child_zwids = JobPosition::where('zwpid', '!=', 0)
|
|
|
+ ->when(!empty($data['childname']), function ($query) use ($data) {
|
|
|
+ $query->where('zwname', 'like', '%' . $data['childname'] . '%');
|
|
|
})
|
|
|
->orderBy('updated_at', 'desc')
|
|
|
- ->pluck('zwpid');
|
|
|
- $zwids = array_values(array_unique($zwids->toArray()));
|
|
|
+ ->pluck('zwpid')
|
|
|
+ // ->get()
|
|
|
+ ->toArray();
|
|
|
+ if(isset($zwids) && is_array($zwids) && is_array($child_zwids)){
|
|
|
+ $child_zwids = array_intersect($zwids, $child_zwids);
|
|
|
+ }
|
|
|
+ $zwids = array_values(array_unique($child_zwids));
|
|
|
}
|
|
|
$count = JobPosition::whereIn('zwid', $zwids)->count();
|
|
|
$position = JobPosition::whereIn('zwid', $zwids)
|
|
|
->offset(($page - 1) * $page_size)
|
|
|
->limit($page_size)->get()
|
|
|
- ->map(function ($item) use ($data, $where) {
|
|
|
+ ->map(function ($item) use ($data) {
|
|
|
$item->children = $item->where('zwpid', $item->zwid)
|
|
|
- ->when(!empty($where) && $data['is_pid'] == 1, function ($query) use ($where) {
|
|
|
- $query->where([$where]); // 修复:将条件包装成二维数组
|
|
|
+ ->when(!empty($data['childname']), function ($query) use ($data) {
|
|
|
+ $query->where('zwname', 'like', '%' . $data['childname'] . '%');
|
|
|
})
|
|
|
->get();
|
|
|
return $item;
|