Browse Source

将逻辑方法修改静态方法

wechat_public_accounts
linyaostalker 5 years ago
parent
commit
e28296daf5
  1. 11
      vendor/antgoods/goods/src/controllers/GoodsController.php
  2. 6
      vendor/antgoods/goods/src/controllers/ShopCategoryController.php

11
vendor/antgoods/goods/src/controllers/GoodsController.php

@ -2,6 +2,7 @@
namespace antgoods\goods\controllers;
use antgoods\goods\models\ars\GoodsSku;
use common\models\ars\TemFile;
use MongoDB\Driver\Manager;
use Yii;
@ -83,8 +84,7 @@ class GoodsController extends Controller
$model = new Goods();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
//商品封面图和商品详情图上传保存处理
$goods_manager = new GoodsManager();
$res = $goods_manager->updateGoods(Yii::$app->request->post(), $model);
$res = GoodsManager::updateGoods(Yii::$app->request->post(), $model);
if ($res['status']) {
return $this->redirect('index');
}
@ -108,19 +108,18 @@ class GoodsController extends Controller
$model = $this->findModel($id);
$model->coverImageId = $model->image;
$model->detailImageId = implode(',', File::find()->select('id')->where(['is_delete' => File::IS_DELETE_NO, 'own_id' => $model->id, 'own_type' => File::OWN_TYPE_GOODS_DETAILS])->column());
$goods_manager = new GoodsManager();
//记录已保存的商品图片id,用于修改
$cover_image_old_id_str = $model->image;
$detail_image_old_id_str = $model->detailImageId;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
//商品封面图和商品详情图上传保存处理
$res = $goods_manager->updateGoods(Yii::$app->request->post(), $model, $cover_image_old_id_str, $detail_image_old_id_str);
$res = GoodsManager::updateGoods(Yii::$app->request->post(), $model, $cover_image_old_id_str, $detail_image_old_id_str);
if ($res['status']) {
return $this->redirect('index');
}
}
$attributeModel = $goods_manager->getAttribute($id);
$checkAttr = $goods_manager->getSkuInfo($id);
$attributeModel = GoodsManager::getAttribute($id);
$checkAttr = GoodsManager::getSkuInfo($id);
return $this->render('update', [
'model' => $model,
'attributeModel' => $attributeModel,

6
vendor/antgoods/goods/src/controllers/ShopCategoryController.php

@ -90,8 +90,7 @@ class ShopCategoryController extends Controller
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON);
$save_icon_image_res = GoodsManager::saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status']){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();
@ -131,8 +130,7 @@ class ShopCategoryController extends Controller
//类目图片上传保存处理
$icon_image_id_str = $model->iconImageId;
$model->save();
$goods_manager = new GoodsManager();
$save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON);
$save_icon_image_res = GoodsManager::saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON);
if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){
$model->icon = $save_icon_image_res['first_file_id'];
$model->save();

Loading…
Cancel
Save