123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /**
- *
- *
- * @category xxx
- * @package PSR
- * @subpackage Documentation\API
- * @author xxx <xxx@xxx.com>
- * @license GPL https://xxx.com
- * @link https://xxx.com
- * @ctime: 2020/4/16 9:36
- */
- namespace App\Repositories;
- use App\Models\Coupon;
- class CouponRepository extends BaseRepository
- {
- public function __construct(Coupon $coupon)
- {
- $this->model = $coupon;
- }
- /**
- * 根据获取区域的配置优惠券
- * @param $user_id
- * Author: Mead
- */
- public function getNewUserCoupons($area_id = 0)
- {
- if ($area_id) {
- $coupons = $this->model->query()->where('area_id', $area_id)->where('site', Coupon::SITE_NEW_USER)->where('status', Coupon::STATUS_OK)->orderBy('area_id')->get();
- if ($coupons) {
- return $coupons;
- }
- }
- $coupons = $coupons = $this->model->query()->where('area_id', 0)->where('site', Coupon::SITE_NEW_USER)->where('status', Coupon::STATUS_OK)->orderBy('area_id')->get();
- return $coupons;
- }
- /**
- * @param $ids
- * Author: Mead
- */
- public function byIdsGetNewUserCoupons($ids)
- {
- if (is_string($ids)) {
- $ids = str2arr($ids);
- }
- return $this->model->query()->whereIn('id', $ids)->where('site', Coupon::SITE_NEW_USER)->where('status', Coupon::STATUS_OK)->get();
- }
- }
|