wesmiler 4 дней назад
Родитель
Сommit
5d5fe3641c
2 измененных файлов с 23 добавлено и 11 удалено
  1. 20 11
      app/Services/Api/BalanceLogService.php
  2. 3 0
      app/Services/Common/BalanceLogService.php

+ 20 - 11
app/Services/Api/BalanceLogService.php

@@ -207,11 +207,12 @@ class BalanceLogService extends BaseService
         $field = isset($fields[$accountType])? $fields[$accountType]:'balance';
         RedisService::set($cacheLockKey, ['user_id' => $userId, 'params' => $params], rand(10, 20));
         $userInfo = MemberModel::where(['id' => $userId, 'mark' => 1])
-            ->select(['id', 'balance','property','buy_type','bonus_status','bd_score','ls_score', 'status'])
+            ->select(['id', 'balance','property','buy_type','withdraw_bonus','bonus_status','bd_score','ls_score', 'status'])
             ->first();
         $realname = isset($userInfo['realname']) ? $userInfo['realname'] : '';
         $status = isset($userInfo['status']) ? $userInfo['status'] : 0;
         $bonusStatus = isset($userInfo['bonus_status']) ? $userInfo['bonus_status'] : 0;
+        $withdrawBonus = isset($userInfo['withdraw_bonus']) ? $userInfo['withdraw_bonus'] : 0;
         $buyType = isset($userInfo['buy_type']) ? $userInfo['buy_type'] : 1;
         $balance = isset($userInfo[$field]) ? $userInfo[$field] : 0;
         if (empty($userInfo) || $status != 1) {
@@ -224,25 +225,30 @@ class BalanceLogService extends BaseService
             $buyType = max(1, $buyType-1);
         }
 
-        // 提现额度
-        $mealPrice = GoodsModel::where(['type'=>2,'mark'=>1])
-            ->where('id','>', $buyType)
-            ->orderBy('id','asc')
-            ->value('price');
-        $withdrawQuota = intval($mealPrice/0.27 * 0.73/100)*100;
-        if($money>$withdrawQuota){
-            $this->error = "抱歉您的账号可提现额度为:{$withdrawQuota}元";
-            RedisService::clear($cacheLockKey);
-            return false;
+        if($accountType==1){
+            // 提现额度
+            $mealPrice = GoodsModel::where(['type'=>2,'mark'=>1])
+                ->where('id','>', $buyType)
+                ->orderBy('id','asc')
+                ->value('price');
+            $withdrawQuota = intval($mealPrice/0.27 * 0.73/100)*100;
+            if(($money+$withdrawBonus)>$withdrawQuota){
+                $quota = moneyFormat($withdrawQuota-$withdrawBonus,2);
+                $this->error = "抱歉您的账号剩余可提现额度为:{$quota}元";
+                RedisService::clear($cacheLockKey);
+                return false;
+            }
         }
 
 
+
         if ($money > $balance) {
             $this->error = '该账户可提现余额不足';
             RedisService::clear($cacheLockKey);
             return false;
         }
 
+
         // 计算实际到账金额
         $poolMoney = 0;
         $ptMoney = 0;
@@ -291,6 +297,9 @@ class BalanceLogService extends BaseService
         // 提现处理
         DB::beginTransaction();
         $updateData = ["{$field}" => DB::raw("{$field} - {$money}"), 'update_time' => time()];
+        if($accountType==1){
+            $updateData['withdraw_bonus'] = DB::raw("withdraw_bonus + {$money}");
+        }
 
         // 会员账户
         $userType = 1;

+ 3 - 0
app/Services/Common/BalanceLogService.php

@@ -230,6 +230,9 @@ class BalanceLogService extends BaseService
         // 如果驳回
         if ($status == 3) {
             $updateData = ["{$field}" => DB::raw("{$field} + {$money}"), 'update_time' => time()];
+            if($accountType == 1){
+                $updateData['withdraw_bonus'] = DB::raw("withdraw_bonus - {$money}");
+            }
             if (!MemberModel::where(['id' => $orderUserId])->update($updateData)) {
                 DB::rollBack();
                 $this->error = '提现审核处理失败';