GoodsSku.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\store\model;
  13. use app\common\model\GoodsSku as GoodsSkuModel;
  14. use app\common\enum\goods\SpecType as SpecTypeEnum;
  15. /**
  16. * 商品规格模型
  17. * Class GoodsSku
  18. * @package app\store\model
  19. */
  20. class GoodsSku extends GoodsSkuModel
  21. {
  22. /**
  23. * 更新商品sku记录
  24. * @param int $goodsId
  25. * @param int $specType
  26. * @param array $skuList
  27. * @return array|bool|false
  28. */
  29. public static function edit(int $goodsId, int $specType = SpecTypeEnum::SINGLE, array $skuList = [])
  30. {
  31. // 删除所有的sku记录
  32. static::deleteAll(['goods_id' => $goodsId]);
  33. // 新增商品sku记录
  34. return static::add($goodsId, $specType, $skuList);
  35. }
  36. }