ProfitShareOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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="分账指令流水号" min-width="240">
  49. <template #default="{ row }">
  50. <div class="order-numbers">
  51. <div class="order-number-item">
  52. <span class="label">商户:</span>
  53. <span class="value">{{ row.out_separate_no }}</span>
  54. </div>
  55. <div class="order-number-item">
  56. <span class="label">平台:</span>
  57. <span class="value">{{ row.separate_no || '--'}}</span>
  58. </div>
  59. </div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="user_id" label="用户ID" width="100" align="center" />
  63. <el-table-column prop="merchant_no" label="分账商户号" width="160" />
  64. <el-table-column prop="total_amt" label="分账总金额(元)" width="140" align="center">
  65. <template #default="{ row }">
  66. <span style="font-weight: 600; color: #e6a23c; font-size: 15px">¥{{ formatAmountToYuan(row.total_amt) }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="接收方商户信息" width="200">
  70. <template #default="{ row }">
  71. <div class="merchant-info">
  72. <div class="merchant-no" :title="row.recv_merchant_no">商户号: {{ row.recv_merchant_no }}</div>
  73. <div class="amount-details">
  74. <div class="amount-row">
  75. <span class="label">分账金额:</span>
  76. <span class="value">¥{{ formatAmountToYuan(row.total_amt - row.separate_value) }}</span>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="分账接收方信息" width="180">
  83. <template #default="{ row }">
  84. <div class="receiver-info">
  85. <div class="receiver-no">编号: {{ row.recv_no }}</div>
  86. <div class="amount-details">
  87. <div class="amount-row">
  88. <span class="label">总金额:</span>
  89. <span class="value">¥{{ formatAmountToYuan(getTotalSeparateAmount(row)) }}</span>
  90. </div>
  91. <div class="amount-row">
  92. <span class="label">手续费:</span>
  93. <span class="value fee">-¥{{ formatAmountToYuan(row.fee_amt) }}</span>
  94. </div>
  95. <div class="divider"></div>
  96. <div class="amount-row total">
  97. <span class="label">实际分账:</span>
  98. <span class="value total">¥{{ formatAmountToYuan(row.separate_value) }}</span>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. </el-table-column>
  104. <el-table-column prop="recv_no" label="分账接收方编号" width="160" />
  105. <el-table-column prop="status" label="分账状态" width="120" align="center">
  106. <template #default="{ row }">
  107. <span :class="['status-badge', `status-${row.status.toLowerCase()}`]">{{ getStatusText(row.status) }}</span>
  108. </template>
  109. </el-table-column>
  110. <el-table-column prop="fail_reason" label="分账失败原因" min-width="180" />
  111. <el-table-column prop="create_time" label="创建时间" width="180" align="center" />
  112. <el-table-column prop="update_time" label="更新时间" width="180" align="center" />
  113. <el-table-column label="操作" width="150" fixed="right">
  114. <template #default="{ row }">
  115. <el-button type="primary" size="small" @click="handleView(row)">详情</el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <!-- 分页 -->
  120. <el-pagination
  121. v-model:current-page="pagination.page"
  122. v-model:page-size="pagination.limit"
  123. :total="pagination.total"
  124. :page-sizes="[10, 20, 50, 100]"
  125. layout="total, sizes, prev, pager, next, jumper"
  126. @size-change="handleSizeChange"
  127. @current-change="handleCurrentChange"
  128. class="pagination"
  129. />
  130. </el-card>
  131. <!-- 详情对话框 -->
  132. <el-dialog
  133. v-model="detailDialogVisible"
  134. title="分账申请详情"
  135. width="600px"
  136. :before-close="handleCloseDetailDialog"
  137. >
  138. <el-form
  139. v-loading="detailLoading"
  140. :model="detailData"
  141. label-width="160px"
  142. label-position="left"
  143. >
  144. <el-form-item label="商户分账指令流水号:">
  145. <span>{{ detailData.out_separate_no }}</span>
  146. </el-form-item>
  147. <el-form-item label="分账指令流水号:">
  148. <span>{{ detailData.separate_no }}</span>
  149. </el-form-item>
  150. <el-form-item label="用户ID:">
  151. <span>{{ detailData.user_id }}</span>
  152. </el-form-item>
  153. <el-form-item label="分账总金额(元):">
  154. <span>{{ formatAmountToYuan(detailData.total_amt) }}</span>
  155. </el-form-item>
  156. <el-form-item label="用户分账金额:">
  157. <div class="amount-calculation detail">
  158. <div class="main-amount">
  159. <span>总金额:</span>
  160. <span class="amount">¥{{ formatAmountToYuan(getTotalSeparateAmount(detailData)) }}</span>
  161. </div>
  162. <div class="fee-amount">
  163. <span>- 手续费:</span>
  164. <span class="amount">¥{{ formatAmountToYuan(detailData.fee_amt) }}</span>
  165. </div>
  166. <div class="divider"></div>
  167. <div class="result-amount">
  168. <span>实际分账:</span>
  169. <span class="amount">¥{{ formatAmountToYuan(detailData.separate_value) }}</span>
  170. </div>
  171. </div>
  172. </el-form-item>
  173. <el-form-item label="商户分账金额(元):">
  174. <span>{{ formatAmountToYuan(getMerchantShareAmount(detailData)) }}</span>
  175. </el-form-item>
  176. <el-form-item label="分账接收方编号:">
  177. <span>{{ detailData.recv_no }}</span>
  178. </el-form-item>
  179. <el-form-item label="分账状态:">
  180. <span>{{ getStatusText(detailData.status) }}</span>
  181. </el-form-item>
  182. <el-form-item v-if="detailData.fail_reason" label="分账失败原因:">
  183. <span>{{ detailData.fail_reason }}</span>
  184. </el-form-item>
  185. <el-form-item label="创建时间:">
  186. <span>{{ detailData.create_time }}</span>
  187. </el-form-item>
  188. <el-form-item label="更新时间:">
  189. <span>{{ detailData.update_time }}</span>
  190. </el-form-item>
  191. </el-form>
  192. <template #footer>
  193. <span class="dialog-footer">
  194. <el-button @click="handleCloseDetailDialog">关闭</el-button>
  195. </span>
  196. </template>
  197. </el-dialog>
  198. </div>
  199. </template>
  200. <script>
  201. export default {
  202. name: "ProfitShareOrder",
  203. inheritAttrs: false,
  204. props: {
  205. axiosInstance: {
  206. type: Object,
  207. default: null
  208. }
  209. },
  210. data() {
  211. return {
  212. loading: false,
  213. detailLoading: false,
  214. searchForm: {
  215. out_separate_no: '',
  216. status: ''
  217. },
  218. tableData: [],
  219. pagination: {
  220. page: 1,
  221. limit: 10,
  222. total: 0
  223. },
  224. detailDialogVisible: false,
  225. detailData: {}
  226. }
  227. },
  228. async created() {
  229. this.fetchData()
  230. },
  231. methods: {
  232. // 计算用户分账总金额(实际分账+手续费)
  233. getTotalSeparateAmount(row) {
  234. // 处理字符串和数字类型的金额值
  235. const separateValue = parseFloat(row.separate_value) || 0;
  236. const feeAmt = parseFloat(row.fee_amt) || 0;
  237. return separateValue + feeAmt;
  238. },
  239. // 格式化金额显示(分转元)
  240. formatAmountToYuan(amount) {
  241. if (amount === null || amount === undefined || amount === '') {
  242. return '-';
  243. }
  244. // 如果是字符串,先转换为浮点数
  245. const numericAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
  246. // 将分转换为元并保留两位小数
  247. return (numericAmount / 100).toFixed(2);
  248. },
  249. // 获取分账状态文本
  250. getStatusText(status) {
  251. const statusMap = {
  252. 'PENDING': '待处理',
  253. 'PROCESSING': '处理中',
  254. 'ACCEPTED': '已受理',
  255. 'SUCCESS': '成功',
  256. 'FAIL': '失败'
  257. }
  258. return statusMap[status] || status
  259. },
  260. // 获取列表数据
  261. async fetchData() {
  262. if (!this.axiosInstance) {
  263. this.$message.error('无法获取请求实例')
  264. return
  265. }
  266. this.loading = true
  267. try {
  268. const params = {
  269. page: this.pagination.page,
  270. limit: this.pagination.limit,
  271. out_separate_no: this.searchForm.out_separate_no,
  272. status: this.searchForm.status
  273. }
  274. const res = await this.axiosInstance.get('/lakala/profit_share_order', { params })
  275. if (res.code === 200) {
  276. this.tableData = res.page.data
  277. this.pagination.total = res.page.total
  278. this.pagination.limit = res.page.per_page
  279. } else {
  280. this.$message.error(res.msg || res.message || '获取数据失败')
  281. }
  282. } catch (error) {
  283. console.error('获取分账申请记录列表失败:', error)
  284. this.$message.error('获取数据失败: ' + (error.message || '未知错误'))
  285. } finally {
  286. this.loading = false
  287. }
  288. },
  289. // 获取详情数据
  290. async fetchDetail(id) {
  291. if (!this.axiosInstance) {
  292. this.$message.error('无法获取请求实例')
  293. return
  294. }
  295. this.detailLoading = true
  296. try {
  297. const res = await this.axiosInstance.get(`/lakala/profit_share_order/${id}`)
  298. if (res.code === 200) {
  299. this.detailData = res.data
  300. } else {
  301. this.$message.error(res.msg || res.message || '获取详情失败')
  302. }
  303. } catch (error) {
  304. console.error('获取分账申请详情失败:', error)
  305. this.$message.error('获取详情失败: ' + (error.message || '未知错误'))
  306. } finally {
  307. this.detailLoading = false
  308. }
  309. },
  310. // 查询
  311. handleSearch() {
  312. this.pagination.page = 1
  313. this.fetchData()
  314. },
  315. // 重置
  316. handleReset() {
  317. this.searchForm = {
  318. out_separate_no: '',
  319. status: ''
  320. }
  321. this.pagination.page = 1
  322. this.fetchData()
  323. },
  324. // 查看详情
  325. async handleView(row) {
  326. await this.fetchDetail(row.id)
  327. this.detailDialogVisible = true
  328. },
  329. // 关闭详情对话框
  330. handleCloseDetailDialog() {
  331. this.detailDialogVisible = false
  332. this.detailData = {}
  333. },
  334. // 分页相关
  335. handleSizeChange(val) {
  336. this.pagination.limit = val
  337. this.pagination.page = 1
  338. this.fetchData()
  339. },
  340. handleCurrentChange(val) {
  341. this.pagination.page = val
  342. this.fetchData()
  343. }
  344. }
  345. }
  346. </script>
  347. <style scoped>
  348. .profit-share-apply {
  349. padding: 20px;
  350. }
  351. .search-card {
  352. margin-bottom: 20px;
  353. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  354. border-radius: 8px;
  355. }
  356. .search-card ::v-deep(.el-card__header) {
  357. background-color: #f5f7fa;
  358. font-weight: bold;
  359. }
  360. .table-card {
  361. margin-bottom: 20px;
  362. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  363. border-radius: 8px;
  364. overflow: hidden;
  365. }
  366. .table-header {
  367. display: flex;
  368. justify-content: space-between;
  369. align-items: center;
  370. }
  371. .header-title {
  372. font-size: 18px;
  373. font-weight: bold;
  374. color: #303133;
  375. }
  376. .pagination {
  377. margin-top: 20px;
  378. text-align: right;
  379. }
  380. .order-numbers {
  381. display: flex;
  382. flex-direction: column;
  383. gap: 4px;
  384. }
  385. .order-number-item {
  386. display: flex;
  387. }
  388. .order-number-item .label {
  389. width: 40px;
  390. font-weight: 500;
  391. color: #606266;
  392. text-align: right;
  393. margin-right: 8px;
  394. flex-shrink: 0;
  395. }
  396. .order-number-item .value {
  397. flex: 1;
  398. color: #303133;
  399. word-break: break-all;
  400. }
  401. .amount-calculation {
  402. font-size: 12px;
  403. }
  404. .amount-calculation.detail {
  405. padding: 12px;
  406. background: linear-gradient(135deg, #f5f7fa 0%, #e4e7ed 100%);
  407. border-radius: 6px;
  408. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  409. }
  410. .amount-calculation .main-amount,
  411. .amount-calculation .fee-amount,
  412. .amount-calculation .result-amount {
  413. display: flex;
  414. justify-content: space-between;
  415. margin-bottom: 5px;
  416. }
  417. .amount-calculation .amount {
  418. font-weight: 600;
  419. color: #303133;
  420. text-align: right;
  421. }
  422. .amount-calculation .result-amount .amount {
  423. color: #67c23a;
  424. font-weight: 700;
  425. font-size: 14px;
  426. }
  427. .amount-calculation .divider {
  428. height: 1px;
  429. background: linear-gradient(to right, transparent, #c0c4cc, transparent);
  430. margin: 6px 0;
  431. }
  432. .merchant-info {
  433. padding: 8px;
  434. background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
  435. border-radius: 4px;
  436. font-size: 12px;
  437. }
  438. .merchant-info .merchant-no {
  439. margin-bottom: 5px;
  440. color: #606266;
  441. font-weight: 500;
  442. }
  443. .receiver-info {
  444. padding: 8px;
  445. background: linear-gradient(135deg, #e8f4ff 0%, #d0e6ff 100%);
  446. border-radius: 4px;
  447. font-size: 12px;
  448. }
  449. .amount-details {
  450. margin-top: 5px;
  451. }
  452. .amount-row {
  453. display: flex;
  454. justify-content: space-between;
  455. margin-bottom: 3px;
  456. }
  457. .amount-row .label {
  458. color: #606266;
  459. }
  460. .amount-row .value {
  461. font-weight: 500;
  462. color: #303133;
  463. }
  464. .amount-row .value.fee {
  465. color: #f56c6c;
  466. }
  467. .amount-row.total {
  468. font-weight: 700;
  469. margin-top: 3px;
  470. padding-top: 3px;
  471. border-top: 1px solid #dcdfe6;
  472. }
  473. .amount-row.total .value {
  474. color: #67c23a;
  475. font-size: 14px;
  476. }
  477. .status-badge {
  478. padding: 4px 8px;
  479. border-radius: 12px;
  480. font-size: 12px;
  481. font-weight: 500;
  482. }
  483. .status-pending {
  484. background-color: #f0f9eb;
  485. color: #67c23a;
  486. }
  487. .status-processing {
  488. background-color: #ecf5ff;
  489. color: #409eff;
  490. }
  491. .status-accepted {
  492. background-color: #e6f3ff;
  493. color: #3a86ff;
  494. }
  495. .status-success {
  496. background-color: #f0f9eb;
  497. color: #67c23a;
  498. }
  499. .status-fail {
  500. background-color: #fef0f0;
  501. color: #f56c6c;
  502. }
  503. .el-table ::v-deep(.el-table__header-wrapper) th {
  504. background-color: #f5f7fa;
  505. color: #606266;
  506. font-weight: 600;
  507. }
  508. .el-table ::v-deep(.el-table__row:hover) td {
  509. background-color: #f5f9ff !important;
  510. }
  511. .dialog-footer {
  512. display: flex;
  513. justify-content: flex-end;
  514. padding: 10px 0;
  515. }
  516. ::v-deep(.el-dialog__header) {
  517. background-color: #f5f7fa;
  518. border-bottom: 1px solid #ebeef5;
  519. font-weight: bold;
  520. }
  521. ::v-deep(.el-form-item__label) {
  522. font-weight: 500;
  523. }
  524. </style>