diff --git a/service/Application/Admin/Controller/AlipayLifeController.class.php b/service/Application/Admin/Controller/AlipayLifeController.class.php index 1388a92a5..0e6c21ef2 100755 --- a/service/Application/Admin/Controller/AlipayLifeController.class.php +++ b/service/Application/Admin/Controller/AlipayLifeController.class.php @@ -202,7 +202,7 @@ class AlipayLifeController extends CommonController } // 图片 - $this->ImagesSave('logo', 'file_logo', 'alipay_life'); + $this->FileSave('logo', 'file_logo', 'alipay_life'); // id为空则表示是新增 $m = D('AlipayLife'); diff --git a/service/Application/Admin/Controller/BrandController.class.php b/service/Application/Admin/Controller/BrandController.class.php index d9850d639..f45c9382b 100755 --- a/service/Application/Admin/Controller/BrandController.class.php +++ b/service/Application/Admin/Controller/BrandController.class.php @@ -198,7 +198,7 @@ class BrandController extends CommonController } // 图片 - $this->ImagesSave('logo', 'file_logo', 'brand'); + $this->FileSave('logo', 'file_logo', 'brand'); // id为空则表示是新增 $m = D('Brand'); diff --git a/service/Application/Admin/Controller/CommonController.class.php b/service/Application/Admin/Controller/CommonController.class.php index db89cdfaf..1692d5081 100755 --- a/service/Application/Admin/Controller/CommonController.class.php +++ b/service/Application/Admin/Controller/CommonController.class.php @@ -290,7 +290,7 @@ class CommonController extends Controller } /** - * 图片删除 + * 文件删除 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -298,7 +298,7 @@ class CommonController extends Controller * @desc description * @param [string] $img [图片地址 path+name] */ - protected function ImagesDelete($img) + protected function FileDelete($img) { if(empty($img)) return false; @@ -310,7 +310,7 @@ class CommonController extends Controller } /** - * 图片批量删除 + * 文件批量删除 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -318,22 +318,22 @@ class CommonController extends Controller * @desc description * @param [array] $img_all [图片地址 path+name] */ - protected function ImagesDeleteAll($img_all) + protected function FileDeleteAll($img_all) { if(!empty($img_all) && is_array($img_all)) { for($i=0; $iImagesDelete($img_all[$i]); - $this->ImagesDelete(str_replace(['compr', 'small'], 'small', $img_all[$i])); - $this->ImagesDelete(str_replace(['compr', 'small'], 'compr', $img_all[$i])); - $this->ImagesDelete(str_replace(['compr', 'small'], 'original', $img_all[$i])); + $this->FileDelete($img_all[$i]); + $this->FileDelete(str_replace(['compr', 'small'], 'small', $img_all[$i])); + $this->FileDelete(str_replace(['compr', 'small'], 'compr', $img_all[$i])); + $this->FileDelete(str_replace(['compr', 'small'], 'original', $img_all[$i])); } } } /** - * 图片存储 + * 文件存储 * @author Devil * @blog http://gong.gg/ * @version 1.0.0 @@ -343,7 +343,7 @@ class CommonController extends Controller * @param [string] $post_name [file form name名称] * @param [string] $dir [存储路径标记] */ - protected function ImagesSave($field, $post_name, $dir = 'common') + protected function FileSave($field, $post_name, $dir = 'common') { if(isset($_FILES[$post_name]['error'])) { diff --git a/service/Application/Admin/Controller/ExpressController.class.php b/service/Application/Admin/Controller/ExpressController.class.php index 1dbff4f25..e5e67a94e 100755 --- a/service/Application/Admin/Controller/ExpressController.class.php +++ b/service/Application/Admin/Controller/ExpressController.class.php @@ -94,7 +94,7 @@ class ExpressController extends CommonController } // 图片 - $this->ImagesSave('icon', 'file_icon', 'express'); + $this->FileSave('icon', 'file_icon', 'express'); // id为空则表示是新增 $m = D('Express'); diff --git a/service/Application/Admin/Controller/GoodsCategoryController.class.php b/service/Application/Admin/Controller/GoodsCategoryController.class.php index 6e6887ee5..584ddd686 100755 --- a/service/Application/Admin/Controller/GoodsCategoryController.class.php +++ b/service/Application/Admin/Controller/GoodsCategoryController.class.php @@ -116,10 +116,10 @@ class GoodsCategoryController extends CommonController } // icon - $this->ImagesSave('icon', 'file_icon', 'goods_category'); + $this->FileSave('icon', 'file_icon', 'goods_category'); // 大图片 - $this->ImagesSave('big_images', 'file_big_images', 'goods_category'); + $this->FileSave('big_images', 'file_big_images', 'goods_category'); // id为空则表示是新增 $m = D('GoodsCategory'); diff --git a/service/Application/Admin/Controller/GoodsController.class.php b/service/Application/Admin/Controller/GoodsController.class.php index 03760acd9..1d6da28df 100755 --- a/service/Application/Admin/Controller/GoodsController.class.php +++ b/service/Application/Admin/Controller/GoodsController.class.php @@ -342,7 +342,11 @@ class GoodsController extends CommonController // 添加/编辑 $m = D('Goods'); - $type = empty($_POST['id']) ? 1 : 2; + // 商品 + $goods_id = I('id'); + $goods = $m->find($goods_id); + + $type = empty($goods) ? 1 : 2; if($m->create($_POST, $type)) { // 开启事务 @@ -356,14 +360,12 @@ class GoodsController extends CommonController } else { // 更新 $data['upd_time'] = time(); - if($m->where(['id'=>I('id')])->save($data) === false) + if($m->where(['id'=>$goods_id])->save($data) === false) { // 回滚事务 $m->rollback(); $this->ajaxReturn(L('common_operation_edit_error'), -100); - } else { - $goods_id = I('id'); } } @@ -410,6 +412,12 @@ class GoodsController extends CommonController // 提交事务 $m->commit(); + // 删除原来的视频 + if(!empty($goods['video']) && !empty($video['data']['file_video']['url'])) + { + $this->FileDelete($goods['video']); + } + // 提示 if($type == 1) { @@ -547,7 +555,7 @@ class GoodsController extends CommonController $result[$key[1]][$key[0]] = DS.$path.'compr'.$date.$small; } else { // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($path.'original'.$date.$original); + $this->FileDelete($path.'original'.$date.$original); } } } @@ -616,7 +624,7 @@ class GoodsController extends CommonController $result[] = DS.$path.'compr'.$date.$small; } else { // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($path.'original'.$date.$original); + $this->FileDelete($path.'original'.$date.$original); } } } @@ -677,7 +685,7 @@ class GoodsController extends CommonController $result[$field] = DS.$path.'compr'.$date.$small; } else { // 如果图片格式有误,则删除原图片 - $this->ImagesDelete($path.'original'.$date.$original); + $this->FileDelete($path.'original'.$date.$original); } } } diff --git a/service/Application/Admin/Controller/PaymentController.class.php b/service/Application/Admin/Controller/PaymentController.class.php index 7138fa042..820dfe87c 100755 --- a/service/Application/Admin/Controller/PaymentController.class.php +++ b/service/Application/Admin/Controller/PaymentController.class.php @@ -205,7 +205,7 @@ class PaymentController extends CommonController } // 图片 - $this->ImagesSave('logo', 'file_logo', 'payment'); + $this->FileSave('logo', 'file_logo', 'payment'); // id为空则表示是新增 $m = D('Payment'); diff --git a/service/Application/Admin/Controller/SiteController.class.php b/service/Application/Admin/Controller/SiteController.class.php index 42a1bc187..d5affced7 100755 --- a/service/Application/Admin/Controller/SiteController.class.php +++ b/service/Application/Admin/Controller/SiteController.class.php @@ -72,8 +72,8 @@ class SiteController extends CommonController public function Save() { // logo存储 - $this->ImagesSave('home_site_logo', 'home_site_logo_img'); - $this->ImagesSave('home_site_logo_wap', 'home_site_logo_wap_img'); + $this->FileSave('home_site_logo', 'home_site_logo_img'); + $this->FileSave('home_site_logo_wap', 'home_site_logo_wap_img'); // 站点状态值处理 if(!isset($_POST['home_user_reg_state'])) diff --git a/service/Application/Api/Controller/GoodsController.class.php b/service/Application/Api/Controller/GoodsController.class.php index b1fb9a684..681ae3733 100755 --- a/service/Application/Api/Controller/GoodsController.class.php +++ b/service/Application/Api/Controller/GoodsController.class.php @@ -55,6 +55,9 @@ class GoodsController extends CommonController // 是否已收藏 $goods['is_favor'] = $this->IsGoodsUserFavor($goods_id); + // 视频 + $goods['video'] = empty($goods['video']) ? null : C('IMAGE_HOST').$goods['video']; + $result = [ // 商品基础数据 'goods' => $goods, @@ -67,6 +70,9 @@ class GoodsController extends CommonController // 属性 'attribute' => $this->GetGoodsAttribute($goods_id), + + // 客服电话 + 'customer_service_tel' => MyC('common_customer_service_tel'), ]; $this->ajaxReturn(L('common_operation_success'), 0, $result);