$cond = array(
'p'=>$p,
'b'=>$b,
'g'=>$g,
'stock'=>$stock,
'keyword'=>$keyword,
);
$reagentProds = Common::getReagentProds($cas);
$reagentProds = $this->tag_filter($reagentProds, $cond);
/**
* 按条件筛选
* @param $v
* @param $cond
* @return mixed
*/
public function tag_filter($v, $cond){
$v = array_filter($v, function($elem) use($cond){
if($cond['p']){
return $elem['purity'] == $cond['p'];
}else{
return true;
}
});
$v = array_filter($v, function($elem) use($cond){
if($cond['b']){
return $elem['reagent_name'] == $cond['b'];
}else{
return true;
}
});
$v = array_filter($v, function($elem) use($cond){
if($cond['g']){
return $elem['pack'] == $cond['g'];
}else{
return true;
}
});
$v = array_filter($v, function($elem) use($cond){
if($cond['stock'] == 1){
return $elem['stock'] >0;
}else{
return true;
}
});
return array_filter($v, function($elem) use($cond){
if($cond['keyword']){
return strpos($elem['packsize'].$elem['packunit'], $cond['keyword'])!==false || strpos($elem['purity'], $cond['keyword'])!==false;
}else{
return true;
}
});
}