作者 anyv
1 个管道 的构建 通过 耗费 0 秒

9

@@ -181,8 +181,12 @@ class IndexController extends WeChatBaseController @@ -181,8 +181,12 @@ class IndexController extends WeChatBaseController
181 */ 181 */
182 public function search_salesman_goods(){ 182 public function search_salesman_goods(){
183 183
184 - $book_name = $_POST['book_name'];  
185 - $data_salesman_goods = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where("type =2 ") -> where('book_name','like',"%".$book_name."%") -> select() -> toArray(); 184 + if(empty($_POST['book_name'])){
  185 + $data_salesman_goods = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where("type =2 ") -> select() -> toArray();
  186 + }else{
  187 + $book_name = $_POST['book_name'];
  188 + $data_salesman_goods = Db::name('goods') -> alias('a') -> field("a.*,b.name") -> join('classification b','a.classify_id = b.id','LEFT') -> where("type =2 ") -> where('book_name','like',"%".$book_name."%") -> select() -> toArray();
  189 + }
186 if(!empty($data_salesman_goods)){ 190 if(!empty($data_salesman_goods)){
187 foreach ($data_salesman_goods as $key => $val){ 191 foreach ($data_salesman_goods as $key => $val){
188 $price = explode('.',$data_salesman_goods[$key]['price']); 192 $price = explode('.',$data_salesman_goods[$key]['price']);