修改了order settlement的检查逻辑
This commit is contained in:
parent
7ec5ff8ddf
commit
286a0ecd10
|
|
@ -21,6 +21,44 @@ const checkers = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单创建的时候要传入合法的settlement
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
action: 'startPaying',
|
||||
checker: (operation, context) => {
|
||||
const { data, filter } = operation;
|
||||
const { id } = filter;
|
||||
assert(id);
|
||||
return pipeline(() => context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
settlement$order: {
|
||||
$entity: 'settlement',
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}, { dontCollect: true }), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, settlement$order } = order;
|
||||
let total = 0;
|
||||
settlement$order?.forEach((ele) => {
|
||||
total += ele.price;
|
||||
assert(ele.iState === 'unsettled');
|
||||
});
|
||||
assert(total === price, '付款前订单应设置好分帐目标');
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
|
|
@ -94,13 +132,14 @@ const checkers = [
|
|||
}, {}), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, paid, refunded, iState, settlement$order: settlements } = order;
|
||||
assert(['paid', 'partiallyRefunded'].includes(iState));
|
||||
assert(['paid'].includes(iState) && refunded === 0 && paid === price);
|
||||
assert(settlements && settlements.length > 0, '该结算订单需添加结算明细');
|
||||
let amount = 0;
|
||||
settlements.forEach((settlement) => {
|
||||
amount += settlement.price;
|
||||
assert(settlement.iState === 'unsettled', '订单结算前,settlement必须处于未分账状态');
|
||||
});
|
||||
assert(amount === paid - refunded);
|
||||
assert(amount === paid);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|||
rowSelection?: any;
|
||||
hideHeader?: boolean | undefined;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
size?: "large" | "middle" | "small" | undefined;
|
||||
scroll?: any;
|
||||
empty?: React.ReactNode;
|
||||
opWidth?: number | undefined;
|
||||
|
|
@ -43,7 +43,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|||
tablePagination?: any;
|
||||
rowSelection?: any;
|
||||
disableSerialNumber?: boolean | undefined;
|
||||
size?: "small" | "middle" | "large" | undefined;
|
||||
size?: "large" | "middle" | "small" | undefined;
|
||||
scroll?: any;
|
||||
empty?: any;
|
||||
opWidth?: number | undefined;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ export default OakComponent({
|
|||
},
|
||||
isList: false,
|
||||
properties: {
|
||||
accountId: '',
|
||||
accountAvailMax: 0,
|
||||
accountId: '', // 是否可以使用帐户中的余额抵扣
|
||||
accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值,调用者自己保证此数值的一致性,不要扣成负数
|
||||
onSetPays: (pays) => undefined,
|
||||
},
|
||||
formData({ data }) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import i18n from "./i18n";
|
||||
import path from './path';
|
||||
import actionAuth from './actionAuth';
|
||||
import shipCompany from "./shipCompany";
|
||||
export default {
|
||||
i18n,
|
||||
path,
|
||||
actionAuth,
|
||||
shipCompany,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ export const entityDesc = {
|
|||
verifyPasswordAt: '最近验证密码时间',
|
||||
accounts: '用户帐户',
|
||||
withdrawAccounts: '用户提现帐户',
|
||||
verifyPasswordAt: '最近验证密码时间',
|
||||
},
|
||||
action: {
|
||||
activate: '激活',
|
||||
|
|
|
|||
|
|
@ -40,11 +40,7 @@ export const desc = {
|
|||
notNull: true,
|
||||
type: "varchar",
|
||||
params: {
|
||||
<<<<<<< HEAD
|
||||
length: 12
|
||||
=======
|
||||
length: 32
|
||||
>>>>>>> dev
|
||||
}
|
||||
},
|
||||
domainId: {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
"hasPassword": "用户是否存在密码",
|
||||
"verifyPasswordAt": "最近验证密码时间",
|
||||
"accounts": "用户帐户",
|
||||
"withdrawAccounts": "用户提现帐户",
|
||||
"verifyPasswordAt": "最近验证密码时间"
|
||||
"withdrawAccounts": "用户提现帐户"
|
||||
},
|
||||
"action": {
|
||||
"activate": "激活",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
|
|||
* @param context
|
||||
* @param refunds
|
||||
*/
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
|
||||
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
|
||||
export default triggers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import WechatPay from './WechatPay';
|
||||
import WechatPayDebug from './WechatPay.debug';
|
||||
declare const _default: typeof WechatPay | typeof WechatPayDebug;
|
||||
declare const _default: typeof WechatPayDebug | typeof WechatPay;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,44 @@ const checkers = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单创建的时候要传入合法的settlement
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
action: 'startPaying',
|
||||
checker: (operation, context) => {
|
||||
const { data, filter } = operation;
|
||||
const { id } = filter;
|
||||
(0, assert_1.default)(id);
|
||||
return (0, executor_1.pipeline)(() => context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
settlement$order: {
|
||||
$entity: 'settlement',
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}, { dontCollect: true }), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, settlement$order } = order;
|
||||
let total = 0;
|
||||
settlement$order?.forEach((ele) => {
|
||||
total += ele.price;
|
||||
(0, assert_1.default)(ele.iState === 'unsettled');
|
||||
});
|
||||
(0, assert_1.default)(total === price, '付款前订单应设置好分帐目标');
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
|
|
@ -97,13 +135,14 @@ const checkers = [
|
|||
}, {}), (orders) => {
|
||||
const [order] = orders;
|
||||
const { price, paid, refunded, iState, settlement$order: settlements } = order;
|
||||
(0, assert_1.default)(['paid', 'partiallyRefunded'].includes(iState));
|
||||
(0, assert_1.default)(['paid'].includes(iState) && refunded === 0 && paid === price);
|
||||
(0, assert_1.default)(settlements && settlements.length > 0, '该结算订单需添加结算明细');
|
||||
let amount = 0;
|
||||
settlements.forEach((settlement) => {
|
||||
amount += settlement.price;
|
||||
(0, assert_1.default)(settlement.iState === 'unsettled', '订单结算前,settlement必须处于未分账状态');
|
||||
});
|
||||
(0, assert_1.default)(amount === paid - refunded);
|
||||
(0, assert_1.default)(amount === paid);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,11 +43,7 @@ exports.desc = {
|
|||
notNull: true,
|
||||
type: "varchar",
|
||||
params: {
|
||||
<<<<<<< HEAD
|
||||
length: 12
|
||||
=======
|
||||
length: 32
|
||||
>>>>>>> dev
|
||||
}
|
||||
},
|
||||
domainId: {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@
|
|||
"hasPassword": "用户是否存在密码",
|
||||
"verifyPasswordAt": "最近验证密码时间",
|
||||
"accounts": "用户帐户",
|
||||
"withdrawAccounts": "用户提现帐户",
|
||||
"verifyPasswordAt": "最近验证密码时间"
|
||||
"withdrawAccounts": "用户提现帐户"
|
||||
},
|
||||
"action": {
|
||||
"activate": "激活",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt';
|
|||
* @param context
|
||||
* @param refunds
|
||||
*/
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>;
|
||||
export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>;
|
||||
declare const triggers: Trigger<EntityDict, 'withdraw', BRC>[];
|
||||
export default triggers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import WechatPay from './WechatPay';
|
||||
import WechatPayDebug from './WechatPay.debug';
|
||||
declare const _default: typeof WechatPay | typeof WechatPayDebug;
|
||||
declare const _default: typeof WechatPayDebug | typeof WechatPay;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,52 @@ const checkers: Checker<EntityDict, 'order', RuntimeCxt>[] = [
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
// 订单创建的时候要传入合法的settlement
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
action: 'startPaying',
|
||||
checker: (operation, context) => {
|
||||
const { data, filter } = operation as EntityDict['order']['Update'];
|
||||
const { id } = filter!;
|
||||
assert(id);
|
||||
|
||||
return pipeline(
|
||||
() => context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
settlement$order: {
|
||||
$entity: 'settlement',
|
||||
data: {
|
||||
id: 1,
|
||||
price: 1,
|
||||
iState: 1,
|
||||
accountId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}, { dontCollect: true }),
|
||||
(orders: EntityDict['order']['Schema'][]) => {
|
||||
const [ order ] = orders;
|
||||
const { price, settlement$order } = order;
|
||||
|
||||
let total = 0 ;
|
||||
settlement$order?.forEach(
|
||||
(ele) => {
|
||||
total += ele.price!;
|
||||
assert(ele.iState === 'unsettled');
|
||||
}
|
||||
);
|
||||
|
||||
assert(total === price, '付款前订单应设置好分帐目标');
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'logicalData',
|
||||
entity: 'order',
|
||||
|
|
@ -110,14 +156,15 @@ const checkers: Checker<EntityDict, 'order', RuntimeCxt>[] = [
|
|||
(orders: EntityDict['order']['Schema'][]) => {
|
||||
const [order] = orders;
|
||||
const { price, paid, refunded, iState, settlement$order: settlements } = order;
|
||||
assert(['paid', 'partiallyRefunded'].includes(iState!));
|
||||
assert(['paid'].includes(iState!) && refunded === 0 && paid === price);
|
||||
assert(settlements && settlements.length > 0, '该结算订单需添加结算明细');
|
||||
|
||||
let amount = 0;
|
||||
settlements.forEach((settlement) => {
|
||||
amount += settlement.price;
|
||||
assert(settlement.iState === 'unsettled', '订单结算前,settlement必须处于未分账状态');
|
||||
})
|
||||
assert(amount === paid - refunded);
|
||||
assert(amount === paid);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@
|
|||
"tsconfig.json",
|
||||
"tsconfig.lib.json",
|
||||
"package-lock.json",
|
||||
"src/components/AbstractComponents.ts",
|
||||
"test",
|
||||
"scripts"
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in New Issue