wesmiler hai 1 ano
pai
achega
3fba88dabe
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      app/Services/Common/AccountLogService.php

+ 8 - 1
app/Services/Common/AccountLogService.php

@@ -199,7 +199,6 @@ class AccountLogService extends BaseService
         $accountName = isset($userTypes[$userType])? $userTypes[$userType] : '会员';
         ActionLogModel::setTitle("{$accountName}[ID:{$accountId}]{$coinName}账户上下分");
         ActionLogModel::record();
-        $amount = $type == 1? $amount : -$amount;
         $userInfo = MemberModel::where(['id'=> $accountId,'mark'=>1])->first();
         $userId = isset($userInfo['id'])? $userInfo['id'] : 0;
         if(empty($userInfo) || $userId<=0){
@@ -211,7 +210,15 @@ class AccountLogService extends BaseService
             return false;
         }
 
+        // 账户余额
+        $userAmount = isset($userInfo[$field])? $userInfo[$field] : 0;
+        if($userAmount < $amount){
+            $this->error = 2035;
+            return false;
+        }
+
         DB::beginTransaction();
+        $amount = $type == 1? $amount : -$amount;
         $updateData = [$field=>DB::raw("{$field} + {$amount}"),'update_time'=>time()];
         if(!MemberModel::where(['id'=> $accountId])->update($updateData)){
             DB::rollBack();