quanwei
2026-01-17 e1e2fe5710a5b5cd9c19bd3aa99c998a1a613ca8
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
<?php
 
namespace app\api\controller\user;
 
use app\api\controller\Controller;
use app\api\model\user\Cash as CashModel;
use app\api\model\settings\Setting as SettingModel;
 
/**
 * 用户余额提现
 */
class Cash extends Controller
{
    private $user;
 
    /**
     * 构造方法
     */
    public function initialize()
    {
        parent::initialize();
        // 用户信息
        $this->user = $this->getUser();
    }
 
    /**
     * 提现数据
     */
    public function index()
    {
        $cash_ratio = SettingModel::getItem('balance_cash')['cash_ratio'];
        $balance = $this->user['balance'];
        return $this->renderSuccess('', compact('cash_ratio', 'balance'));
    }
 
    /**
     * 提交提现申请
     */
    public function submit($data)
    {
        $formData = json_decode(htmlspecialchars_decode($data), true);
        $model = new CashModel;
        if ($model->submit($this->user, $formData)) {
            return $this->renderSuccess('申请提现成功');
        }
        return $this->renderError($model->getError() ?: '提交失败');
    }
 
    /**
     * 余额提现明细
     */
    public function lists($status = -1)
    {
 
        $model = new CashModel;
        return $this->renderSuccess('', [
            // 提现明细列表
            'list' => $model->getList($this->user['user_id'], (int)$status, $this->postData()),
        ]);
    }
 
}