Browse Source

钱包迁移,后台

lizhen_gitee 2 years ago
parent
commit
451ef253cf

+ 3 - 3
application/admin/controller/RecharOrder.php

@@ -99,8 +99,8 @@ class RecharOrder extends Backend
                 throw new Exception('已退款');
             }
             //验证用户钻石是否足够
-            $userWhere['id'] = $row['user_id'];
-            $user = model('User')->where($userWhere)->lock(true)->find();
+            $userWhere['user_id'] = $row['user_id'];
+            $user = Db::name('user_wallet')->where($userWhere)->lock(true)->find();
             $userJewel = isset($user['jewel']) ? $user['jewel'] : 0;
             if ($userJewel < $row['jewel']) {
                 throw new Exception('钻石不足,无法退款');
@@ -115,7 +115,7 @@ class RecharOrder extends Backend
                 throw new Exception('更新退款金额失败');
             }
             //记录退款日志
-            $res = model('Wallet')->lockChangeAccountRemain($row['user_id'],$row['jewel'],'-',$user['jewel'],'充值退款',18,'jewel');
+            $res = model('Wallet')->lockChangeAccountRemain($row['user_id'],$row['jewel'],'-',0,'充值退款',18,'jewel');
             if (!$res['status']) {
                 throw new Exception($res['msg']);
             }

+ 1 - 3
application/admin/controller/Withdraw.php

@@ -113,10 +113,8 @@ class Withdraw extends Backend
                 //状态:created=申请中,successed=成功,rejected=已拒绝
                 $remark = '';
                 if ($params['status'] == 'rejected') {//返回金额
-                    $user = model('User')->find($row['user_id']);
-                    $before = $user['money'];
                     $remark = '提现'.$row['money'].'驳回';
-                    $res = model('Wallet')->lockChangeAccountRemain($row['user_id'],$row['money'],'+',$before,$remark,105,'money');
+                    $res = model('Wallet')->lockChangeAccountRemain($row['user_id'],$row['money'],'+',0,$remark,105,'money');
                     if (!$res['status']) {
                         throw new Exception($res['status']);
                     }

+ 5 - 4
application/admin/controller/user/User.php

@@ -373,13 +373,14 @@ class User extends Backend
                     $row->validateFailException(true)->validate($validate);
                 }
                 if (!empty($params['jewel_add'])) {//钻石充值
-                    $userWhere['user_id'] = $row['id'];
-                    $user = Db::name('user_wallet')->where($userWhere)->lock(true)->find();
+                    $userWhere['id'] = $row['id'];
+                    $user = Db::name('user')->where($userWhere)->find();
+                    $userwallet = Db::name('user_wallet')->where('user_id',$row['id'])->lock(true)->find();
                     $jewelRes = model('Wallet')->lockChangeAccountRemain($row['id'],$params['jewel_add'],'+',0,'钻石充值',17,'jewel');
                     if (!$jewelRes['status']) {
                         throw new Exception($jewelRes['msg']);
                     }
-                    $params['jewel'] = bcadd($user['jewel'],$params['jewel_add']);
+                    $params['jewel'] = bcadd($userwallet['jewel'],$params['jewel_add']);
                     //充值日志记录
                     //判断是否首充
                     $jewellogWhere['user_id'] = $row['id'];
@@ -390,7 +391,7 @@ class User extends Backend
                         $isFirst = 0;
                     }
                     $preUserId = $user['pre_userid'];
-                    $userRechargeLogRes = model('UserRechargeLog')->addRecord($row['id'], $params['jewel_add'], $user['money'], $params['jewel'], $user['money'], 4, 4,$isFirst,$preUserId);
+                    $userRechargeLogRes = model('UserRechargeLog')->addRecord($row['id'], $params['jewel_add'], $userwallet['money'], $params['jewel'], $userwallet['money'], 4, 4,$isFirst,$preUserId);
                     if (!$userRechargeLogRes) {
                         throw new Exception('充值记录生成失败');
                     }