StoreProductAttrDao.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\product\sku;
  12. use app\dao\BaseDao;
  13. use app\model\product\sku\StoreProductAttr;
  14. /**
  15. * Class StoreProductAttrDao
  16. * @package app\dao\product\sku
  17. */
  18. class StoreProductAttrDao extends BaseDao
  19. {
  20. /**
  21. * 设置模型
  22. * @return string
  23. */
  24. protected function setModel(): string
  25. {
  26. return StoreProductAttr::class;
  27. }
  28. /**
  29. * 删除sku
  30. * @param int $id
  31. * @param int $type
  32. * @return bool
  33. * @throws \Exception
  34. */
  35. public function del(int $id, int $type)
  36. {
  37. return $this->search(['product_id' => $id, 'type' => $type])->delete();
  38. }
  39. /**
  40. * 保存sku
  41. * @param array $data
  42. * @return mixed|\think\Collection
  43. * @throws \Exception
  44. */
  45. public function saveAll(array $data)
  46. {
  47. return $this->getModel()->saveAll($data);
  48. }
  49. /**
  50. * 获取商品sku
  51. * @param array $where
  52. * @return array
  53. * @throws \think\db\exception\DataNotFoundException
  54. * @throws \think\db\exception\DbException
  55. * @throws \think\db\exception\ModelNotFoundException
  56. */
  57. public function getProductAttr(array $where)
  58. {
  59. return $this->search($where)->select()->toArray();
  60. }
  61. /**
  62. * 获取商品sku
  63. * @param array $where
  64. * @return \think\Collection
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. */
  69. public function getProductValue(array $where)
  70. {
  71. return $this->search($where)->select();
  72. }
  73. }