From ff6fd084b88544d1c3ceb56d4a865fa8989a859b Mon Sep 17 00:00:00 2001 From: Donny Wong Date: Fri, 4 Jan 2019 21:53:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=8A=9F=E8=83=BD=20feat:=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=A0=E9=99=A4=E6=97=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=B0=86=E8=A6=81=E6=B8=85=E7=90=86=E7=9A=84=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=88=96=E8=A7=86=E9=A2=91=E6=8E=A8=E9=80=81=E7=BB=99=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=B8=85=E7=90=86=E9=98=9F=E5=88=97=20feat:=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=A0=E9=99=A4=E6=97=B6=EF=BC=8C=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81=E7=9B=B8=E5=85=B3=E7=9A=84?= =?UTF-8?q?SKU=E3=80=81=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Api/Console/Product.php | 34 +++++++++++++++++++++++----- src/Core/Product/ProductImgModel.php | 25 +++++++++++++++++++- src/Core/Product/ProductModel.php | 6 +++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/src/Api/Console/Product.php b/src/Api/Console/Product.php index 4e09548..858a9fb 100644 --- a/src/Api/Console/Product.php +++ b/src/Api/Console/Product.php @@ -347,12 +347,12 @@ public function getProduct(){ ]); - //调用属性集服务 - $response = $this->apiRequest('product.propset.get',['id'=>$returnData['propsetId'],'loadPropvalue'=>1]); - $response = json_decode($response,true); - if($response['status']==0 && $response['data']){ - $propkeyList = $response['data']['propkeyList']; - } + //API:调用属性集服务 +// $response = $this->apiRequest('product.propset.get',['id'=>$returnData['propsetId'],'loadPropvalue'=>1]); +// $response = json_decode($response,true); +// if($response['status']==0 && $response['data']){ +// $propkeyList = $response['data']['propkeyList']; +// } return $returnData; @@ -392,4 +392,26 @@ public function listProducts(){ $returnData['limit'] = $data['limit']; return $returnData; } + + /** + * 删除商品,只是做假删除 + */ + public function remove(){ + $data = $this->_toParamObject($this->getParams()); + $model = ProductModel::findFirst([ + 'id=:id: and isDeleted=0', + 'bind'=>['id'=>$data['id']] + ]); + if(!$model){ + throw new ApiException(ApiException::$EXCODE_NOTEXIST); + } + $result = false; + if($data['isPhysical']){ + $result = $model->delete(); + }else{ + $model->isDeleted = 1; + $result = $model->update(); + } + return $result; + } } \ No newline at end of file diff --git a/src/Core/Product/ProductImgModel.php b/src/Core/Product/ProductImgModel.php index 38c8803..31a5847 100644 --- a/src/Core/Product/ProductImgModel.php +++ b/src/Core/Product/ProductImgModel.php @@ -1,6 +1,6 @@ 'videoUrl' ]; } + + /** + * 清除之后,图片与视频要清理 + */ + public function afterDelete(){ + $data = []; + if($this->imgUrl){ + $data[] = $this->imgUrl; + } + if($this->videoUrl){ + $data[] = $this->videoUrl; + } + try { + if (!empty($data)) { + $queue = new \Qing\Lib\Queue(); + //$queue = $this->getDI()->getShared('queue'); + $queue->put('mediaRecycle', $data); + } + }catch(ModelException $e){ + //无队列处理则跳过 + } + return true; + } } diff --git a/src/Core/Product/ProductModel.php b/src/Core/Product/ProductModel.php index 46d8338..63adef5 100644 --- a/src/Core/Product/ProductModel.php +++ b/src/Core/Product/ProductModel.php @@ -115,6 +115,12 @@ public function initialize(){ $this->hasMany('id','ProductDescModel','productId',[ ['foreignKey' => ['action' => Relation::ACTION_CASCADE], 'namespace' => 'Kuga\\Core\\Product'] ]); + $this->hasMany('id','ProductPropModel','productId',[ + ['foreignKey' => ['action' => Relation::ACTION_CASCADE], 'namespace' => 'Kuga\\Core\\Product'] + ]); + $this->hasMany('id','ProductSkuModel','productId',[ + ['foreignKey' => ['action' => Relation::ACTION_CASCADE], 'namespace' => 'Kuga\\Core\\Product'] + ]); } /** * Independent Column Mapping.