|
|
@@ -7,20 +7,9 @@
|
|
|
<div class="card">
|
|
|
<div class="card-header d-flex align-items-center justify-content-between">
|
|
|
<h3 class="card-title mb-0">公用配置管理</h3>
|
|
|
- <small class="text-muted">编辑 5 档参数并一键保存</small>
|
|
|
+ <small class="text-muted">编辑 6 档参数并一键保存 (索引 0-5)</small>
|
|
|
</div>
|
|
|
<div class="card-body">
|
|
|
- @php
|
|
|
- $configData = $configs[0]['config'] ? $configs[0]['config'] : [
|
|
|
- "0" => ["FreeWinMax" => 1000, "TaxPercent" => 100, "RechargeMaxPercent" => 0, "RechargeMin" => 0, "RechargeMax" => 1],
|
|
|
- "1" => ["FreeWinMax" => 20, "TaxPercent" => 100, "RechargeMaxPercent" => 80, "RechargeMin" => 1, "RechargeMax" => 101],
|
|
|
- "2" => ["FreeWinMax" => 100, "TaxPercent" => 95, "RechargeMaxPercent" => 70, "RechargeMin" => 101, "RechargeMax" => 501],
|
|
|
- "3" => ["FreeWinMax" => 400, "TaxPercent" => 90, "RechargeMaxPercent" => 60, "RechargeMin" => 501, "RechargeMax" => 1001],
|
|
|
- "4" => ["FreeWinMax" => 8000, "TaxPercent" => 85, "RechargeMaxPercent" => 55, "RechargeMin" => 1001,"RechargeMax" => 10001],
|
|
|
- "5" => ["FreeWinMax" => 0,"TaxPercent" => 80, "RechargeMaxPercent" => 50, "RechargeMin" => 10001,"RechargeMax" => 99999999]
|
|
|
- ];
|
|
|
- @endphp
|
|
|
-
|
|
|
<div class="table-responsive">
|
|
|
<table class="table table-striped table-hover align-middle mb-0" style="min-width: 900px;">
|
|
|
<thead class="thead-light">
|
|
|
@@ -30,11 +19,11 @@
|
|
|
<th style="width:180px;">充值区间上限 (RechargeMax)</th>
|
|
|
<th style="width:180px;">固定值 (FreeWinMax)</th>
|
|
|
<th style="width:180px;">充值最大百分比 (RechargeMaxPercent)</th>
|
|
|
- <th style="width:160px;">税收系数比例 (TaxPercent)</th>
|
|
|
+ <th style="width:160px;">税收比例 (TaxPercent)</th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody class="config-form">
|
|
|
- @foreach([0,1,2,3,4,5] as $level)
|
|
|
+ @foreach([0,1,2,3,4,5] as $index => $level)
|
|
|
<tr>
|
|
|
<td>
|
|
|
<span class="badge badge-primary">等级{{ $level }}</span>
|
|
|
@@ -42,23 +31,23 @@
|
|
|
<td>
|
|
|
<input type="number" class="form-control form-control-sm"
|
|
|
name="level[{{ $level }}][RechargeMin]"
|
|
|
- value="{{ $configData[$level]['RechargeMin'] ?? 0 }}" />
|
|
|
+ value="{{ $config[$level]['RechargeMin'] ?? 0 }}" />
|
|
|
</td>
|
|
|
<td>
|
|
|
<input type="number" class="form-control form-control-sm"
|
|
|
name="level[{{ $level }}][RechargeMax]"
|
|
|
- value="{{ $configData[$level]['RechargeMax'] ?? 0 }}" />
|
|
|
+ value="{{ $config[$level]['RechargeMax'] ?? 0 }}" />
|
|
|
</td>
|
|
|
<td>
|
|
|
<input type="number" class="form-control form-control-sm"
|
|
|
name="level[{{ $level }}][FreeWinMax]"
|
|
|
- value="{{ $configData[$level]['FreeWinMax'] ?? 0 }}" />
|
|
|
+ value="{{ $config[$level]['FreeWinMax'] ?? 0 }}" />
|
|
|
</td>
|
|
|
<td>
|
|
|
<div class="input-group input-group-sm">
|
|
|
<input type="number" class="form-control"
|
|
|
name="level[{{ $level }}][RechargeMaxPercent]"
|
|
|
- value="{{ $configData[$level]['RechargeMaxPercent'] ?? 0 }}" />
|
|
|
+ value="{{ $config[$level]['RechargeMaxPercent'] ?? 0 }}" />
|
|
|
<div class="input-group-append"><span class="input-group-text">%</span></div>
|
|
|
</div>
|
|
|
</td>
|
|
|
@@ -66,7 +55,7 @@
|
|
|
<div class="input-group input-group-sm">
|
|
|
<input type="number" class="form-control"
|
|
|
name="level[{{ $level }}][TaxPercent]"
|
|
|
- value="{{ $configData[$level]['TaxPercent'] ?? 0 }}" />
|
|
|
+ value="{{ $config[$level]['TaxPercent'] ?? 0 }}" />
|
|
|
<div class="input-group-append"><span class="input-group-text">%</span></div>
|
|
|
</div>
|
|
|
</td>
|
|
|
@@ -97,22 +86,33 @@ $(function() {
|
|
|
$btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 保存中...');
|
|
|
$status.html('').removeClass('text-success text-danger');
|
|
|
|
|
|
- let configObj = {"0":{},"1":{},"2":{},"3":{},"4":{},"5":{}};
|
|
|
+ // 构建索引数组
|
|
|
+ let configArray = [];
|
|
|
+ for (let i = 0; i <= 5; i++) {
|
|
|
+ configArray[i] = {
|
|
|
+ "RechargeMin": 0,
|
|
|
+ "RechargeMax": 0,
|
|
|
+ "FreeWinMax": 0,
|
|
|
+ "RechargeMaxPercent": 0,
|
|
|
+ "TaxPercent": 0
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
$form.find('input').each(function() {
|
|
|
- const name = this.name; // level[1][RechargeMin]
|
|
|
+ const name = this.name; // level[0][RechargeMin]
|
|
|
const val = this.value;
|
|
|
const m = name.match(/level\[(\d+)\]\[([^\]]+)\]/);
|
|
|
if (m) {
|
|
|
- const lvl = m[1];
|
|
|
+ const lvl = parseInt(m[1]);
|
|
|
const key = m[2];
|
|
|
- let num = (key === 'RechargeMaxPercent' || key === 'TaxPercent') ? parseInt(val || 0) : parseFloat(val || 0);
|
|
|
+ let num = parseInt(val || 0);
|
|
|
if (isNaN(num)) num = 0;
|
|
|
- configObj[lvl][key] = num;
|
|
|
+ configArray[lvl][key] = num;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$.post("{{ url('/admin/common-config/update') }}", {
|
|
|
- config: JSON.stringify(configObj),
|
|
|
+ config: JSON.stringify(configArray),
|
|
|
_token: "{{ csrf_token() }}"
|
|
|
}).done(function(res){
|
|
|
$btn.prop('disabled', false).html('<i class="mdi mdi-content-save"></i> 保存配置');
|