wesmiler 1 ano atrás
pai
commit
83a00c49c5

+ 10 - 4
app/Services/Api/BalanceLogService.php

@@ -55,22 +55,28 @@ class BalanceLogService extends BaseService
      * @param $type 类型:1-充值,2-提现
      * @return array|mixed
      */
-    public function getCountByType(int $userId=0, $type=1, $coinType=1)
+    public function getCountByType(int $userId=0, $type=1, $coinType=1, $status=2)
     {
-        $cacheKey = "caches:balance:counts_{$userId}_{$type}_{$coinType}";
+        $cacheKey = "caches:balance:counts_{$userId}_{$type}_{$coinType}_{$status}";
         $counts = RedisService::get($cacheKey);
         if($counts){
             return $counts;
         }
 
-        $where = ['user_id'=> $userId,'coin_type'=>0,'type'=>$type,'status'=>2,'mark'=>1];
+        $where = ['user_id'=> $userId,'coin_type'=>0,'type'=>$type,'mark'=>1];
         if($coinType){
             $where['coin_type'] = $coinType;
         }else{
             unset($where['coin_type']);
         }
 
-        $data = $this->model->where($where)->sum('money');
+        $data = $this->model->where($where)->where(function ($query)use($status){
+            if($status){
+                $query->where('status', $status);
+            }else{
+                $query->whereIn('status', [1,2]);
+            }
+        })->sum('money');
         RedisService::set($cacheKey, $data, rand(3, 5));
         return $data;
     }

+ 1 - 1
app/Services/Api/MemberService.php

@@ -555,7 +555,7 @@ class MemberService extends BaseService
             DB::beginTransaction();
             if ($coinType == 1) {
                 $maxUsdtRate = ConfigService::make()->getConfigByCode('usdt_withdraw_max_rate', 0);
-                $withdrawTotal = BalanceLogService::make()->getCountByType($userId, 2, 1);
+                $withdrawTotal = BalanceLogService::make()->getCountByType($userId, 2, 1,0);
                 $maxWithdrawMoney = ($withdrawTotal + $userUsdt);
                 $maxWithdrawMoney = $maxUsdtRate > 0 && $maxUsdtRate < 100 ? moneyFormat($maxWithdrawMoney * $maxUsdtRate / 100, 2) : $maxWithdrawMoney;
                 if (($withdrawTotal + floatval($money)) >= $maxWithdrawMoney) {