Browse Source

钱包迁移,api

lizhen_gitee 2 years ago
parent
commit
16c7b7b160

+ 14 - 6
application/api/controller/Money.php

@@ -994,15 +994,15 @@ class Money extends Common
             //减去用户余额
             //减去用户余额
             $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,$exchangeMoney,'-',0,$detail,114,'money');
             $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,$exchangeMoney,'-',0,$detail,114,'money');
             if($rs_wallet['status'] == false){
             if($rs_wallet['status'] == false){
-                $this->error($rs_wallet['msg']);
                 Db::rollback();
                 Db::rollback();
+                $this->error($rs_wallet['msg']);
             }
             }
 
 
             //增加用户钻石余额
             //增加用户钻石余额
             $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $scoin, '+', 0, $detail, 14,'jewel');
             $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $scoin, '+', 0, $detail, 14,'jewel');
             if($rs_wallet['status'] == false){
             if($rs_wallet['status'] == false){
-                $this->error($rs_wallet['msg']);
                 Db::rollback();
                 Db::rollback();
+                $this->error($rs_wallet['msg']);
             }
             }
 
 
             // 添加兑换记录
             // 添加兑换记录
@@ -1600,21 +1600,29 @@ class Money extends Common
         try {
         try {
             $orderModel = new \app\common\model\RecharOrder();
             $orderModel = new \app\common\model\RecharOrder();
             $userModel = new \app\common\model\User();
             $userModel = new \app\common\model\User();
-            $jewellogModel = new \app\common\model\UserJewelLog();
             $rechargelogModel = new \app\common\model\UserRechargeLog();
             $rechargelogModel = new \app\common\model\UserRechargeLog();
             $orderInfo = $orderModel->where(["order_no" => $out_trade_no])->find();
             $orderInfo = $orderModel->where(["order_no" => $out_trade_no])->find();
             $userInfo = $userModel->where(["id" => $orderInfo["user_id"]])->find();
             $userInfo = $userModel->where(["id" => $orderInfo["user_id"]])->find();
+            $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
             // 修改订单状态
             // 修改订单状态
             $res1 = $orderModel->update(["status" => 1, 'platform' => 2], ["order_no" => $out_trade_no]);
             $res1 = $orderModel->update(["status" => 1, 'platform' => 2], ["order_no" => $out_trade_no]);
             // 修改用户钻石余额
             // 修改用户钻石余额
-            $res2 = $userModel->where(["id" => $orderInfo["user_id"]])->setInc("jewel", $orderInfo["jewel"]);
+            $res2 = true;
             // 添加钻石流水记录
             // 添加钻石流水记录
             $detail = "充值";
             $detail = "充值";
-            $res3 = $jewellogModel->addUserJewelLog($userInfo["id"], $orderInfo["jewel"], "+", $userInfo["jewel"], $detail, 1);
+            $res3 = true;
+                //增加用户钻石余额
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($userInfo["id"], $orderInfo["jewel"], "+", 0, $detail, 1,'jewel');
+            if($rs_wallet['status'] == false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+
+            //
             $rechargeCount = $rechargelogModel->where('user_id',$orderInfo["user_id"])->count();
             $rechargeCount = $rechargelogModel->where('user_id',$orderInfo["user_id"])->count();
             $isFirstRecharge = $rechargeCount > 0 ? 0 : 1;
             $isFirstRecharge = $rechargeCount > 0 ? 0 : 1;
             // 添加充值记录
             // 添加充值记录
-            $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], $payamount, bcadd($userInfo["jewel"], $orderInfo["jewel"], 2), $userInfo["money"], 2, 4, $isFirstRecharge, $userInfo["pre_userid"]);
+            $res4 = $rechargelogModel->addRecord($userInfo["id"], $orderInfo["jewel"], $payamount, bcadd($userwallet["jewel"], $orderInfo["jewel"], 2), $userwallet["money"], 2, 4, $isFirstRecharge, $userInfo["pre_userid"]);
             if ($res1 && $res2 && $res3 && $res4) {
             if ($res1 && $res2 && $res3 && $res4) {
                 // 添加统计
                 // 添加统计
                 $time = time();
                 $time = time();

+ 3 - 3
application/api/controller/Party.php

@@ -1779,8 +1779,8 @@ class Party extends Common
                     // 扣除当前用户钻石余额
                     // 扣除当前用户钻石余额
                     $rs_wallet = model('wallet')->lockChangeAccountRemain($userauthid, $giftValue, '-', 0, "赠送礼物:'" . $giftInfo["name"] . "',扣除" . $giftValue . "钻石!", 3,'jewel');
                     $rs_wallet = model('wallet')->lockChangeAccountRemain($userauthid, $giftValue, '-', 0, "赠送礼物:'" . $giftInfo["name"] . "',扣除" . $giftValue . "钻石!", 3,'jewel');
                     if($rs_wallet['status'] == false){
                     if($rs_wallet['status'] == false){
-                        $this->error($rs_wallet['msg']);
                         Db::rollback();
                         Db::rollback();
+                        $this->error($rs_wallet['msg']);
                     }
                     }
                 }
                 }
 
 
@@ -1827,8 +1827,8 @@ class Party extends Common
                     if($getMoney > 0){
                     if($getMoney > 0){
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$this->auth->nickname}送你{$giftInfo['name']}x{$number}",101,'money');
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$this->auth->nickname}送你{$giftInfo['name']}x{$number}",101,'money');
                         if($rs_wallet['status'] == false){
                         if($rs_wallet['status'] == false){
-                            $this->error($rs_wallet['msg']);
                             Db::rollback();
                             Db::rollback();
+                            $this->error($rs_wallet['msg']);
                         }
                         }
                     }
                     }
                 }*/
                 }*/
@@ -1839,8 +1839,8 @@ class Party extends Common
                     if($guilderMoney > 0){
                     if($guilderMoney > 0){
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$this->auth->nickname}送礼物{$giftInfo['name']}x{$number}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$this->auth->nickname}送礼物{$giftInfo['name']}x{$number}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
                         if($rs_wallet['status'] == false){
                         if($rs_wallet['status'] == false){
-                            $this->error($rs_wallet['msg']);
                             Db::rollback();
                             Db::rollback();
+                            $this->error($rs_wallet['msg']);
                         }
                         }
                     }
                     }
                 }*/
                 }*/

+ 2 - 2
application/index/controller/Plantask.php

@@ -164,8 +164,8 @@ class Plantask extends Controller
                     if($getMoney > 0){
                     if($getMoney > 0){
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$authuser_info['nickname']}送你{$giftuserparty['gift_name']}x{$giftuserparty['number']}",101,'money');
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($user_id,$getMoney,'+',0,"{$authuser_info['nickname']}送你{$giftuserparty['gift_name']}x{$giftuserparty['number']}",101,'money');
                         if($rs_wallet['status'] == false){
                         if($rs_wallet['status'] == false){
-                            $this->error($rs_wallet['msg']);
                             Db::rollback();
                             Db::rollback();
+                            $this->error($rs_wallet['msg']);
                         }
                         }
                     }
                     }
                 }
                 }
@@ -176,8 +176,8 @@ class Plantask extends Controller
                     if($guilderMoney > 0){
                     if($guilderMoney > 0){
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$authuser_info['nickname']}送礼物{$giftuserparty['gift_name']}x{$giftuserparty['number']}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
                         $rs_wallet = model('wallet')->lockChangeAccountRemain($partyInfo->user_id,$guilderMoney,'+',0,"{$authuser_info['nickname']}送礼物{$giftuserparty['gift_name']}x{$giftuserparty['number']}给{$touserInfo['nickname']},房间礼物抽成",102,'money');
                         if($rs_wallet['status'] == false){
                         if($rs_wallet['status'] == false){
-                            $this->error($rs_wallet['msg']);
                             Db::rollback();
                             Db::rollback();
+                            $this->error($rs_wallet['msg']);
                         }
                         }
                     }
                     }
                 }
                 }