Ken 1 week geleden
bovenliggende
commit
ef84710d90
2 gewijzigde bestanden met toevoegingen van 7 en 15 verwijderingen
  1. 5 14
      app/Http/Controllers/admin/Withdraw.php
  2. 2 1
      app/Services/WithdrawService.php

+ 5 - 14
app/Http/Controllers/admin/Withdraw.php

@@ -126,19 +126,6 @@ class Withdraw extends Controller
         return $this->success($result);
     }
 
-    /**
-     * @api {post} /admin/withdraw/setStatus 通过|拒绝
-     * @apiGroup 提现管理
-     *
-     * @apiUse result
-     * @apiUse header
-     * @apiVersion 1.0.0
-     *
-     * @apiParam {string} id 提现表ID
-     * @apiParam {int} status 状态
-     * - 1 通过
-     * - 2 拒绝
-     */
     public function setStatus()
     {
         DB::beginTransaction();
@@ -155,8 +142,12 @@ class Withdraw extends Controller
             request()->validate($validate);
             $ids = request()->input('ids');
             $remark = request()->input('remark');
+            $count = 0;
             foreach ($ids as $id) {
-                WithdrawService::setStatus($id, $status, $remark);
+                $count += WithdrawService::setStatus($id, $status, $remark);
+            }
+            if ($count < 1) {
+                throw new Exception('操作失败', HttpStatus::CUSTOM_ERROR);
             }
             DB::commit();
         } catch (ValidationException $e) {

+ 2 - 1
app/Services/WithdrawService.php

@@ -622,7 +622,7 @@ class WithdrawService
     public static function setStatus($id, $status, $remark)
     {
         $w = WithdrawService::findOne(['id' => $id, 'status' => 0]);
-        if (!$w) return;
+        if (!$w) return 0;
         // 汇率
         $rate = $w->exchange_rate ?? 1;
         if ($status == 1) {
@@ -657,6 +657,7 @@ class WithdrawService
             'chat_id' => $w->member_id,
             'text' => $text,
         ]);
+        return 1;
     }