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