12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\model;
- use addons\faqueue\library\QueueApi;
- use think\Model;
- /**
- * 赠送礼物模型
- */
- class GiftUserParty extends Model
- {
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- /*
- protected static function init()
- {
- GiftUserParty::afterInsert(function ($giftUserParty) {
- if ($giftUserParty->party_id > 0) {
- $giftNotice = config("site.giftNotice");
- $bigGiftNotice = config("site.bigGiftNotice");
- $partyInfo = $giftUserParty->party;
- $money = $giftUserParty->value;
- $type = 0;
- if ($money >= $bigGiftNotice) {
- $type = 72;
- }elseif ($money >= $giftNotice){
- $type = 71;
- }
- $type > 0 and QueueApi::sendGroupMessage($type, $giftUserParty->user->nickname, $giftUserParty->toUser->nickname, $partyInfo, $giftUserParty);
- }
- });
- }
- */
- public function user()
- {
- return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function toUser()
- {
- return $this->belongsTo('app\common\model\User', 'user_to_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function party()
- {
- return $this->belongsTo('app\common\model\Party', 'party_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|