Browse Source

钱包迁移,全局money

lizhen_gitee 2 years ago
parent
commit
6758a52dfb

+ 2 - 2
application/api/controller/Eggnew.php

@@ -342,7 +342,7 @@ class Eggnew extends Api
             ->join("egg_jackpot jp","a.Jackpot_id = jp.id","left")
             ->join("egg_jackpot jp","a.Jackpot_id = jp.id","left")
             ->where($where)
             ->where($where)
 //            ->group("a.user_id")
 //            ->group("a.user_id")
-            ->order("money","desc")
+            ->order("a.money","desc")
             ->limit(20)
             ->limit(20)
             ->select();
             ->select();
         $this->success("获取成功!",$ranklist);
         $this->success("获取成功!",$ranklist);
@@ -366,7 +366,7 @@ class Eggnew extends Api
             ->join("hx_user u","u.id = a.user_id","inner")
             ->join("hx_user u","u.id = a.user_id","inner")
             ->where($where)
             ->where($where)
             ->group("a.user_id")
             ->group("a.user_id")
-            ->order("money","desc")
+            ->order("a.money","desc")
             ->limit(20)
             ->limit(20)
             ->select();
             ->select();
         if(!$ranklist) $this->success("获取成功!",[]);
         if(!$ranklist) $this->success("获取成功!",[]);

+ 1 - 1
application/api/controller/Live.php

@@ -56,7 +56,7 @@ class Live extends Common
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = bcdiv($withdraw, 100,2);
         $withdraw = bcdiv($withdraw, 100,2);
         $sum = bcsub($moneylog, $withdraw,2);
         $sum = bcsub($moneylog, $withdraw,2);
-        $usermoney = \app\common\model\User::where(["id" => $user_id])->value("money");
+//        $usermoney = \app\common\model\User::where(["id" => $user_id])->value("money");
         if ($usermoney == $sum) {
         if ($usermoney == $sum) {
             echo 1;
             echo 1;
         } else {
         } else {

+ 23 - 9
application/api/controller/Money.php

@@ -38,7 +38,15 @@ class Money extends Common
      */
      */
     public function getUserMoney()
     public function getUserMoney()
     {
     {
-        $this->success("获取成功!", \app\common\model\User::field("money,rebate_money,score,jewel,sound_coin,hammer")->find($this->auth->id));
+
+        $rs = Db::name('user')->field("rebate_money,score,sound_coin,hammer")->where('id',$this->auth->id)->find();
+
+        //用户钱包
+        $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
+        $rs['money'] = $userwallet['money'];
+        $rs['jewel'] = $userwallet['jewel'];
+
+        $this->success("获取成功!", $rs);
     }
     }
 
 
     /**
     /**
@@ -393,9 +401,9 @@ class Money extends Common
         // 查询资金余额
         // 查询资金余额
         $userModel = new \app\common\model\User();
         $userModel = new \app\common\model\User();
         $userInfo = $userModel->where('id',$user_id)->lock(true)->find();
         $userInfo = $userModel->where('id',$user_id)->lock(true)->find();
-        if (bcsub($money, $userInfo["money"], 2) > 0) {
+       /* if (bcsub($money, $userInfo["money"], 2) > 0) {
             $this->error("资金余额不足!", [], 100);
             $this->error("资金余额不足!", [], 100);
-        }
+        }*/
 
 
         // 增加提现收益记录
         // 增加提现收益记录
         $withdrawRate = (100 - config("site.withdrawRate")) / 100;
         $withdrawRate = (100 - config("site.withdrawRate")) / 100;
@@ -456,7 +464,7 @@ class Money extends Common
                 try {
                 try {
                     $withdrawallogModel = new \app\common\model\UserWithdrawalLog();
                     $withdrawallogModel = new \app\common\model\UserWithdrawalLog();
                     // 减去用户可用资金余额
                     // 减去用户可用资金余额
-                    $res1 = $userModel->where(["id" => $user_id])->setDec("money", $money);
+//                    $res1 = $userModel->where(["id" => $user_id])->setDec("money", $money);
                     // 增加用户冻结资金余额
                     // 增加用户冻结资金余额
                     $res2 = $userModel->where(["id" => $user_id])->setInc("frozen", $money);
                     $res2 = $userModel->where(["id" => $user_id])->setInc("frozen", $money);
                     // 新增用户提现记录申请
                     // 新增用户提现记录申请
@@ -930,7 +938,7 @@ class Money extends Common
             // 减去用户声币余额
             // 减去用户声币余额
             $res4 = $userModel->where(["id" => $this->auth->id])->setDec("sound_coin", $scoin);
             $res4 = $userModel->where(["id" => $this->auth->id])->setDec("sound_coin", $scoin);
             // 增加用户资金余额
             // 增加用户资金余额
-            $res5 = $userModel->where(["id" => $this->auth->id])->setInc("money", $exchangeMoney);
+//            $res5 = $userModel->where(["id" => $this->auth->id])->setInc("money", $exchangeMoney);
             if ($res1 && $res2 && $res3 && $res4 && $res5) {
             if ($res1 && $res2 && $res3 && $res4 && $res5) {
                 Db::commit();
                 Db::commit();
                 $this->success("兑换成功!");
                 $this->success("兑换成功!");
@@ -1108,8 +1116,8 @@ class Money extends Common
 
 
         // 查询资金余额
         // 查询资金余额
         $userModel = new \app\common\model\User();
         $userModel = new \app\common\model\User();
-        $userInfo = $userModel->get($this->auth->id);
-        if ($money > $userInfo["money"]) {
+        $user_wallet = Db::name('user_wallet')->where(['user_id'=>$this->auth->id])->find();
+        if ($money > $user_wallet["money"]) {
             $this->error("资金余额不足!", [], 100);
             $this->error("资金余额不足!", [], 100);
         }
         }
 
 
@@ -1117,7 +1125,13 @@ class Money extends Common
         try {
         try {
             $withdrawallogModel = new \app\common\model\UserWithdrawalLog();
             $withdrawallogModel = new \app\common\model\UserWithdrawalLog();
             // 减去用户可用资金余额
             // 减去用户可用资金余额
-            $res1 = $userModel->where(["id" => $this->auth->id])->setDec("money", $money);
+            $res1 = true;
+            //扣余额
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,$money,'-',0,'申请提现',104,'money');
+            if($rs_wallet['status'] === false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
             // 增加用户冻结资金余额
             // 增加用户冻结资金余额
             $res2 = $userModel->where(["id" => $this->auth->id])->setInc("frozen", $money);
             $res2 = $userModel->where(["id" => $this->auth->id])->setInc("frozen", $money);
             // 新增用户提现记录申请
             // 新增用户提现记录申请
@@ -1417,7 +1431,7 @@ class Money extends Common
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = \app\common\model\UserWithdrawalLog::where(["user_id" => $user_id, "status" => ["in", [0, 1]]])->sum("money");
         $withdraw = bcdiv($withdraw, 100,2);
         $withdraw = bcdiv($withdraw, 100,2);
         $sum = bcsub($moneylog, $withdraw,2);
         $sum = bcsub($moneylog, $withdraw,2);
-        $usermoney = \app\common\model\User::where(["id" => $user_id])->value("money");
+//        $usermoney = \app\common\model\User::where(["id" => $user_id])->value("money");
         if ($usermoney == $sum) {
         if ($usermoney == $sum) {
             return true;
             return true;
         } else {
         } else {

+ 3 - 1
application/api/controller/Usercenter.php

@@ -1018,7 +1018,9 @@ class UserCenter extends Common
      * 获取用户钻石余额
      * 获取用户钻石余额
      */
      */
     public function getUserJewel() {
     public function getUserJewel() {
-        $data = \app\common\model\User::field("Jewel,money")->where(["id"=>$this->auth->id])->find();
+        //用户钱包
+        $data = Db::name('user_wallet')->field("jewel,money")->where('user_id',$this->auth->id)->find();
+
         return $this->success("获取成功!",$data);
         return $this->success("获取成功!",$data);
     }
     }
 
 

+ 14 - 5
application/api/controller/Withdraw.php

@@ -149,8 +149,13 @@ class Withdraw extends Common
     public function getUserInfoByMobile() {
     public function getUserInfoByMobile() {
         $mobile = $this->request->request('mobile');// 手机号
         $mobile = $this->request->request('mobile');// 手机号
         if(!$mobile) $this->error("请输入手机号!");
         if(!$mobile) $this->error("请输入手机号!");
-        $field = "u_id,avatar,money,nickname,mobile";
-        $userInfo = \app\common\model\User::getByMobile($mobile,$field);
+        $field = "id,u_id,avatar,nickname,mobile";
+        $userInfo = Db::name('user')->where('mobile',$mobile)->field($field)->find();
+
+        //用户钱包
+        $userwallet = Db::name('user_wallet')->where('user_id',$userInfo['id'])->find();
+        $userInfo['money'] = $userwallet['money'];
+
         $this->success("获取成功!",$userInfo);
         $this->success("获取成功!",$userInfo);
     }
     }
 
 
@@ -323,9 +328,13 @@ class Withdraw extends Common
      */
      */
     public function getUserAccountInfo() {
     public function getUserAccountInfo() {
         // 获取用户信息
         // 获取用户信息
-        $res = \app\common\model\User::field("id,u_id,avatar,mobile,nickname,money as use_money,frozen")->where(["id"=>$this->auth->id])->find();
-        $res["all_money"] = bcadd($res["use_money"],$res["frozen"],2);
-        unset($res["frozen"]);
+        $res = \app\common\model\User::field("id,u_id,avatar,mobile,nickname")->where(["id"=>$this->auth->id])->find();
+
+        //用户钱包
+        $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
+        $res['use_money'] = $userwallet['money'];
+        $res['all_money'] = $userwallet['money'];
+
         // 获取用户实名认证信息
         // 获取用户实名认证信息
         $res["realname"] = \app\common\model\UserAuth::where(["user_id"=>$res["id"]])->value("realname");
         $res["realname"] = \app\common\model\UserAuth::where(["user_id"=>$res["id"]])->value("realname");
         // 获取用户银行卡信息
         // 获取用户银行卡信息

+ 1 - 1
application/common/service/UserService.php

@@ -223,7 +223,7 @@ class UserService
         try {
         try {
             $userId = isset($params['user_id']) ? $params['user_id'] : 0;
             $userId = isset($params['user_id']) ? $params['user_id'] : 0;
             if (!empty($userId)) {
             if (!empty($userId)) {
-                $field = 'id,pre_userid,money';
+                $field = 'id,pre_userid';
                 $where['id'] = $userId;
                 $where['id'] = $userId;
                 $user = model('User')->field($field)->where($where)->find();
                 $user = model('User')->field($field)->where($where)->find();
                 if (!empty($user)) {
                 if (!empty($user)) {