84 lines
1.7 KiB
PHP
84 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class DistributionPreIncome extends Model
|
|
{
|
|
public const STATUS_PENDING = 0;
|
|
public const STATUS_PROCESSING = 1;
|
|
public const STATUS_PROCESSED = 2;
|
|
|
|
public const TYPE_PRICE_DIFF = 1;
|
|
public const TYPE_LEVEL_SAME = 2;
|
|
public const TYPE_LEVEL_DIFF = 3;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $attributes = [
|
|
'status' => self::STATUS_PENDING,
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'rule' => 'json',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'user_id',
|
|
'order_id',
|
|
'type',
|
|
'agent_level',
|
|
'total_amount',
|
|
'total_sales_value',
|
|
'total_revenue',
|
|
'rule',
|
|
'status',
|
|
'remarks',
|
|
'rule',
|
|
'completed_at',
|
|
];
|
|
|
|
public static $typeTexts = [
|
|
self::TYPE_PRICE_DIFF => '推粉丝赚差价',
|
|
self::TYPE_LEVEL_SAME => '平级奖励',
|
|
self::TYPE_LEVEL_DIFF => '级差奖金',
|
|
];
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
public static $statusTexts = [
|
|
self::STATUS_PENDING => '待结算',
|
|
self::STATUS_PROCESSING => '结算中',
|
|
self::STATUS_PROCESSED => '已结算',
|
|
];
|
|
|
|
/**
|
|
* 仅查询未结算的预收益
|
|
*/
|
|
public function scopeUnsettlement($query)
|
|
{
|
|
return $query->whereIn('status', [
|
|
static::STATUS_PENDING,
|
|
static::STATUS_PROCESSING,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 此预收益的变更记录
|
|
*/
|
|
public function logs()
|
|
{
|
|
return $this->hasMany(DistributionPreIncomeLog::class, 'pre_income_id');
|
|
}
|
|
}
|