field('rec_id,professions')->where('rec_id','=',$array['id'])->find(); empty($result) ? $msg = '暂无数据!' : $msg = '查询成功!'; //查询用户收藏的专业 $resCollect = []; if($user_id){ $resCollect = CollectNewMajor::getUserNewMajor($user_id); } if(empty($result)){ $arr = []; }else{ $res = json_decode($result['professions']); foreach ($res as $key => $val){ $arr[$key]['probability'] = $val->probability; $arr[$key]['professionName'] = $val->professionName; $arr[$key]['cost'] = $val->cost; $arr[$key]['professionCode'] = $val->professionCode; $arr[$key]['enterNum'] = $val->enterNum; $arr[$key]['planNum'] = $val->planNum; $arr[$key]['majorCode'] = $val->majorCode; $arr[$key]['recommendType'] = $val->recommendType; $arr[$key]['chooseCns'] = $val->chooseCns; $arr[$key]['rec_id'] = $result['rec_id']; $arr[$key]['lowestRank'] = $val->minSort;; $arr[$key]['minScore'] = $val->minScore; $arr[$key]['is_collect'] = 0;//收藏默认0,后期修改 if(is_array($resCollect)){ if(in_array($result['rec_id'].'_'.$val->majorCode.'_'.$val->professionCode,$resCollect)){ $arr[$key]['is_collect'] = 1; } } } } return $arr; } }