test(payment): 补充退款迟到结果不回退支付与订单状态的用例
This commit is contained in:
+36
-1
@@ -11,7 +11,8 @@ import {
|
||||
verifyMessageSignature,
|
||||
decryptAesGcm,
|
||||
} from "../utils/wechatpay.js";
|
||||
import { createOrderQueryCache } from "../handler/payment.js";
|
||||
import { createOrderQueryCache, HandlerPayment } from "../handler/payment.js";
|
||||
import { DBModel } from "../models/index.js";
|
||||
|
||||
test("元转分按小数点拆位,不经过浮点", () => {
|
||||
assert.equal(yuanToFen("500.00"), 50000);
|
||||
@@ -178,3 +179,37 @@ test("force 可绕过轮询缓存", async () => {
|
||||
await query("T4", { force: true });
|
||||
assert.equal(calls, 2);
|
||||
});
|
||||
|
||||
test("退款成功后的迟到处理中结果不会回退支付与订单状态", async () => {
|
||||
const previous = {
|
||||
RefundRecord: DBModel.RefundRecord,
|
||||
PaymentRecord: DBModel.PaymentRecord,
|
||||
EscortRecord: DBModel.EscortRecord,
|
||||
};
|
||||
let refundFilter = null;
|
||||
let downstreamWrites = 0;
|
||||
DBModel.RefundRecord = {
|
||||
updateOne: async (filter) => {
|
||||
refundFilter = filter;
|
||||
return { matchedCount: 0 };
|
||||
},
|
||||
};
|
||||
DBModel.PaymentRecord = {
|
||||
updateOne: async () => { downstreamWrites += 1; },
|
||||
};
|
||||
DBModel.EscortRecord = {
|
||||
updateOne: async () => { downstreamWrites += 1; },
|
||||
};
|
||||
|
||||
try {
|
||||
const status = await HandlerPayment.applyRefundResult(
|
||||
{ _id: "r1", paymentId: "p1", recordId: "o1", status: "success" },
|
||||
{ status: "PROCESSING" }
|
||||
);
|
||||
assert.equal(status, "success");
|
||||
assert.deepEqual(refundFilter.status, { $ne: "success" });
|
||||
assert.equal(downstreamWrites, 0);
|
||||
} finally {
|
||||
Object.assign(DBModel, previous);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user