ship增加了个别trigger
This commit is contained in:
parent
dad12657a3
commit
13bd23414d
|
|
@ -24,10 +24,10 @@ export default OakComponent({
|
|||
},
|
||||
isList: false,
|
||||
properties: {
|
||||
accountId: '',
|
||||
accountAvailMax: 0,
|
||||
accountId: '', // 是否可以使用帐户中的余额抵扣
|
||||
accountAvailMax: 0, // 本次交易可以使用的帐户中的Avail max值,调用者自己保证此数值的一致性,不要扣成负数
|
||||
onSetPays: (pays) => undefined,
|
||||
accountTips: '',
|
||||
accountTips: '', // 使用余额支付的提示说明
|
||||
autoStartPay: false,
|
||||
},
|
||||
formData({ data }) {
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ export const entityDesc = {
|
|||
},
|
||||
v: {
|
||||
iState: {
|
||||
unshipped: '未发货',
|
||||
shipping: '发货中',
|
||||
unshipped: '待发货',
|
||||
shipping: '运输中',
|
||||
received: '已收货',
|
||||
rejected: '已拒绝',
|
||||
givenUp: '已放弃',
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
},
|
||||
"v": {
|
||||
"iState": {
|
||||
"unshipped": "未发货",
|
||||
"shipping": "发货中",
|
||||
"unshipped": "待发货",
|
||||
"shipping": "运输中",
|
||||
"received": "已收货",
|
||||
"rejected": "已拒绝",
|
||||
"givenUp": "已放弃",
|
||||
|
|
|
|||
|
|
@ -77,6 +77,40 @@ const triggers = [
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '当物流创建时,将对应的order状态变为已发货',
|
||||
entity: 'ship',
|
||||
action: 'create',
|
||||
when: 'after',
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data } = operation;
|
||||
const orders = await context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
gState: 1,
|
||||
},
|
||||
filter: {
|
||||
shipOrder$order: {
|
||||
shipId: data.id,
|
||||
}
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const unshipped = orders.filter(ele => ele.gState === 'unshipped');
|
||||
if (unshipped.length > 0) {
|
||||
await context.operate('order', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'ship',
|
||||
data: {},
|
||||
filter: {
|
||||
id: {
|
||||
$in: unshipped.map(ele => ele.id),
|
||||
},
|
||||
},
|
||||
}, option);
|
||||
}
|
||||
return unshipped.length;
|
||||
}
|
||||
}
|
||||
];
|
||||
export default triggers;
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ exports.entityDesc = {
|
|||
},
|
||||
v: {
|
||||
iState: {
|
||||
unshipped: '未发货',
|
||||
shipping: '发货中',
|
||||
unshipped: '待发货',
|
||||
shipping: '运输中',
|
||||
received: '已收货',
|
||||
rejected: '已拒绝',
|
||||
givenUp: '已放弃',
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
},
|
||||
"v": {
|
||||
"iState": {
|
||||
"unshipped": "未发货",
|
||||
"shipping": "发货中",
|
||||
"unshipped": "待发货",
|
||||
"shipping": "运输中",
|
||||
"received": "已收货",
|
||||
"rejected": "已拒绝",
|
||||
"givenUp": "已放弃",
|
||||
|
|
|
|||
|
|
@ -79,6 +79,40 @@ const triggers = [
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '当物流创建时,将对应的order状态变为已发货',
|
||||
entity: 'ship',
|
||||
action: 'create',
|
||||
when: 'after',
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data } = operation;
|
||||
const orders = await context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
gState: 1,
|
||||
},
|
||||
filter: {
|
||||
shipOrder$order: {
|
||||
shipId: data.id,
|
||||
}
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
const unshipped = orders.filter(ele => ele.gState === 'unshipped');
|
||||
if (unshipped.length > 0) {
|
||||
await context.operate('order', {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action: 'ship',
|
||||
data: {},
|
||||
filter: {
|
||||
id: {
|
||||
$in: unshipped.map(ele => ele.id),
|
||||
},
|
||||
},
|
||||
}, option);
|
||||
}
|
||||
return unshipped.length;
|
||||
}
|
||||
}
|
||||
];
|
||||
exports.default = triggers;
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
|
|||
},
|
||||
v: {
|
||||
iState: {
|
||||
unshipped: '未发货',
|
||||
shipping: '发货中',
|
||||
unshipped: '待发货',
|
||||
shipping: '运输中',
|
||||
received: '已收货',
|
||||
rejected: '已拒绝',
|
||||
givenUp: '已放弃',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { CreateTriggerInTxn, Trigger, UpdateTriggerInTxn } from 'oak-domain/lib/types/Trigger';
|
||||
import { CreateTrigger, CreateTriggerCrossTxn, CreateTriggerInTxn, Trigger, UpdateTriggerInTxn } from 'oak-domain/lib/types/Trigger';
|
||||
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { BRC } from '../types/RuntimeCxt';
|
||||
|
|
@ -30,7 +30,7 @@ const triggers: Trigger<EntityDict, 'ship', BRC>[] = [
|
|||
}
|
||||
return;
|
||||
},
|
||||
},
|
||||
} as CreateTriggerCrossTxn<EntityDict, 'ship', BRC>,
|
||||
{
|
||||
entity: 'ship',
|
||||
name: '当虚拟的ship变为shipping状态时,调用小程序发货信息录入接口',
|
||||
|
|
@ -84,7 +84,42 @@ const triggers: Trigger<EntityDict, 'ship', BRC>[] = [
|
|||
}
|
||||
return 1;
|
||||
}
|
||||
} as UpdateTriggerInTxn<EntityDict, 'ship', BRC>
|
||||
} as UpdateTriggerInTxn<EntityDict, 'ship', BRC>,
|
||||
{
|
||||
name: '当物流创建时,将对应的order状态变为已发货',
|
||||
entity: 'ship',
|
||||
action: 'create',
|
||||
when: 'after',
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data } = operation as EntityDict['ship']['CreateSingle'];
|
||||
const orders = await context.select('order', {
|
||||
data: {
|
||||
id: 1,
|
||||
gState: 1,
|
||||
},
|
||||
filter: {
|
||||
shipOrder$order: {
|
||||
shipId: data.id,
|
||||
}
|
||||
}
|
||||
}, { dontCollect: true });
|
||||
|
||||
const unshipped = orders.filter(ele => ele.gState === 'unshipped');
|
||||
if (unshipped.length > 0) {
|
||||
await context.operate('order', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'ship',
|
||||
data: {},
|
||||
filter: {
|
||||
id: {
|
||||
$in: unshipped.map(ele => ele.id!),
|
||||
},
|
||||
},
|
||||
}, option);
|
||||
}
|
||||
return unshipped.length;
|
||||
}
|
||||
} as CreateTrigger<EntityDict, 'ship', BRC>
|
||||
];
|
||||
|
||||
export default triggers;
|
||||
Loading…
Reference in New Issue