quanwei
2025-11-03 ef5d748e3e3331bd20d4065c33e7867c2637d1db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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));
    }
 
}