UserWalletApply.php 1.2 KB
<?php

namespace addons\groupon\controller;


class UserWalletApply extends Base
{

    protected $noNeedLogin = ['rule'];
    protected $noNeedRight = ['*'];


    public function index()
    {
        $this->success('提现记录', \addons\groupon\model\UserWalletApply::getList());
    }


    public function apply () {
        repeat_filter();        // 防抖
        $type = $this->request->post('type');
        $money = $this->request->post('money');
        
        $apply = \addons\groupon\model\UserWalletApply::apply($type, $money);

        if ($apply) {
            $this->success('申请成功');
        }
        $this->error('申请失败');
    }


    public function rule () {
        // 提现规则
        $config = \addons\groupon\model\UserWalletApply::getWithdrawConfig();
        $min = round(floatval($config['min']), 2);
        $max = round(floatval($config['max']), 2);
        $service_fee = floatval($config['service_fee']) * 100;
        $service_fee = round($service_fee, 1);      // 1 位小数

        $rule = [
            'min' => $min,
            'max' => $max,
            'service_fee' => $service_fee,
            'methods' => $config['methods'] ?? []
        ];

        $this->success('提现规则', $rule);
    }

}