index.vue 19 KB

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