Browse Source

钱包迁移,api,贵族

lizhen_gitee 2 years ago
parent
commit
cec8c5f1ec
2 changed files with 21 additions and 6 deletions
  1. 1 1
      application/api/controller/Money.php
  2. 20 5
      application/api/controller/Noble.php

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

@@ -1611,7 +1611,7 @@ class Money extends Common
             // 添加钻石流水记录
             $detail = "充值";
             $res3 = true;
-                //增加用户钻石余额
+            //增加用户钻石余额
             $rs_wallet = model('wallet')->lockChangeAccountRemain($userInfo["id"], $orderInfo["jewel"], "+", 0, $detail, 1,'jewel');
             if($rs_wallet['status'] == false){
                 Db::rollback();

+ 20 - 5
application/api/controller/Noble.php

@@ -130,8 +130,9 @@ class Noble extends Api
         $where = [];
         $where["id"] = $this->auth->id;
         $userInfo = $userModel->where($where)->find();
+        $userwallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->find();
         // 判断用户余额
-        if($userInfo["jewel"]-$money < 0) {
+        if($userwallet["jewel"]-$money < 0) {
             $this->error("您的钻石余额不足,请先充值");
         }
 
@@ -155,14 +156,21 @@ class Noble extends Api
             $data = [];
             $data["noble"] = $level_id;
             $data["noble_duetime"] = $duetime;
-            $submoney = bcsub($userInfo["jewel"],$money);
             // 开通返现
             $return = $nldlCount>0?$noblelevelInfo["give"]:$noblelevelInfo["firstgive"];
-            $data["jewel"] = bcadd($submoney,$return);
 
             $res1 = $userModel->update($data,$where);
             // 添加当前用户钻石流水记录
-            $res2 = $userjewellogModel->addUserJewelLog($this->auth->id, $money, "-", $userInfo["jewel"], "开通贵族:'" . $noblelevelInfo["name"] . "',扣除" . $money . "钻石!", 5);
+            $res2 = true;
+
+            //扣除用户钻石余额
+            if($money > 0){
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $money, "-", 0, "开通贵族:'" . $noblelevelInfo["name"] . "',扣除" . $money . "钻石!", 5,'jewel');
+                if($rs_wallet['status'] == false){
+                    Db::rollback();
+                    $this->error($rs_wallet['msg']);
+                }
+            }
 
             // 添加贵族等级开通明细
             $data = [];
@@ -173,7 +181,14 @@ class Noble extends Api
             $res3 = $nldlModel->insertGetId($data);
 
             // 添加当前用户钻石流水记录
-            $res4 = $userjewellogModel->addUserJewelLog($this->auth->id, $return, "+", $userInfo["jewel"] - $money, "开通贵族:'" . $noblelevelInfo["name"] . "',赠送" . $return . "钻石!", 15);
+            $res4 = true;
+            if($return > 0){
+                $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id, $return, "+", 0, "开通贵族:'" . $noblelevelInfo["name"] . "',赠送" . $return . "钻石!", 15,'jewel');
+                if($rs_wallet['status'] == false){
+                    Db::rollback();
+                    $this->error($rs_wallet['msg']);
+                }
+            }
 
 
             if($res1 && $res2 && $res3 && $res4) {