Ken 5 روز پیش
والد
کامیت
dee89a6be7
1فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 11 10
      app/Http/Controllers/admin/PaymentOrder.php

+ 11 - 10
app/Http/Controllers/admin/PaymentOrder.php

@@ -19,7 +19,7 @@ class PaymentOrder extends Controller
         try {
             $validate = [
 //                'id' => ['required', 'integer', 'min:1'],
-                'ids' => ['required', 'array', 'min:1','max:20'],
+                'ids' => ['required', 'array', 'min:1', 'max:20'],
                 'ids.*' => ['required', 'integer', 'min:1'],
                 'status' => ['required', 'integer', 'in:1,3'],
             ];
@@ -31,16 +31,17 @@ class PaymentOrder extends Controller
             $remark = request()->input('remark', '');
 
             $count = 0;
-            if ($params['status'] == 1) {
-                $ret = PaymentOrderService::createPayout($params['id']);
-                if ($ret['code'] === 0)$count++;
-                if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
-            } else {
-                $ret = PaymentOrderService::withdrawalFailed($params['id'], $remark);
-                if ($ret['code'] === 0)$count++;
-                if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
+            foreach ($params['ids'] as $id) {
+                if ($params['status'] == 1) {
+                    $ret = PaymentOrderService::createPayout($id);
+                    if ($ret['code'] === 0) $count++;
+                    if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
+                } else {
+                    $ret = PaymentOrderService::withdrawalFailed($id, $remark);
+                    if ($ret['code'] === 0) $count++;
+                    if ($ret['code'] !== 0) throw new Exception($ret['msg'], HttpStatus::CUSTOM_ERROR);
+                }
             }
-
             if ($count < 1) {
                 throw new Exception('操作失败', HttpStatus::CUSTOM_ERROR);
             }