channel_withdrawal_configall.blade.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. @extends('base.base')
  2. @section('base')
  3. <!-- 内容区域 -->
  4. <div class="main-panel">
  5. <div class="content-wrapper">
  6. <div class="row">
  7. <div class="col-12 grid-margin stretch-card">
  8. <div class="card">
  9. <div class="card-body">
  10. <h4 class="card-title">{{ __('auto.请填写配置信息') }}</h4>
  11. @php
  12. $ratioMap = [];
  13. foreach (($ratioConfig ?? []) as $pixType => $items) {
  14. foreach ($items as $item) {
  15. $ratioMap[$pixType][$item['agent']] = $item['ratio'];
  16. }
  17. }
  18. @endphp
  19. <form class="forms-sample" id="form">
  20. <div class="form-group" style="margin-top: 20px">
  21. <label for=""><h4>自动免审代付比例</h4></label>
  22. <div class="alert alert-info">
  23. CashApp、PayPal、CashApp小额(提现金额&lt;50)分别配置比例,每种提现方式下开启的比例总和必须为 100。
  24. </div>
  25. @foreach(($pixTypeOptions ?? [1 => 'CashApp', 2 => 'PayPal', 'cash_small' => 'CashApp小额(<50)']) as $pixType => $pixTypeName)
  26. <h5>{{ $pixTypeName }}</h5>
  27. <div class="row">
  28. @foreach($agent as $val)
  29. <div class="col-md-3" style="margin-bottom: 10px">
  30. <label>{{$val->name}} ({{$val->config_value}},费率:{{$val->withdraw_fee_texts[$pixType] ?? '-'}})</label>
  31. <input class="form-control agent-ratio" type="number" min="0" max="100"
  32. name="agent_ratio[{{$pixType}}][{{$val->config_value}}]"
  33. data-pix-type="{{$pixType}}"
  34. value="{{ $ratioMap[$pixType][$val->config_value] ?? 0 }}">
  35. </div>
  36. @endforeach
  37. </div>
  38. <div class="ratio-total" data-pix-type="{{$pixType}}" style="margin-bottom: 10px"></div>
  39. @endforeach
  40. </div>
  41. <button type="button" onclick="commit({{ $config->channel }})"
  42. class="btn btn-sm btn-gradient-primary btn-icon-text">
  43. <i class="mdi mdi-file-check btn-icon-prepend"></i>
  44. {{ __('auto.提交') }}
  45. </button>
  46. <button type="button" onclick="cancel()"
  47. class="btn btn-sm btn-gradient-warning btn-icon-text">
  48. <i class="mdi mdi-reload btn-icon-prepend"></i>
  49. {{ __('auto.取消') }}
  50. </button>
  51. </form>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <script>
  59. function commit(id) {
  60. if (!checkForm()) {
  61. return false;
  62. }
  63. if (!checkAgentRatio()) {
  64. return false;
  65. }
  66. var data = $("#form").serializeObject();
  67. myRequest("/admin/channel/withdrawal_configall", "post", data, function (res) {
  68. if (res.code == '200') {
  69. layer.msg(res.msg)
  70. setTimeout(function () {
  71. parent.location.reload();
  72. }, 1500)
  73. } else {
  74. layer.msg(res.msg)
  75. }
  76. });
  77. }
  78. function cancel() {
  79. parent.location.reload();
  80. }
  81. function checkAgentRatio() {
  82. var pass = true;
  83. var pixTypes = @json(array_keys($pixTypeOptions ?? [1 => 'CashApp', 2 => 'PayPal', 'cash_small' => 'CashApp小额(<50)']));
  84. pixTypes.forEach(function (pixType) {
  85. var total = 0;
  86. $('.agent-ratio[data-pix-type="' + pixType + '"]').each(function () {
  87. total += parseInt($(this).val()) || 0;
  88. });
  89. if (total !== 100) {
  90. pass = false;
  91. }
  92. });
  93. if (!pass) {
  94. layer.msg('CashApp、PayPal、CashApp小额的比例总和都必须为100');
  95. }
  96. return pass;
  97. }
  98. $(document).ready(function () {
  99. function refreshRatioTotal() {
  100. var pixTypes = @json(array_keys($pixTypeOptions ?? [1 => 'CashApp', 2 => 'PayPal', 'cash_small' => 'CashApp小额(<50)']));
  101. pixTypes.forEach(function (pixType) {
  102. var total = 0;
  103. $('.agent-ratio[data-pix-type="' + pixType + '"]').each(function () {
  104. total += parseInt($(this).val()) || 0;
  105. });
  106. $('.ratio-total[data-pix-type="' + pixType + '"]').text('当前总和:' + total + '%');
  107. });
  108. }
  109. $('.agent-ratio').on('input', refreshRatioTotal);
  110. refreshRatioTotal();
  111. });
  112. </script>
  113. @endsection