JSON_SUCCESS_STATUS
JSON_SUCCESS_STATUS = 1
分销商提现 Class Withdraw
$view : \think\View
$request : \think\Request
__construct(\think\Request $request = null)
构造方法
\think\Request | $request | Request 对象 |
getUser(boolean $is_force = true) : \app\api\model\User|boolean|null
获取当前用户信息
boolean | $is_force |
validate(array $data, string|array $validate, array $message = array(), boolean $batch = false, mixed $callback = null) : array|string|true
验证数据
array | $data | 数据 |
string|array | $validate | 验证器名或者验证规则数组 |
array | $message | 提示信息 |
boolean | $batch | 是否批量验证 |
mixed | $callback | 回调方法(闭包) |
<?php
namespace app\api\controller\user\dealer;
use app\api\controller\Controller;
use app\api\model\dealer\Setting;
use app\api\model\dealer\User as DealerUserModel;
use app\api\model\dealer\Withdraw as WithdrawModel;
/**
* 分销商提现
* Class Withdraw
* @package app\api\controller\user\dealer
*/
class Withdraw extends Controller
{
/* @var \app\api\model\User $user */
private $user;
private $dealer;
private $setting;
/**
* 构造方法
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function _initialize()
{
parent::_initialize();
// 用户信息
$this->user = $this->getUser();
// 分销商用户信息
$this->dealer = DealerUserModel::detail($this->user['user_id']);
// 分销商设置
$this->setting = Setting::getAll();
}
/**
* 提交提现申请
* @param $data
* @return array
* @throws \app\common\exception\BaseException
*/
public function submit($data)
{
$formData = json_decode(htmlspecialchars_decode($data), true);
$model = new WithdrawModel;
if ($model->submit($this->dealer, $formData)) {
return $this->renderSuccess([], '申请提现成功');
}
return $this->renderError($model->getError() ?: '提交失败');
}
/**
* 分销商提现明细
* @param int $status
* @return array
* @throws \think\exception\DbException
*/
public function lists($status = -1)
{
$model = new WithdrawModel;
return $this->renderSuccess([
// 提现明细列表
'list' => $model->getList($this->user['user_id'], (int)$status),
// 页面文字
'words' => $this->setting['words']['values'],
]);
}
}