ProfitShareOrder.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template>
  2. <div class="profit-share-apply">
  3. <!-- 搜索条件 -->
  4. <el-card class="search-card">
  5. <el-form :model="searchForm" label-width="140px" inline>
  6. <el-form-item label="商户分账指令流水号">
  7. <el-input
  8. v-model="searchForm.out_separate_no"
  9. placeholder="请输入商户分账指令流水号"
  10. clearable
  11. style="width: 300px"
  12. @keyup.enter="handleSearch"
  13. />
  14. </el-form-item>
  15. <el-form-item label="分账状态">
  16. <el-select v-model="searchForm.status" placeholder="请选择分账状态" clearable style="width: 150px">
  17. <el-option label="全部" value="" />
  18. <el-option label="待处理" value="PENDING" />
  19. <el-option label="处理中" value="PROCESSING" />
  20. <el-option label="已受理" value="ACCEPTED" />
  21. <el-option label="成功" value="SUCCESS" />
  22. <el-option label="失败" value="FAIL" />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" @click="handleSearch">查询</el-button>
  27. <el-button @click="handleReset">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </el-card>
  31. <!-- 列表数据 -->
  32. <el-card class="table-card">
  33. <template #header>
  34. <div class="table-header">
  35. <div class="header-title">分账申请记录列表</div>
  36. </div>
  37. </template>
  38. <el-table
  39. v-loading="loading"
  40. :data="tableData"
  41. border
  42. stripe
  43. style="width: 100%"
  44. :header-cell-style="{background: '#f8f9fa', color: '#606266'}"
  45. highlight-current-row
  46. >
  47. <el-table-column prop="id" label="ID" width="80" align="center" />
  48. <el-table-column label="用户信息" width="200">
  49. <template #default="{ row }">
  50. <div class="user-info">
  51. <div class="user-detail-item">
  52. <span class="label">ID:</span>
  53. <span class="value">{{ row.user_id }}</span>
  54. </div>
  55. <div class="user-detail-item">
  56. <span class="label">昵称:</span>
  57. <span class="value">{{ row.user?.nickname || '-' }}</span>
  58. </div>
  59. <div class="user-detail-item">
  60. <span class="label">用户名:</span>
  61. <span class="value">{{ row.user?.username || '-' }}</span>
  62. </div>
  63. <div class="user-detail-item">
  64. <span class="label">手机:</span>
  65. <span class="value">{{ row.user?.mobile || '-' }}</span>
  66. </div>
  67. </div>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="分账指令流水号" min-width="240">
  71. <template #default="{ row }">
  72. <div class="order-numbers">
  73. <div class="order-number-item">
  74. <span class="label">商户:</span>
  75. <span class="value">{{ row.out_separate_no }}</span>
  76. </div>
  77. <div class="order-number-item">
  78. <span class="label">平台:</span>
  79. <span class="value">{{ row.separate_no || '--'}}</span>
  80. </div>
  81. </div>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="total_amt" label="分账总金额(元)" width="140" align="right">
  85. <template #default="{ row }">
  86. <span style="font-weight: 600; color: #e6a23c; font-size: 16px">¥{{ formatAmountToYuan(row.total_amt) }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="接收方商户信息" width="220">
  90. <template #default="{ row }">
  91. <div class="merchant-info">
  92. <div class="merchant-no" :title="row.recv_merchant_no">商户号: {{ row.recv_merchant_no }}</div>
  93. <div class="merchant-no" :title="row.merchant_no">分账商户号: {{ row.merchant_no }}</div>
  94. <div class="amount-details">
  95. <div class="amount-row">
  96. <span class="label">分账金额:</span>
  97. <span class="value">¥{{ formatAmountToYuan(row.total_amt - row.separate_value) }}</span>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="分账接收方信息" width="180">
  104. <template #default="{ row }">
  105. <div class="receiver-info">
  106. <div class="receiver-no">编号: {{ row.recv_no }}</div>
  107. <div class="amount-details">
  108. <div class="amount-row">
  109. <span class="label">总金额:</span>
  110. <span class="value">¥{{ formatAmountToYuan(getTotalSeparateAmount(row)) }}</span>
  111. </div>
  112. <div class="amount-row">
  113. <span class="label">手续费:</span>
  114. <span class="value fee">-¥{{ formatAmountToYuan(row.fee_amt) }}</span>
  115. </div>
  116. <div class="divider"></div>
  117. <div class="amount-row total">
  118. <span class="label">实际分账:</span>
  119. <span class="value total">¥{{ formatAmountToYuan(row.separate_value) }}</span>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. </el-table-column>
  125. <el-table-column prop="status" label="分账状态" width="120" align="center">
  126. <template #default="{ row }">
  127. <span :class="['status-badge', `status-${row.status.toLowerCase()}`]">{{ getStatusText(row.status) }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column prop="fail_reason" label="分账失败原因" min-width="180" />
  131. <el-table-column prop="create_time" label="创建时间" width="180" align="center" />
  132. <el-table-column prop="update_time" label="更新时间" width="180" align="center" />
  133. <el-table-column label="操作" width="180" fixed="right">
  134. <template #default="{ row }">
  135. <div v-if="row.status === 'PENDING'">
  136. <el-button type="success" size="small" @click="handleApprove(row)">通过</el-button>
  137. <el-button type="danger" size="small" @click="handleReject(row)">驳回</el-button>
  138. </div>
  139. <div>
  140. <el-button
  141. type="primary"
  142. size="small"
  143. link
  144. @click="showBalanceRecordDialog(row.user_id)"
  145. >
  146. 资金明细
  147. </el-button>
  148. </div>
  149. </template>
  150. </el-table-column>
  151. </el-table>
  152. <!-- 分页 -->
  153. <el-pagination
  154. v-model:current-page="pagination.page"
  155. v-model:page-size="pagination.limit"
  156. :total="pagination.total"
  157. :page-sizes="[10, 20, 50, 100]"
  158. layout="total, sizes, prev, pager, next, jumper"
  159. @size-change="handleSizeChange"
  160. @current-change="handleCurrentChange"
  161. class="pagination"
  162. />
  163. </el-card>
  164. <!-- 驳回对话框 -->
  165. <el-dialog
  166. v-model="rejectDialogVisible"
  167. title="驳回分账申请"
  168. width="500px"
  169. destroy-on-close
  170. >
  171. <el-form label-width="100px">
  172. <el-form-item label="驳回原因" required>
  173. <el-input
  174. v-model="rejectForm.reason"
  175. type="textarea"
  176. :rows="3"
  177. placeholder="请输入驳回原因"
  178. />
  179. </el-form-item>
  180. </el-form>
  181. <template #footer>
  182. <span class="dialog-footer">
  183. <el-button @click="rejectDialogVisible = false">取消</el-button>
  184. <el-button type="primary" @click="submitReject" :loading="rejectLoading">确定</el-button>
  185. </span>
  186. </template>
  187. </el-dialog>
  188. <!-- 资金明细对话框 -->
  189. <el-dialog
  190. v-model="balanceRecordDialogVisible"
  191. title="资金明细"
  192. width="800px"
  193. @close="closeBalanceRecordDialog"
  194. >
  195. <el-table
  196. v-loading="balanceRecordLoading"
  197. :data="balanceRecords"
  198. stripe
  199. style="width: 100%"
  200. >
  201. <el-table-column prop="id" label="ID" width="80" />
  202. <el-table-column prop="type_text" label="类型" width="100" />
  203. <el-table-column prop="amount" label="金额" width="120" align="right">
  204. <template #default="scope">
  205. <span :class="scope.row.amount > 0 ? 'amount-increase' : 'amount-decrease'">
  206. {{ scope.row.amount > 0 ? '+' : '' }}{{ scope.row.amount }}
  207. </span>
  208. </template>
  209. </el-table-column>
  210. <el-table-column prop="balance" label="余额" width="120" align="right" />
  211. <el-table-column prop="description" label="描述" show-overflow-tooltip />
  212. <el-table-column prop="create_time" label="时间" width="160" />
  213. </el-table>
  214. <!-- 资金明细分页 -->
  215. <div class="pagination-container" style="margin-top: 20px;">
  216. <el-pagination
  217. v-model:current-page="balanceRecordPagination.page"
  218. v-model:page-size="balanceRecordPagination.limit"
  219. :total="balanceRecordPagination.total"
  220. :page-sizes="[10, 20, 50]"
  221. background
  222. layout="total, sizes, prev, pager, next, jumper"
  223. @size-change="handleBalanceRecordSizeChange"
  224. @current-change="handleBalanceRecordCurrentChange"
  225. />
  226. </div>
  227. <template #footer>
  228. <span class="dialog-footer">
  229. <el-button @click="closeBalanceRecordDialog">关闭</el-button>
  230. </span>
  231. </template>
  232. </el-dialog>
  233. </div>
  234. </template>
  235. <script>
  236. export default {
  237. name: "ProfitShareOrder",
  238. inheritAttrs: false,
  239. props: {
  240. axiosInstance: {
  241. type: Object,
  242. default: null
  243. }
  244. },
  245. data() {
  246. return {
  247. loading: false,
  248. rejectLoading: false,
  249. balanceRecordLoading: false,
  250. searchForm: {
  251. out_separate_no: '',
  252. status: ''
  253. },
  254. tableData: [],
  255. pagination: {
  256. page: 1,
  257. limit: 10,
  258. total: 0
  259. },
  260. // 驳回对话框相关
  261. rejectDialogVisible: false,
  262. rejectForm: {
  263. orderId: null,
  264. reason: ''
  265. },
  266. // 资金明细对话框相关
  267. balanceRecordDialogVisible: false,
  268. balanceRecords: [],
  269. balanceRecordPagination: {
  270. page: 1,
  271. limit: 10,
  272. total: 0
  273. },
  274. currentUserId: null
  275. }
  276. },
  277. async created() {
  278. this.fetchData()
  279. },
  280. methods: {
  281. // 计算用户分账总金额(实际分账+手续费)
  282. getTotalSeparateAmount(row) {
  283. // 处理字符串和数字类型的金额值
  284. const separateValue = parseFloat(row.separate_value) || 0;
  285. const feeAmt = parseFloat(row.fee_amt) || 0;
  286. return separateValue + feeAmt;
  287. },
  288. // 格式化金额显示(分转元)
  289. formatAmountToYuan(amount) {
  290. if (amount === null || amount === undefined || amount === '') {
  291. return '-';
  292. }
  293. // 如果是字符串,先转换为浮点数
  294. const numericAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
  295. // 将分转换为元并保留两位小数
  296. return (numericAmount / 100).toFixed(2);
  297. },
  298. // 获取分账状态文本
  299. getStatusText(status) {
  300. const statusMap = {
  301. 'PENDING': '待处理',
  302. 'PROCESSING': '处理中',
  303. 'ACCEPTED': '已受理',
  304. 'SUCCESS': '成功',
  305. 'FAIL': '失败'
  306. }
  307. return statusMap[status] || status
  308. },
  309. // 获取列表数据
  310. async fetchData() {
  311. if (!this.axiosInstance) {
  312. this.$message.error('无法获取请求实例')
  313. return
  314. }
  315. this.loading = true
  316. try {
  317. const params = {
  318. page: this.pagination.page,
  319. limit: this.pagination.limit,
  320. out_separate_no: this.searchForm.out_separate_no,
  321. status: this.searchForm.status
  322. }
  323. const res = await this.axiosInstance.get('/lakala/profit_share_order', { params })
  324. if (res.code === 200) {
  325. this.tableData = res.page.data
  326. this.pagination.total = res.page.total
  327. this.pagination.limit = res.page.per_page
  328. } else {
  329. this.$message.error(res.msg || res.message || '获取数据失败')
  330. }
  331. } catch (error) {
  332. console.error('获取分账申请记录列表失败:', error)
  333. this.$message.error('获取数据失败: ' + (error.message || '未知错误'))
  334. } finally {
  335. this.loading = false
  336. }
  337. },
  338. // 查询
  339. handleSearch() {
  340. this.pagination.page = 1
  341. this.fetchData()
  342. },
  343. // 重置
  344. handleReset() {
  345. this.searchForm = {
  346. out_separate_no: '',
  347. status: ''
  348. }
  349. this.pagination.page = 1
  350. this.fetchData()
  351. },
  352. // 通过分账申请
  353. async handleApprove(row) {
  354. try {
  355. await this.$confirm('确认通过该分账申请吗?', '提示', {
  356. confirmButtonText: '确定',
  357. cancelButtonText: '取消',
  358. type: 'warning'
  359. });
  360. const res = await this.axiosInstance.post(`/lakala/profit_share_order/${row.id}/approve`);
  361. if (res.code === 200) {
  362. this.$message.success('操作成功');
  363. this.fetchData(); // 刷新列表
  364. } else {
  365. this.$message.error(res.msg || res.message || '操作失败');
  366. }
  367. } catch (error) {
  368. if (error !== 'cancel') {
  369. console.error('通过分账申请失败:', error);
  370. this.$message.error('操作失败: ' + (error.message || '未知错误'));
  371. }
  372. }
  373. },
  374. // 显示驳回对话框
  375. handleReject(row) {
  376. this.rejectForm.orderId = row.id;
  377. this.rejectForm.reason = '';
  378. this.rejectDialogVisible = true;
  379. },
  380. // 提交驳回
  381. async submitReject() {
  382. if (!this.rejectForm.reason) {
  383. this.$message.warning('请输入驳回原因');
  384. return;
  385. }
  386. this.rejectLoading = true;
  387. try {
  388. const res = await this.axiosInstance.post(`/lakala/profit_share_order/${this.rejectForm.orderId}/reject`, {
  389. reason: this.rejectForm.reason
  390. });
  391. if (res.code === 200) {
  392. this.$message.success('驳回成功');
  393. this.rejectDialogVisible = false;
  394. this.fetchData(); // 刷新列表
  395. } else {
  396. this.$message.error(res.msg || res.message || '驳回失败');
  397. }
  398. } catch (error) {
  399. console.error('驳回分账申请失败:', error);
  400. this.$message.error('驳回失败: ' + (error.message || '未知错误'));
  401. } finally {
  402. this.rejectLoading = false;
  403. }
  404. },
  405. // 分页相关
  406. handleSizeChange(val) {
  407. this.pagination.limit = val;
  408. this.pagination.page = 1;
  409. this.fetchData();
  410. },
  411. handleCurrentChange(val) {
  412. this.pagination.page = val;
  413. this.fetchData();
  414. },
  415. // 显示资金明细对话框
  416. showBalanceRecordDialog(userId) {
  417. this.currentUserId = userId;
  418. this.balanceRecordDialogVisible = true;
  419. this.getBalanceRecords();
  420. },
  421. // 关闭资金明细对话框
  422. closeBalanceRecordDialog() {
  423. this.balanceRecordDialogVisible = false;
  424. this.balanceRecords = [];
  425. this.balanceRecordPagination.page = 1;
  426. this.balanceRecordPagination.total = 0;
  427. this.currentUserId = null;
  428. },
  429. // 获取资金明细
  430. async getBalanceRecords() {
  431. if (!this.axiosInstance) {
  432. this.$message.error('无法获取请求实例');
  433. return;
  434. }
  435. try {
  436. this.balanceRecordLoading = true;
  437. const params = {
  438. user_id: this.currentUserId,
  439. page: this.balanceRecordPagination.page,
  440. limit: this.balanceRecordPagination.limit
  441. };
  442. const res = await this.axiosInstance.get('/balpay/log', { params });
  443. if (res.code === 200) {
  444. this.balanceRecords = res.page?.data || [];
  445. this.balanceRecordPagination.total = res.page?.total || 0;
  446. } else {
  447. this.$message.error(res.msg || '获取资金明细失败');
  448. }
  449. } catch (error) {
  450. console.error('获取资金明细失败:', error);
  451. this.$message.error('获取资金明细失败');
  452. } finally {
  453. this.balanceRecordLoading = false;
  454. }
  455. },
  456. // 资金明细分页处理
  457. handleBalanceRecordSizeChange(size) {
  458. this.balanceRecordPagination.limit = size;
  459. this.balanceRecordPagination.page = 1;
  460. this.getBalanceRecords();
  461. },
  462. handleBalanceRecordCurrentChange(page) {
  463. this.balanceRecordPagination.page = page;
  464. this.getBalanceRecords();
  465. }
  466. }
  467. }
  468. </script>
  469. <style scoped>
  470. .profit-share-apply {
  471. padding: 20px;
  472. }
  473. .search-card {
  474. margin-bottom: 20px;
  475. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  476. border-radius: 8px;
  477. }
  478. .search-card ::v-deep(.el-card__header) {
  479. background-color: #f5f7fa;
  480. font-weight: bold;
  481. }
  482. .table-card {
  483. margin-bottom: 20px;
  484. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  485. border-radius: 8px;
  486. overflow: hidden;
  487. }
  488. .table-header {
  489. display: flex;
  490. justify-content: space-between;
  491. align-items: center;
  492. }
  493. .header-title {
  494. font-size: 18px;
  495. font-weight: bold;
  496. color: #303133;
  497. }
  498. .pagination {
  499. margin-top: 20px;
  500. text-align: right;
  501. }
  502. .user-info {
  503. display: flex;
  504. flex-direction: column;
  505. gap: 4px;
  506. }
  507. .user-detail-item {
  508. display: flex;
  509. font-size: 12px;
  510. }
  511. .user-detail-item .label {
  512. width: 50px;
  513. font-weight: 500;
  514. color: #606266;
  515. flex-shrink: 0;
  516. }
  517. .user-detail-item .value {
  518. flex: 1;
  519. color: #303133;
  520. word-break: break-all;
  521. }
  522. .order-numbers {
  523. display: flex;
  524. flex-direction: column;
  525. gap: 4px;
  526. }
  527. .order-number-item {
  528. display: flex;
  529. }
  530. .order-number-item .label {
  531. width: 40px;
  532. font-weight: 500;
  533. color: #606266;
  534. text-align: right;
  535. margin-right: 8px;
  536. flex-shrink: 0;
  537. }
  538. .order-number-item .value {
  539. flex: 1;
  540. color: #303133;
  541. word-break: break-all;
  542. }
  543. .amount-calculation {
  544. font-size: 12px;
  545. }
  546. .amount-calculation.detail {
  547. padding: 12px;
  548. background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%);
  549. border-radius: 6px;
  550. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  551. }
  552. .amount-calculation .main-amount,
  553. .amount-calculation .fee-amount,
  554. .amount-calculation .result-amount {
  555. display: flex;
  556. justify-content: space-between;
  557. margin-bottom: 5px;
  558. }
  559. .amount-calculation .amount {
  560. font-weight: 600;
  561. color: #303133;
  562. text-align: right;
  563. }
  564. .amount-calculation .result-amount .amount {
  565. color: #67c23a;
  566. font-weight: 700;
  567. font-size: 14px;
  568. }
  569. .amount-calculation .divider {
  570. height: 1px;
  571. background: linear-gradient(to right, transparent, #c0c4cc, transparent);
  572. margin: 6px 0;
  573. }
  574. .merchant-info {
  575. padding: 8px;
  576. background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
  577. border-radius: 4px;
  578. font-size: 12px;
  579. }
  580. .merchant-info .merchant-no {
  581. margin-bottom: 5px;
  582. color: #606266;
  583. font-weight: 500;
  584. }
  585. .receiver-info {
  586. padding: 8px;
  587. background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
  588. border-radius: 4px;
  589. font-size: 12px;
  590. }
  591. .amount-details {
  592. margin-top: 5px;
  593. }
  594. .amount-row {
  595. display: flex;
  596. justify-content: space-between;
  597. margin-bottom: 3px;
  598. }
  599. .amount-row .label {
  600. color: #606266;
  601. }
  602. .amount-row .value {
  603. font-weight: 500;
  604. color: #303133;
  605. }
  606. .amount-row .value.fee {
  607. color: #f56c6c;
  608. }
  609. .amount-row.total {
  610. font-weight: 700;
  611. margin-top: 3px;
  612. padding-top: 3px;
  613. border-top: 1px solid #dcdfe6;
  614. }
  615. .amount-row.total .value {
  616. color: #67c23a;
  617. font-size: 14px;
  618. }
  619. .status-badge {
  620. padding: 4px 8px;
  621. border-radius: 12px;
  622. font-size: 12px;
  623. font-weight: 500;
  624. }
  625. .status-pending {
  626. background-color: #f0f9eb;
  627. color: #67c23a;
  628. }
  629. .status-processing {
  630. background-color: #ecf5ff;
  631. color: #409eff;
  632. }
  633. .status-accepted {
  634. background-color: #e6f3ff;
  635. color: #3a86ff;
  636. }
  637. .status-success {
  638. background-color: #f0f9eb;
  639. color: #67c23a;
  640. }
  641. .status-fail {
  642. background-color: #fef0f0;
  643. color: #f56c6c;
  644. }
  645. .el-table ::v-deep(.el-table__header-wrapper) th {
  646. background-color: #f5f7fa;
  647. color: #606266;
  648. font-weight: 600;
  649. }
  650. .el-table ::v-deep(.el-table__row:hover) td {
  651. background-color: #f5f9ff !important;
  652. }
  653. .dialog-footer {
  654. display: flex;
  655. justify-content: flex-end;
  656. padding: 10px 0;
  657. }
  658. ::v-deep(.el-dialog__header) {
  659. background-color: #f5f7fa;
  660. border-bottom: 1px solid #ebeef5;
  661. font-weight: bold;
  662. }
  663. ::v-deep(.el-form-item__label) {
  664. font-weight: 500;
  665. }
  666. .amount-increase {
  667. color: #67c23a;
  668. }
  669. .amount-decrease {
  670. color: #f56c6c;
  671. }
  672. .pagination-container {
  673. display: flex;
  674. justify-content: flex-end;
  675. margin-top: 20px;
  676. }
  677. </style>