<?php
|
|
namespace app\common\model\agent;
|
|
use app\common\model\BaseModel;
|
use app\common\enum\user\balanceLog\BalanceLogSceneEnum;
|
use app\agent\model\Agent;
|
/**
|
* 用户余额变动明细模型
|
*/
|
class BalanceLog extends BaseModel
|
{
|
protected $name = 'dlagent_balance_log';
|
protected $updateTime = false;
|
|
/**
|
* 获取当前模型属性
|
*/
|
public static function getAttributes()
|
{
|
return [
|
// 充值方式
|
'scene' => BalanceLogSceneEnum::data(),
|
];
|
}
|
|
/**
|
* 与代理商关联
|
* @return \think\model\relation\BelongsTo
|
*/
|
public function agent()
|
{
|
|
return $this->hasOne(Agent::class, 'agent_id', 'agent_id');
|
|
}
|
|
/**
|
* 余额变动场景
|
*/
|
public function getSceneAttr($value)
|
{
|
return ['text' => BalanceLogSceneEnum::data()[$value]['name'], 'value' => $value];
|
}
|
|
/**
|
* 新增记录
|
*/
|
public static function add($scene, $data, $describeParam)
|
{
|
$model = new static;
|
$model->save(array_merge([
|
'scene' => $scene,
|
'describe' => $describeParam,
|
'app_id' => 0
|
], $data));
|
}
|
|
}
|