GiftUserParty.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace app\common\model;
  3. use addons\faqueue\library\QueueApi;
  4. use think\Model;
  5. /**
  6. * 赠送礼物模型
  7. */
  8. class GiftUserParty extends Model
  9. {
  10. // 开启自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'int';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. /*
  15. protected static function init()
  16. {
  17. GiftUserParty::afterInsert(function ($giftUserParty) {
  18. if ($giftUserParty->party_id > 0) {
  19. $giftNotice = config("site.giftNotice");
  20. $bigGiftNotice = config("site.bigGiftNotice");
  21. $partyInfo = $giftUserParty->party;
  22. $money = $giftUserParty->value;
  23. $type = 0;
  24. if ($money >= $bigGiftNotice) {
  25. $type = 72;
  26. }elseif ($money >= $giftNotice){
  27. $type = 71;
  28. }
  29. $type > 0 and QueueApi::sendGroupMessage($type, $giftUserParty->user->nickname, $giftUserParty->toUser->nickname, $partyInfo, $giftUserParty);
  30. }
  31. });
  32. }
  33. */
  34. public function user()
  35. {
  36. return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  37. }
  38. public function toUser()
  39. {
  40. return $this->belongsTo('app\common\model\User', 'user_to_id', 'id', [], 'LEFT')->setEagerlyType(0);
  41. }
  42. public function party()
  43. {
  44. return $this->belongsTo('app\common\model\Party', 'party_id', 'id', [], 'LEFT')->setEagerlyType(0);
  45. }
  46. }