74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace app\api\validate;
|
|
|
|
use app\common\basics\Validate;
|
|
use app\common\model\subsidy_withdrawal\SubsidyWithdrawal;
|
|
use app\common\server\ConfigServer;
|
|
use app\api\logic\BillionsLogic;
|
|
|
|
class BillionsWithdrawValidate extends Validate
|
|
{
|
|
protected $rule = [
|
|
'id' => 'require', //参数缺失
|
|
'type' => 'require|in:1,2,3,4,5',//提现类型
|
|
'money' => 'require|checkMoney',//提现佣金
|
|
'account' => 'requireIf:type,3|requireIf:type,4|requireIf:type,5',//账户类型
|
|
'real_name' => 'requireIf:type,3|requireIf:type,4|requireIf:type,5|chs',//真实姓名
|
|
'money_qr_code' => 'requireIf:type,3|requireIf:type,4',//收款码
|
|
'bank' => 'requireIf:type,5', // 提现银行
|
|
'subbank' => 'requireIf:type,5', // 银行支行
|
|
];
|
|
|
|
protected $message = [
|
|
'id.require' => '参数缺失',
|
|
'type.require' => '参数错误',
|
|
'type.in' => '提现类型错误',
|
|
'money.require' => '参数错误',
|
|
'account.requireIf' => '请填写账号',
|
|
'real_name.requireIf' => '请填写真实姓名',
|
|
'real_name.chs' => '请填写真实姓名',
|
|
'money_qr_code.requireIf' => '请上传收款码',
|
|
'bank.requireIf' => '请填写提现银行',
|
|
'subbank.requireIf' => '请填写银行支行',
|
|
];
|
|
|
|
public function sceneApply()
|
|
{
|
|
return $this->only(['type', 'money', 'account', 'real_name', 'money_qr_code', 'bank', 'subbank']);
|
|
}
|
|
|
|
public function sceneInfo()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
|
|
protected function checkMoney($value, $rule, $data = [])
|
|
{
|
|
$able_withdraw = SubsidyWithdrawal::where('user_id', $data['user_id'])->value('total_amount');
|
|
|
|
// 1.如果提现金额大于余额
|
|
if ($value > $able_withdraw) {
|
|
return '可提现金额不足';
|
|
}
|
|
|
|
// 2.最低提现金额
|
|
$min_withdraw = BillionsLogic::MINIMUM_WITHDRAWAL;
|
|
if ($value < $min_withdraw) {
|
|
return '最低提现' . $min_withdraw . '元';
|
|
}
|
|
|
|
// 3.最高提现金额
|
|
$max_withdraw = BillionsLogic::MAXIMUM_WITHDRAWAL;
|
|
if ($value > $max_withdraw) {
|
|
return '最高提现' . $max_withdraw . '元';
|
|
}
|
|
|
|
// 4.如果提现金额在扣除手续费之后,小于最低提现金额则提现失败
|
|
$left_money = $value - ($value * (BillionsLogic::COMMISSION / 100));
|
|
if ($left_money < $min_withdraw) {
|
|
return '扣除手续费后提现金额不能小于' . $min_withdraw . '元';
|
|
}
|
|
return true;
|
|
}
|
|
} |