'请填写身份证号码'], ['id_card', 'checkIdCard'], ['card0', 'required', 'message' => '请选择身份证正面照片'], ['card0', 'file'], ['card1', 'required', 'message' => '请选择身份证反面照片'], ['card1', 'file'], ['name', 'required', 'message' => '请填写姓名'], ['address', 'required', 'message' => '请填写地址'], //['mobile', 'required', 'message' => '请填写手机号码'], //['mobile', 'match', 'pattern' => '/^1(3[0-9]|4[57]|5[0-35-9]|7[01678]|8[0-9])\d{8}$/'], ['email', 'required', 'message' => '请填写电子邮箱'], ['email', 'email'], ['rid', 'required', 'message' => '请填写推荐人ID'], ['ref_id', 'required', 'message' => '请填写上级代理ID'], ['vcode', 'required', 'message' => '请填写邮件验证码'], ['vcode', 'checkMailVcode'], /* ['bank_name', 'required', 'message' => '请选择银行'], ['bank_province', 'required', 'message' => '请选择省'], ['bank_city', 'required', 'message' => '请选择市'], ['bank_branch', 'required', 'message' => '请填写支行名称'], ['bank_card_no', 'required', 'message' => '请填写银行卡号'], ['bank_card_no', 'checkBankCardNo'], ['bank_swift_code', 'required', 'message' => '请填写银行swift代码'], */ ['collect_name', 'required', 'message' => '请填写收款人姓名'], ['rid', 'integer'], [['agree1', 'agree2'], 'boolean', 'trueValue' => 'on'], ]; } /** * @param string $attribute * @param array $params */ public function checkIdCard($attribute, $params = []) { if (!$this->hasErrors()) { if (Idcard::getInstance()->isChinaIDCard($this->id_card) == false) { $this->addError($attribute, '身份证号码格式错误'); } } } /** * @param string $attribute * @param array $params */ public function checkBankCardNo($attribute, $params = []) { if (!$this->hasErrors()) { if (BankCardHelper2::check_bankCard($this->bank_card_no) == false) { $this->addError($attribute, '银行卡账号格式错误'); } } } /** * @param string $attribute * @param array $params */ public function checkMailVcode($attribute, $params = []) { if (!$this->hasErrors()) { $api = new MailApi(); $result = $api->getMailCode($this->email); if ($result['code'] == 1) { $code = isset($result['data']['code']) ? trim($result['data']['code']) : ''; $created = isset($result['data']['created']) ? trim($result['data']['created']) : 0; if ($code == $this->vcode && (intval($created / 1000) + 1800) >= time()) { // 验证码正确 有效 } else { $this->addError($attribute, '邮件证码错误'); } } } } /** * 代理商(ib)开户申请 * @return bool */ public function complete() { if ($this->validate()) { $open = $openRecord = []; $openApi = new OpenApi(); $open['open_type'] = 2; $open['name'] = $this->name; $open['id_card'] = $this->id_card; $open['email'] = $this->email; //$open['mobile'] = $this->mobile; $webRoot = \Yii::getAlias('@webroot'); if ($this->card0 instanceof UploadedFile) { $filename = false; for ($i = 0; $i < 2; $i++) { $temp = '/upload/' . date('YmdHis_') . mt_rand(10000, 99999) . '.' . $this->card0->getExtension(); if (!is_file($webRoot . $temp)) { $filename = $temp; break; } } if ($filename != false && $this->card0->saveAs($webRoot . $filename)) { $open['id_card_file_path0'] = $filename; } } if ($this->card1 instanceof UploadedFile) { $filename = false; for ($i = 0; $i < 2; $i++) { $temp = '/upload/' . date('YmdHis_') . mt_rand(10000, 99999) . '.' . $this->card1->getExtension(); if (!is_file($webRoot . $temp)) { $filename = $temp; break; } } if ($filename != false && $this->card1->saveAs($webRoot . $filename)) { $open['id_card_file_path1'] = $filename; } } $open['rid'] = $this->rid; $open['address'] = $this->address; $rs = $openApi->open($open); if ($rs['code'] == 1) { $open_id = $rs['data']['id']; $openRecord['open_id'] = $open_id; $openRecord['ref_id'] = $this->ref_id; $openRecord['collect_name'] = $this->collect_name; /* $openRecord['bank_name'] = $this->bank_name; $openRecord['bank_province'] = $this->bank_province; $openRecord['bank_city'] = $this->bank_city; $openRecord['bank_district'] = $this->bank_district; $openRecord['bank_branch'] = $this->bank_branch; $openRecord['bank_card_no'] = $this->bank_card_no; $openRecord['bank_swift_code'] = $this->bank_swift_code; */ $result = $openApi->openRecord($openRecord); if ($result['code'] == 1) { return true; } else { if (is_array($result['message'])) { $this->addErrors($result['message']); } else { $this->addError('name', $result['message']); } } } else { if (is_array($rs['message'])) { $this->addErrors($rs['message']); } else { $this->addError('name', $rs['message']); } } } else { $this->addErrors($this->getErrors()); } return !$this->hasErrors(); } }