index.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <div class="panel">
  5. <div class="panel-heading">
  6. <h3 class="panel-title">{{ trans('admin.aff.title') }}</h3>
  7. </div>
  8. <div class="panel-body">
  9. <form class="form-row">
  10. <div class="form-group col-lg-2 col-sm-4">
  11. <input class="form-control" name="username" type="text" value="{{ Request::query('username') }}"
  12. placeholder="{{ trans('model.user.username') }}" />
  13. </div>
  14. <div class="form-group col-lg-2 col-sm-4">
  15. <select class="form-control" id="status" name="status" data-plugin="selectpicker" data-style="btn-outline btn-primary"
  16. title="{{ trans('common.status.attribute') }}">
  17. <option value="-1">{{ trans('common.status.rejected') }}</option>
  18. <option value="0">{{ trans('common.status.review') }}</option>
  19. <option value="1">{{ trans('common.status.reviewed') }}</option>
  20. <option value="2">{{ trans('common.status.paid') }}</option>
  21. </select>
  22. </div>
  23. <div class="form-group col-lg-1 col-sm-4 btn-group">
  24. <button class="btn btn-primary" type="submit">{{ trans('common.search') }}</button>
  25. <button class="btn btn-danger" type="button" onclick="resetSearchForm()">{{ trans('common.reset') }}</button>
  26. </div>
  27. </form>
  28. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  29. <thead class="thead-default">
  30. <tr>
  31. <th> #</th>
  32. <th> {{ trans('model.referral.created_at') }}</th>
  33. <th> {{ trans('model.referral.user') }}</th>
  34. <th> {{ trans('model.referral.amount') }}</th>
  35. <th> {{ trans('common.status.attribute') }}</th>
  36. <th> {{ trans('model.aff.updated_at') }}</th>
  37. <th> {{ trans('common.action') }}</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. @foreach ($applyList as $apply)
  42. <tr>
  43. <td> {{ $apply->id }} </td>
  44. <td> {{ $apply->created_at }} </td>
  45. <td>
  46. @if (empty($apply->user))
  47. 【{{ trans('common.deleted_item', ['attribute' => trans('common.account')]) }}】
  48. @else
  49. @can('admin.user.index')
  50. <a href="{{ route('admin.user.index', ['id' => $apply->user_id]) }}" target="_blank">
  51. {{ $apply->user->username }}
  52. </a>
  53. @else
  54. {{ $apply->user->username }}
  55. @endcan
  56. @endif
  57. </td>
  58. <td> {{ $apply->amount_tag }} </td>
  59. <td>
  60. @if ($apply->status === -1)
  61. <span class="badge badge-lg badge-danger"> {{ trans('common.status.rejected') }} </span>
  62. @elseif($apply->status === 0)
  63. <span class="badge badge-lg badge-info"> {{ trans('common.status.review') }} </span>
  64. @elseif($apply->status === 2)
  65. <span class="badge badge-lg badge-success"> {{ trans('common.status.paid') }} </span>
  66. @else
  67. <span class="badge badge-lg badge-default"> {{ trans('common.status.payment_pending') }} </span>
  68. @endif
  69. </td>
  70. <td> {{ $apply->created_at === $apply->updated_at ? '' : $apply->updated_at }} </td>
  71. <td>
  72. @canany(['admin.aff.setStatus', 'admin.aff.detail'])
  73. <div class="btn-group">
  74. @can('admin.aff.setStatus')
  75. @if ($apply->status === 0)
  76. <a class="btn btn-sm btn-success" href="javascript:setStatus('{{ $apply->id }}','1')">
  77. <i class="icon wb-check" aria-hidden="true"></i>{{ trans('common.status.pass') }}
  78. </a>
  79. <a class="btn btn-sm btn-danger" href="javascript:setStatus('{{ $apply->id }}','-1')">
  80. <i class="icon wb-close" aria-hidden="true"></i>{{ trans('common.status.reject') }}
  81. </a>
  82. @elseif($apply->status === 1)
  83. @can('admin.user.updateCredit')
  84. <a class="btn
  85. btn-sm
  86. btn-success"
  87. href="javascript:handleUserCredit('{{ $apply->user->id }}','{{ $apply->amount }}', '{{ $apply->id }}','2')">
  88. <i class="icon wb-payment" id="makePayment_{{ $apply->id }}" aria-hidden="true"></i>
  89. {{ trans('common.status.send_to_credit') }}
  90. </a>
  91. @endcan
  92. <a class="btn btn-sm btn-primary" href="javascript:setStatus('{{ $apply->id }}', '2')">
  93. <i class="icon wb-check-circle" aria-hidden="true"></i> {{ trans('common.status.paid') }}
  94. </a>
  95. @endif
  96. @endcan
  97. @can('admin.aff.detail')
  98. <a class="btn btn-sm btn-default" href="{{ route('admin.aff.detail', $apply->id) }}">
  99. <i class="icon wb-search"></i></a>
  100. @endcan
  101. </div>
  102. @endcanany
  103. </td>
  104. </tr>
  105. @endforeach
  106. </tbody>
  107. </table>
  108. </div>
  109. <div class="panel-footer">
  110. <div class="row">
  111. <div class="col-sm-4">
  112. {!! trans('admin.aff.apply_counts', ['num' => $applyList->total()]) !!}
  113. </div>
  114. <div class="col-sm-8">
  115. <nav class="Page navigation float-right">
  116. {{ $applyList->links() }}
  117. </nav>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. @endsection
  124. @push('javascript')
  125. <script>
  126. $(document).ready(function() {
  127. $('#status').selectpicker('val', @json(Request::query('status')));
  128. });
  129. @can('admin.aff.setStatus')
  130. // 更改状态
  131. function setStatus(id, status) {
  132. $.ajax({
  133. method: 'PUT',
  134. url: '{{ route('admin.aff.setStatus', '') }}/' + id,
  135. data: {
  136. _token: '{{ csrf_token() }}',
  137. status: status,
  138. },
  139. dataType: 'json',
  140. success: function(ret) {
  141. if (ret.status === 'success') {
  142. swal.fire({
  143. title: ret.message,
  144. icon: 'success',
  145. timer: 1000,
  146. showConfirmButton: false,
  147. }).then(() => window.location.reload());
  148. } else {
  149. swal.fire({
  150. title: ret.message,
  151. icon: 'error'
  152. }).then(() => window.location.reload());
  153. }
  154. },
  155. error: function(data) {
  156. let str = '';
  157. const errors = data.responseJSON;
  158. if ($.isEmptyObject(errors) === false) {
  159. $.each(errors.errors, function(index, value) {
  160. str += '<li>' + value + '</li>';
  161. });
  162. swal.fire({
  163. title: '{{ trans('admin.hint') }}',
  164. html: str,
  165. icon: 'error',
  166. confirmButtonText: '{{ trans('common.confirm') }}',
  167. });
  168. }
  169. },
  170. });
  171. }
  172. @endcan
  173. @can('admin.user.updateCredit')
  174. // 余额充值
  175. function handleUserCredit(uid, amount, aid, status) {
  176. $.ajax({
  177. url: '{{ route('admin.user.updateCredit', '') }}/' + uid,
  178. method: 'POST',
  179. data: {
  180. _token: '{{ csrf_token() }}',
  181. amount: amount,
  182. description: '{{ trans('admin.aff.referral') }}',
  183. },
  184. beforeSend: function() {
  185. $('#makePayment_' + aid).removeClass('wb-payment').addClass('wb-loop icon-spin');
  186. },
  187. success: function(ret) {
  188. if (ret.status === 'success') {
  189. swal.fire({
  190. title: ret.message,
  191. icon: 'success',
  192. timer: 1000,
  193. showConfirmButton: false
  194. }).then(() => {
  195. setStatus(aid, status);
  196. });
  197. } else {
  198. swal.fire({
  199. title: ret.message,
  200. icon: 'error'
  201. }).then(() => window.location.reload());
  202. }
  203. },
  204. error: function() {
  205. $('#msg').show().html('{{ trans('common.request_failed') }}');
  206. },
  207. complete: function() {},
  208. });
  209. }
  210. @endcan
  211. </script>
  212. @endpush