request; if ($request->isAjax) { // 提交等级内容 if ($request->isPost) { $params = Yii::$app->request->post(); $res = Yii::$app->services->validate->validate($params, [ [['goods_id','id','status'], 'safe'], ]); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params =CardSecretGoods::exceptNullVal($params); $params['create_at'] = time(); if(!$params['name']) unset($params['name']); $params['mall_id'] = $this->mall_id; if(isset($params['status']) && !in_array($params['status'],[StatusEnum::DISABLED,StatusEnum::ENABLED,StatusEnum::DELETE])) throw new Exception("参数错误");; $res =CardSecretGoods::setData($params); if ($res === false) throw new Exception(Cate::getStaticError()); return $this->success('操作成功'); }else{ $params = Yii::$app->request->get(); $res = Yii::$app->services->validate->validate($params, [ [['goods_id'], 'safe'], ]); if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $params =CardSecretGoods::exceptNullVal($params); $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'goods_id', $params['goods_id']]; $where[] = ['>=', 'status', StatusEnum::DISABLED]; $detail =CardSecretGoods::getOne($where,true); if ($detail === false) throw new Exception(CardSecretGoods::getStaticError()); $list['cate_id'] = $detail['cate_id']; $list['cate_list'] = Cate::getCateMap(2,$this->mall_id); return $this->success('操作成功',$list); } } } catch (\Exception $e) { return $this->error($e->getMessage(), []); } } }