|
@@ -74,6 +74,7 @@ export class RefundService extends BaseService {
|
|
const { refundTraceNo } = await this.dispatchService.refund(refund);
|
|
const { refundTraceNo } = await this.dispatchService.refund(refund);
|
|
refund.refundTraceNo = refundTraceNo;
|
|
refund.refundTraceNo = refundTraceNo;
|
|
await this.refundEntity.update(refund.id, refund);
|
|
await this.refundEntity.update(refund.id, refund);
|
|
|
|
+ this.startQueryRefund(refund.id);
|
|
return {
|
|
return {
|
|
outOrderNo: refund.outOrderNo,
|
|
outOrderNo: refund.outOrderNo,
|
|
orderNo: refund.orderNo,
|
|
orderNo: refund.orderNo,
|
|
@@ -89,6 +90,23 @@ export class RefundService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ async startQueryRefund(id, times = 10) {
|
|
|
|
+ await new Promise(resolve => {
|
|
|
|
+ setTimeout(() => { resolve(1) }, 8000);
|
|
|
|
+ })
|
|
|
|
+ if (times === 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ const result = await this.queryByApi(id);
|
|
|
|
+ if (+result.status === 0) {
|
|
|
|
+ this.startQueryRefund(id, times - 1);
|
|
|
|
+ }
|
|
|
|
+ } catch (e) {
|
|
|
|
+ this.startQueryRefund(id, times - 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
async updateRefundFail(refund, message) {
|
|
async updateRefundFail(refund, message) {
|
|
refund.remark = message;
|
|
refund.remark = message;
|
|
refund.status = 2;
|
|
refund.status = 2;
|
|
@@ -108,7 +126,7 @@ export class RefundService extends BaseService {
|
|
|
|
|
|
async updateRefundSuccess(data) {
|
|
async updateRefundSuccess(data) {
|
|
const refund = await this.refundEntity.findOneBy({ id: data.id });
|
|
const refund = await this.refundEntity.findOneBy({ id: data.id });
|
|
- if (!refund || +refund.status === 1) {
|
|
|
|
|
|
+ if (!refund || +refund.status === 1 || +refund.status === 2) {
|
|
// 订单早就已退款成功,无需做任何操作
|
|
// 订单早就已退款成功,无需做任何操作
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -134,7 +152,7 @@ export class RefundService extends BaseService {
|
|
if (!refund) {
|
|
if (!refund) {
|
|
throw new CoolCommException('订单不存在');
|
|
throw new CoolCommException('订单不存在');
|
|
}
|
|
}
|
|
- if (+refund.status === 0 || +refund.status === 2) {
|
|
|
|
|
|
+ if (+refund.status === 0) {
|
|
const { status, message, refundTraceNo, date } =
|
|
const { status, message, refundTraceNo, date } =
|
|
await this.dispatchService.queryRefund(refund);
|
|
await this.dispatchService.queryRefund(refund);
|
|
if (+status === 1) {
|
|
if (+status === 1) {
|
|
@@ -149,7 +167,7 @@ export class RefundService extends BaseService {
|
|
}
|
|
}
|
|
return { status, message };
|
|
return { status, message };
|
|
} else {
|
|
} else {
|
|
- return refund.status;
|
|
|
|
|
|
+ return { status: refund.status, message: "订单已有结果,请勿重复查询" }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|