|
@@ -176,65 +176,72 @@ class Withdraw extends Common
|
|
|
* 绑定银行卡
|
|
|
*/
|
|
|
public function bindBank() {
|
|
|
- $realname = $this->request->request('realname');// 真实姓名
|
|
|
- $bank_no = $this->request->request('bank_no');// 银行账号
|
|
|
- $idCard = $this->request->request('id_card');// 身份证号
|
|
|
- /*$bank_name = $this->request->request('bank_name');// 银行名称
|
|
|
- $open_address = $this->request->request('open_address');// 开户地*/
|
|
|
- $open_bank = $this->request->request('open_bank');// 开户行
|
|
|
- /*$bank_mobile = $this->request->request('bank_mobile');// 银行预留手机号
|
|
|
- $captcha = $this->request->request('captcha'); // 验证码
|
|
|
- $mobile = $this->request->request('mobile'); // 手机号*/
|
|
|
- $userId = $this->auth->id;
|
|
|
- //|| !$bank_name || !$open_address || !$bank_mobile || !$captcha || !$mobile
|
|
|
- if(!$realname || !$bank_no || !$open_bank ) {
|
|
|
- $this->error("请将信息填写完整");
|
|
|
- }
|
|
|
- $userService = new UserService();
|
|
|
- $aliParams = [
|
|
|
- 'bank_no' => $bank_no,
|
|
|
- 'id_card' => $idCard,
|
|
|
- 'real_name' => $realname,
|
|
|
- ];
|
|
|
- $aliBankCheckRes = $userService->bankCheck($aliParams);
|
|
|
- if (!$aliBankCheckRes['status']) {
|
|
|
- throw new Exception($aliBankCheckRes['msg']);
|
|
|
- }
|
|
|
- // 获取用户信息
|
|
|
- //$userInfo = \app\common\model\User::where(["id"=>$this->auth->id])->find();
|
|
|
+ try {
|
|
|
+ $realname = $this->request->request('realname');// 真实姓名
|
|
|
+ $bank_no = $this->request->request('bank_no');// 银行账号
|
|
|
+ //$idCard = $this->request->request('id_card');// 身份证号
|
|
|
+ /*$bank_name = $this->request->request('bank_name');// 银行名称
|
|
|
+ $open_address = $this->request->request('open_address');// 开户地*/
|
|
|
+ $open_bank = $this->request->request('open_bank');// 开户行
|
|
|
+ /*$bank_mobile = $this->request->request('bank_mobile');// 银行预留手机号
|
|
|
+ $captcha = $this->request->request('captcha'); // 验证码
|
|
|
+ $mobile = $this->request->request('mobile'); // 手机号*/
|
|
|
+ $userId = $this->auth->id;
|
|
|
+ //|| !$bank_name || !$open_address || !$bank_mobile || !$captcha || !$mobile
|
|
|
+ if(!$realname || !$bank_no || !$open_bank ) {
|
|
|
+ throw new Exception("请将信息填写完整");
|
|
|
+ }
|
|
|
+ $userAuthWhere['user_id'] = $userId;
|
|
|
+ $userAuth = model('UserAuth')->where($userAuthWhere)->find();
|
|
|
+ if (empty($userAuth)) {
|
|
|
+ throw new Exception('请先实名认证');
|
|
|
+ }
|
|
|
+ $idCard = $userAuth['idcard'];
|
|
|
+ $userService = new UserService();
|
|
|
+ $aliParams = [
|
|
|
+ 'bank_no' => $bank_no,
|
|
|
+ 'id_card' => $idCard,
|
|
|
+ 'real_name' => $realname,
|
|
|
+ ];
|
|
|
+ $aliBankCheckRes = $userService->bankCheck($aliParams);
|
|
|
+ if (!$aliBankCheckRes['status']) {
|
|
|
+ throw new Exception($aliBankCheckRes['msg']);
|
|
|
+ }
|
|
|
+ // 获取用户信息
|
|
|
+ //$userInfo = \app\common\model\User::where(["id"=>$this->auth->id])->find();
|
|
|
|
|
|
- /*if($userInfo->mobile !== $mobile) $this->error("请输入账号绑定的手机号码!");
|
|
|
+ /*if($userInfo->mobile !== $mobile) $this->error("请输入账号绑定的手机号码!");
|
|
|
|
|
|
- if (!Sms::check($mobile, $captcha, 'binkBank')) {
|
|
|
- $this->error(__('验证码不正确!'));
|
|
|
- }*/
|
|
|
+ if (!Sms::check($mobile, $captcha, 'binkBank')) {
|
|
|
+ $this->error(__('验证码不正确!'));
|
|
|
+ }*/
|
|
|
|
|
|
- // 查询是否有过绑定
|
|
|
- $bankInfo = \app\common\model\UserBank::where(["user_id"=>$userId])->find();
|
|
|
- $data = [];
|
|
|
- $data["realname"] = $realname;
|
|
|
- $data["bank_no"] = $bank_no;
|
|
|
- $data["open_bank"] = $open_bank;
|
|
|
- $data["id_card"] = $idCard;
|
|
|
- /*$data["bank_name"] = $bank_name;
|
|
|
- $data["open_address"] = $open_address;
|
|
|
- $data["mobile"] = $bank_mobile;*/
|
|
|
- if($bankInfo) {
|
|
|
- $data["updatetime"] = time();
|
|
|
- $res = \app\common\model\UserBank::update($data,["user_id"=>$userId]);
|
|
|
- } else {
|
|
|
- $data["user_id"] = $userId;
|
|
|
- $data["createtime"] = time();
|
|
|
- $res = \app\common\model\UserBank::insert($data);
|
|
|
- }
|
|
|
+ // 查询是否有过绑定
|
|
|
+ $bankInfo = \app\common\model\UserBank::where(["user_id"=>$userId])->find();
|
|
|
+ $data = [];
|
|
|
+ $data["realname"] = $realname;
|
|
|
+ $data["bank_no"] = $bank_no;
|
|
|
+ $data["open_bank"] = $open_bank;
|
|
|
+ $data["id_card"] = $idCard;
|
|
|
+ /*$data["bank_name"] = $bank_name;
|
|
|
+ $data["open_address"] = $open_address;
|
|
|
+ $data["mobile"] = $bank_mobile;*/
|
|
|
+ if($bankInfo) {
|
|
|
+ $data["updatetime"] = time();
|
|
|
+ $res = \app\common\model\UserBank::update($data,["user_id"=>$userId]);
|
|
|
+ } else {
|
|
|
+ $data["user_id"] = $userId;
|
|
|
+ $data["createtime"] = time();
|
|
|
+ $res = \app\common\model\UserBank::insert($data);
|
|
|
+ }
|
|
|
|
|
|
- if($res) {
|
|
|
- //Sms::flush($mobile, 'binkBank');
|
|
|
+ if(!$res) {
|
|
|
+ throw new Exception("网络异常,请稍后重试!");
|
|
|
+ }
|
|
|
$this->success("银行卡绑定成功!");
|
|
|
- } else {
|
|
|
- $this->error("网络异常,请稍后重试!");
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|