index.vue 18 KB

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