|
@@ -974,29 +974,53 @@ class goodsModel extends Model
|
|
|
public function delGoodsAll($condition)
|
|
|
{
|
|
|
$goods_list = $this->getGoodsList($condition, 'goods_id,goods_commonid,store_id');
|
|
|
- if (empty($goods_list)) {
|
|
|
- return false;
|
|
|
+ if (!empty($goods_list)) {
|
|
|
+ $goodsid_array = array();
|
|
|
+ $commonid_array = array();
|
|
|
+ foreach ($goods_list as $val) {
|
|
|
+ $goodsid_array[] = $val['goods_id'];
|
|
|
+ $commonid_array[] = $val['goods_commonid'];
|
|
|
+ // 商品公共缓存
|
|
|
+ $this->_dGoodsCommonCache($val['goods_commonid']);
|
|
|
+ // 商品规格缓存
|
|
|
+ $this->_dGoodsSpecCache($val['goods_commonid']);
|
|
|
+ }
|
|
|
+ $commonid_array = array_unique($commonid_array);
|
|
|
+
|
|
|
+ // 删除商品表数据
|
|
|
+ $this->delGoods(array('goods_id' => array('in', $goodsid_array)));
|
|
|
+ // 删除商品公共表数据
|
|
|
+ $this->table('goods_common')->where(array('goods_commonid' => array('in', $commonid_array)))->delete();
|
|
|
+ // 删除商品图片表数据
|
|
|
+ $this->delGoodsImages(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+ // 删除商品F码
|
|
|
+ Model('goods_fcode')->delGoodsFCode(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+ } else {
|
|
|
+ if(isset($condition['goods_commonid'])) {
|
|
|
+ $commonid_array = $condition['goods_commonid'][1];
|
|
|
+ if(is_array($commonid_array)) {
|
|
|
+ foreach ($commonid_array as $val)
|
|
|
+ {
|
|
|
+ // 商品公共缓存
|
|
|
+ $this->_dGoodsCommonCache($val);
|
|
|
+ // 商品规格缓存
|
|
|
+ $this->_dGoodsSpecCache($val);
|
|
|
+ }
|
|
|
+ // 删除商品表数据
|
|
|
+ $this->delGoods(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+ // 删除商品公共表数据
|
|
|
+ $this->table('goods_common')->where(array('goods_commonid' => array('in', $commonid_array)))->delete();
|
|
|
+ // 删除商品图片表数据
|
|
|
+ $this->delGoodsImages(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+ // 删除商品F码
|
|
|
+ Model('goods_fcode')->delGoodsFCode(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- $goodsid_array = array();
|
|
|
- $commonid_array = array();
|
|
|
- foreach ($goods_list as $val) {
|
|
|
- $goodsid_array[] = $val['goods_id'];
|
|
|
- $commonid_array[] = $val['goods_commonid'];
|
|
|
- // 商品公共缓存
|
|
|
- $this->_dGoodsCommonCache($val['goods_commonid']);
|
|
|
- // 商品规格缓存
|
|
|
- $this->_dGoodsSpecCache($val['goods_commonid']);
|
|
|
- }
|
|
|
- $commonid_array = array_unique($commonid_array);
|
|
|
-
|
|
|
- // 删除商品表数据
|
|
|
- $this->delGoods(array('goods_id' => array('in', $goodsid_array)));
|
|
|
- // 删除商品公共表数据
|
|
|
- $this->table('goods_common')->where(array('goods_commonid' => array('in', $commonid_array)))->delete();
|
|
|
- // 删除商品图片表数据
|
|
|
- $this->delGoodsImages(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
- // 删除商品F码
|
|
|
- Model('goods_fcode')->delGoodsFCode(array('goods_commonid' => array('in', $commonid_array)));
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|