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