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
<?php
 
namespace app\branch\model\order;
 
use app\common\model\order\OrderSettled as OrderSettledModel;
 
/**
 * 售后管理模型
 */
class OrderSettled extends OrderSettledModel
{
    /**
     * 获取售后单列表
     */
    public function getList($branch_id, $params)
    {
        $model = $this;
        // 查询条件:订单号
        if (isset($params['order_no']) && !empty($params['order_no'])) {
            $model = $model->where('order.order_no', 'like', "%{$params['order_no']}%");
        }
        if(isset($params['start_day']) && !empty($params['start_day'])){
            $model = $model->where('settled.create_time', '>=', strtotime($params['start_day']));
        }
        if(isset($params['end_day']) && !empty($params['end_day'])){
            $model = $model->where('settled.create_time', '<', strtotime($params['end_day']));
        }
        // 是否结算
        if (isset($params['is_settled']) && $params['is_settled'] > -1) {
            $model = $model->where('settled.is_settled', '=', $params['is_settled']);
        }
        
        // 获取列表数据
        return $model->alias('settled')->field('settled.*')
            ->with(['orderMaster'])
            ->join('order', 'order.order_id = settled.order_id')
            ->where('settled.branch_id', '=', $branch_id)
            ->order(['settled.create_time' => 'desc'])
            ->paginate($params);
    }
    /**
     * 获取支出分销佣金
     */
    public function getAgentMoney($branch_id)
    {
        // 退款金额
        return $this->where('branch_id', '=', $branch_id)
            ->sum('agent_money');
    }
    /**
     * 获取支出团队分红
     */
    public function getTeamMoney($branch_id)
    {
        // 退款金额
        return $this->where('branch_id', '=', $branch_id)
            ->sum('team_money');
    }
    /**
     * 获取支出区域佣金
     */
    public function getRegionMoney($branch_id)
    {
        // 退款金额
        return $this->where('branch_id', '=', $branch_id)
            ->sum('region_money');
    }
    /**
     * 获取支出区域佣金
     */
    public function getShareholderMoney($branch_id)
    {
        // 退款金额
        return $this->where('branch_id', '=', $branch_id)
            ->sum('shareholder_money');
    }
}