StoreCouponProductDao.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\common\dao\store\coupon;
  12. use app\common\dao\BaseDao;
  13. use app\common\model\BaseModel;
  14. use app\common\model\store\coupon\StoreCouponProduct;
  15. use think\Collection;
  16. use think\db\exception\DataNotFoundException;
  17. use think\db\exception\DbException;
  18. use think\db\exception\ModelNotFoundException;
  19. /**
  20. * Class StoreCouponProductDao
  21. * @package app\common\dao\store\coupon
  22. * @author xaboy
  23. * @day 2020-05-13
  24. */
  25. class StoreCouponProductDao extends BaseDao
  26. {
  27. /**
  28. * @return BaseModel
  29. * @author xaboy
  30. * @day 2020-03-30
  31. */
  32. protected function getModel(): string
  33. {
  34. return StoreCouponProduct::class;
  35. }
  36. /**
  37. * @param array $data
  38. * @return int
  39. * @author xaboy
  40. * @day 2020-05-13
  41. */
  42. public function insertAll(array $data)
  43. {
  44. return StoreCouponProduct::getDB()->insertAll($data);
  45. }
  46. /**
  47. * @param $couponId
  48. * @return int
  49. * @throws DbException
  50. * @author xaboy
  51. * @day 2020-05-13
  52. */
  53. public function clear($couponId)
  54. {
  55. return StoreCouponProduct::getDB()->where('coupon_id', $couponId)->delete();
  56. }
  57. /**
  58. * @param $productId
  59. * @return array
  60. * @author xaboy
  61. * @day 2020/6/1
  62. */
  63. public function productByCouponId($productId)
  64. {
  65. return StoreCouponProduct::getDB()->whereIn('product_id', $productId)->column('coupon_id');
  66. }
  67. }