index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
  5. <el-form-item label="所属商户" prop="merchantId">
  6. <el-select
  7. v-model="queryParams.merchantId"
  8. clearable
  9. @clear="()=>{queryParams.merchantId = null}"
  10. filterable
  11. remote
  12. reserve-keyword
  13. placeholder="请选择所属商户"
  14. @change="handleGetAppListByMerchantId"
  15. :remote-method="handleGetMerchantListByName"
  16. :loading="merchantLoading">
  17. <el-option
  18. v-for="item in merchantList"
  19. :key="item.id"
  20. :label="item.name"
  21. :value="item.id">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item label="应用编号" prop="appId">
  26. <el-select
  27. clearable
  28. v-model="queryParams.appId"
  29. filterable
  30. placeholder="请选择应用信息">
  31. <el-option
  32. v-for="item in appList"
  33. :key="item.id"
  34. :label="item.name"
  35. :value="item.id">
  36. </el-option>
  37. </el-select>
  38. </el-form-item>
  39. <el-form-item label="渠道编码" prop="channelCode">
  40. <el-select v-model="queryParams.channelCode" placeholder="请输入渠道编码" clearable
  41. size="small" @clear="()=>{queryParams.channelCode = null}">
  42. <el-option v-for="dict in payChannelCodeDictDatum" :key="dict.value" :label="dict.label" :value="dict.value"/>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="商户订单编号" prop="merchantOrderId">
  46. <el-input v-model="queryParams.merchantOrderId" placeholder="请输入商户订单编号" clearable size="small"
  47. @keyup.enter.native="handleQuery"/>
  48. </el-form-item>
  49. <el-form-item label="渠道订单号" prop="channelOrderNo">
  50. <el-input v-model="queryParams.channelOrderNo" placeholder="请输入渠道订单号" clearable size="small"
  51. @keyup.enter.native="handleQuery"/>
  52. </el-form-item>
  53. <el-form-item label="支付状态" prop="status">
  54. <el-select v-model="queryParams.status" placeholder="请选择支付状态" clearable size="small">
  55. <el-option v-for="dict in payOrderDictDatum" :key="parseInt(dict.value)"
  56. :label="dict.label" :value="parseInt(dict.value)"/>
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="退款状态" prop="refundStatus">
  60. <el-select v-model="queryParams.refundStatus" placeholder="请选择退款状态" clearable size="small">
  61. <el-option v-for="dict in payOrderRefundDictDatum" :key="parseInt(dict.value)"
  62. :label="dict.label" :value="parseInt(dict.value)"/>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="回调商户状态" prop="notifyStatus">
  66. <el-select v-model="queryParams.notifyStatus" placeholder="请选择订单回调商户状态" clearable size="small">
  67. <el-option v-for="dict in payOrderNotifyDictDatum" :key="parseInt(dict.value)"
  68. :label="dict.label" :value="parseInt(dict.value)"/>
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="创建时间">
  72. <el-date-picker
  73. v-model="dateRangeCreateTime" size="small" style="width: 350px"
  74. value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange" range-separator="-"
  75. :default-time="['00:00:00','23:59:59']" start-placeholder="开始日期" end-placeholder="结束日期">
  76. </el-date-picker>
  77. </el-form-item>
  78. <el-form-item>
  79. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  80. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  81. </el-form-item>
  82. </el-form>
  83. <!-- 操作工具栏 -->
  84. <el-row :gutter="10" class="mb8">
  85. <el-col :span="1.5">
  86. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  87. v-hasPermi="['pay:order:export']">导出
  88. </el-button>
  89. </el-col>
  90. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  91. </el-row>
  92. <!-- 列表 -->
  93. <el-table v-loading="loading" :data="list">
  94. <el-table-column label="订单编号" align="center" prop="id" width="80"/>
  95. <!-- <el-table-column label="商户名称" align="center" prop="merchantName" width="120"/>-->
  96. <!-- <el-table-column label="应用名称" align="center" prop="appName" width="120"/>-->
  97. <el-table-column label="支付渠道" align="center" width="130">
  98. <template v-slot="scope">
  99. <el-popover trigger="hover" placement="top">
  100. <p>商户名称: {{ scope.row.merchantName }}</p>
  101. <p>应用名称: {{ scope.row.appName }}</p>
  102. <p>渠道名称: {{ scope.row.channelCodeName }}</p>
  103. <div slot="reference" class="name-wrapper">
  104. {{ scope.row.channelCodeName }}
  105. </div>
  106. </el-popover>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="支付订单" align="left" width="250">
  110. <template v-slot="scope">
  111. <p class="order-font"><el-tag size="mini">商户</el-tag> {{scope.row.merchantOrderId}}</p>
  112. <p class="order-font"><el-tag size="mini" type="warning">支付</el-tag> {{scope.row.channelOrderNo}}</p>
  113. </template>
  114. </el-table-column>
  115. <!-- <el-table-column label="商户订单编号" align="center" prop="merchantOrderId" width="140"/>-->
  116. <!-- <el-table-column label="渠道订单号" align="center" prop="channelOrderNo" width="140"/>-->
  117. <el-table-column label="商品标题" align="center" prop="subject" width="180" :show-overflow-tooltip="true"/>
  118. <el-table-column label="支付金额" align="center" prop="amount" width="100">
  119. <template slot-scope="scope">
  120. ¥{{ parseFloat(scope.row.amount / 100).toFixed(2) }}
  121. </template>
  122. </el-table-column>
  123. <el-table-column label="手续金额" align="center" prop="channelFeeAmount" width="100">
  124. <template slot-scope="scope">
  125. ¥{{ parseFloat(scope.row.channelFeeAmount / 100).toFixed(2) }}
  126. </template>
  127. </el-table-column>
  128. <el-table-column label="退款金额" align="center" prop="refundAmount" width="100">
  129. <template slot-scope="scope">
  130. ¥{{ parseFloat(scope.row.refundAmount / 100).toFixed(2) }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column label="支付状态" align="center" prop="status">
  134. <template slot-scope="scope">
  135. <span>{{ getDictDataLabel(DICT_TYPE.PAY_ORDER_STATUS, scope.row.status) }}</span>
  136. </template>
  137. </el-table-column>
  138. <!-- <el-table-column label="退款状态" align="center" prop="refundStatus">-->
  139. <!-- <template slot-scope="scope">-->
  140. <!-- <span>{{ getDictDataLabel(DICT_TYPE.PAY_ORDER_REFUND_STATUS, scope.row.refundStatus) }}</span>-->
  141. <!-- </template>-->
  142. <!-- </el-table-column>-->
  143. <el-table-column label="回调状态" align="center" prop="notifyStatus" width="100">
  144. <template slot-scope="scope">
  145. <span>{{ getDictDataLabel(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS, scope.row.notifyStatus) }}</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="创建时间" align="center" prop="createTime" width="100">
  149. <template slot-scope="scope">
  150. <span>{{ parseTime(scope.row.createTime) }}</span>
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="支付时间" align="center" prop="successTime" width="100">
  154. <template slot-scope="scope">
  155. <span>{{ parseTime(scope.row.successTime) }}</span>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
  159. <template slot-scope="scope">
  160. <el-button size="mini" type="text" icon="el-icon-search" @click="handleQueryDetails(scope.row)"
  161. v-hasPermi="['pay:order:query']">查看详情
  162. </el-button>
  163. </template>
  164. </el-table-column>
  165. </el-table>
  166. <!-- 分页组件 -->
  167. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  168. @pagination="getList"/>
  169. <!-- 对话框(添加 / 修改) -->
  170. <el-dialog title="订单详情" :visible.sync="open" width="50%">
  171. <el-descriptions :column="2" label-class-name="desc-label">
  172. <el-descriptions-item label="商户名称">{{ orderDetail.merchantName }}</el-descriptions-item>
  173. <el-descriptions-item label="应用名称">{{ orderDetail.appName }}</el-descriptions-item>
  174. <el-descriptions-item label="商品名称">{{ orderDetail.subject }}</el-descriptions-item>
  175. </el-descriptions>
  176. <el-divider></el-divider>
  177. <el-descriptions :column="2" label-class-name="desc-label">
  178. <el-descriptions-item label="商户订单号">
  179. <el-tag size="small">{{ orderDetail.merchantOrderId }}</el-tag>
  180. </el-descriptions-item>
  181. <el-descriptions-item label="渠道订单号">
  182. <el-tag class="tag-purple" size="small">{{ orderDetail.channelOrderNo }}</el-tag>
  183. </el-descriptions-item>
  184. <el-descriptions-item label="支付订单号">
  185. <el-tag v-if="orderDetail.payOrderExtension.no !== ''" class="tag-pink" size="small">
  186. {{ orderDetail.payOrderExtension.no }}
  187. </el-tag>
  188. </el-descriptions-item>
  189. <el-descriptions-item label="金额">
  190. <el-tag type="success" size="small">{{ parseFloat(orderDetail.amount / 100, 2) }}</el-tag>
  191. </el-descriptions-item>
  192. <el-descriptions-item label="手续费">
  193. <el-tag type="warning" size="small">{{ parseFloat(orderDetail.channelFeeAmount / 100, 2) }}</el-tag>
  194. </el-descriptions-item>
  195. <el-descriptions-item label="手续费比例">
  196. {{ parseFloat(orderDetail.channelFeeRate / 100, 2) }}%
  197. </el-descriptions-item>
  198. <el-descriptions-item label="支付状态">
  199. <el-tag :type="statusType" size="small">
  200. {{ getDictDataLabel(DICT_TYPE.PAY_ORDER_STATUS, orderDetail.status) }}
  201. </el-tag>
  202. </el-descriptions-item>
  203. <el-descriptions-item label="回调状态">
  204. <el-tag :type="notifyStatusType" size="small">
  205. {{ getDictDataLabel(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS, orderDetail.notifyStatus) }}
  206. </el-tag>
  207. </el-descriptions-item>
  208. <el-descriptions-item label="回调地址">{{ orderDetail.notifyUrl }}</el-descriptions-item>
  209. <el-descriptions-item label="创建时间">{{ parseTime(orderDetail.createTime) }}</el-descriptions-item>
  210. <el-descriptions-item label="支付时间">{{ parseTime(orderDetail.successTime) }}</el-descriptions-item>
  211. <el-descriptions-item label="失效时间">{{ parseTime(orderDetail.expireTime) }}</el-descriptions-item>
  212. <el-descriptions-item label="通知时间">{{ parseTime(orderDetail.notifyTime) }}</el-descriptions-item>
  213. </el-descriptions>
  214. <el-divider></el-divider>
  215. <el-descriptions :column="2" label-class-name="desc-label">
  216. <el-descriptions-item label="支付渠道">{{ orderDetail.channelCodeName }}</el-descriptions-item>
  217. <el-descriptions-item label="支付IP">{{ orderDetail.userIp }}</el-descriptions-item>
  218. <el-descriptions-item label="退款状态">
  219. <el-tag :type="refundStatusType" size="small">
  220. {{ getDictDataLabel(DICT_TYPE.PAY_ORDER_REFUND_STATUS, orderDetail.refundStatus) }}
  221. </el-tag>
  222. </el-descriptions-item>
  223. <el-descriptions-item label="退款次数">{{ orderDetail.refundTimes }}</el-descriptions-item>
  224. <el-descriptions-item label="退款金额">
  225. <el-tag type="warning">
  226. {{ parseFloat(orderDetail.refundAmount / 100, 2) }}
  227. </el-tag>
  228. </el-descriptions-item>
  229. </el-descriptions>
  230. <el-divider></el-divider>
  231. <el-descriptions :column="1" label-class-name="desc-label" direction="vertical" border>
  232. <el-descriptions-item label="商品描述">
  233. {{ orderDetail.body }}
  234. </el-descriptions-item>
  235. <el-descriptions-item label="支付通道异步回调内容">
  236. {{ orderDetail.payOrderExtension.channelNotifyData }}
  237. </el-descriptions-item>
  238. </el-descriptions>
  239. </el-dialog>
  240. </div>
  241. </template>
  242. <script>
  243. import {getOrder, getOrderPage, exportOrderExcel} from "@/api/pay/order";
  244. import {getMerchantListByName} from "@/api/pay/merchant";
  245. import {getAppListByMerchantId} from "@/api/pay/app";
  246. import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  247. import {payOrderNotifyStatusEnum, payOrderRefundStatusEnum, payOrderStatusEnum} from "@/utils/constants";
  248. import { getNowDateTime} from "@/utils/ruoyi";
  249. const defaultOrderDetail = {
  250. merchantName: '',
  251. appName: '',
  252. channelCodeName: '',
  253. subject: '',
  254. merchantOrderId: null,
  255. channelOrderNo: '',
  256. body: '',
  257. amount: null,
  258. channelFeeRate: null,
  259. channelFeeAmount: null,
  260. userIp: '',
  261. status: null,
  262. notifyUrl: '',
  263. notifyStatus: null,
  264. refundStatus: null,
  265. refundTimes: '',
  266. refundAmount: null,
  267. createTime: '',
  268. successTime: '',
  269. notifyTime: '',
  270. expireTime: '',
  271. payOrderExtension: {
  272. channelNotifyData: '',
  273. no: ''
  274. }
  275. };
  276. export default {
  277. name: "Order",
  278. components: {},
  279. data() {
  280. return {
  281. // 遮罩层
  282. loading: true,
  283. // 显示搜索条件
  284. showSearch: true,
  285. // 总条数
  286. total: 0,
  287. // 支付订单列表
  288. list: [],
  289. // 弹出层标题
  290. title: "",
  291. // 是否显示弹出层
  292. open: false,
  293. dateRangeExpireTime: [],
  294. dateRangeSuccessTime: [],
  295. dateRangeNotifyTime: [],
  296. dateRangeCreateTime: [],
  297. // 查询参数
  298. queryParams: {
  299. pageNo: 1,
  300. pageSize: 10,
  301. merchantId: null,
  302. appId: null,
  303. channelId: null,
  304. channelCode: null,
  305. merchantOrderId: null,
  306. subject: null,
  307. body: null,
  308. notifyUrl: null,
  309. notifyStatus: null,
  310. amount: null,
  311. channelFeeRate: null,
  312. channelFeeAmount: null,
  313. status: null,
  314. userIp: null,
  315. successExtensionId: null,
  316. refundStatus: null,
  317. refundTimes: null,
  318. refundAmount: null,
  319. channelUserId: null,
  320. channelOrderNo: null,
  321. },
  322. // 商户加载遮罩层
  323. merchantLoading: false,
  324. // 商户列表集合
  325. merchantList: null,
  326. // 支付应用列表集合
  327. appList: null,
  328. // 支付渠道编码字典数据集合
  329. payChannelCodeDictDatum: getDictDatas(DICT_TYPE.PAY_CHANNEL_CODE_TYPE),
  330. // 订单回调商户状态字典数据集合
  331. payOrderNotifyDictDatum: getDictDatas(DICT_TYPE.PAY_ORDER_NOTIFY_STATUS),
  332. // 订单状态字典数据集合
  333. payOrderDictDatum: getDictDatas(DICT_TYPE.PAY_ORDER_STATUS),
  334. // 订单退款状态字典数据集合
  335. payOrderRefundDictDatum: getDictDatas(DICT_TYPE.PAY_ORDER_REFUND_STATUS),
  336. orderDetail: JSON.parse(JSON.stringify(defaultOrderDetail)),
  337. // el-tag订单状态type值
  338. statusType: '',
  339. // el-tag订单回调通知状态type值
  340. notifyStatusType: '',
  341. // el-tag订单退款状态type值
  342. refundStatusType: '',
  343. };
  344. },
  345. created() {
  346. // 初始化默认时间
  347. this.initTime();
  348. this.getList();
  349. this.handleGetMerchantListByName(null);
  350. },
  351. methods: {
  352. initTime(){
  353. this.dateRangeCreateTime = [getNowDateTime("00:00:00"), getNowDateTime("23:59:59")];
  354. },
  355. /** 查询列表 */
  356. getList() {
  357. // 判断选择的日期是否超过了一个月
  358. let oneMonthTime = 31 * 24 * 3600 * 1000;
  359. if (this.dateRangeCreateTime == null){
  360. this.initTime();
  361. } else {
  362. let minDateTime = new Date(this.dateRangeCreateTime[0]).getTime();
  363. let maxDateTime = new Date(this.dateRangeCreateTime[1]).getTime()
  364. if (maxDateTime - minDateTime > oneMonthTime) {
  365. this.$message.error('时间范围最大为 31 天!');
  366. return false;
  367. }
  368. }
  369. this.loading = true;
  370. // 处理查询参数
  371. let params = {...this.queryParams};
  372. this.addBeginAndEndTime(params, this.dateRangeExpireTime, 'expireTime');
  373. this.addBeginAndEndTime(params, this.dateRangeSuccessTime, 'successTime');
  374. this.addBeginAndEndTime(params, this.dateRangeNotifyTime, 'notifyTime');
  375. this.addDateRange(params, this.dateRangeCreateTime, 'CreateTime');
  376. // 执行查询
  377. getOrderPage(params).then(response => {
  378. this.list = response.data.list;
  379. this.total = response.data.total;
  380. this.loading = false;
  381. });
  382. },
  383. /** 取消按钮 */
  384. cancel() {
  385. this.open = false;
  386. },
  387. /** 搜索按钮操作 */
  388. handleQuery() {
  389. this.queryParams.pageNo = 1;
  390. this.getList();
  391. },
  392. /** 重置按钮操作 */
  393. resetQuery() {
  394. this.dateRangeSuccessTime = [];
  395. this.dateRangeNotifyTime = [];
  396. this.dateRangeExpireTime = [];
  397. this.resetForm("queryForm");
  398. this.initTime();
  399. this.handleQuery();
  400. },
  401. /**
  402. * 查看订单详情
  403. */
  404. handleQueryDetails(row) {
  405. this.orderDetail = JSON.parse(JSON.stringify(defaultOrderDetail));
  406. getOrder(row.id).then(response => {
  407. this.orderDetail = response.data;
  408. if (response.data.payOrderExtension === null) {
  409. this.orderDetail.payOrderExtension = Object.assign(defaultOrderDetail.payOrderExtension, {});
  410. }
  411. switch (this.orderDetail.status) {
  412. case payOrderStatusEnum.WAITING.status:
  413. this.statusType = "info";
  414. break;
  415. case payOrderStatusEnum.SUCCESS.status:
  416. this.statusType = "success";
  417. break;
  418. case payOrderStatusEnum.CLOSED.status:
  419. this.statusType = "danger";
  420. break;
  421. }
  422. switch (this.orderDetail.notifyStatus) {
  423. case payOrderNotifyStatusEnum.NO.status:
  424. this.notifyStatusType = "info";
  425. break;
  426. case payOrderNotifyStatusEnum.SUCCESS.status:
  427. this.notifyStatusType = "success";
  428. break;
  429. case payOrderNotifyStatusEnum.FAILURE.status:
  430. this.notifyStatusType = "danger";
  431. break;
  432. }
  433. switch (this.orderDetail.refundStatus) {
  434. case payOrderRefundStatusEnum.NO.status:
  435. this.refundStatusType = "success";
  436. break;
  437. case payOrderRefundStatusEnum.SOME.status:
  438. this.refundStatusType = "warning";
  439. break;
  440. case payOrderRefundStatusEnum.ALL.status:
  441. this.refundStatusType = "danger";
  442. break;
  443. }
  444. this.open = true;
  445. });
  446. },
  447. /** 导出按钮操作 */
  448. handleExport() {
  449. // 处理查询参数
  450. let params = {...this.queryParams};
  451. params.pageNo = undefined;
  452. params.pageSize = undefined;
  453. this.addBeginAndEndTime(params, this.dateRangeExpireTime, 'expireTime');
  454. this.addBeginAndEndTime(params, this.dateRangeSuccessTime, 'successTime');
  455. this.addBeginAndEndTime(params, this.dateRangeNotifyTime, 'notifyTime');
  456. this.addDateRange(params, this.dateRangeCreateTime, 'CreateTime');
  457. // 执行导出
  458. this.$confirm('是否确认导出所有支付订单数据项?', "警告", {
  459. confirmButtonText: "确定",
  460. cancelButtonText: "取消",
  461. type: "warning"
  462. }).then(function () {
  463. return exportOrderExcel(params);
  464. }).then(response => {
  465. this.downloadExcel(response, '支付订单.xls');
  466. })
  467. },
  468. /**
  469. * 根据商户名称模糊匹配商户信息
  470. * @param name 商户名称
  471. */
  472. handleGetMerchantListByName(name) {
  473. getMerchantListByName(name).then(response => {
  474. this.merchantList = response.data;
  475. this.merchantLoading = false;
  476. });
  477. },
  478. /**
  479. * 根据商户 ID 查询支付应用信息
  480. */
  481. handleGetAppListByMerchantId() {
  482. this.queryParams.appId = null;
  483. getAppListByMerchantId(this.queryParams.merchantId).then(response => {
  484. this.appList = response.data;
  485. });
  486. }
  487. }
  488. };
  489. </script>
  490. <style>
  491. .desc-label {
  492. font-weight: bold;
  493. }
  494. .tag-purple {
  495. color: #722ed1;
  496. background: #f9f0ff;
  497. border-color: #d3adf7;
  498. }
  499. .tag-cyan {
  500. color: #13c2c2;
  501. background: #e6fffb;
  502. border-color: #87e8de;
  503. }
  504. .tag-pink {
  505. color: #eb2f96;
  506. background: #fff0f6;
  507. border-color: #ffadd2;
  508. }
  509. .order-font{
  510. font-size: 12px;
  511. padding: 2px 0;
  512. }
  513. </style>