|
|
@@ -12,9 +12,11 @@ use App\Http\logic\admin\RechargeLogic;
|
|
|
use App\Jobs\ClearCache;
|
|
|
use App\Models\AppSwitch;
|
|
|
use App\Models\SystemStatusInfo;
|
|
|
+use App\Models\WithdrawalAgentRatioConfig;
|
|
|
use App\Models\WithdrawalChannelPositionConfig;
|
|
|
use App\Models\WithdrawalPositionConfig;
|
|
|
use App\Services\GameRoomInfo;
|
|
|
+use App\Services\PayConfig;
|
|
|
use App\Util;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
@@ -736,33 +738,20 @@ class ChannelController
|
|
|
->where('type', 'cash')
|
|
|
->where('status', 1)
|
|
|
->get();
|
|
|
+ $this->markWithdrawalAgentFee($agent);
|
|
|
return view('admin.channel.channel_withdrawal_configall', [
|
|
|
'config' => $config,
|
|
|
'agent' => $agent,
|
|
|
+ 'ratioConfig' => WithdrawalAgentRatioConfig::getGlobal(),
|
|
|
+ 'pixTypeOptions' => WithdrawalAgentRatioConfig::pixTypeOptions(),
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- $data = array_filter($request->all(), function ($item) {
|
|
|
- return $item !== null && $item !== '';
|
|
|
- });
|
|
|
- $validator = Validator::make($data, [
|
|
|
- 'status' => 'required|in:1,2',
|
|
|
- 'agent' => 'required|integer',
|
|
|
- ]);
|
|
|
- if ($validator->fails()) {
|
|
|
- return apiReturnFail($validator->errors()->first());
|
|
|
- }
|
|
|
-// $configs=WithdrawalChannelPositionConfig::query()->where('channel','<>',103)->get() ;
|
|
|
- $configs=WithdrawalChannelPositionConfig::query()->get() ;
|
|
|
- foreach ($configs as $config) {
|
|
|
-
|
|
|
-// if($config->channel==103)continue;
|
|
|
- $config->status = $request->input('status', 0);
|
|
|
- $config->agent = $request->input('agent', 0);
|
|
|
- $config->limit_manual_review_show = $request->input('limit_manual_review_show', 0);
|
|
|
- $config->save();
|
|
|
- //$config->update(['status'=>$request->input('status', 0),'agent'=>$request->input('agent', 0),'limit_manual_review_show'=>$request->input('limit_manual_review_show', 0)]);
|
|
|
+ list($ratioValid, $ratioRules) = $this->withdrawalAgentRatioRules($request);
|
|
|
+ if (!$ratioValid) {
|
|
|
+ return apiReturnFail($ratioRules);
|
|
|
}
|
|
|
+ WithdrawalAgentRatioConfig::saveGlobal($ratioRules);
|
|
|
|
|
|
return apiReturnSuc();
|
|
|
}
|
|
|
@@ -799,31 +788,129 @@ class ChannelController
|
|
|
->where('type', 'cash')
|
|
|
->where('status', 1)
|
|
|
->get();
|
|
|
+ $this->markWithdrawalAgentFee($agent);
|
|
|
return view('admin.channel.channel_withdrawal_config', [
|
|
|
'config' => $config,
|
|
|
'agent' => $agent,
|
|
|
+ 'ratioConfig' => WithdrawalAgentRatioConfig::getGlobal(),
|
|
|
+ 'pixTypeOptions' => WithdrawalAgentRatioConfig::pixTypeOptions(),
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- $data = array_filter($request->all(), function ($item) {
|
|
|
- return $item !== null && $item !== '';
|
|
|
- });
|
|
|
- $validator = Validator::make($data, [
|
|
|
- 'status' => 'required|in:1,2',
|
|
|
- 'agent' => 'required|integer',
|
|
|
- ]);
|
|
|
- if ($validator->fails()) {
|
|
|
- return apiReturnFail($validator->errors()->first());
|
|
|
+ list($ratioValid, $ratioRules) = $this->withdrawalAgentRatioRules($request);
|
|
|
+ if (!$ratioValid) {
|
|
|
+ return apiReturnFail($ratioRules);
|
|
|
}
|
|
|
-
|
|
|
- $config->status = $request->input('status', 0);
|
|
|
- $config->agent = $request->input('agent', 0);
|
|
|
- $config->limit_manual_review_show = $request->input('limit_manual_review_show', 0);
|
|
|
- $config->save();
|
|
|
+ WithdrawalAgentRatioConfig::saveGlobal($ratioRules);
|
|
|
|
|
|
return apiReturnSuc();
|
|
|
}
|
|
|
|
|
|
+ private function withdrawalAgentRatioRules(Request $request)
|
|
|
+ {
|
|
|
+ $input = $request->input('agent_ratio', []);
|
|
|
+ $rules = [];
|
|
|
+ $pixTypeNames = WithdrawalAgentRatioConfig::pixTypeOptions();
|
|
|
+
|
|
|
+ foreach ($pixTypeNames as $pixType => $pixTypeName) {
|
|
|
+ $total = 0;
|
|
|
+
|
|
|
+ foreach (($input[$pixType] ?? []) as $agent => $ratio) {
|
|
|
+ if ($ratio === null || $ratio === '') {
|
|
|
+ $ratio = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!is_numeric($ratio)) {
|
|
|
+ return [false, $pixTypeName . '比例必须是数字'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $ratio = (int)$ratio;
|
|
|
+ if ($ratio < 0 || $ratio > 100) {
|
|
|
+ return [false, $pixTypeName . '比例必须在0-100之间'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $total += $ratio;
|
|
|
+ if ($ratio > 0) {
|
|
|
+ $rules[$pixType][(int)$agent] = $ratio;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($total != 100) {
|
|
|
+ return [false, $pixTypeName . '比例总和必须为100'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $rules];
|
|
|
+ }
|
|
|
+
|
|
|
+ private function markWithdrawalAgentFee($agent)
|
|
|
+ {
|
|
|
+ foreach ($agent as $item) {
|
|
|
+ $item->withdraw_fee_texts = $this->withdrawalAgentFeeTexts($item->config_value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function withdrawalAgentFeeTexts($agent)
|
|
|
+ {
|
|
|
+ $configKey = $this->withdrawalPayConfigKey($agent);
|
|
|
+ $empty = [
|
|
|
+ 1 => '-',
|
|
|
+ 2 => '-',
|
|
|
+ WithdrawalAgentRatioConfig::PIX_TYPE_CASH_SMALL => '-',
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (!$configKey) {
|
|
|
+ return $empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ $config = (new PayConfig())->getConfig($configKey);
|
|
|
+ $payRates = $config['pay_rate'] ?? null;
|
|
|
+ if (empty($payRates) || !is_array($payRates)) {
|
|
|
+ return $empty;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (is_array(reset($payRates))) {
|
|
|
+ return [
|
|
|
+ 1 => isset($payRates[1]) ? $this->formatWithdrawalPayRate($payRates[1]) : '-',
|
|
|
+ 2 => isset($payRates[2]) ? $this->formatWithdrawalPayRate($payRates[2]) : '-',
|
|
|
+ WithdrawalAgentRatioConfig::PIX_TYPE_CASH_SMALL => isset($payRates[1]) ? $this->formatWithdrawalPayRate($payRates[1]) : '-',
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $feeText = $this->formatWithdrawalPayRate($payRates);
|
|
|
+ return [
|
|
|
+ 1 => $feeText,
|
|
|
+ 2 => $feeText,
|
|
|
+ WithdrawalAgentRatioConfig::PIX_TYPE_CASH_SMALL => $feeText,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ private function withdrawalPayConfigKey($agent)
|
|
|
+ {
|
|
|
+ $map = [
|
|
|
+ 99 => 'WiwiPayOut',
|
|
|
+ 100 => 'WDPayOut',
|
|
|
+ 103 => 'PagYeepPayOut',
|
|
|
+ 105 => 'AiNewPayOut',
|
|
|
+ 106 => 'SafePayOut',
|
|
|
+ 107 => 'BotImPayOut',
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $map[(int)$agent] ?? null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function formatWithdrawalPayRate($rate)
|
|
|
+ {
|
|
|
+ if (!is_array($rate)) {
|
|
|
+ return '-';
|
|
|
+ }
|
|
|
+
|
|
|
+ $percent = $rate[0] ?? 0;
|
|
|
+ $fixed = $rate[1] ?? 0;
|
|
|
+
|
|
|
+ return $percent . '%+$' . $fixed;
|
|
|
+ }
|
|
|
+
|
|
|
public function quickCreateChannel(Request $request)
|
|
|
{
|
|
|
if ($request->isMethod('post')) {
|