Forráskód Böngészése

feat(admin): 更新分润订单审核接口为PUT请求

- 将前端调用的HTTP方法从POST更改为PUT以匹配后端路由配置
- 在后端路由中添加了针对approve操作的PUT请求定义
- 实现了新的approve控制器方法来处理订单状态更新逻辑
- 确保只有待处理状态的订单可以被批准并更新其状态为处理中
- 返回更新后的订单实体作为响应数据
runphp 3 hónapja
szülő
commit
5eef0e85f0

+ 1 - 1
resource/admin/ProfitShareOrder.vue

@@ -416,7 +416,7 @@ export default {
           type: 'warning'
         });
         
-        const res = await this.axiosInstance.post(`/lakala/profit_share_order/${row.id}/approve`);
+        const res = await this.axiosInstance.put(`/lakala/profit_share_order/${row.id}/approve`);
         if (res.code === 200) {
           this.$message.success('操作成功');
           this.fetchData(); // 刷新列表

+ 1 - 0
route/admin.php

@@ -22,6 +22,7 @@ Route::resource('profit_share_receiver', ProfitShareReceiverController::class, f
 })->middleware(['auth', MacroPageMiddleware::class]);
 
 Route::resource('profit_share_order', ProfitShareOrderController::class, function () {
+    Route::put('approve', [ProfitShareOrderController::class, 'approve']);
     Route::put('reject', [ProfitShareOrderController::class, 'reject']);
 })->middleware(['auth', MacroPageMiddleware::class]);
 

+ 14 - 0
src/Controller/Admin/ProfitShareOrderController.php

@@ -28,6 +28,20 @@ class ProfitShareOrderController
         );
     }
 
+    public function approve(
+        int $id,
+        ProfitShareOrderEntity $profitShareOrderEntity,
+        ExtensionBalpayLogEntity $extensionBalpayLogEntity): Response
+    {
+        $entity = $profitShareOrderEntity->where(['id' => $id, 'status' => ProfitShareOrderStatusEnum::PENDING])->findOrEmpty();
+        if ($entity->isEmpty()) {
+            throw_logic_exception('订单不存在或状态异常');
+        }
+        $entity->status = ProfitShareOrderStatusEnum::PROCESSING;
+        $entity->save();
+
+        return success_response($entity);
+    }
     public function reject(
         int $id,
         Request $request,