支持0元支付和退款

This commit is contained in:
wkj 2024-11-08 16:02:59 +08:00
parent 241fb97074
commit b03830ce1a
3 changed files with 12 additions and 11 deletions

View File

@ -35,13 +35,14 @@
"wechat-pay-nodejs": "^0.2.3"
},
"peerDependencies": {
"@ant-design/icons": ">=5.2.6",
"antd": ">=5.13.0",
"@ant-design/icons": ">=5.3.4",
"antd": ">=5.11.0",
"antd-mobile": ">=5.33.0",
"antd-mobile-icons": ">=0.3.0",
"react": "=18.2.0",
"react-dom": "=18.2.0",
"react-native": ">=0.72.0",
"react": ">=18.2.0",
"react-dom": ">=18.2.0",
"react-native": ">=0.72.7",
"react-router": ">=6.3.0",
"react-router-dom": ">=6.3.0"
},
"devDependencies": {

View File

@ -31,8 +31,8 @@ const checkers: Checker<EntityDict, 'pay', RuntimeCxt>[] = [
action: 'create',
checker(data) {
const { entity, entityId, price, orderId, depositId } = data as EntityDict['pay']['CreateSingle']['data'];
if (price! <= 0) {
throw new OakInputIllegalException('pay', ['price'], '支付金额必须大于0');
if (price! < 0) {
throw new OakInputIllegalException('pay', ['price'], '支付金额必须不小于零');
}
if (!orderId) {
// 充值类订单

View File

@ -84,7 +84,7 @@ async function changeOrderStateByPay(
}
}
else if (hasRefunding) {
assert(!hasPaying && payPaid === orderPrice && payRefunded < orderPrice);
assert(!hasPaying && payPaid === orderPrice && payRefunded <= orderPrice);
if (orderIState !== 'refunding' || orderRefunded !== payRefunded) {
await context.operate('order', {
id: await generateNewIdAsync(),
@ -98,7 +98,7 @@ async function changeOrderStateByPay(
}, option);
}
}
else if (payRefunded) {
else if (payRefunded >= 0) {
// 已经在退款流程当中
assert(payPaid === orderPrice && payPaid === orderPaid);
const iState = payPaid === orderPrice ? 'refunded' : 'partiallyRefunded';
@ -116,9 +116,9 @@ async function changeOrderStateByPay(
}, option);
}
}
else if (payPaid) {
else if (payPaid >= 0) {
// 在支付流程当中
//存在已完成的pay更新order的paid和iState
// 存在已完成的pay更新order的paid和iState
assert(orderRefunded === 0);
const iState = payPaid === orderPrice ? 'paid' : 'partiallyPaid';
if (orderIState !== iState || orderPaid !== payPaid) {