model=new \app\admin\model\GoodChange(); } //列表详情 public function list(){ $params = $this->request->param(['spuCode'=>'','page' => 1,'size' => 15],'post','trim'); $where = []; if($params['spuCode'] !== '') { $where[] = ['spuCode','like',"%{$params['spuCode']}%"]; } $list = $this->model ->where($where)->json(['before','after'],true) ->order('id desc') ->select(); $result = []; foreach ($list as $item){ $keys = array_keys($item["before"]); foreach ($keys as $key){ $temp=[]; $temp['field'] = \app\admin\model\GoodChange::$mapField[$key] ?? ""; $temp['before'] = $item['before'][$key] ?? ""; $temp['after'] = $item['after'][$key] ?? ""; $temp['apply_name'] = $item['apply_name']; $temp['addtime'] = $item['addtime']; $result[] = $temp; } } $this->success('获取成功', $result); } //详情 public function info(){ $params=$this->request->param(['id'=>''],'post','trim'); $valid=Validate::rule(['id|修改记录ID'=>'require']); if($valid->check($params)==false){ $this->error($valid->getError()); } $changeInfo = $this->model ->json(['before','after']) ->where(["id"=>$params['id']]) ->findOrEmpty(); if($changeInfo->isEmpty()){ $this->error("修改记录不存在"); } $this->success("获取成功",$changeInfo); } }