wlzboy
2026-04-01 c459808efab29dc1b8439fbb90556bdb16f4c88b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="渠道交易号" prop="channelTradeNo">
        <el-input v-model="queryParams.channelTradeNo" placeholder="请输入渠道交易号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="业务订单号" prop="bizOrderId">
        <el-input v-model="queryParams.bizOrderId" placeholder="请输入业务订单号" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="订单标题" prop="subject">
        <el-input v-model="queryParams.subject" placeholder="请输入订单标题" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="最新交易ID" prop="latestTransactionId">
        <el-input v-model="queryParams.latestTransactionId" placeholder="请输入最新交易ID" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
 
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
 
    <el-table v-loading="loading" :data="orderList">
      <el-table-column label="订单ID" align="center" prop="id" width="160" />
      <el-table-column label="业务订单号" align="center" prop="bizOrderId" width="180" :show-overflow-tooltip="true" />
      <el-table-column label="订单标题" align="center" prop="subject" width="200" :show-overflow-tooltip="true" />
      <el-table-column label="金额(元)" align="center" width="100">
        <template slot-scope="scope">
          <span>{{ formatAmount(scope.row.amount) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付渠道" align="center" prop="channel" width="100">
        <template slot-scope="scope">
          <el-tag :type="channelType(scope.row.channel)">{{ scope.row.channel }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="订单状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          <el-tag :type="statusType(scope.row.status)">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="渠道交易号" align="center" prop="channelTradeNo" width="180" :show-overflow-tooltip="true" />
      <el-table-column label="最新交易ID" align="center" prop="latestTransactionId" width="120" />
      <el-table-column label="描述(含taskId)" align="center" prop="description" width="200" :show-overflow-tooltip="true" />
      <el-table-column label="创建时间" align="center" prop="createdAt" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createdAt) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付时间" align="center" prop="paidAt" width="160">
        <template slot-scope="scope">
          <span>{{ scope.row.paidAt ? parseTime(scope.row.paidAt) : '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看明细</el-button>
          <el-button v-if="extractTaskId(scope.row.description)" size="mini" type="text" icon="el-icon-link" @click="handleViewTask(scope.row)">查看转运单</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <!-- 订单详情对话框 -->
    <el-dialog :title="'订单详情 - ' + form.id" :visible.sync="open" width="700px" append-to-body>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="订单ID">{{ form.id }}</el-descriptions-item>
        <el-descriptions-item label="业务订单号">{{ form.bizOrderId }}</el-descriptions-item>
        <el-descriptions-item label="订单标题">{{ form.subject }}</el-descriptions-item>
        <el-descriptions-item label="金额">{{ formatAmount(form.amount) }} 元</el-descriptions-item>
        <el-descriptions-item label="币种">{{ form.currency }}</el-descriptions-item>
        <el-descriptions-item label="支付渠道">
          <el-tag :type="channelType(form.channel)">{{ form.channel }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="订单状态">
          <el-tag :type="statusType(form.status)">{{ form.status }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="渠道交易号">{{ form.channelTradeNo || '-' }}</el-descriptions-item>
        <el-descriptions-item label="最新交易ID">{{ form.latestTransactionId || '-' }}</el-descriptions-item>
        <el-descriptions-item label="乐观锁版本">{{ form.version }}</el-descriptions-item>
        <el-descriptions-item label="创建时间">{{ parseTime(form.createdAt) }}</el-descriptions-item>
        <el-descriptions-item label="更新时间">{{ parseTime(form.updatedAt) }}</el-descriptions-item>
        <el-descriptions-item label="支付时间">{{ form.paidAt ? parseTime(form.paidAt) : '-' }}</el-descriptions-item>
        <el-descriptions-item label="过期时间">{{ parseTime(form.expireAt) }}</el-descriptions-item>
        <el-descriptions-item label="回调地址" :span="2">{{ form.callbackUrl }}</el-descriptions-item>
        <el-descriptions-item label="描述" :span="2">{{ form.description }}</el-descriptions-item>
      </el-descriptions>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="extractTaskId(form.description)" type="primary" @click="handleViewTask(form)">查看关联转运单</el-button>
        <el-button @click="open = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import { listPayOrder, getPayOrder } from "@/api/payment/order";
 
export default {
  name: "PayOrder",
  data() {
    return {
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: true,
      // 订单表格数据
      orderList: [],
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        channelTradeNo: undefined,
        bizOrderId: undefined,
        subject: undefined,
        latestTransactionId: undefined
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询支付订单列表 */
    getList() {
      this.loading = true;
      // 转换 latestTransactionId 为数字
      const params = { ...this.queryParams };
      if (params.latestTransactionId) {
        params.latestTransactionId = Number(params.latestTransactionId);
      }
      listPayOrder(params).then(response => {
        this.orderList = response.data || [];
        this.loading = false;
      }).catch(() => {
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.getList();
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.reset();
      getPayOrder(row.id).then(response => {
        this.form = response.data;
        this.open = true;
      });
    },
    // 表单重置
    reset() {
      this.form = {};
    },
    // 格式化金额(分转元)
    formatAmount(amount) {
      if (amount === undefined || amount === null) return '-';
      return (amount / 100).toFixed(2);
    },
    // 渠道标签类型
    channelType(channel) {
      const map = {
        'WECHAT': 'success',
        'ALIPAY': 'primary',
        'ALIPAY_THIRD': 'warning'
      };
      return map[channel] || '';
    },
    // 状态标签类型
    statusType(status) {
      const map = {
        'CREATED': 'info',
        'PENDING': 'warning',
        'PAID': 'success',
        'CLOSED': 'danger',
        'EXPIRED': 'danger'
      };
      return map[status] || '';
    },
    // 从 description 中提取 taskId
    extractTaskId(description) {
      if (!description) return null;
      // 匹配 taskId:1234 格式
      const match = description.match(/taskId[::]\s*(\d+)/i);
      return match ? match[1] : null;
    },
    // 查看关联转运单
    handleViewTask(row) {
      const taskId = this.extractTaskId(row.description);
      if (taskId) {
        // 使用通用任务详情页路由
        this.$router.push('/task/general-detail/index/' + taskId);
      } else {
        this.$message.warning('未找到关联的转运单ID');
      }
    }
  }
};
</script>