where([ ["store_id", '=', $store_id], ["product_id", '=', $product_id], ["is_delete", '=', 0] ])->find(); } /** * @param array $params * @return \think\Paginator * @throws \think\db\exception\DbException */ public function findByPaginate(array $params) { // if(!is_null($params['bar_code'])) // array_push($where,['bar_code', 'like', "%".$params['bar_code']."%"]); // if(!is_null($params['category_id']) && $params['category_id'] > 0) // array_push($where,['category_id', '=', $params['category_id']]); // if(!is_null($params['is_serve'])) // array_push($where,['is_serve', '=', $params['is_serve']]); $store_where = [ ['is_delete','=', 0], ]; $product_where = [ ['is_delete','=', 0], ]; if($params['store_id'] > 0) array_push($store_where,["id", "=", $params['store_id']]); return $this->where('erp_store_product.is_delete',0) ->hasWhere('store', $store_where) ->hasWhere('product',$product_where) ->with(['store', 'product']) ->order(isset($params['sort']) ? $params['sort'] : 'create_time','desc') ->paginate(['list_rows'=>10, "query" => $params]); } }