Files
tuiguangzhushou/application/common/validate/Withdrawal.php
2020-08-06 15:26:41 +08:00

67 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\validate;
use think\Db;
use think\Validate;
class Withdrawal extends Validate
{
/**
* 验证规则
* @var array
*/
protected $rule = [
'money' => 'require|number|checkmoney:|checkaccount:',
'price' => 'checkprice:',
];
/**
* 提示信息
* @var array
*/
protected $message = [
'money.require' => '提现金额不能为空',
'money.number' => '提现金额必须是数字',
'money.checkmoney' => '提现金额必须大于100小于2000',
'money.checkaccount' => '账户余额不足',
'price.checkprice' => '实到金额不足1元不能提现',
];
public function checkaccount($value, $rule, $data)
{
$acc = Db::name('Account')->where(['uid' => $data['uid']])->value('price') ?: 0;
if ($value > abs($acc)) {
return false;
} else {
return true;
}
}
public function checkprice($value, $rule, $data)
{
if ($value < 1) {
return false;
} else {
return true;
}
}
protected function checkmoney($value, $rule, $data)
{
if ($value < 100 || $value > 2000) {
return false;
} else {
return true;
}
}
}