Explorar el Código

提现拿出来,用户银行与支付宝绑定,用户银行阿里云三方验证,尚未验证

lizhen_gitee hace 1 año
padre
commit
11fe2b1cbf

+ 74 - 0
application/api/controller/Takecash.php

@@ -0,0 +1,74 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 提现
+ */
+class Takecash extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    //提现配置
+    public function take_cash_config(){
+        $idcard_confirm = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->find();
+
+        $data = [
+            'money' => model('wallet')->getwallet($this->auth->id,'money'),
+            'alipay_account' => ($this->auth->idcard_status == 1 && isset($idcard_confirm['alipay_account'])) ? $idcard_confirm['alipay_account'] : '',
+            'min' => 1,
+            'max' => 1000,
+        ];
+
+        $this->success('success',$data);
+    }
+
+    //提现
+    public function take_cash(){
+        $money = floatval(input_post('money',0));
+
+        if(empty($money)){
+            $this->error();
+        }
+
+        if(empty($this->auth->idcard_status)){
+            $this->error('请先完成实名认证');
+        }
+
+        $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
+        if($check){
+            $this->error('您已经申请了提现,请等待审核');
+        }
+
+        $user_money = model('wallet')->getwallet($this->auth->id,'money');
+        if($money > $user_money){
+            $this->error('提现金额不能大于可提现余额');
+        }
+
+        $idcard_confirm = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->find();
+        $data = [
+            'user_id' => $this->auth->id,
+            'number' => $money,
+            'alipay_account' => $idcard_confirm['alipay_account'],
+            'status' => 0,
+            'createtime' => time(),
+            'updatetime' => time(),
+        ];
+
+        Db::name('take_cash')->insertGetId($data);
+
+        //审核时候再扣,或者这里先扣,等需求方确认
+        $this->success('申请成功请等待审核');
+    }
+
+    //提现记录
+    public function take_cash_log(){
+        $list = Db::name('take_cash')->where(['user_id'=>$this->auth->id])->autopage()->select();
+
+        $this->success('success',$list);
+    }
+
+}

+ 0 - 42
application/api/controller/User.php

@@ -418,49 +418,7 @@ class User extends Api
         $this->success('success',$check);
         $this->success('success',$check);
     }
     }
 
 
-    //申请私密视频
-    public function apply_secretvideo(){
-        $secretvideo = input('secretvideo','');
 
 
-        if(empty($secretvideo)){
-            $this->error();
-        }
-
-        Db::startTrans();
-        $check = Db::name('user_secretvideo')->where('user_id',$this->auth->id)->lock(true)->find();
-        if(!empty($check)){
-            if($check['status'] == 0){
-                Db::rollback();
-                $this->error('您已经提交私密视频,请等待审核');
-            }
-        }
-
-        $data = [
-            'user_id' => $this->auth->id,
-            'secretvideo' => $secretvideo,
-            'status' => 0,
-            'createtime' => time(),
-            'updatetime' => time(),
-            'audittime'  => 0,
-            'auditremark' => '',
-        ];
-
-        //更新
-        $update_rs = Db::name('user')->where('id',$this->auth->id)->update(['secretvideo_status'=>0]);
-        if(!empty($check)){
-            $rs = Db::name('user_secretvideo')->where('id',$check['id'])->update($data);
-        }else{
-            $rs = Db::name('user_secretvideo')->insertGetId($data);
-        }
-
-        if(!$rs || !$update_rs){
-            Db::rollback();
-            $this->error('提交失败');
-        }
-
-        Db::commit();
-        $this->success('提交成功,请等待审核');
-    }
 
 
     //申请实名认证
     //申请实名认证
     public function apply_idcard_confirm(){
     public function apply_idcard_confirm(){

+ 155 - 0
application/api/controller/Userbank.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+use app\common\service\UserService;
+
+
+/**
+ *
+ */
+class Userbank extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    /**
+     * 验证身份证号
+     */
+    public function validateCard() {
+        $idcard = $this->request->request('idcard');// 身份证号
+        if(!$idcard) $this->error("参数缺失!");
+        // 获取用户信息
+        $idcardInfo = \app\common\model\UserAuth::where(["user_id"=>$this->auth->id])->value("idcard");
+        if($idcardInfo === $idcard) {
+            $this->success("验证成功!");
+        } else {
+            $this->error("验证失败!");
+        }
+    }
+
+
+    /**
+     * 绑定银行卡
+     */
+    public function bindBank() {
+
+        $bank_no = $this->request->request('bank_no');// 银行账号
+
+        $open_bank = $this->request->request('open_bank');// 开户行
+
+        $userId = $this->auth->id;
+
+        if(!$bank_no || !$open_bank ) {
+            $this->error("请将信息填写完整");
+        }
+        $userAuthWhere['user_id'] = $userId;
+        $userAuth = Db::name('user_auth')->where($userAuthWhere)->find();
+        if (empty($userAuth)) {
+            $this->error('请先实名认证');
+        }
+        if ($userAuth['status'] != 1) {
+            $this->error('请先实名认证通过');
+        }
+        $realname = $userAuth['realname'];
+        $idCard = $userAuth['idcard'];
+        $userService = new UserService();
+        $aliParams = [
+            'bank_no' => $bank_no,
+            'id_card' => $idCard,
+            'real_name' => $realname,
+        ];
+        $aliBankCheckRes = $userService->bankCheck($aliParams);
+        if (!$aliBankCheckRes['status']) {
+            $this->error($aliBankCheckRes['msg']);
+        }
+
+
+        // 查询是否有过绑定
+        $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;
+
+        if($bankInfo) {
+            $res = Db::name('user_bank')->where(["user_id"=>$userId])->update($data);
+        } else {
+            $data["user_id"] = $userId;
+            $res = Db::name('user_bank')->insertGetId($data);
+        }
+
+        if(!$res) {
+            $this->error("网络异常,请稍后重试!");
+        }
+        $this->success("银行卡绑定成功!");
+
+    }
+
+    /**
+     * 获取绑定银行卡信息
+     */
+    public function getBankInfo() {
+        // 查询是否有过绑定
+        $bankInfo = Db::name('user_bank')->where(["user_id"=>$this->auth->id])->find();
+
+        $this->success("获取成功!",$bankInfo);
+    }
+
+    /**
+     * 绑定支付宝
+     */
+    public function bindAlipay() {
+        $payNo = $this->request->request('pay_no');//支付宝账号
+
+        $userId = $this->auth->id;
+        //姓名和身份证号 取实名认证
+        $userAuthWhere['user_id'] = $userId;
+        $userAuth = Db::name('user_auth')->where($userAuthWhere)->find();
+        if (empty($userAuth)) {
+            $this->error('请先实名认证');
+        }
+        if ($userAuth['status'] != 1) {
+            $this->error('请先实名认证通过');
+        }
+        $realname = $userAuth['realname'];
+        $cardNo = $userAuth['idcard'];
+        if(!$realname || !$payNo || !$cardNo) {
+            $this->error("请将信息填写完整");
+        }
+
+        // 查询是否有过绑定
+        $bankInfo = Db::name('user_alipay')->where(["user_id"=>$userId])->find();
+        $data = [];
+        $data["realname"] = $realname;
+        $data["pay_no"] = $payNo;
+        $data["card_no"] = $cardNo;
+        if($bankInfo) {
+            $data["updatetime"] = time();
+            $res = Db::name('user_alipay')->where(["user_id"=>$userId])->update($data);
+        } else {
+            $data["user_id"] = $userId;
+            $data["createtime"] = time();
+            $res = Db::name('user_alipay')->insertGetId($data);
+        }
+        if($res) {
+            $this->success("支付宝绑定成功!");
+        } else {
+            $this->error("网络异常,请稍后重试!");
+        }
+    }
+
+    /**
+     * 获取绑定银行卡信息
+     */
+    public function getAlipayInfo() {
+        // 查询是否有过绑定
+        $alipayInfo = Db::name('user_alipay')->where(["user_id"=>$this->auth->id])->find();
+        $this->success("获取成功!",$alipayInfo);
+    }
+
+
+}

+ 0 - 57
application/api/controller/Userwallet.php

@@ -146,63 +146,6 @@ class Userwallet extends Api
         $this->success('success',$list);
         $this->success('success',$list);
     }
     }
 
 
-    //提现配置
-    public function take_cash_config(){
-        $idcard_confirm = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->find();
-
-        $data = [
-            'money' => model('wallet')->getwallet($this->auth->id,'money'),
-            'alipay_account' => ($this->auth->idcard_status == 1 && isset($idcard_confirm['alipay_account'])) ? $idcard_confirm['alipay_account'] : '',
-            'min' => 1,
-            'max' => 1000,
-        ];
-
-        $this->success('success',$data);
-    }
-
-    //提现
-    public function take_cash(){
-        $money = floatval(input_post('money',0));
-
-        if(empty($money)){
-            $this->error();
-        }
 
 
-        if(empty($this->auth->idcard_status)){
-            $this->error('请先完成实名认证');
-        }
-
-        $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
-        if($check){
-            $this->error('您已经申请了提现,请等待审核');
-        }
-
-        $user_money = model('wallet')->getwallet($this->auth->id,'money');
-        if($money > $user_money){
-            $this->error('提现金额不能大于可提现余额');
-        }
-
-        $idcard_confirm = Db::name('user_idconfirm')->where('user_id',$this->auth->id)->find();
-        $data = [
-            'user_id' => $this->auth->id,
-            'number' => $money,
-            'alipay_account' => $idcard_confirm['alipay_account'],
-            'status' => 0,
-            'createtime' => time(),
-            'updatetime' => time(),
-        ];
-
-        Db::name('take_cash')->insertGetId($data);
-
-        //审核时候再扣,或者这里先扣,等需求方确认
-        $this->success('申请成功请等待审核');
-    }
-
-    //提现记录
-    public function take_cash_log(){
-        $list = Db::name('take_cash')->where(['user_id'=>$this->auth->id])->autopage()->select();
-
-        $this->success('success',$list);
-    }
 
 
 }
 }

+ 390 - 0
application/common/service/UserService.php

@@ -0,0 +1,390 @@
+<?php
+
+namespace app\common\service;
+
+use fast\Random;
+use think\Exception;
+
+class UserService
+{
+
+    /**
+     * 获取请求参数
+     * @return void
+     */
+    public function faceAuth($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '获取成功',
+            'data' => [],
+        ];
+        try {
+            $idCard = isset($params['id_card']) ? $params['id_card'] : '';
+            $realName = isset($params['real_name']) ? $params['real_name'] : '';
+            $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+            $tencentConfig = config('tencent_yun');
+            $sercrtId = isset($tencentConfig['SecretId']) ? $tencentConfig['SecretId'] : '';
+            $sercrtKey = isset($tencentConfig['SecretKey']) ? $tencentConfig['SecretKey'] : '';
+            //获取token
+            $token_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/access_token?app_id='.$sercrtId.'&secret='.$sercrtKey.'&grant_type=client_credential&version=1.0.0';
+            $token_result = file_get_contents($token_url);
+            if (!$token_result) {
+                throw new Exception('您的网络开小差啦1~');
+            }
+            $token_result = json_decode($token_result, true);
+            if ($token_result['code'] != 0) {
+                throw new Exception('您的网络开小差啦2~');
+            }
+            $token = $token_result['access_token'];
+
+            //获取签名鉴权参数ticket
+            $ticket_url = 'https://miniprogram-kyc.tencentcloudapi.com/api/oauth2/api_ticket?app_id='.$sercrtId.'&access_token='.$token.'&type=SIGN&version=1.0.0';
+            $ticket_result = file_get_contents($ticket_url);
+            if (!$ticket_result) {
+                throw new Exception('您的网络开小差啦3~');
+            }
+            $ticket_result = json_decode($ticket_result, true);
+            if ($ticket_result['code'] != 0) {
+                throw new Exception('您的网络开小差啦4~');
+            }
+            $ticket = $ticket_result['tickets'][0]['value'];
+
+            //获取签名
+            $sign_data = [
+                'wbappid' => $sercrtId,
+                'userId'  => (string)$userId,
+                'version' => '1.0.0',
+                'ticket'  => $ticket,
+                'nonce'   => Random::alnum(32)
+            ];
+            asort($sign_data);//排序
+            $sign_string = join('', $sign_data);
+            $sign = sha1($sign_string);
+
+            //上传身份信息
+            $orderNo = getMillisecond() . $userId . mt_rand(1, 1000); //商户请求的唯一标识
+            $url = 'https://miniprogram-kyc.tencentcloudapi.com/api/server/getAdvFaceId?orderNo='.$orderNo;
+            $data = [
+                'webankAppId' => $sercrtId,
+                'orderNo' => $orderNo,
+                'userId' => (string)$userId,
+                'name' => $realName,//姓名
+                'idNo' => $idCard,//证件号
+                'version' => '1.0.0',
+                'sign' => $sign,
+                'nonce' => $sign_data['nonce']
+            ];
+            $res = curl_post($url,json_encode($data, 320), ['Content-Type: application/json']);
+            $result['data'] = json_decode($res,true);
+            $result['data']['nonce'] = $sign_data['nonce'];
+            $result['data']['sign'] = $sign;
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+
+    /**
+     * 阿里实名认证二要素
+     * https://market.aliyun.com/products/57000002/cmapi026109.html
+     * @return void
+     */
+    public function aliCheck($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '',
+            'data' => [],
+        ];
+        try {
+            $idCard = isset($params['id_card']) ? $params['id_card'] : '';
+            $realName = isset($params['real_name']) ? $params['real_name'] : '';
+            $aliyunConfig = config('ali_yun');
+            $host = "https://eid.shumaidata.com";
+            $path = "/eid/check";
+            $method = "POST";
+            $appcode = isset($aliyunConfig['app_code']) ? $aliyunConfig['app_code'] : '';
+            $headers = ['Content-Type: application/json'];
+            array_push($headers, "Authorization:APPCODE " . $appcode);
+            $querys = "idcard=".$idCard."&name=".urlencode($realName);
+            $bodys = "";
+            $url = $host . $path . "?" . $querys;
+
+            $curl = curl_init();
+            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
+            curl_setopt($curl, CURLOPT_URL, $url);
+            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+            curl_setopt($curl, CURLOPT_FAILONERROR, false);
+            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+            //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头
+            //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false
+            curl_setopt($curl, CURLOPT_HEADER, false);
+            if (1 == strpos("$".$host, "https://"))
+            {
+                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+            }
+            $returnRes = curl_exec($curl);
+            curl_close($curl);
+            $resultData = json_decode($returnRes,true);
+            if (isset($resultData['code']) && !empty($resultData['code'])) {
+                throw new Exception($resultData['message']);
+            }
+            if (isset($resultData['result']['res']) && $resultData['result']['res'] != 1) {
+                throw new Exception($resultData['result']['description']);
+            }
+            $result['data'] = $resultData;
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+
+    /**
+     * 阿里银行卡三要素
+     * https://market.aliyun.com/products/57000002/cmapi00063283.html
+     * @return void
+     */
+    public function bankCheck($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '',
+            'data' => [],
+        ];
+        try {
+            $bankcard = isset($params['bank_no']) ? $params['bank_no'] : '';//银行卡
+            $idCard = isset($params['id_card']) ? $params['id_card'] : '';//身份证号
+            $realName = isset($params['real_name']) ? $params['real_name'] : '';//姓名
+            $aliyunConfig = config('ali_yun');
+            $host = "https://sxbank3v2.market.alicloudapi.com";
+            $path = "/bankcard3/check";
+            $method = "POST";
+            $appcode = isset($aliyunConfig['app_code']) ? $aliyunConfig['app_code'] : '';
+            $headers = [];
+            array_push($headers, "Authorization:APPCODE " . $appcode);
+            $querys = "bankcard=".$bankcard."&idCard=".$idCard."&name=".urlencode($realName);
+            $bodys = "";
+            $url = $host . $path . "?" . $querys;
+
+            $curl = curl_init();
+            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
+            curl_setopt($curl, CURLOPT_URL, $url);
+            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
+            curl_setopt($curl, CURLOPT_FAILONERROR, false);
+            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+            //设定返回信息中是否包含响应信息头,启用时会将头文件的信息作为数据流输出,true 表示输出信息头, false表示不输出信息头
+            //如果需要将字符串转成json,请将 CURLOPT_HEADER 设置成 false
+            curl_setopt($curl, CURLOPT_HEADER, false);
+            if (1 == strpos("$".$host, "https://"))
+            {
+                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
+            }
+            $returnRes = curl_exec($curl);
+            curl_close($curl);
+            $resultData = json_decode($returnRes,true);
+            if (isset($resultData['code']) && !empty($resultData['code'])) {
+                throw new Exception($resultData['msg']);
+            }
+            $aliResult = isset($resultData['data']['result']) ? $resultData['data']['result'] : 0;
+            if ($aliResult != 1) {
+                //核查结果(1:一致,2:不一致,3:无效卡号或卡状态异常)
+                $aliMsg = '';
+                if ($aliResult == 2) {
+                    $aliMsg = '不一致';
+                } elseif ($aliResult == 3) {
+                    $aliMsg = '无效卡号或卡状态异常';
+                }
+                throw new Exception($aliMsg);
+            }
+            $result['data'] = $resultData;
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+
+    /**
+     * 邀请赠送金额
+     * @return void
+     */
+    public function inviteMoney($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '',
+            'data' => [],
+        ];
+        try {
+            $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+            if (!empty($userId)) {
+                $field = 'id,pre_userid,money';
+                $where['id'] = $userId;
+                $user = model('User')->field($field)->where($where)->find();
+                if (!empty($user)) {
+                    if (!empty($user['pre_userid'])) {
+                        $preWhere['id'] = $user['pre_userid'];
+                        $preUser = model('User')->field($field)->where($preWhere)->find();
+                        if (!empty($preUser)) {
+                            //查看是否赠送过金额
+                            $moneyLogWhere['invite_user_id'] = $userId;
+                            $moneyLogWhere['type'] = 103;
+                            $moneyLog = model('UserMoneyLog')->where($moneyLogWhere)->find();
+                            if (empty($moneyLog)) {
+                                //充值金额满足才能获取充值奖励
+                                $inviteMaxMoney = config('site.invite_max_money');
+                                $recharWhere['user_id'] = $userId;
+                                $recharWhere['status'] = 1;
+                                $userRecharMoney = model('RecharOrder')->where($recharWhere)->sum('money');
+                                if ($userRecharMoney >= $inviteMaxMoney) {
+                                    $money = config('site.invite_money');
+                                    if ($money > 0) {
+                                        $remark = '邀请推广充值';
+                                        $res = model('Wallet')->lockChangeAccountRemain($preUser['id'],$money,'+',$preUser['money'],$remark,103,'money',$userId);
+                                        if (!$res['status']) {
+                                            throw new Exception($res['msg']);
+                                        }
+                                    }
+                                    $inviteGift = config('site.invite_gift');
+                                    if ($inviteGift > 0) {
+                                        $inviteGiftNum = config('site.invite_gift_num');
+                                        $giftWhere['id'] = $inviteGift;
+                                        $gift = model('Gift')->where($giftWhere)->find();
+                                        if (!empty($gift) && $inviteGiftNum > 0) {
+                                            $userGiftBackWhere['user_id'] = $preUser['id'];
+                                            $userGiftBackWhere['invite_user_id'] = $userId;
+                                            $userGiftBackWhere['get_way'] = 5;
+                                            $userGiftBack = model('GiftBack')->where($userGiftBackWhere)->find();
+                                            if (empty($userGiftBack)) {
+                                                for($i=1;$i<=$inviteGiftNum;$i++) {
+                                                    $giftBack[] = [
+                                                        'user_id' => $preUser['id'],//用户ID
+                                                        'gift_id' => $inviteGift,//礼物ID
+                                                        'name' => $gift['name'],//礼物名称
+                                                        'image' => $gift['image'],//礼物静图
+                                                        'gif_image' => $gift['special'],//礼物动图
+                                                        'value' => $gift['value'],//购买价值
+                                                        'number' => 1,//数量
+                                                        'get_way' => 5,//获得途径:1=活动获得,2=充值购买,3=爵位赠送,4=签到赠送,5=邀请获得
+                                                        'createtime' => time(),
+                                                    ];
+                                                }
+                                                //$giftBackRes = model('GiftBack')->insertGetId($giftBack);
+                                                $giftBackRes = model('GiftBack')->insertAll($giftBack);
+                                                if (!$giftBackRes) {
+                                                    throw new Exception('赠送礼物失败');
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+
+    /**
+     * 获取用户家族角色
+     * @return void
+     */
+    public function getGuildRole($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '操作成功',
+            'data' => [],
+        ];
+        try {
+            $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+            $guildId = isset($params['guild_id']) ? $params['guild_id'] : 0;
+            if (empty($userId) || empty($guildId)) {
+                throw new Exception('参数错误');
+            }
+            $guildWhere['id'] = $guildId;
+            $guild = model('Guild')->where($guildWhere)->find();
+            if (empty($guild)) {
+                throw new Exception('未找到家族信息');
+            }
+            $guildRole = 4;//家族角色:1组长,2副族长,3成员,4非成员
+            if ($userId == $guild['user_id']) {
+                $guildRole = 1;
+            }
+            $guildMemberWhere['guild_id'] = $guildId;
+            $guildMemberWhere['user_id'] = $userId;
+            $guildMember = model('GuildMember')->field('id,role')->where($guildMemberWhere)->find();
+            if (!empty($guildMember)) {
+                if ($guildMember['role'] == 0) {
+                    $guildRole = 3;
+                } elseif ($guildMember['role'] == 1) {
+                    $guildRole = 2;
+                }
+            }
+            $result['data'] = [
+                'guild_role' => $guildRole,
+            ];
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+
+    /**
+     * 更新用户消费/魅力/礼物数据
+     * @return void
+     */
+    public function updateGuildMember($params=[])
+    {
+        $result = [
+            'status' => 1,
+            'msg' => '操作成功',
+            'data' => [],
+        ];
+        try {
+            $userId = isset($params['user_id']) ? $params['user_id'] : 0;
+            if (!empty($userId)) {
+                $guildMemberWhere['user_id'] = $userId;
+                $guildMember = model('GuildMember')->where($guildMemberWhere)->count();
+                if (!empty($guildMember)) {
+                    $wealth = $charm = $gift_num = 0;
+                    $userJewelLogWhere["type"] = ["in",[0,2,3,5,6,13]];//查看wallet.php文件
+                    $userJewelLogWhere["user_id"] = $userId;
+                    $userJewelLogPay = model('UserJewelLog')
+                        ->field("sum(value) as total_price")
+                        ->where($userJewelLogWhere)
+                        ->select();
+                    $wealth = isset($userJewelLogPay[0]['total_price']) ? (int)$userJewelLogPay[0]['total_price'] : 0;
+                    $userGiftWhere = [];
+                    $userGiftWhere["user_to_id"] = $userId;
+                    $userGift = model('GiftUserParty')
+                        ->field("sum(value) as total_price,sum(number)as gift_total_num")
+                        ->where($userGiftWhere)
+                        ->select();
+                    $charm = isset($userGift[0]['total_price']) ? (int)$userGift[0]['total_price'] : 0;
+                    $giftNum = isset($userGift[0]['gift_total_num']) ? (int)$userGift[0]['gift_total_num'] : 0;
+                    $guildMemberData = ['wealth'=>$wealth,'charm'=>$charm,'gift_num'=>$giftNum];
+                    $r = model('GuildMember')->update($guildMemberData,$guildMemberWhere);
+                    if (!$r) {
+                        throw new Exception('更新失败');
+                    }
+                }
+            }
+        } catch (Exception $e) {
+            $result['status'] = 0;
+            $result['msg'] = $e->getMessage();
+        }
+        return $result;
+    }
+}

+ 7 - 0
application/config.php

@@ -375,6 +375,13 @@ return [
         'secret' => '35dfe74bdec9ceced7aa494f9f45c844',
         'secret' => '35dfe74bdec9ceced7aa494f9f45c844',
     ],
     ],
 
 
+    //阿里银行卡三要素
+    'ali_yun' => [
+        'app_key' => '203989188',
+        'app_secret' => '4yku6nam6YK0TGdlEemkmMbBR4catDVU',
+        'app_code' => '3f4fc2408a0143509e5be5c20eb97c5b',
+    ],
+
 
 
 
 
 ];
 ];