feat : coupon
This commit is contained in:
@@ -4,6 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use App\Constants\Common\CouponCode;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\DbConnection\Model\Model;
|
||||
|
||||
/**
|
||||
@@ -48,4 +51,16 @@ class UserCoupon extends Model
|
||||
->pluck('coupon_id')
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @return Builder[]|Collection
|
||||
*/
|
||||
public function getNoUseCouponByUserId(int $userId): Collection|array
|
||||
{
|
||||
return $this
|
||||
->where('user_id', $userId)
|
||||
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user