BindMobileAward.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /****************************************************************
  3. * Author: king -- LiBaoJia
  4. * Date: 2020/7/9 2:25 PM
  5. * Email: livsyitian@163.com
  6. * QQ: 995265288
  7. * IDE: PhpStorm
  8. * User: 芸众商城 www.yunzshop.com
  9. ****************************************************************/
  10. namespace app\common\models\point;
  11. use app\common\models\BaseModel;
  12. use app\common\observers\point\BindMobileAwardObserver;
  13. class BindMobileAward extends BaseModel
  14. {
  15. protected $table = 'yz_bind_mobile_award_point';
  16. protected $guarded = [];
  17. public static function boot()
  18. {
  19. parent::boot();
  20. self::observe(new BindMobileAwardObserver());
  21. }
  22. /**
  23. * @param int $memberId
  24. *
  25. * @return bool
  26. */
  27. public static function isAwarded($memberId)
  28. {
  29. return !!static::where('member_id', $memberId)->first();
  30. }
  31. /**
  32. * @param int $memberId
  33. * @param float $point
  34. *
  35. * @return bool
  36. */
  37. public static function awardMember($memberId, $point)
  38. {
  39. return (new static())->fill([
  40. 'uniacid' => \YunShop::app()->uniacid,
  41. 'point' => $point,
  42. 'member_id' => $memberId
  43. ])->save();
  44. }
  45. }