quanwei
2025-11-01 121b714d710cf3c865f4a1b5efe81abec11056d1
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
85
<?php
 
namespace app\branch\controller\cash;
 
use app\branch\model\order\Order as OrderModel;
use app\branch\controller\Controller;
use app\branch\model\branch\Account as BranchAccountModel;
use app\branch\model\branch\Branch as BranchModel;
use app\branch\model\branch\Cash as BranchCashModel;
use app\branch\model\order\OrderRefund as OrderRefundModel;
use app\branch\model\order\OrderSettled as OrderSettledModel;
use app\branch\model\branch\Capital as BranchCapitalModel;
/**
 * 提现
 */
class Cash extends Controller
{
    /**
     * 首页概况
     */
    public function index()
    {
        $branch = BranchModel::detail($this->getBranchId());
        // 统计数据
        $tj_data = [
            'nosettled_money' => (new OrderModel())->getNoSettledMoney($this->getBranchId()),
            'refund_money' => (new OrderRefundModel())->getRefundMoney($this->getBranchId()),
            'agent_money' => (new OrderSettledModel())->getAgentMoney($this->getBranchId()),
            'team_money' => (new OrderSettledModel())->getTeamMoney($this->getBranchId()),
            'region_money' => (new OrderSettledModel())->getRegionMoney($this->getBranchId()),
            'shareholder_money' => (new OrderSettledModel())->getShareholderMoney($this->getBranchId()),
        ];
        // 收入列表
        $cash_list = (new BranchCapitalModel())->getList($this->getBranchId(), $this->postData());
        return $this->renderSuccess('', compact('branch', 'tj_data', 'cash_list'));
    }
 
 
    /**
     * 获取提现金额
     */
    public function getCapitalMoney()
    {
        $postData = $this->postData();
        $money = (new BranchCapitalModel())->getCapitalMoney($this->getBranchId(), $postData);
        $date = date("Y-m-d",strtotime($postData["start_day"]))." - ".date("Y-m-d",strtotime($postData["end_day"]));
        return $this->renderSuccess('', compact('money', 'date'));
    }
 
 
    /**
     * 保存用户提现账户信息
     */
    public function account(){
        if($this->request->isGet()){
            $model = BranchAccountModel::detail($this->getBranchId());
            return $this->renderSuccess('', compact('model'));
        }
        $model = new BranchAccountModel();
        if($model->add($this->getBranchId(), $this->postData())){
            return $this->renderSuccess('操作成功', compact('model'));
        }
        return $this->renderError($model->getError()?:'保存失败');
    }
 
    /**
     * 提现记录
     */
    public function lists(){
        $model = new BranchCashModel();
        $list = $model->getList($this->getBranchId(), $this->postData());
        return $this->renderSuccess('', compact('list'));
    }
 
    /**
     * 申请提现
     */
    public function apply(){
        $model = new BranchCashModel;
        if ($model->submit($this->getBranchId(), $this->postData())) {
            return $this->renderSuccess('申请提现成功');
        }
        return $this->renderError($model->getError() ?: '提交失败');
    }
}