getPage($params); $limit = $this->getLimit($params); // list处理 $list_callback = function($list) { return array_map(function($item) { $item['values'] = Json::decode($item['values']); return $item; }, $list); }; return GoodsSpecs::getPageList($page, $limit, function($model) use ($store_id) { $model->where(['mall_id' => $this->mall_id, 'store_id' => $store_id]); }, 'id desc', $list_callback); } /** * 添加规格 * * @param string $name * @param array $values * @return boolean */ public function add(string $name, array $values, $store_id = 0) { return GoodsSpecs::addGoodsSpecs( $this->mall_id, $name, $values, $store_id ); } /** * 修改规格 * * @param integer $id * @param string $name * @param array $values * @return boolean */ public function edit(int $id, string $name, array $values) { /** * @var GoodsSpecs|null */ $specs = GoodsSpecs::getSpecsById($this->mall_id, $id); if (empty($specs)) { return $this->error('规格不存在'); } return $specs->editSpecs($name, $values); } /** * 删除 * * @return boolean */ public function del(int $id) { /** * @var GoodsSpecs|null */ $specs = GoodsSpecs::getSpecsById($this->mall_id, $id); if (empty($specs)) { return $this->error('规格不存在'); } return $specs->delete(); } }