params[ 'page' ]) ? $this->params[ 'page' ] : 1; $page_size = isset($this->params[ 'page_size' ]) ? $this->params[ 'page_size' ] : PAGE_LIST_ROWS; $inventory_no = isset($this->params[ 'inventory_no' ]) ? $this->params[ 'inventory_no' ] : ''; $store_id = $this->store_id; $condition = array ( [ 'site_id', '=', $this->site_id ], ); if ($store_id > 0) { $condition[] = [ 'store_id', '=', $store_id ]; } if (!empty($inventory_no)) { $condition[] = [ 'inventory_no', 'like', '%' . $inventory_no . '%' ]; } $inventory_model = new Inventory(); $list = $inventory_model->getInventoryPageList($condition, $page, $page_size, 'create_time desc'); return $this->response($list); } /** * 库存盘点详情 */ public function detail() { $inventory_no = isset($this->params[ 'inventory_no' ]) ? $this->params[ 'inventory_no' ] : 0; $inventory_model = new Inventory(); $condition = array ( [ 'site_id', '=', $this->site_id ], [ 'inventory_no', '=', $inventory_no ], [ 'store_id', '=', $this->store_id ], ); $inventory_detail = $inventory_model->getInventoryInfo($condition); if (empty($inventory_detail)) { return $this->response($this->error("盘点单不存在")); } return $this->response($inventory_detail); } /** *新增盘点记录 * @return mixed */ public function add() { $inventory_model = new Inventory(); $store_id = $this->store_id; $stock_list = isset($this->params[ 'stock_json' ]) ? $this->params[ 'stock_json' ] : '';//商品库存映照json {{'sku_id':1, 'stock' : 10, 'cost_price':10,'source':'来源'}} $stock_list = json_decode($stock_list, true); $params = array ( 'site_id' => $this->site_id, 'store_id' => $store_id, 'sku_list' => $stock_list, 'user_info' => $this->user_info, ); $result = $inventory_model->addInventory($params); return $this->response($result); } }