12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\shopapi\validate;
-
- use app\common\basics\Validate;
- use app\common\model\shop\Shop;
- use app\common\model\shop\ShopBank;
- use app\common\server\ConfigServer;
-
-
- class ShopWithdrawValidate extends Validate{
- protected $rule = [
- 'money' => '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 '账户不存在,请重新选择';
- }
-
- }
|