| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- <template>
- <div class="profit-share-apply">
- <!-- 搜索条件 -->
- <el-card class="search-card">
- <el-form :model="searchForm" label-width="140px" inline>
- <el-form-item label="商户分账指令流水号">
- <el-input
- v-model="searchForm.out_separate_no"
- placeholder="请输入商户分账指令流水号"
- clearable
- style="width: 300px"
- @keyup.enter="handleSearch"
- />
- </el-form-item>
- <el-form-item label="分账状态">
- <el-select v-model="searchForm.status" placeholder="请选择分账状态" clearable style="width: 150px">
- <el-option label="全部" value="" />
- <el-option label="待处理" value="PENDING" />
- <el-option label="处理中" value="PROCESSING" />
- <el-option label="已受理" value="ACCEPTED" />
- <el-option label="成功" value="SUCCESS" />
- <el-option label="失败" value="FAIL" />
- </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
- style="width: 100%"
- :header-cell-style="{background: '#f8f9fa', color: '#606266'}"
- highlight-current-row
- >
- <el-table-column prop="id" label="ID" width="80" align="center" />
- <el-table-column label="用户信息" width="200">
- <template #default="{ row }">
- <div class="user-info">
- <div class="user-detail-item">
- <span class="label">ID:</span>
- <span class="value">{{ row.user_id }}</span>
- </div>
- <div class="user-detail-item">
- <span class="label">昵称:</span>
- <span class="value">{{ row.user?.nickname || '-' }}</span>
- </div>
- <div class="user-detail-item">
- <span class="label">用户名:</span>
- <span class="value">{{ row.user?.username || '-' }}</span>
- </div>
- <div class="user-detail-item">
- <span class="label">手机:</span>
- <span class="value">{{ row.user?.mobile || '-' }}</span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="分账指令流水号" min-width="240">
- <template #default="{ row }">
- <div class="order-numbers">
- <div class="order-number-item">
- <span class="label">商户:</span>
- <span class="value">{{ row.out_separate_no }}</span>
- </div>
- <div class="order-number-item">
- <span class="label">平台:</span>
- <span class="value">{{ row.separate_no || '--'}}</span>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="total_amt" label="分账总金额(元)" width="140" align="right">
- <template #default="{ row }">
- <span style="font-weight: 600; color: #e6a23c; font-size: 16px">¥{{ formatAmountToYuan(row.total_amt) }}</span>
- </template>
- </el-table-column>
- <el-table-column label="接收方商户信息" width="220">
- <template #default="{ row }">
- <div class="merchant-info">
- <div class="merchant-no" :title="row.recv_merchant_no">商户号: {{ row.recv_merchant_no }}</div>
- <div class="merchant-no" :title="row.merchant_no">分账商户号: {{ row.merchant_no }}</div>
- <div class="amount-details">
- <div class="amount-row">
- <span class="label">分账金额:</span>
- <span class="value">¥{{ formatAmountToYuan(row.total_amt - row.separate_value) }}</span>
- </div>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="分账接收方信息" width="180">
- <template #default="{ row }">
- <div class="receiver-info">
- <div class="receiver-no">编号: {{ row.recv_no }}</div>
- <div class="amount-details">
- <div class="amount-row">
- <span class="label">总金额:</span>
- <span class="value">¥{{ formatAmountToYuan(getTotalSeparateAmount(row)) }}</span>
- </div>
- <div class="amount-row">
- <span class="label">手续费:</span>
- <span class="value fee">-¥{{ formatAmountToYuan(row.fee_amt) }}</span>
- </div>
- <div class="divider"></div>
- <div class="amount-row total">
- <span class="label">实际分账:</span>
- <span class="value total">¥{{ formatAmountToYuan(row.separate_value) }}</span>
- </div>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="status" label="分账状态" width="120" align="center">
- <template #default="{ row }">
- <span :class="['status-badge', `status-${row.status.toLowerCase()}`]">{{ getStatusText(row.status) }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="fail_reason" label="分账失败原因" min-width="180" />
- <el-table-column prop="create_time" label="创建时间" width="180" align="center" />
- <el-table-column prop="update_time" label="更新时间" width="180" align="center" />
- <el-table-column label="操作" width="180" fixed="right">
- <template #default="{ row }">
- <div v-if="row.status === 'PENDING'">
- <el-button type="success" size="small" @click="handleApprove(row)">通过</el-button>
- <el-button type="danger" size="small" @click="handleReject(row)">驳回</el-button>
- </div>
- <div>
- <el-button
- type="primary"
- size="small"
- link
- @click="showBalanceRecordDialog(row.user_id)"
- >
- 资金明细
- </el-button>
- </div>
- </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>
- <!-- 驳回对话框 -->
- <el-dialog
- v-model="rejectDialogVisible"
- title="驳回分账申请"
- width="500px"
- destroy-on-close
- >
- <el-form label-width="100px">
- <el-form-item label="驳回原因" required>
- <el-input
- v-model="rejectForm.reason"
- type="textarea"
- :rows="3"
- placeholder="请输入驳回原因"
- />
- </el-form-item>
- </el-form>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="rejectDialogVisible = false">取消</el-button>
- <el-button type="primary" @click="submitReject" :loading="rejectLoading">确定</el-button>
- </span>
- </template>
- </el-dialog>
-
- <!-- 资金明细对话框 -->
- <el-dialog
- v-model="balanceRecordDialogVisible"
- title="资金明细"
- width="800px"
- @close="closeBalanceRecordDialog"
- >
- <el-table
- v-loading="balanceRecordLoading"
- :data="balanceRecords"
- stripe
- style="width: 100%"
- >
- <el-table-column prop="id" label="ID" width="80" />
- <el-table-column prop="type_text" label="类型" width="100" />
- <el-table-column prop="amount" label="金额" width="120" align="right">
- <template #default="scope">
- <span :class="scope.row.amount > 0 ? 'amount-increase' : 'amount-decrease'">
- {{ scope.row.amount > 0 ? '+' : '' }}{{ scope.row.amount }}
- </span>
- </template>
- </el-table-column>
- <el-table-column prop="balance" label="余额" width="120" align="right" />
- <el-table-column prop="description" label="描述" show-overflow-tooltip />
- <el-table-column prop="create_time" label="时间" width="160" />
- </el-table>
- <!-- 资金明细分页 -->
- <div class="pagination-container" style="margin-top: 20px;">
- <el-pagination
- v-model:current-page="balanceRecordPagination.page"
- v-model:page-size="balanceRecordPagination.limit"
- :total="balanceRecordPagination.total"
- :page-sizes="[10, 20, 50]"
- background
- layout="total, sizes, prev, pager, next, jumper"
- @size-change="handleBalanceRecordSizeChange"
- @current-change="handleBalanceRecordCurrentChange"
- />
- </div>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="closeBalanceRecordDialog">关闭</el-button>
- </span>
- </template>
- </el-dialog>
- </div>
- </template>
- <script>
- export default {
- name: "ProfitShareOrder",
- inheritAttrs: false,
- props: {
- axiosInstance: {
- type: Object,
- default: null
- }
- },
- data() {
- return {
- loading: false,
- rejectLoading: false,
- balanceRecordLoading: false,
- searchForm: {
- out_separate_no: '',
- status: ''
- },
- tableData: [],
- pagination: {
- page: 1,
- limit: 10,
- total: 0
- },
- // 驳回对话框相关
- rejectDialogVisible: false,
- rejectForm: {
- orderId: null,
- reason: ''
- },
- // 资金明细对话框相关
- balanceRecordDialogVisible: false,
- balanceRecords: [],
- balanceRecordPagination: {
- page: 1,
- limit: 10,
- total: 0
- },
- currentUserId: null
- }
- },
- async created() {
- this.fetchData()
- },
- methods: {
- // 计算用户分账总金额(实际分账+手续费)
- getTotalSeparateAmount(row) {
- // 处理字符串和数字类型的金额值
- const separateValue = parseFloat(row.separate_value) || 0;
- const feeAmt = parseFloat(row.fee_amt) || 0;
- return separateValue + feeAmt;
- },
- // 格式化金额显示(分转元)
- formatAmountToYuan(amount) {
- if (amount === null || amount === undefined || amount === '') {
- return '-';
- }
-
- // 如果是字符串,先转换为浮点数
- const numericAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
-
- // 将分转换为元并保留两位小数
- return (numericAmount / 100).toFixed(2);
- },
- // 获取分账状态文本
- getStatusText(status) {
- const statusMap = {
- 'PENDING': '待处理',
- 'PROCESSING': '处理中',
- 'ACCEPTED': '已受理',
- 'SUCCESS': '成功',
- 'FAIL': '失败'
- }
- return statusMap[status] || status
- },
- // 获取列表数据
- async fetchData() {
- if (!this.axiosInstance) {
- this.$message.error('无法获取请求实例')
- return
- }
-
- this.loading = true
- try {
- const params = {
- page: this.pagination.page,
- limit: this.pagination.limit,
- out_separate_no: this.searchForm.out_separate_no,
- status: this.searchForm.status
- }
-
- const res = await this.axiosInstance.get('/lakala/profit_share_order', { params })
- if (res.code === 200) {
- this.tableData = res.page.data
- this.pagination.total = res.page.total
- this.pagination.limit = res.page.per_page
- } else {
- this.$message.error(res.msg || 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 = {
- out_separate_no: '',
- status: ''
- }
- this.pagination.page = 1
- this.fetchData()
- },
-
- // 通过分账申请
- async handleApprove(row) {
- try {
- await this.$confirm('确认通过该分账申请吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- });
-
- const res = await this.axiosInstance.post(`/lakala/profit_share_order/${row.id}/approve`);
- if (res.code === 200) {
- this.$message.success('操作成功');
- this.fetchData(); // 刷新列表
- } else {
- this.$message.error(res.msg || res.message || '操作失败');
- }
- } catch (error) {
- if (error !== 'cancel') {
- console.error('通过分账申请失败:', error);
- this.$message.error('操作失败: ' + (error.message || '未知错误'));
- }
- }
- },
- // 显示驳回对话框
- handleReject(row) {
- this.rejectForm.orderId = row.id;
- this.rejectForm.reason = '';
- this.rejectDialogVisible = true;
- },
- // 提交驳回
- async submitReject() {
- if (!this.rejectForm.reason) {
- this.$message.warning('请输入驳回原因');
- return;
- }
-
- this.rejectLoading = true;
- try {
- const res = await this.axiosInstance.post(`/lakala/profit_share_order/${this.rejectForm.orderId}/reject`, {
- reason: this.rejectForm.reason
- });
-
- if (res.code === 200) {
- this.$message.success('驳回成功');
- this.rejectDialogVisible = false;
- this.fetchData(); // 刷新列表
- } else {
- this.$message.error(res.msg || res.message || '驳回失败');
- }
- } catch (error) {
- console.error('驳回分账申请失败:', error);
- this.$message.error('驳回失败: ' + (error.message || '未知错误'));
- } finally {
- this.rejectLoading = false;
- }
- },
-
- // 分页相关
- handleSizeChange(val) {
- this.pagination.limit = val;
- this.pagination.page = 1;
- this.fetchData();
- },
-
- handleCurrentChange(val) {
- this.pagination.page = val;
- this.fetchData();
- },
-
- // 显示资金明细对话框
- showBalanceRecordDialog(userId) {
- this.currentUserId = userId;
- this.balanceRecordDialogVisible = true;
- this.getBalanceRecords();
- },
- // 关闭资金明细对话框
- closeBalanceRecordDialog() {
- this.balanceRecordDialogVisible = false;
- this.balanceRecords = [];
- this.balanceRecordPagination.page = 1;
- this.balanceRecordPagination.total = 0;
- this.currentUserId = null;
- },
- // 获取资金明细
- async getBalanceRecords() {
- if (!this.axiosInstance) {
- this.$message.error('无法获取请求实例');
- return;
- }
-
- try {
- this.balanceRecordLoading = true;
-
- const params = {
- user_id: this.currentUserId,
- page: this.balanceRecordPagination.page,
- limit: this.balanceRecordPagination.limit
- };
-
- const res = await this.axiosInstance.get('/balpay/log', { params });
- if (res.code === 200) {
- this.balanceRecords = res.page?.data || [];
- this.balanceRecordPagination.total = res.page?.total || 0;
- } else {
- this.$message.error(res.msg || '获取资金明细失败');
- }
- } catch (error) {
- console.error('获取资金明细失败:', error);
- this.$message.error('获取资金明细失败');
- } finally {
- this.balanceRecordLoading = false;
- }
- },
- // 资金明细分页处理
- handleBalanceRecordSizeChange(size) {
- this.balanceRecordPagination.limit = size;
- this.balanceRecordPagination.page = 1;
- this.getBalanceRecords();
- },
- handleBalanceRecordCurrentChange(page) {
- this.balanceRecordPagination.page = page;
- this.getBalanceRecords();
- }
- }
- }
- </script>
- <style scoped>
- .profit-share-apply {
- padding: 20px;
- }
- .search-card {
- margin-bottom: 20px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- border-radius: 8px;
- }
- .search-card ::v-deep(.el-card__header) {
- background-color: #f5f7fa;
- font-weight: bold;
- }
- .table-card {
- margin-bottom: 20px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- border-radius: 8px;
- overflow: hidden;
- }
- .table-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .header-title {
- font-size: 18px;
- font-weight: bold;
- color: #303133;
- }
- .pagination {
- margin-top: 20px;
- text-align: right;
- }
- .user-info {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
- .user-detail-item {
- display: flex;
- font-size: 12px;
- }
- .user-detail-item .label {
- width: 50px;
- font-weight: 500;
- color: #606266;
- flex-shrink: 0;
- }
- .user-detail-item .value {
- flex: 1;
- color: #303133;
- word-break: break-all;
- }
- .order-numbers {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
- .order-number-item {
- display: flex;
- }
- .order-number-item .label {
- width: 40px;
- font-weight: 500;
- color: #606266;
- text-align: right;
- margin-right: 8px;
- flex-shrink: 0;
- }
- .order-number-item .value {
- flex: 1;
- color: #303133;
- word-break: break-all;
- }
- .amount-calculation {
- font-size: 12px;
- }
- .amount-calculation.detail {
- padding: 12px;
- background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%);
- border-radius: 6px;
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- }
- .amount-calculation .main-amount,
- .amount-calculation .fee-amount,
- .amount-calculation .result-amount {
- display: flex;
- justify-content: space-between;
- margin-bottom: 5px;
- }
- .amount-calculation .amount {
- font-weight: 600;
- color: #303133;
- text-align: right;
- }
- .amount-calculation .result-amount .amount {
- color: #67c23a;
- font-weight: 700;
- font-size: 14px;
- }
- .amount-calculation .divider {
- height: 1px;
- background: linear-gradient(to right, transparent, #c0c4cc, transparent);
- margin: 6px 0;
- }
- .merchant-info {
- padding: 8px;
- background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
- border-radius: 4px;
- font-size: 12px;
- }
- .merchant-info .merchant-no {
- margin-bottom: 5px;
- color: #606266;
- font-weight: 500;
- }
- .receiver-info {
- padding: 8px;
- background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
- border-radius: 4px;
- font-size: 12px;
- }
- .amount-details {
- margin-top: 5px;
- }
- .amount-row {
- display: flex;
- justify-content: space-between;
- margin-bottom: 3px;
- }
- .amount-row .label {
- color: #606266;
- }
- .amount-row .value {
- font-weight: 500;
- color: #303133;
- }
- .amount-row .value.fee {
- color: #f56c6c;
- }
- .amount-row.total {
- font-weight: 700;
- margin-top: 3px;
- padding-top: 3px;
- border-top: 1px solid #dcdfe6;
- }
- .amount-row.total .value {
- color: #67c23a;
- font-size: 14px;
- }
- .status-badge {
- padding: 4px 8px;
- border-radius: 12px;
- font-size: 12px;
- font-weight: 500;
- }
- .status-pending {
- background-color: #f0f9eb;
- color: #67c23a;
- }
- .status-processing {
- background-color: #ecf5ff;
- color: #409eff;
- }
- .status-accepted {
- background-color: #e6f3ff;
- color: #3a86ff;
- }
- .status-success {
- background-color: #f0f9eb;
- color: #67c23a;
- }
- .status-fail {
- background-color: #fef0f0;
- color: #f56c6c;
- }
- .el-table ::v-deep(.el-table__header-wrapper) th {
- background-color: #f5f7fa;
- color: #606266;
- font-weight: 600;
- }
- .el-table ::v-deep(.el-table__row:hover) td {
- background-color: #f5f9ff !important;
- }
- .dialog-footer {
- display: flex;
- justify-content: flex-end;
- padding: 10px 0;
- }
- ::v-deep(.el-dialog__header) {
- background-color: #f5f7fa;
- border-bottom: 1px solid #ebeef5;
- font-weight: bold;
- }
- ::v-deep(.el-form-item__label) {
- font-weight: 500;
- }
- .amount-increase {
- color: #67c23a;
- }
- .amount-decrease {
- color: #f56c6c;
- }
- .pagination-container {
- display: flex;
- justify-content: flex-end;
- margin-top: 20px;
- }
- </style>
|