GoodsSku.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\store\model\sharp;
  10. use app\common\model\sharp\GoodsSku as GoodsSkuModel;
  11. /**
  12. * 整点秒杀-秒杀商品sku模型
  13. * Class Goods
  14. * @package app\store\model\sharp
  15. */
  16. class GoodsSku extends GoodsSkuModel
  17. {
  18. /**
  19. * 批量添加商品sku记录
  20. * @param $sharpGoodsId
  21. * @param $specList
  22. * @return array|false
  23. * @throws \Exception
  24. */
  25. public function addSkuList($sharpGoodsId, $specList)
  26. {
  27. $data = [];
  28. foreach ($specList as $item) {
  29. $data[] = array_merge($item['form'], [
  30. 'spec_sku_id' => $item['spec_sku_id'],
  31. 'sharp_goods_id' => $sharpGoodsId,
  32. 'wxapp_id' => self::$wxapp_id,
  33. ]);
  34. }
  35. return $this->allowField(true)->saveAll($data);
  36. }
  37. /**
  38. * 移除指定商品的所有sku
  39. * @param $sharpGoodsId
  40. * @return int
  41. */
  42. public function removeAll($sharpGoodsId)
  43. {
  44. return $this->where('sharp_goods_id', '=', $sharpGoodsId)->delete();
  45. }
  46. }