Browse Source

开发修改运费模板删除方法

antshop
linyaostalker 5 years ago
parent
commit
8f0d66c18b
  1. 11
      backend/modules/shop/controllers/ExpressTemplateController.php

11
backend/modules/shop/controllers/ExpressTemplateController.php

@ -8,13 +8,14 @@ use backend\modules\shop\models\searchs\ExpressAreaSearch;
use Yii;
use backend\modules\shop\models\ars\ExpressTemplate;
use backend\modules\shop\models\searchs\ExpressTemplateSearch;
use yii\caching\Cache;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
use yii\widgets\ActiveForm;
use backend\modules\shop\models\ars\ExpressArea;
use backend\modules\goods\models\ars\Goods;
/**
* ExpressTemplateController implements the CRUD actions for ExpressTemplate model.
@ -112,7 +113,13 @@ class ExpressTemplateController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
if (Goods::find()->where(['express_template' => $id])->count() == 0) {
$expressTemplateModel = $this->findModel($id);
ExpressArea::deleteAll(['express_template' => $expressTemplateModel->id]);
$expressTemplateModel->delete();
} else {
Yii::$app->session->setFlash('error', '该模板已被使用');
}
return $this->redirect(['index']);
}

Loading…
Cancel
Save