Browse Source

Merge branch 'master' of http://git.huxiukeji.com/zhangxiaobin/ggyuyin

lizhen_gitee 1 year ago
parent
commit
e5349c31f1

+ 20 - 7
application/api/controller/Money.php

@@ -109,14 +109,27 @@ class Money extends Common
         $time = time();
         $money = (float)bcadd($amount, 0, 2);
         // 生成订单
+        $epayConfig = get_addon_config('epay');
+        if ($type == 'wechat') {
+            $payType = 1;
+            $businessNo = isset($epayConfig['wechat']['mch_id']) ? $epayConfig['wechat']['mch_id'] : '';
+        } elseif ($type == 'alipay') {
+            $payType = 2;
+            $businessNo = isset($epayConfig['wechat']['app_id']) ? $epayConfig['wechat']['app_id'] : '';
+        } else {
+            $payType = 3;
+            $businessNo = '';
+        }
         $recharOrderMode = new \app\common\model\RecharOrder();
-//        $data = [];
-//        $data["user_id"] = $user_id;
-//        $data["order_no"] = $out_trade_no;
-//        $data["money"] = $money;
-//        $data["jewel"] = $recharInfo["jewel"];
-//        $data["createtime"] = time();
-        $orderid = $recharOrderMode->execute("INSERT INTO `hx_rechar_order` (`user_id` , `order_no` , `money` , `jewel` , `createtime`) VALUES ($user_id , $out_trade_no , $money , " . $jewel . " , $time)");
+        $data["user_id"] = $user_id;
+        $data["order_no"] = $out_trade_no;
+        $data["money"] = $money;
+        $data["jewel"] = $jewel;
+        $data["pay_type"] = $payType;//支付渠道:1=微信,2=支付宝,3=衫德
+        $data["business_no"] = $businessNo;//商户号
+        $data["createtime"] = $time;
+        //$orderid = $recharOrderMode->execute("INSERT INTO `hx_rechar_order` (`user_id` , `order_no` , `money` , `jewel` , `createtime`) VALUES ($user_id , $out_trade_no , $money , " . $jewel . " , $time)");
+        $orderid = $recharOrderMode->insertGetId($data);
         if (!$orderid) $this->error("订单创建失败!");
         $payTest = config('pay_test');//支付测试:0=正常,1=支付0.01
         if ($payTest == 1) {

+ 7 - 1
application/api/controller/Notify.php

@@ -184,8 +184,14 @@ class Notify extends Api
                         // +EXP 充值超过100
                         \app\common\model\TaskLog::tofinish($orderInfo["user_id"], "DaCVgOLu", 1);
                     }
-                    Db::commit();
+
+                } else {
+                    $res1 = $orderModel->update(["status" => -1], ["order_no" => $out_trade_no]);
+                    if (!$res1) {
+                        throw new Exception('更新充值状态失败:'.$out_trade_no);
+                    }
                 }
+                Db::commit();
             } catch (ValidateException $e) {
                 Db::rollback();
                 $this->error($e->getMessage());

+ 60 - 53
application/api/controller/Withdraw.php

@@ -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());
         }
-
     }
 
     /**