123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
-
- namespace app\api\validate;
-
- use app\common\basics\Validate;
- use app\common\server\ConfigServer;
- use app\common\model\user\User;
-
-
- class WithdrawValidate 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 = User::where('id', $data['user_id'])->value('earnings');
- if ($value > $able_withdraw) {
- return '可提现金额不足';
- }
-
-
- $min_withdraw = ConfigServer::get('withdraw', 'min_withdraw', 0);
- if ($value < $min_withdraw) {
- return '最低提现' . $min_withdraw . '元';
- }
-
-
- $max_withdraw = ConfigServer::get('withdraw', 'max_withdraw', 0);
- if ($value > $max_withdraw) {
- return '最高提现' . $max_withdraw . '元';
- }
- return true;
- }
- }
|