StoreCouponIssueUserRepository.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\repositories\store\coupon;
  12. use app\common\dao\store\coupon\StoreCouponIssueUserDao;
  13. use app\common\repositories\BaseRepository;
  14. /**
  15. * Class StoreCouponIssueUserRepository
  16. * @package app\common\repositories\store\coupon
  17. * @author xaboy
  18. * @day 2020/6/1
  19. * @mixin StoreCouponIssueUserDao
  20. */
  21. class StoreCouponIssueUserRepository extends BaseRepository
  22. {
  23. /**
  24. * StoreCouponIssueUserRepository constructor.
  25. * @param StoreCouponIssueUserDao $dao
  26. */
  27. public function __construct(StoreCouponIssueUserDao $dao)
  28. {
  29. $this->dao = $dao;
  30. }
  31. public function issue($couponId, $uid)
  32. {
  33. return $this->dao->create([
  34. 'coupon_id' => $couponId,
  35. 'uid' => $uid,
  36. ]);
  37. }
  38. public function getList(array $where, $page, $limit)
  39. {
  40. $query = $this->dao->search($where);
  41. $count = $query->count();
  42. $list = $query->with(['coupon', 'user'])->page($page, $limit)->select();
  43. return compact('count', 'list');
  44. }
  45. }