StoreDiscountsProductsDao.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\activity\discounts;
  12. use app\dao\BaseDao;
  13. use app\model\activity\discounts\StoreDiscountsProducts;
  14. /**
  15. * 优惠套餐商品
  16. * Class StoreDiscountsProductsDao
  17. * @package app\dao\activity\discounts
  18. */
  19. class StoreDiscountsProductsDao extends BaseDao
  20. {
  21. /**
  22. * 设置模型
  23. * @return string
  24. */
  25. protected function setModel(): string
  26. {
  27. return StoreDiscountsProducts::class;
  28. }
  29. /**
  30. * 获取商品列表
  31. * @param $where
  32. * @return array
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public function getList($where)
  38. {
  39. return $this->search($where)->select()->toArray();
  40. }
  41. /**
  42. * 获取套餐商品
  43. * @param int $id
  44. * @param string $field
  45. * @param array $with
  46. * @return array|\think\Model|null
  47. * @throws \think\db\exception\DataNotFoundException
  48. * @throws \think\db\exception\DbException
  49. * @throws \think\db\exception\ModelNotFoundException
  50. */
  51. public function getDiscountProductInfo(int $id, string $field, array $with = [])
  52. {
  53. return $this->getModel()->where('id', $id)->when($with, function ($query) use ($with) {
  54. $query->with($with);
  55. })->field($field)->find();
  56. }
  57. }