lip 3 часов назад
Родитель
Сommit
5710345c91

+ 137 - 0
app/Http/Controllers/admin/RechargeChannel.php

@@ -0,0 +1,137 @@
+<?php
+
+namespace App\Http\Controllers\admin;
+
+use App\Http\Controllers\Controller;
+use App\Models\RechargeChannel as RechargeChannelModel;
+use App\Models\RechargeChannelGroup;
+use Exception;
+use App\Constants\HttpStatus;
+
+class RechargeChannel extends Controller
+{
+
+    /**
+     * 充值通道组合列表
+     */
+    public function groupList()
+    {
+        try {
+            $page = request()->input('page', 1);
+            $limit = request()->input('limit', 15);
+
+            $query = new RechargeChannelGroup();
+            $count = $query->count();
+            $list = $query->with(['rechargeChannel'])
+                ->forPage($page, $limit)
+                ->get();
+        } catch (Exception $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
+        }
+        return $this->success(['total' => $count, 'data' => $list]);
+    }
+
+    /**
+     * 充值通道组合管理更新
+     */
+    public function updateGroup()
+    {
+        try {
+            $params = request()->validate([
+                'id' => ['nullable','integer'],
+                'name' => ['nullable','string'],
+                'channel_ids' => ['nullable','string'],
+            ]);
+            
+            if (empty($params['id'])) {
+                RechargeChannelGroup::create($params);
+            } else {
+                $info = RechargeChannelGroup::where('id', $params['id'])->first();
+                if (!$info) throw new Exception('数据不存在');
+                $info->update($params);
+                $info->save();
+            }
+            
+            return $this->success();
+        } catch (Exception $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
+        }
+    }
+
+    /**
+     * 充值通道管理列表
+     */
+    public function list()
+    {
+        try {
+            $params = request()->validate([
+                'page' => ['nullable', 'integer', 'min:1'],
+                'limit' => ['nullable', 'integer', 'min:1'],
+                'type' => ['nullable', 'string'],
+                'from' => ['nullable', 'integer'],
+                'key' => ['nullable', 'string'],
+                'name' => ['nullable', 'string'],
+            ]);
+            $page = request()->input('page', 1);
+            $limit = request()->input('limit', 15);
+
+            $query = new RechargeChannelModel();
+            if (!empty($params['type'])) {
+                $query = $query->where('type', $params['type']);
+            }
+            if (isset($params['from'])) {
+                $query = $query->where('from', $params['from']);
+            }
+            if (!empty($params['key'])) {
+                $query = $query->where('key', $params['key']);
+            }
+            if (!empty($params['name'])) {
+                $query = $query->where('name', 'like', '%'.$params['name'].'%');
+            }
+            $count = $query->count();
+            $list = $query
+                ->forPage($page, $limit)
+                ->orderBy('sort', 'asc')
+                ->get();
+        } catch (Exception $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
+        }
+        return $this->success(['total' => $count, 'data' => $list]);
+    }
+
+    /**
+     * 充值通道管理更新
+     */
+    public function update()
+    {
+        try {
+            $params = request()->validate([
+                'id' => ['nullable','integer'],
+                'from' => ['nullable','integer'],
+                'key' => ['nullable','string'],
+                'name' => ['nullable','string'],
+                'type' => ['required','string'],
+                'rate' => ['required','numeric'],
+                'min_amount' => ['nullable','integer'],
+                'max_amount' => ['nullable','integer'],
+                'fixed_amounts' => ['nullable','string'],
+                'status' => ['nullable','integer'],
+                'sort' => ['nullable','integer'],
+            ]);
+
+            if (empty($params['id'])) {
+                RechargeChannelModel::create($params);
+            } else {
+                $info = RechargeChannelModel::where('id', $params['id'])->first();
+                if (!$info) throw new Exception('数据不存在');
+                $info->update($params);
+                $info->save();
+            }
+            
+            return $this->success();
+        } catch (Exception $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());
+        }
+    }
+
+}

+ 30 - 10
app/Http/Controllers/admin/Sport.php

@@ -32,6 +32,7 @@ class Sport extends Controller
             $limit = request()->input('limit', 15);
 
             $query = new SportOdds();
+            $query = $query->whereNotNull('function_name');
             if (!empty($params['odd_name'])) {
                 $odd_name = $params['odd_name'];
                 $query = $query->where(function ($query) use ($odd_name) {
@@ -56,24 +57,43 @@ class Sport extends Controller
         try {
             $params = request()->validate([
                 'id' => ['required'],
-                'maxinum' => ['required','numeric'],
-                'mininum' => ['required','numeric'],
+                'maxinum' => ['required', 'numeric'],
+                'mininum' => ['required', 'numeric', 'min:1'],
             ]);
-            if ($params['maxinum'] <= $params['mininum']) throw new Exception('最高下注限额不能小于等于最低下注限额');
-            if ($params['mininum'] < 1) throw new Exception('最低下注限额不能小于1');
+            
+            // 验证金额逻辑
+            if ($params['maxinum'] <= $params['mininum']) {
+                throw new Exception('最高下注限额必须大于最低下注限额');
+            }
+            
             $id = $params['id'];
+            
+            // 构建查询
+            $query = SportOdds::query();
+            
             if (is_array($id)) {
-                $where = ['id', 'in', $id];
+                if (empty($id)) {
+                    throw new Exception('ID列表不能为空');
+                }
+                $query->whereIn('id', array_map('intval', $id));
             } else {
-                $where = ['id', '=', $id];
+                if (!is_numeric($id) || $id <= 0) {
+                    throw new Exception('ID必须是有效的正整数');
+                }
+                $query->where('id', (int)$id);
             }
-            $count = SportOdds::where($where)->count();
-            if (!$count) throw new Exception('玩法不存在');
-
-            SportOdds::where($where)->update([
+            
+            // 检查玩法是否存在
+            if (!$query->exists()) {
+                throw new Exception('玩法不存在');
+            }
+            
+            // 执行更新
+            $updated = $query->update([
                 'maxinum' => $params['maxinum'],
                 'mininum' => $params['mininum'],
             ]);
+        
             return $this->success();
         } catch (Exception $e) {
             return $this->error(HttpStatus::CUSTOM_ERROR,$e->getMessage());

+ 19 - 0
app/Http/Controllers/admin/User.php

@@ -194,4 +194,23 @@ class User extends Controller
 
     }
 
+    function setRechargeChannelGroup()
+    {
+        try {
+            $params = request()->validate([
+                'member_id' => ['required', 'string', 'min:1'],
+                'recharge_channel_group_id' => ['required', 'integer', 'min:1'],
+            ]);
+            $user = UserModel::where('member_id', $params['member_id'])->first();
+            if (!$user) throw new Exception("用户不存在", HttpStatus::CUSTOM_ERROR);
+            $user->recharge_channel_group_id = $params['recharge_channel_group_id'];
+            $user->save();
+        } catch (ValidationException $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
+        } catch (Exception $e) {
+            return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
+        }
+        return $this->success();
+    }
+
 }

+ 7 - 37
app/Http/Controllers/api/Wallet.php

@@ -11,8 +11,8 @@ use App\Models\Withdraw;
 use App\Models\User;
 use App\Models\Bank;
 use App\Models\Address;
+use App\Models\RechargeChannel;
 use App\Services\BalanceLogService;
-use App\Services\Payment\SanJinService;
 use App\Services\PaymentOrderService;
 use App\Services\QianBaoWithdrawService;
 use App\Services\Payment\QianBaoService;
@@ -33,43 +33,13 @@ class Wallet extends BaseController
     //获取三斤充值通道(微信、支付宝、扫码充值)
     public function getChannel()
     {
-        $data = SanJinService::getChannel();
-        $product = SanJinService::$PRODUCT;
-        $list = [];
-        foreach($data as $k => $v) {
-            $config = [];
-            foreach($product as $pv) {
-                if ($k == $pv['type']) {
-                    if ($config) {
-                        if (empty($config['range'])) {
-                            $config['range'][] = $config;
-                        }
-                        if ($pv['min'] < $config['min']) {
-                            $config['min'] = $pv['min'];
-                        } 
-                        if ($pv['max'] > $config['max']) {
-                            $config['max'] = $pv['max'];
-                        }
-                        if ($pv['rate'] < $config['rate']) {
-                            $config['max_rate'] = $config['rate'];
-                            $config['min_rate'] = $pv['rate'];
-                        }
-                        if ($pv['rate'] > $config['rate']) {
-                            $config['max_rate'] = $pv['rate'];
-                        }
-                        $config['range'][] = $pv;
-                    } else {
-                        $config = $pv;
-                    }
-                }
-            }
-            $list[] = [
-                'label' => lang($v),
-                'value' => $k,
-                'config' => $config ?? [],
-            ];
+        $member_id = request()->user->member_id;
+        if (empty(request()->user->recharge_channel_group_id)) {
+            $recharge_channel_group_id = User::where('member_id', $member_id)->value('recharge_channel_group_id');
+        } else {
+            $recharge_channel_group_id = request()->user->recharge_channel_group_id;
         }
-            
+        $list = RechargeChannel::getFormatChannel($recharge_channel_group_id);
         return $this->success([
             'list' => $list,
         ]);

+ 68 - 0
app/Models/RechargeChannel.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace App\Models;
+
+class RechargeChannel extends BaseModel
+{
+
+    protected $table = 'recharge_channel';
+    protected $fillable = ['key', 'name', 'type', 'rate','min_amount','max_amount' ,'fixed_amounts' ,'sort'];
+    protected $hidden = [];
+
+    //获取充值通道
+    public static function product($from = '')
+    {
+        $where['status'] = 1;
+        if($from){
+            $where['from'] = $from;
+        }
+        $list = self::where($where)->orderBy('sort', 'asc')->get()->toArray();
+        return array_column($list, null, 'key');
+    }
+
+    public static function getFormatChannel($recharge_channel_group_id = '')
+    {
+        $where['status'] = 1;
+        if ($recharge_channel_group_id) {
+            $channel_ids = RechargeChannelGroup::where('id', $recharge_channel_group_id)->value('channel_ids');
+            if ($channel_ids) {
+                $channel_ids = explode(',', $channel_ids);
+                $where['id'] = ['in', $channel_ids];
+            }
+        }
+        $product = self::where($where)->orderBy('sort', 'asc')->get()->toArray();
+        
+        $list = [];
+        $config = [];
+        foreach($product as $pv) {
+            if ($config) {
+                if (empty($config['range'])) {
+                    $config['range'][] = $config;
+                }
+                if ($pv['min'] < $config['min']) {
+                    $config['min'] = $pv['min'];
+                } 
+                if ($pv['max'] > $config['max']) {
+                    $config['max'] = $pv['max'];
+                }
+                if ($pv['rate'] < $config['rate']) {
+                    $config['max_rate'] = $config['rate'];
+                    $config['min_rate'] = $pv['rate'];
+                }
+                if ($pv['rate'] > $config['rate']) {
+                    $config['max_rate'] = $pv['rate'];
+                }
+                $config['range'][] = $pv;
+            } else {
+                $config = $pv;
+            }
+        }
+        $list[] = [
+            'label' => lang($pv['type']),
+            'value' => $pv['type'],
+            'config' => $config ?? [],
+        ];
+    
+        return $list;
+    }
+}

+ 16 - 0
app/Models/RechargeChannelGroup.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+class RechargeChannelGroup extends BaseModel
+{
+
+    protected $table = 'recharge_channel_group';
+    protected $fillable = ['name', 'channel_ids'];
+    protected $hidden = [];
+
+    public function rechargeChannel()
+    {
+        return $this->hasMany(RechargeChannel::class, 'channel_ids', 'id');
+    }
+}

+ 100 - 94
app/Services/Payment/SanJinService.php

@@ -7,6 +7,7 @@ use GuzzleHttp\Exception\RequestException;
 use GuzzleHttp\Psr7\Response;
 use App\Services\BaseService;
 use Illuminate\Support\Facades\Lang;
+use App\Models\RechargeChannel;
 
 class SanJinService extends BaseService
 {
@@ -29,106 +30,110 @@ class SanJinService extends BaseService
      * @description: 获取支付频道
      * @return {*}
      */    
-    public static function getChannel($key = '')
+    public static function getChannel($type = '')
     {
-        
-        $channel = self::$CHANNEL;
-        if($key){
-            return Lang($channel[$key]);
-        }else{
-            foreach($channel as $k => $v){
-                $channel[$k] = lang($v);
+        if ($type) {
+            $name = RechargeChannel::where('type', $type)->value('name');
+            return Lang($name);
+        } else {
+            $channel = [];
+            $product = self::product();
+            foreach($product as $v){
+                $channel[$v['type']] = lang($v['name']);
             }
             return $channel;
         }
-        
     }
 
-    public static $PRODUCT = [
-        // 'T888' => [
-        //     'type' => 'test',
-        //     'rate' => 0.02,
-        //     'max' => 5000,
-        //     'min' => 10
-        // ],
-        'WX002' => [
-            'type' => 'wxsm',
-            'rate' => 0.095,
-            'max' => 3000,
-            'min' => 100
-        ],
-        'YL001' => [
-            'type' => 'ylsm',
-            'rate' => 0.05,
-            'max' => 500,
-            'min' => 50
-        ],
-        'SZ002' => [
-            'type' => 'szrmb',
-            'rate' => 0.05,
-            'max' => 100,
-            'min' => 10
-        ],
-        'SZ001' => [
-            'type' => 'szrmb',
-            'rate' => 0.048,
-            'max' => 5000,
-            'min' => 100
-        ],
-        'ZFB001' => [
-            'type' => 'zfbsm',
-            'rate' => 0.085,
-            'max' => 200,
-            'min' => 100
-        ],
-        'ZFB002' => [
-            'type' => 'zfbsm',
-            'rate' => 0.057,
-            'max' => 1000,
-            'min' => 200
-        ],
-        'ZFB003' => [
-            'type' => 'zfbsm',
-            'rate' => 0.052,
-            'max' => 3000,
-            'min' => 1000
-        ],
-        'ZFB004' => [
-            'type' => 'zfbsm',
-            'rate' => 0.042,
-            'max' => 20000,
-            'min' => 3000
-        ],
-        'ZFB005' => [
-            'type' => 'zfbge',
-            'rate' => 0.027,
-            'fixed' => [945 ,988 ,990]
-        ],
-        'ZFBZK001' => [
-            'type' => 'zfbzk',
-            'rate' => 0.05,
-            'max' => 2000,
-            'min' => 200
-        ],
-        'JT000' => [
-            'type' => 'sdjt',
-            'rate' => 0.08,
-            'max' => 300,
-            'min' => 100
-        ],
-        'JT001' => [
-            'type' => 'sdjt',
-            'rate' => 0.08,
-            'max' => 3000,
-            'min' => 300
-        ],
-        'JT002' => [
-            'type' => 'sdjt',
-            'rate' => 0.08,
-            'max' => 5000,
-            'min' => 500
-        ],
-    ];
+    // public static $PRODUCT = [
+    //     // 'T888' => [
+    //     //     'type' => 'test',
+    //     //     'rate' => 0.02,
+    //     //     'max' => 5000,
+    //     //     'min' => 10
+    //     // ],
+    //     'WX002' => [
+    //         'type' => 'wxsm',
+    //         'rate' => 0.095,
+    //         'max' => 3000,
+    //         'min' => 100
+    //     ],
+    //     'YL001' => [
+    //         'type' => 'ylsm',
+    //         'rate' => 0.05,
+    //         'max' => 500,
+    //         'min' => 50
+    //     ],
+    //     'SZ002' => [
+    //         'type' => 'szrmb',
+    //         'rate' => 0.05,
+    //         'max' => 100,
+    //         'min' => 10
+    //     ],
+    //     'SZ001' => [
+    //         'type' => 'szrmb',
+    //         'rate' => 0.048,
+    //         'max' => 5000,
+    //         'min' => 100
+    //     ],
+    //     'ZFB001' => [
+    //         'type' => 'zfbsm',
+    //         'rate' => 0.085,
+    //         'max' => 200,
+    //         'min' => 100
+    //     ],
+    //     'ZFB002' => [
+    //         'type' => 'zfbsm',
+    //         'rate' => 0.057,
+    //         'max' => 1000,
+    //         'min' => 200
+    //     ],
+    //     'ZFB003' => [
+    //         'type' => 'zfbsm',
+    //         'rate' => 0.052,
+    //         'max' => 3000,
+    //         'min' => 1000
+    //     ],
+    //     'ZFB004' => [
+    //         'type' => 'zfbsm',
+    //         'rate' => 0.042,
+    //         'max' => 20000,
+    //         'min' => 3000
+    //     ],
+    //     'ZFB005' => [
+    //         'type' => 'zfbge',
+    //         'rate' => 0.027,
+    //         'fixed' => [945 ,988 ,990]
+    //     ],
+    //     'ZFBZK001' => [
+    //         'type' => 'zfbzk',
+    //         'rate' => 0.05,
+    //         'max' => 2000,
+    //         'min' => 200
+    //     ],
+    //     'JT000' => [
+    //         'type' => 'sdjt',
+    //         'rate' => 0.08,
+    //         'max' => 300,
+    //         'min' => 100
+    //     ],
+    //     'JT001' => [
+    //         'type' => 'sdjt',
+    //         'rate' => 0.08,
+    //         'max' => 3000,
+    //         'min' => 300
+    //     ],
+    //     'JT002' => [
+    //         'type' => 'sdjt',
+    //         'rate' => 0.08,
+    //         'max' => 5000,
+    //         'min' => 500
+    //     ],
+    // ];
+    public static function product()
+    {
+        return RechargeChannel::product(1);
+    }
 
     // 获取商户ID
     public static function getMerchantId()
@@ -257,4 +262,5 @@ class SanJinService extends BaseService
     {
         return [];
     }
+
 }

+ 1 - 1
app/Services/PaymentOrderService.php

@@ -179,7 +179,7 @@ class PaymentOrderService extends BaseService
         $result['code'] = 0;
         $result['url'] = '';
         $channel = ''; // 支付的通道
-        $product = SanJinService::$PRODUCT;
+        $product = SanJinService::product();
         $max = 0;
         $min = 0;
         $rate = 0;

+ 1 - 1
app/Services/SanJinRechargeService.php

@@ -76,7 +76,7 @@ class SanJinRechargeService extends BaseService
             Cache::put(get_step_key($chatId), StepStatus::INPUT_RECHARGE_SJ_MONEY);
 
             $paymentType = $k;
-            $product = SanJinService::$PRODUCT;
+            $product = SanJinService::product();
             $max = 0;
             $min = 0;
             $rate = 0;

+ 1 - 0
lang/en/messages.php

@@ -134,6 +134,7 @@ return [
     "vi" => "Vietnamese",
     "语言设置成功" => "Language set successfully",
     "请选择支付的通道" => "Please select the payment channel",
+    "USDT充值" => "USDT Recharge",
     "支付宝扫码" => "Alipay QR Code",
     "支付宝固额" => "Alipay Fixed Amount",
     "支付宝转卡" => "Alipay Transfer to Card",

+ 1 - 0
lang/vi/messages.php

@@ -134,6 +134,7 @@ return [
     "vi" => "Tiếng Việt",
     "语言设置成功" => "Cài đặt ngôn ngữ thành công",
     "请选择支付的通道" => "Vui lòng chọn kênh thanh toán",
+    "USDT充值" => "Nạp tiền USDT",
     "支付宝扫码" => "Quét mã Alipay",
     "支付宝固额" => "Số tiền cố định Alipay",
     "支付宝转卡" => "Chuyển thẻ Alipay",

+ 1 - 0
lang/zh/messages.php

@@ -134,6 +134,7 @@ return [
     "vi" => "越南语",
     "语言设置成功" => "语言设置成功",
     "请选择支付的通道" => "请选择支付的通道",
+    "USDT充值" => "USDT充值",
     "支付宝扫码" => "支付宝扫码",
     "支付宝固额" => "支付宝固额",
     "支付宝转卡" => "支付宝转卡",

+ 11 - 0
routes/admin.php

@@ -36,6 +36,7 @@ use App\Http\Controllers\admin\LhcLottery;
 use App\Http\Controllers\admin\Sport;
 use App\Http\Controllers\admin\Level;
 use App\Http\Controllers\admin\YueBao;
+use App\Http\Controllers\admin\RechargeChannel;
 
 Route::post('/login', [Admin::class, 'login']);
 Route::get('/test', [Wallet::class, 'test']);
@@ -197,6 +198,15 @@ Route::middleware(['admin.jwt'])->group(function () {
             Route::get("/bankList", [Wallet::class, 'bankList']);
             Route::get("/address", [Wallet::class, 'address']);
             Route::get("/withdrawChannel", [Wallet::class, 'withdrawChannel']);
+            Route::get("/getChannel", [Wallet::class, 'getChannel']);
+
+        });
+
+        Route::prefix('/RechargeChannel')->group(function () {
+            Route::get("/list", [RechargeChannel::class, 'list']);
+            Route::post("/update", [RechargeChannel::class, 'update']);
+            Route::get("/groupList", [RechargeChannel::class, 'groupList']);
+            Route::post("/updateGroup", [RechargeChannel::class, 'updateGroup']);
 
         });
 
@@ -207,6 +217,7 @@ Route::middleware(['admin.jwt'])->group(function () {
             Route::post('/setNote', [User::class, 'setNote']);
             Route::post('/banned', [User::class, 'banned']);
             Route::get('/loginLog', [User::class, 'loginLog']);
+            Route::post('/setRechargeChannelGroup', [User::class, 'setRechargeChannelGroup']);
 
 
         });