index.vue 20 KB

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