|
|
|
@ -138,14 +138,14 @@ class GoodsSku extends SharpGoodsSkuModel |
|
|
|
|
* @param int $specType |
|
|
|
|
* @return array|bool|false |
|
|
|
|
*/ |
|
|
|
|
public static function add(int $sharpGoodsId, int $specType = SpecTypeEnum::SINGLE, array $newSkuList = []) |
|
|
|
|
public static function add(int $sharpGoodsId, int $specType = SpecTypeEnum::SINGLE, array $newSkuList = [], $storeId = 0) |
|
|
|
|
{ |
|
|
|
|
// 单规格模式 |
|
|
|
|
if ($specType === SpecTypeEnum::SINGLE) { |
|
|
|
|
return (new static)->save(array_merge($newSkuList, [ |
|
|
|
|
'sharp_goods_id' => $sharpGoodsId, |
|
|
|
|
'goods_sku_id' => 0, |
|
|
|
|
'store_id' => self::$storeId |
|
|
|
|
'store_id' => $storeId ? $storeId : self::$storeId |
|
|
|
|
])); |
|
|
|
|
} // 多规格模式 |
|
|
|
|
elseif ($specType === SpecTypeEnum::MULTI) { |
|
|
|
@ -162,12 +162,12 @@ class GoodsSku extends SharpGoodsSkuModel |
|
|
|
|
* @param array $skuList |
|
|
|
|
* @return array|bool|false |
|
|
|
|
*/ |
|
|
|
|
public static function edit(int $sharpGoodsId, int $specType = SpecTypeEnum::SINGLE, array $skuList = []) |
|
|
|
|
public static function edit(int $sharpGoodsId, int $specType = SpecTypeEnum::SINGLE, array $skuList = [], $storeId = 0) |
|
|
|
|
{ |
|
|
|
|
// 删除所有的sku记录 |
|
|
|
|
static::deleteAll(['sharp_goods_id' => $sharpGoodsId]); |
|
|
|
|
// 新增商品sku记录 |
|
|
|
|
return static::add($sharpGoodsId, $specType, $skuList); |
|
|
|
|
return static::add($sharpGoodsId, $specType, $skuList, $storeId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|