mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-07 04:59:36 +00:00
1. 修复原版本中节点/用户每日流量日志记录错误; 原版:在30号看到的29号的总流量,其实是28号当天产生的流量;依次类推全部流量都错位1天; 现:日流量表精确到当天,天流量表精确到当前; 2. 修复原流量折线图的日期-流量配对错误; 原版:并不是按照记录日期,而是按照有的记录; 现:按照记录日期排序; ----- 以上皆为SSRPanel中遗留的问题代码----- 3. 简化,规范化日期转换 4. 清理多余代码;
75 lines
2.5 KiB
PHP
75 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Models;
|
||
|
||
use Auth;
|
||
use Illuminate\Database\Eloquent\Builder;
|
||
use Illuminate\Database\Eloquent\Model;
|
||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||
|
||
/**
|
||
* 返利日志
|
||
*
|
||
* @property int $id
|
||
* @property int $user_id 用户ID
|
||
* @property int $ref_user_id 推广人ID
|
||
* @property int $order_id 关联订单ID
|
||
* @property int $amount 消费金额,单位分
|
||
* @property int $ref_amount 返利金额
|
||
* @property int $status 状态:0-未提现、1-审核中、2-已提现
|
||
* @property \Illuminate\Support\Carbon $created_at 创建时间
|
||
* @property \Illuminate\Support\Carbon $updated_at 最后更新时间
|
||
* @property-read \App\Models\Order|null $order
|
||
* @property-read \App\Models\User|null $ref_user
|
||
* @property-read \App\Models\User|null $user
|
||
* @method static Builder|ReferralLog newModelQuery()
|
||
* @method static Builder|ReferralLog newQuery()
|
||
* @method static Builder|ReferralLog query()
|
||
* @method static Builder|ReferralLog uid()
|
||
* @method static Builder|ReferralLog whereAmount($value)
|
||
* @method static Builder|ReferralLog whereCreatedAt($value)
|
||
* @method static Builder|ReferralLog whereId($value)
|
||
* @method static Builder|ReferralLog whereOrderId($value)
|
||
* @method static Builder|ReferralLog whereRefAmount($value)
|
||
* @method static Builder|ReferralLog whereRefUserId($value)
|
||
* @method static Builder|ReferralLog whereStatus($value)
|
||
* @method static Builder|ReferralLog whereUpdatedAt($value)
|
||
* @method static Builder|ReferralLog whereUserId($value)
|
||
* @mixin \Eloquent
|
||
*/
|
||
class ReferralLog extends Model {
|
||
protected $table = 'referral_log';
|
||
|
||
public function scopeUid($query) {
|
||
return $query->whereRefUserId(Auth::id());
|
||
}
|
||
|
||
public function user(): HasOne {
|
||
return $this->hasOne(User::class, 'id', 'user_id');
|
||
}
|
||
|
||
public function ref_user(): HasOne {
|
||
return $this->hasOne(User::class, 'id', 'ref_user_id');
|
||
}
|
||
|
||
public function order(): HasOne {
|
||
return $this->hasOne(Order::class, 'oid', 'order_id');
|
||
}
|
||
|
||
public function getAmountAttribute($value) {
|
||
return $value / 100;
|
||
}
|
||
|
||
public function setAmountAttribute($value): void {
|
||
$this->attributes['amount'] = $value * 100;
|
||
}
|
||
|
||
public function getRefAmountAttribute($value) {
|
||
return $value / 100;
|
||
}
|
||
|
||
public function setRefAmountAttribute($value): void {
|
||
$this->attributes['ref_amount'] = $value * 100;
|
||
}
|
||
}
|