ProfitShareOrder.vue 15 KB

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