test 7 сар өмнө
parent
commit
7ba0258034

+ 148 - 3
build/cool/temp/eps.d.ts

@@ -456,7 +456,7 @@ declare namespace Eps {
 		 */
 		notifyUrl?: string;
 		/**
-		 * 订单状态 0-待支付 1 已支付 2 支付失败
+		 * 订单状态 0-待支付 1 已支付 2 支付失败 3 退款成功
 		 */
 		status?: boolean;
 		/**
@@ -927,7 +927,7 @@ declare namespace Eps {
 		 */
 		notifyUrl?: string;
 		/**
-		 * 订单状态 0-待支付 1 已支付 2 支付失败
+		 * 订单状态 0-待支付 1 已支付 2 支付失败 3 退款成功
 		 */
 		status?: boolean;
 		/**
@@ -1038,6 +1038,81 @@ declare namespace Eps {
 		[key: string]: any;
 	}
 
+	interface RefundEntity {
+		/**
+		 * ID
+		 */
+		id?: number;
+		/**
+		 * 订单号
+		 */
+		orderNo?: string;
+		/**
+		 * 商户订单号
+		 */
+		outOrderNo?: string;
+		/**
+		 * 交易号
+		 */
+		traceNo?: string;
+		/**
+		 * 退款订单号
+		 */
+		refundNo?: string;
+		/**
+		 * 退款交易号
+		 */
+		refundTraceNo?: string;
+		/**
+		 * 通道码
+		 */
+		code?: string;
+		/**
+		 * 商户号
+		 */
+		mchId?: string;
+		/**
+		 * 退款金额
+		 */
+		amount?: number;
+		/**
+		 * 手续费
+		 */
+		charge?: number;
+		/**
+		 * 货币单位
+		 */
+		currency?: string;
+		/**
+		 * 退款原因
+		 */
+		reson?: string;
+		/**
+		 * 退款时间
+		 */
+		date?: Date;
+		/**
+		 * 订单状态 0-退款中 1 退款成功 2 退款失败
+		 */
+		status?: boolean;
+		/**
+		 * 备注
+		 */
+		remark?: string;
+		/**
+		 * 创建时间
+		 */
+		createTime?: Date;
+		/**
+		 * 更新时间
+		 */
+		updateTime?: Date;
+		/**
+		 * 任意键值
+		 */
+		[key: string]: any;
+	}
+
 	interface WalletEntity {
 		/**
 		 * ID
@@ -1186,7 +1261,7 @@ declare namespace Eps {
 		 */
 		basicFee?: number;
 		/**
-		 * 单笔最费用
+		 * 单笔最���费用
 		 */
 		feeMin?: number;
 		/**
@@ -3217,6 +3292,10 @@ declare namespace Eps {
 	}
 
 	interface DjOrder {
+		/**
+		 * 退款
+		 */
+		toRefund(data?: any): Promise<any>;
 		/**
 		 * 统计
 		 */
@@ -3269,6 +3348,7 @@ declare namespace Eps {
 		 * 权限标识
 		 */
 		permission: {
+			toRefund: string;
 			summary: string;
 			notify: string;
 			update: string;
@@ -3285,6 +3365,7 @@ declare namespace Eps {
 		 * 权限状态
 		 */
 		_permission: {
+			toRefund: boolean;
 			summary: boolean;
 			notify: boolean;
 			update: boolean;
@@ -3417,6 +3498,69 @@ declare namespace Eps {
 		request: Service["request"];
 	}
 
+	interface DjRefund {
+		/**
+		 * 修改
+		 */
+		update(data?: any): Promise<any>;
+		/**
+		 * 查单
+		 */
+		query(data?: any): Promise<any>;
+		/**
+		 * 单个信息
+		 */
+		info(data?: any): Promise<RefundEntity>;
+		/**
+		 * 分页查询
+		 */
+		page(data?: any): Promise<{
+			pagination: { size: number; page: number; total: number };
+			list: RefundEntity[];
+			[key: string]: any;
+		}>;
+		/**
+		 * list
+		 */
+		list(data?: any): Promise<RefundEntity[]>;
+		/**
+		 * delete
+		 */
+		delete(data?: any): Promise<any>;
+		/**
+		 * add
+		 */
+		add(data?: any): Promise<any>;
+		/**
+		 * 权限标识
+		 */
+		permission: {
+			update: string;
+			query: string;
+			info: string;
+			page: string;
+			list: string;
+			delete: string;
+			add: string;
+		};
+		/**
+		 * 权限状态
+		 */
+		_permission: {
+			update: boolean;
+			query: boolean;
+			info: boolean;
+			page: boolean;
+			list: boolean;
+			delete: boolean;
+			add: boolean;
+		};
+		/**
+		 * 请求
+		 */
+		request: Service["request"];
+	}
+
 	interface DjWallet {
 		/**
 		 * 删除
@@ -3985,6 +4129,7 @@ declare namespace Eps {
 			order: DjOrder;
 			payType: DjPayType;
 			rate: DjRate;
+			refund: DjRefund;
 			wallet: DjWallet;
 			withdraw: DjWithdraw;
 			withdrawChannel: DjWithdrawChannel;

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
build/cool/temp/eps.json


+ 88 - 11
src/modules/dj/views/order.vue

@@ -60,17 +60,20 @@
 
 		<!-- 新增、编辑 -->
 		<cl-upsert ref="Upsert" />
+		<cl-form ref="Form" />
 	</cl-crud>
 </template>
 
 <script lang="ts" name="pay-order" setup>
-import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
+import { useCrud, useTable, useUpsert, useForm } from "@cool-vue/crud";
 import { ref } from "vue";
 import { useCool } from "/@/cool";
 import dayjs from "dayjs";
 import { ElMessage } from "element-plus";
 import { checkPerm } from "/$/base";
 
+const Form = useForm();
+
 const { service } = useCool();
 
 const showSummary = ref(false);
@@ -82,6 +85,62 @@ const filterParam = ref({
 	]
 });
 
+function openRefund(data: any) {
+	Form.value?.open({
+		title: "发起退款",
+		width: "800px",
+		form: {
+			orderNo: data.orderNo,
+			reson: data.reson,
+			amount: data.amount
+		},
+		items: [
+			{
+				prop: "orderNo",
+				label: "订单号",
+				component: {
+					name: "el-input",
+					props: {
+						disabled: true
+					}
+				},
+				required: true
+			},
+			{
+				label: "金额",
+				prop: "amount",
+				required: true,
+				component: {
+					name: "el-input-number",
+					props: {
+						style: { width: "200px" },
+						precision: 2,
+						min: 0
+					}
+				}
+			},
+			{
+				prop: "reson",
+				label: "退款原因",
+				component: { name: "el-input", props: { type: "textarea", rows: 4 } },
+			}
+		],
+		on: {
+			async submit(data, { done, close }) {
+				try {
+					await service.dj.order.toRefund(data);
+					ElMessage.success("订单发起退款成功,请到退款订单页面查询结果");
+					close()
+				} catch (e) {
+					ElMessage.error(e.message);
+					close()
+				}
+			}
+		}
+	});
+}
+
+
 const summary = ref({
 	num1: 0,
 	num2: 0,
@@ -155,6 +214,10 @@ const items = ref<ClForm.Item[]>([
 				{
 					label: "下单失败",
 					value: 2
+				},
+				{
+					label: "退款成功",
+					value: 3
 				}
 			]
 		}
@@ -273,6 +336,10 @@ const Upsert = useUpsert({
 					{
 						label: "下单失败",
 						value: 2
+					},
+					{
+						label: "退款成功",
+						value: 3
 					}
 				]
 			},
@@ -346,7 +413,8 @@ const Table = useTable({
 			dict: [
 				{ label: "待支付", value: 0, color: "#909399" },
 				{ label: "支付成功", value: 1, color: "#67C23A" },
-				{ label: "下单失败", value: 2, color: "#F56C6C" }
+				{ label: "下单失败", value: 2, color: "#F56C6C" },
+				{ label: "退款成功", value: 3, color: "#F56C6C" }
 			], width: 90
 		},
 		{
@@ -369,16 +437,16 @@ const Table = useTable({
 			width: checkPerm(service.dj.order.permission.update) ? 210 : 120,
 			buttons({ scope }) {
 				const btns = [];
-				if (checkPerm(service.dj.order.permission.update)) {
-					btns.push({
-						label: "标记成功",
-						type: "danger",
-						onClick({ scope }: any) {
-							Upsert.value?.edit(scope.row);
-						}
-					});
-				}
 				if (+scope.row.status === 1) {
+					if (checkPerm(service.dj.order.permission.toRefund)) {
+						btns.push({
+							label: "退款",
+							type: "danger",
+							async onClick({ scope }: any) {
+								openRefund(scope.row)
+							}
+						});
+					}
 					if (checkPerm(service.dj.order.permission.notify)) {
 						btns.push({
 							label: "补发通知",
@@ -397,6 +465,15 @@ const Table = useTable({
 						});
 					}
 				} else {
+					if (checkPerm(service.dj.order.permission.update)) {
+						btns.push({
+							label: "标记成功",
+							type: "danger",
+							onClick({ scope }: any) {
+								Upsert.value?.edit(scope.row);
+							}
+						});
+					}
 					if (checkPerm(service.dj.order.permission.query)) {
 						btns.push({
 							label: "API查单",

+ 245 - 0
src/modules/dj/views/refund.vue

@@ -0,0 +1,245 @@
+<template>
+	<cl-crud ref="Crud">
+		<cl-row>
+			<cl-filter-group :items="items" :data="filterParam" :reset-btn="true" />
+			<cl-export-btn :columns="Table?.columns" />
+		</cl-row>
+
+		<cl-row>
+			<cl-table ref="Table" :contextMenu="[]">
+			</cl-table>
+		</cl-row>
+
+		<cl-row>
+			<cl-flex1 />
+			<!-- 分页控件 -->
+			<cl-pagination />
+		</cl-row>
+	</cl-crud>
+</template>
+
+<script lang="ts" name="dj-refund" setup>
+import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
+import { useCool } from "/@/cool";
+import { ref } from "vue";
+import dayjs from "dayjs";
+import { checkPerm } from "/$/base";
+import { ElMessage } from "element-plus";
+
+const { service } = useCool();
+
+const filterParam = ref({
+	createTime: [
+		dayjs().format("YYYY-MM-DD ") + "00:00:00",
+		dayjs().format("YYYY-MM-DD ") + "23:59:59"
+	]
+});
+
+const items = ref<ClForm.Item[]>([
+	{
+		label: "订单号",
+		prop: "orderNo",
+		component: {
+			name: "el-input"
+		}
+	},
+	{
+		label: "商户订单号",
+		prop: "outOrderNo",
+		component: {
+			name: "el-input"
+		}
+	},
+	{
+		label: "交易号",
+		prop: "traceNo",
+		component: {
+			name: "el-input"
+		}
+	},
+	{
+		label: "退款订单号",
+		prop: "refundNo",
+		component: {
+			name: "el-input"
+		}
+	},
+	{
+		label: "退款交易号",
+		prop: "RefundTraceNo",
+		component: {
+			name: "el-input"
+		}
+	},
+	{
+		label: "商户号",
+		prop: "mchId",
+		component: {
+			name: "el-input"
+		},
+		hidden: !checkPerm(service.dj.order.permission.mch)
+	},
+	{
+		label: "退款状态",
+		prop: "status",
+		component: {
+			name: "el-select",
+			props: {
+				clearable: true
+			},
+			options: [
+				{
+					label: "退款中",
+					value: 0
+				},
+				{
+					label: "退款成功",
+					value: 1
+				},
+				{
+					label: "退款失败",
+					value: 2
+				}
+			]
+		}
+	},
+	{
+		label: "日期范围",
+		prop: "createTime",
+		component: {
+			name: "el-date-picker",
+			props: {
+				style: { width: "360px" },
+				type: "datetimerange",
+				unlinkPanels: true,
+				valueFormat: "YYYY-MM-DD HH:mm:ss",
+				shortcuts: [
+					{
+						text: '今天',
+						value: () => {
+							return [dayjs().startOf('day'), dayjs().endOf('day')]
+						}
+					},
+					{
+						text: '昨天',
+						value: () => {
+							return [dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day')]
+						}
+					},
+					{
+						text: '近三天',
+						value: () => {
+							return [dayjs().subtract(2, 'day').startOf('day'), dayjs().endOf('day')]
+						}
+					},
+					{
+						text: '近七天',
+						value: () => {
+							return [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')]
+						}
+					},
+					{
+						text: '近一个月',
+						value: () => {
+							return [dayjs().startOf('month'), dayjs().endOf('month')]
+						}
+					},
+				],
+				onChange() { }
+			}
+		}
+	}
+]);
+
+// cl-table
+const Table = useTable({
+	columns: [
+		{ label: "#", type: "index" },
+		{ prop: "orderNo", label: "订单号", showOverflowTooltip: true, width: 120 },
+		{ prop: "refundNo", label: "退款订单号", showOverflowTooltip: true, width: 120 },
+		{
+			prop: "mchId", label: "商户号", hidden: !checkPerm(service.dj.order.permission.mch), showOverflowTooltip: true, width: 120
+		},
+		{
+			prop: "amount",
+			label: "退款金额",
+			width: 90,
+			formatter(row) {
+				return (+row.amount).toFixed(2);
+			}
+		},
+		{
+			prop: "charge",
+			label: "手续费",
+			width: 90,
+			formatter(row) {
+				return (+row.charge).toFixed(2);
+			}
+		},
+		{ prop: "currency", label: "货币单位", width: 90 },
+		{
+			prop: "code", label: "通道编码", hidden: !checkPerm(service.dj.order.permission.code), width: 90
+		},
+		{
+			prop: "status",
+			label: "订单状态",
+			width: 90,
+			dict: [
+				{ label: "退款中", value: 0, color: "#909399" },
+				{ label: "退款成功", value: 1, color: "#67C23A" },
+				{ label: "退款失败", value: 2, color: "#F56C6C" }
+			],
+		},
+		{ prop: "createTime", label: "创建时间", width: 155 },
+		{ prop: "reson", label: "退款原因", showOverflowTooltip: true, width: 120 },
+		{
+			prop: "date",
+			label: "退款时间",
+			width: 155,
+			component: { name: "cl-date-text", props: { format: "YYYY-MM-DD" } }
+		},
+		{ prop: "refundTraceNo", label: "退款交易号", showOverflowTooltip: true, width: 120 },
+		{ prop: "outOrderNo", label: "商户订单号", showOverflowTooltip: true, width: 120 },
+		{ prop: "traceNo", label: "交易号", showOverflowTooltip: true, width: 120 },
+		{ prop: "remark", label: "备注", showOverflowTooltip: true, width: 120 },
+		{
+			type: "op",
+			width: 120,
+			buttons({ scope }) {
+				return [
+					{
+						label: "API查单",
+						type: "primary",
+						async onClick({ scope }: any) {
+							try {
+								const data = await service.dj.refund.query({ id: scope.row.id });
+								if (+data.status === 2) {
+									ElMessage.error("订单退款失败,已刷新状态!");
+									Crud.value?.refresh();
+								} else if (+data.status === 1) {
+									ElMessage.success("订单退款成功,已刷新状态!");
+									Crud.value?.refresh();
+								} else {
+									ElMessage.warning("订单仍在处理中,请稍后查询");
+								}
+							} catch (e: any) {
+								ElMessage.warning(e.message);
+							}
+						}
+					}
+				];
+			}
+		}
+	]
+});
+
+// cl-crud
+const Crud = useCrud(
+	{
+		service: service.dj.refund
+	},
+	(app) => {
+		app.refresh(filterParam.value);
+	}
+);
+</script>

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно