'require|gt:0|checkMoney', 'bank_id' => 'require|checkBank', ]; protected $message = [ 'money.require' => '请输入提现金额', 'money.gt' => '提现金额必须大于零', 'bank_id.require' => '请现在提现账户', ]; //验证提现金额是否满足条件 protected function checkMoney($value,$rule,$data){ $min_withdrawal_money = ConfigServer::get('shop_withdrawal', 'min_withdrawal_money', 0); $max_withdrawal_money = ConfigServer::get('shop_withdrawal', 'max_withdrawal_money', 0); $wallet = Shop::where(['id'=>$data['shop_id']]) ->value("wallet"); if($wallet < $value){ return '当前账户仅剩:'.$wallet.'元'; } if($min_withdrawal_money > $value){ return '最低提现金额:'.$min_withdrawal_money.'元'; } if($max_withdrawal_money < $value){ return '最高提现金额:'.$max_withdrawal_money.'元'; } return true; } //验证提现账户是否存在 protected function checkBank($value,$rule,$data){ if(ShopBank::where(['id'=>$value,'shop_id'=>$data['shop_id'],'del'=>0])->find()){ return true; } return '账户不存在,请重新选择'; } }