liyaozhi
2025-10-28 1320688354fd168c51cf2e05f29a2253f4ed9c00
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
 
namespace app\shop\model\takeout;
 
use app\common\model\takeout\Commander as CommanderModel;
 
/**
 * 用户模型
 * Class User
 * @package app\shop\model\takeout
 */
class Commander extends CommanderModel
{
    /**
     * 获取列表
     */
    public function getList($data)
    {
        // 构建查询规则
        $model = $this->alias('commander')->with(['school'])
            ->field('commander.*, user.nickName, user.avatarUrl')
            ->join('user', 'user.user_id = commander.user_id')
            ->where('commander.is_delete', '=', 0)
            ->where('user.is_delete', '=', 0)
            ->order(['commander.create_time' => 'desc']);
        // 查询条件
        if (!empty($data['nick_name'])) {
            $model = $model->where('user.nickName|commander.real_name|commander.mobile', 'like', '%' . $data['nick_name'] . '%');
        }
        // 获取列表数据
        $list = $model->paginate($data);
        /*foreach ($list as &$val){
 
        }*/
        return $list;
    }
    /**
     * 编辑用户
     * @param $data
     * @return bool
     */
    public function edit($data)
    {
       return $this->save($data);
    }
 
 
    /**
     * 删除
     * @return mixed
     */
    public function setDelete()
    {
        // 标记为已删除
        return $this->save([
            'is_delete' => 1
        ]);
    }
 
    /**
     * 提现打款成功:累积提现佣金
     */
    public static function totalMoney($commander_id, $money)
    {
        $model = self::detail($commander_id);
        return $model->save([
            'freeze_money' => $model['freeze_money'] - $money,
            'total_money' => $model['total_money'] + $money,
        ]);
    }
 
    /**
     * 提现驳回:解冻分销商资金
     */
    public static function backFreezeMoney($commander_id, $money)
    {
        $model = self::detail($commander_id);
        return $model->save([
            'money' => $model['money'] + $money,
            'freeze_money' => $model['freeze_money'] - $money,
        ]);
    }
 
}