StoreCouponUserUserServices.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\services\activity\coupon;
  13. use app\services\BaseServices;
  14. use app\dao\activity\coupon\StoreCouponUserUserDao;
  15. /**
  16. *
  17. * Class StoreCouponUserUserServices
  18. * @package app\services\coupon
  19. */
  20. class StoreCouponUserUserServices extends BaseServices
  21. {
  22. /**
  23. * StoreCouponUserUserServices constructor.
  24. * @param StoreCouponUserUserDao $dao
  25. */
  26. public function __construct(StoreCouponUserUserDao $dao)
  27. {
  28. $this->dao = $dao;
  29. }
  30. /**
  31. * 获取列表
  32. * @param array $where
  33. * @return array
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public function getList(array $where)
  39. {
  40. [$page, $limit] = $this->getPageValue();
  41. $list = $this->dao->sysPage($where, $page, $limit);
  42. foreach ($list as $k => &$v) {
  43. $v['start_time'] = $v['start_time'] > 0 ? $v['start_time'] : $v['add_time'];
  44. if ($v['end_time'] < time() || $v['use_time'] != 0) $v['is_fail'] = 1;
  45. }
  46. $count = $this->dao->sysCount($where);
  47. return compact('list', 'count');
  48. }
  49. }