|
|
@ -285,7 +285,7 @@ class GoodsManager |
|
|
|
$data['id'] = $sku->id; |
|
|
|
$data['price'] = $sku->price; |
|
|
|
$data['stock'] = $sku->stock; |
|
|
|
$data['weight'] = $sku->goods_weight; |
|
|
|
$data['weight'] = $sku->weight; |
|
|
|
return $data; |
|
|
|
} |
|
|
|
|
|
|
@ -350,6 +350,7 @@ class GoodsManager |
|
|
|
*/ |
|
|
|
public static function AddOrUpdateData($sku, $type, $goodsId) |
|
|
|
{ |
|
|
|
$goodsModel = Goods::findOne($goodsId); |
|
|
|
if ($sku['id'] > 0) { |
|
|
|
$goodsSku = GoodsSku::findOne($sku['id']); |
|
|
|
$attrId = array_filter(explode(',', $goodsSku->goods_attr)); |
|
|
@ -358,7 +359,7 @@ class GoodsManager |
|
|
|
$goodsSku = new GoodsSku(); |
|
|
|
$attr = new GoodsAttr(); |
|
|
|
} |
|
|
|
if (!$attr || !$goodsSku) { |
|
|
|
if (!$attr || !$goodsSku || !$goodsModel) { |
|
|
|
throw new \yii\db\Exception('系统异常'); |
|
|
|
} |
|
|
|
if ($type == Goods::SKU_MODE_MANUAL) { |
|
|
@ -375,6 +376,7 @@ class GoodsManager |
|
|
|
$goodsSku->price = $sku['price']; |
|
|
|
$goodsSku->stock = $sku['stock']; |
|
|
|
$goodsSku->weight = $sku['weight']; |
|
|
|
$goodsSku->goods_sn = $goodsModel->sn; |
|
|
|
if (!$goodsSku->save()) { |
|
|
|
throw new \yii\db\Exception('保存失败,请检查是否有重复规格'); |
|
|
|
} |
|
|
|