Sfoglia il codice sorgente

Merge branch 'master' into dev

lip 1 giorno fa
parent
commit
4a2d133925

+ 9 - 3
app/Http/Controllers/admin/Home.php

@@ -6,6 +6,7 @@ use App\Constants\HttpStatus;
 use App\Http\Controllers\Controller;
 use App\Models\PaymentOrder;
 use App\Models\Recharge;
+use App\Models\User;
 use App\Services\PaymentOrderService;
 use Illuminate\Validation\ValidationException;
 use Exception;
@@ -27,9 +28,13 @@ class Home extends Controller
             $end = request()->input('end_date');
             if (empty($end)) $end = date('Y-m-d');
             if (empty($start)) $start = date('Y-m-d');
-
-
             $end = Carbon::createFromFormat('Y-m-d', $end)->addDay()->format('Y-m-d');
+
+            //新增会员统计
+            $query = User::query();
+            $query->where('from','<>',2)->whereBetween('created_at', [$start, $end]);
+            $totalUser = (float)$query->count('id');
+            
             $query = PaymentOrder::query();
             $query->whereBetween('created_at', [$start, $end]);
             $query1 = clone $query;
@@ -104,7 +109,8 @@ class Home extends Controller
                     'total_amount' => $totalAmount,
                     'total_processing' => $totalProcessing,
                     'total_pending' => $totalPending
-                ]
+                ],
+                'total_user' => $totalUser,
 
             ];
         } catch (ValidationException $e) {

+ 14 - 2
app/Http/Controllers/api/Wallet.php

@@ -275,9 +275,16 @@ class Wallet extends BaseController
             if ($check === false) {
                 throw new Exception(lang("不支持此提现方式"));
             }
-            $serviceCharge = (new WithdrawService())->serviceCharge;
+            
             $amount = $params['amount'];
             $address = $params['address'];
+            
+            //校验提现金额的限制
+            if ($amount < $check->min || $amount > $check->max) {
+                throw new Exception(lang("提现金额超出限制"));
+            }
+
+            $serviceCharge = (new WithdrawService())->serviceCharge;
             $real = bcsub($amount, $serviceCharge, 10);
             $real = floatval($real);
 
@@ -356,11 +363,16 @@ class Wallet extends BaseController
             if ($check === false) {
                 throw new Exception(lang("不支持此提现方式"));
             }
+
+            $amount = $params['amount'];
+            //校验提现金额的限制
+            if ($amount < $check->min || $amount > $check->max) {
+                throw new Exception(lang("提现金额超出限制"));
+            }
             
             if ($params['channel'] == 'rgtx') {
                 
                 DB::beginTransaction();
-                $amount = $params['amount'];
                 try {
                     $wallet = WalletService::findOne(['member_id' => $member_id]);
                     if (!$wallet) throw new Exception('钱包不存在', HttpStatus::CUSTOM_ERROR);

+ 7 - 0
app/Models/BalanceLog.php

@@ -14,5 +14,12 @@ class BalanceLog extends BaseModel
             ->select(['id', 'member_id', 'username', 'first_name', 'admin_note', 'status', 'phone', 'visitor_id', 'register_ip']);
     }
 
+    //用户累计消费总额
+    public static function getTotalConsume($memberId){
+        $amount = self::where('member_id', $memberId)->where('type',1)->where('change_type', 'like', '%投注%')->sum('amount');
+        $refund = self::where('member_id', $memberId)->where('type',1)->where('change_type', 'like', '%彩退款')->sum('amount');
+        $amount = abs($amount) - $refund;
+        return $amount > 0 ? bcadd($amount, 0, 2) : 0;
+    }
 
 }

+ 1 - 1
app/Models/RechargeChannel.php

@@ -100,7 +100,7 @@ class RechargeChannel extends BaseModel
         $recharge_channel_group_id = $recharge_channel_group_id > 0 ? $recharge_channel_group_id : 1;
         $withdraw_type = RechargeChannelGroup::where('id', $recharge_channel_group_id)->value('withdraw_type');
         if (in_array($type, $withdraw_type)) {
-            return true;
+            return self::where('data_type', 2)->where('type', $type)->first();
         } else {
             return false;
         }

+ 4 - 0
app/Services/UserService.php

@@ -7,6 +7,7 @@ namespace App\Services;
 use App\Http\Controllers\api\TelegramWebHook;
 use App\Services\BaseService;
 use App\Models\User;
+use App\Models\BalanceLog;
 use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Collection;
@@ -131,6 +132,9 @@ class UserService extends BaseService
             ->select("users.*")
             ->forPage($page, $limit)
             ->get();
+        foreach($list as &$item) {
+            $item['total_consume'] = BalanceLog::getTotalConsume($item->member_id);//用户累计消费总额
+        }
         return ['total' => $total, 'data' => $list];
     }