Explorar el Código

feat(lakala): 添加拉卡拉分账管理后台功能
- 新增分账接收方申请和分帐申请管理界面
- 实现分账接收方列表展示与查询功能
- 添加订单号和状态筛选条件
- 集成分页加载和详情查看功能
- 注册后台路由并添加认证中间件- 支持通过axios实例进行数据请求
- 更新插件管理组件以支持axios实例传递

runphp hace 4 meses
padre
commit
857083aa7b

+ 14 - 0
resource/admin/ProfitShareApply.vue

@@ -0,0 +1,14 @@
+<template>
+  <div>
+    分账申请记录
+  </div>
+</template>
+
+<script>
+export default {
+  name: "ProfitShareApply"
+}
+</script>
+
+<style scoped>
+</style>

+ 207 - 0
resource/admin/ProfitShareReceiver.vue

@@ -0,0 +1,207 @@
+<template>
+  <div class="profit-share-receiver">
+    <!-- 搜索条件 -->
+    <el-card class="search-card">
+      <el-form :model="searchForm" label-width="100px" inline>
+        <el-form-item label="订单号">
+          <el-input 
+            v-model="searchForm.order_no" 
+            placeholder="请输入订单号" 
+            clearable
+            @keyup.enter="handleSearch"
+          />
+        </el-form-item>
+        <el-form-item label="状态">
+          <el-select v-model="searchForm.status" placeholder="请选择状态" clearable>
+            <el-option label="全部" value="" />
+            <el-option label="待处理" value="pending" />
+            <el-option label="已通过" value="approved" />
+            <el-option label="已拒绝" value="rejected" />
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handleSearch">查询</el-button>
+          <el-button @click="handleReset">重置</el-button>
+        </el-form-item>
+      </el-form>
+    </el-card>
+
+    <!-- 列表数据 -->
+    <el-card class="table-card">
+      <template #header>
+        <div class="table-header">
+          <div class="header-title">分账接收方列表</div>
+        </div>
+      </template>
+      
+      <el-table
+        v-loading="loading"
+        :data="tableData"
+        border
+        stripe
+      >
+        <el-table-column prop="id" label="ID" width="80" />
+        <el-table-column prop="order_no" label="订单号" min-width="180" />
+        <el-table-column prop="receiver_name" label="接收方名称" min-width="150" />
+        <el-table-column prop="receiver_account" label="接收方账户" min-width="180" />
+        <el-table-column prop="amount" label="分账金额" width="120">
+          <template #default="{ row }">
+            ¥{{ row.amount }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="status" label="状态" width="100">
+          <template #default="{ row }">
+            <el-tag v-if="row.status === 'pending'" type="warning">待处理</el-tag>
+            <el-tag v-else-if="row.status === 'approved'" type="success">已通过</el-tag>
+            <el-tag v-else-if="row.status === 'rejected'" type="danger">已拒绝</el-tag>
+            <el-tag v-else>{{ row.status }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="create_time" label="申请时间" width="180" />
+        <el-table-column label="操作" width="150" fixed="right">
+          <template #default="{ row }">
+            <el-button type="primary" size="small" @click="handleView(row)">详情</el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      
+      <!-- 分页 -->
+      <el-pagination
+        v-model:current-page="pagination.page"
+        v-model:page-size="pagination.limit"
+        :total="pagination.total"
+        :page-sizes="[10, 20, 50, 100]"
+        layout="total, sizes, prev, pager, next, jumper"
+        @size-change="handleSizeChange"
+        @current-change="handleCurrentChange"
+        class="pagination"
+      />
+    </el-card>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'ProfitShareReceiver',
+  props: {
+    axiosInstance: {
+      type: Object,
+      default: null
+    }
+  },
+  data() {
+    return {
+      loading: false,
+      searchForm: {
+        order_no: '',
+        status: ''
+      },
+      tableData: [],
+      pagination: {
+        page: 1,
+        limit: 10,
+        total: 0
+      }
+    }
+  },
+  async created() {
+    this.fetchData()
+  },
+  methods: {
+    // 获取列表数据
+    async fetchData() {
+      // 优先使用通过props传递的axios实例
+      if (!this.axiosInstance) {
+        this.$message.error('无法获取请求实例')
+        return
+      }
+      
+      this.loading = true
+      try {
+        const params = {
+          page: this.pagination.page,
+          limit: this.pagination.limit,
+          order_no: this.searchForm.order_no,
+          status: this.searchForm.status
+        }
+        
+        const res = await this.axiosInstance.get('/lakala/profit_share_receiver', { params })
+        if (res.code === 200) {
+          this.tableData = res.data.list
+          this.pagination.total = res.data.total
+        } else {
+          this.$message.error(res.message || '获取数据失败')
+        }
+      } catch (error) {
+        console.error('获取分账接收方列表失败:', error)
+        this.$message.error('获取数据失败: ' + (error.message || '未知错误'))
+      } finally {
+        this.loading = false
+      }
+    },
+    
+    // 查询
+    handleSearch() {
+      this.pagination.page = 1
+      this.fetchData()
+    },
+    
+    // 重置
+    handleReset() {
+      this.searchForm = {
+        order_no: '',
+        status: ''
+      }
+      this.pagination.page = 1
+      this.fetchData()
+    },
+    
+    // 查看详情
+    handleView(row) {
+      this.$message.info('查看详情功能待实现')
+    },
+    
+    // 分页相关
+    handleSizeChange(val) {
+      this.pagination.limit = val
+      this.pagination.page = 1
+      this.fetchData()
+    },
+    
+    handleCurrentChange(val) {
+      this.pagination.page = val
+      this.fetchData()
+    }
+  }
+}
+</script>
+
+<style scoped>
+.profit-share-receiver {
+  padding: 20px;
+}
+
+.search-card {
+  margin-bottom: 20px;
+}
+
+.table-card {
+  margin-bottom: 20px;
+}
+
+.table-header {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.header-title {
+  font-size: 16px;
+  font-weight: bold;
+}
+
+.pagination {
+  margin-top: 20px;
+  text-align: right;
+}
+</style>

+ 94 - 0
resource/admin/index.vue

@@ -0,0 +1,94 @@
+<template>
+  <div class="lakala-container">
+    <el-container>
+      <el-header height="60px">
+        <el-menu
+          :default-active="activeMenu"
+          mode="horizontal"
+          @select="handleMenuSelect"
+          class="el-menu-horizontal"
+        >
+          <el-menu-item index="profitShareReceiver">
+            <span>分账接收方申请</span>
+          </el-menu-item>
+          <el-menu-item index="profitShareApply">
+            <span>分帐申请</span>
+          </el-menu-item>
+        </el-menu>
+      </el-header>
+      
+      <el-main>
+        <component 
+          :is="currentComponent" 
+          :axios-instance="axiosInstance" 
+        />
+      </el-main>
+    </el-container>
+  </div>
+</template>
+
+<script>
+import ProfitShareReceiver from './ProfitShareReceiver.vue'
+import ProfitShareApply from './ProfitShareApply.vue'
+
+export default {
+  name: 'LakalaAdmin',
+  components: {
+    ProfitShareReceiver,
+    ProfitShareApply
+  },
+  props: {
+    axiosInstance: {
+      type: Object,
+      default: null
+    }
+  },
+  data() {
+    return {
+      activeMenu: 'profitShareReceiver'
+    }
+  },
+  computed: {
+    currentComponent() {
+      if (this.activeMenu === 'profitShareReceiver') {
+        return 'ProfitShareReceiver'
+      } else if (this.activeMenu === 'profitShareApply') {
+        return 'ProfitShareApply'
+      }
+      return 'ProfitShareReceiver'
+    }
+  },
+  methods: {
+    handleMenuSelect(key) {
+      this.activeMenu = key
+    }
+  }
+}
+</script>
+
+<style scoped>
+.lakala-container {
+  padding: 0;
+  height: calc(100vh - 120px);
+}
+
+.el-menu-horizontal {
+  height: 60px;
+  font-size: 16px;
+}
+
+.el-header {
+  padding: 0;
+  background-color: #fff;
+  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+}
+
+.el-main {
+  padding: 30px;
+  background: #fff;
+  margin: 20px;
+  border-radius: 8px;
+  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+  flex: 1;
+}
+</style>

+ 10 - 0
route/admin.php

@@ -2,3 +2,13 @@
 declare(strict_types=1);
 
 use think\facade\Route;
+use SixShop\Lakala\Controller\Admin\ProfitShareReceiverController;
+use SixShop\System\Middleware\MacroPageMiddleware;
+// Admin路由
+// 路由前缀: /admin/lakala
+//
+// 如果需要登录请添加认证中间件auth
+// ->middleware(['auth'])
+
+Route::resource('profit_share_receiver', ProfitShareReceiverController::class)
+    ->middleware(['auth', MacroPageMiddleware::class]);

+ 28 - 0
src/Controller/Admin/ProfitShareReceiverController.php

@@ -0,0 +1,28 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Controller\Admin;
+
+use SixShop\Core\Request;
+use SixShop\Lakala\Config;
+use SixShop\Lakala\Entity\ProfitShareReceiverEntity;
+use think\Response;
+use function SixShop\Core\page_response;
+use function SixShop\Core\success_response;
+
+class ProfitShareReceiverController
+{
+    public function index(Request $request, ProfitShareReceiverEntity $entity): Response
+    {
+        $params = $request->get([
+            'status/d' => 0,
+            'order_no' => '',
+        ]);
+        return page_response(page: $entity->getReceiverList($params, $request->pageAndLimit()));
+    }
+
+    public function read(int $id, Request $request, ProfitShareReceiverEntity $entity):Response
+    {
+        $params = ['id' => $id];
+        return success_response($entity->getReceiver($params));
+    }
+}