oak-pay-business 3.1.2 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/aspects/AspectDict.d.ts +3 -0
- package/es/aspects/index.js +2 -1
- package/es/aspects/ship.d.ts +6 -0
- package/es/aspects/ship.js +40 -0
- package/es/components/AbstractComponents.d.ts +3 -8
- package/es/components/account/detail/index.js +28 -15
- package/es/components/pay/detail/index.js +45 -21
- package/es/entities/SettlePlan.d.ts +2 -0
- package/es/entities/SettlePlan.js +2 -0
- package/es/oak-app-domain/SettlePlan/Storage.js +6 -0
- package/es/oak-app-domain/SettlePlan/_baseSchema.d.ts +8 -0
- package/es/oak-app-domain/SettlePlan/locales/zh_CN.json +3 -1
- package/es/timers/ship.js +19 -18
- package/es/triggers/settlePlan.js +142 -100
- package/es/triggers/ship.js +24 -51
- package/es/triggers/withdraw.d.ts +1 -1
- package/es/watchers/settlePlan.js +22 -3
- package/es/watchers/ship.js +30 -30
- package/lib/aspects/AspectDict.d.ts +3 -0
- package/lib/aspects/index.js +1 -0
- package/lib/aspects/ship.d.ts +6 -0
- package/lib/aspects/ship.js +42 -1
- package/lib/entities/SettlePlan.d.ts +2 -0
- package/lib/entities/SettlePlan.js +2 -0
- package/lib/oak-app-domain/SettlePlan/Storage.js +6 -0
- package/lib/oak-app-domain/SettlePlan/_baseSchema.d.ts +8 -0
- package/lib/oak-app-domain/SettlePlan/locales/zh_CN.json +3 -1
- package/lib/timers/ship.js +19 -18
- package/lib/triggers/settlePlan.js +142 -100
- package/lib/triggers/ship.js +24 -51
- package/lib/triggers/withdraw.d.ts +1 -1
- package/lib/watchers/settlePlan.js +22 -3
- package/lib/watchers/ship.js +30 -30
- package/package.json +1 -1
- package/src/entities/SettlePlan.ts +4 -0
package/es/aspects/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getWithdrawCreateData } from './withdraw';
|
|
2
|
-
import { getExpressPrintInfo, getMpShipState } from './ship';
|
|
2
|
+
import { getExpressPrintInfo, getMpShipState, shipConfirmSuccess } from './ship';
|
|
3
3
|
const aspectDict = {
|
|
4
4
|
getMpShipState,
|
|
5
5
|
getWithdrawCreateData,
|
|
6
6
|
getExpressPrintInfo,
|
|
7
|
+
shipConfirmSuccess,
|
|
7
8
|
};
|
|
8
9
|
export default aspectDict;
|
package/es/aspects/ship.d.ts
CHANGED
package/es/aspects/ship.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OakPreConditionUnsetException } from 'oak-domain/lib/types';
|
|
2
2
|
import { getOrderShipState } from '../utils/ship';
|
|
3
3
|
import { getShipClazz } from '../utils/shipClazz';
|
|
4
|
+
import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
|
4
5
|
/**
|
|
5
6
|
* 获取小程序订单发货状态
|
|
6
7
|
* @param params
|
|
@@ -39,3 +40,42 @@ export async function getExpressPrintInfo(params, context) {
|
|
|
39
40
|
const clazz = await getShipClazz(entity, entityId, context);
|
|
40
41
|
return await clazz.getPrintInfo(shipId, context);
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* 小程序确认收货组件成功后更新ship状态
|
|
45
|
+
*/
|
|
46
|
+
export async function shipConfirmSuccess(params, context) {
|
|
47
|
+
const application = context.getApplication();
|
|
48
|
+
const { type, } = application;
|
|
49
|
+
if (type === 'wechatMp') {
|
|
50
|
+
try {
|
|
51
|
+
const { shipId } = params;
|
|
52
|
+
const shipState = await getOrderShipState(context, shipId);
|
|
53
|
+
if (shipState === 'received') {
|
|
54
|
+
//微信端已确认收货
|
|
55
|
+
const [ship] = await context.select('ship', {
|
|
56
|
+
data: {
|
|
57
|
+
id: 1,
|
|
58
|
+
iState: 1,
|
|
59
|
+
}, filter: {
|
|
60
|
+
id: shipId,
|
|
61
|
+
}
|
|
62
|
+
}, { forUpdate: true });
|
|
63
|
+
if (ship.iState === 'receiving') {
|
|
64
|
+
await context.operate('ship', {
|
|
65
|
+
id: await generateNewIdAsync(),
|
|
66
|
+
action: 'succeedReceiving',
|
|
67
|
+
data: {},
|
|
68
|
+
filter: {
|
|
69
|
+
id: shipId,
|
|
70
|
+
},
|
|
71
|
+
}, {});
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
@@ -21,13 +21,8 @@ declare const List: <T extends keyof EntityDict>(props: ReactComponentProps<Enti
|
|
|
21
21
|
rowSelection?: any;
|
|
22
22
|
hideHeader?: boolean | undefined;
|
|
23
23
|
disableSerialNumber?: boolean | undefined;
|
|
24
|
-
size?: "small" | "
|
|
25
|
-
scroll?:
|
|
26
|
-
x?: string | number | true | undefined;
|
|
27
|
-
y?: string | number | undefined;
|
|
28
|
-
} & {
|
|
29
|
-
scrollToFirstRowOnChange?: boolean | undefined;
|
|
30
|
-
}) | undefined;
|
|
24
|
+
size?: "small" | "large" | "middle" | undefined;
|
|
25
|
+
scroll?: any;
|
|
31
26
|
empty?: React.ReactNode;
|
|
32
27
|
opWidth?: number | undefined;
|
|
33
28
|
ellipsis?: boolean | undefined;
|
|
@@ -48,7 +43,7 @@ declare const ListPro: <T extends keyof EntityDict>(props: {
|
|
|
48
43
|
tablePagination?: any;
|
|
49
44
|
rowSelection?: any;
|
|
50
45
|
disableSerialNumber?: boolean | undefined;
|
|
51
|
-
size?: "small" | "
|
|
46
|
+
size?: "small" | "large" | "middle" | undefined;
|
|
52
47
|
scroll?: any;
|
|
53
48
|
empty?: any;
|
|
54
49
|
opWidth?: number | undefined;
|
|
@@ -347,30 +347,43 @@ export default OakComponent({
|
|
|
347
347
|
},
|
|
348
348
|
success: async () => {
|
|
349
349
|
console.log('success');
|
|
350
|
-
const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
|
|
350
|
+
// const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
|
|
351
|
+
// shipId: ship.id,
|
|
352
|
+
// })
|
|
353
|
+
// if (mpShipState === 'received') {
|
|
354
|
+
// await this.features.cache.operate('ship',
|
|
355
|
+
// [{
|
|
356
|
+
// id: await generateNewIdAsync(),
|
|
357
|
+
// action: 'succeedReceiving',
|
|
358
|
+
// data: {},
|
|
359
|
+
// filter: {
|
|
360
|
+
// id: ship.id,
|
|
361
|
+
// },
|
|
362
|
+
// }]
|
|
363
|
+
// );
|
|
364
|
+
// this.setMessage({
|
|
365
|
+
// type: 'success',
|
|
366
|
+
// content: this.t('ship.success')
|
|
367
|
+
// });
|
|
368
|
+
// } else {
|
|
369
|
+
// console.log(mpShipState);
|
|
370
|
+
// this.reRender();
|
|
371
|
+
// // this.setMessage({
|
|
372
|
+
// // type: 'warning',
|
|
373
|
+
// // content: this.t('ship.wait'),
|
|
374
|
+
// // })
|
|
375
|
+
// }
|
|
376
|
+
const { result } = await this.features.cache.exec('shipConfirmSuccess', {
|
|
351
377
|
shipId: ship.id,
|
|
352
378
|
});
|
|
353
|
-
if (
|
|
354
|
-
await this.features.cache.operate('ship', [{
|
|
355
|
-
id: await generateNewIdAsync(),
|
|
356
|
-
action: 'succeedReceiving',
|
|
357
|
-
data: {},
|
|
358
|
-
filter: {
|
|
359
|
-
id: ship.id,
|
|
360
|
-
},
|
|
361
|
-
}]);
|
|
379
|
+
if (result) {
|
|
362
380
|
this.setMessage({
|
|
363
381
|
type: 'success',
|
|
364
382
|
content: this.t('ship.success')
|
|
365
383
|
});
|
|
366
384
|
}
|
|
367
385
|
else {
|
|
368
|
-
console.log(mpShipState);
|
|
369
386
|
this.reRender();
|
|
370
|
-
// this.setMessage({
|
|
371
|
-
// type: 'warning',
|
|
372
|
-
// content: this.t('ship.wait'),
|
|
373
|
-
// })
|
|
374
387
|
}
|
|
375
388
|
},
|
|
376
389
|
fail: () => {
|
|
@@ -360,30 +360,43 @@ export default OakComponent({
|
|
|
360
360
|
},
|
|
361
361
|
success: async () => {
|
|
362
362
|
console.log('success');
|
|
363
|
-
const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
|
|
363
|
+
// const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
|
|
364
|
+
// shipId,
|
|
365
|
+
// })
|
|
366
|
+
// if (mpShipState === 'received') {
|
|
367
|
+
// await this.features.cache.operate('ship',
|
|
368
|
+
// [{
|
|
369
|
+
// id: await generateNewIdAsync(),
|
|
370
|
+
// action: 'succeedReceiving',
|
|
371
|
+
// data: {},
|
|
372
|
+
// filter: {
|
|
373
|
+
// id: shipId,
|
|
374
|
+
// },
|
|
375
|
+
// }]
|
|
376
|
+
// );
|
|
377
|
+
// this.reRender();
|
|
378
|
+
// this.setMessage({
|
|
379
|
+
// type: 'success',
|
|
380
|
+
// content: this.t('ship.success')
|
|
381
|
+
// });
|
|
382
|
+
// } else {
|
|
383
|
+
// console.log(mpShipState);
|
|
384
|
+
// // this.setMessage({
|
|
385
|
+
// // type: 'warning',
|
|
386
|
+
// // content: this.t('ship.wait'),
|
|
387
|
+
// // })
|
|
388
|
+
// this.reRender();
|
|
389
|
+
// }
|
|
390
|
+
const { result } = await this.features.cache.exec('shipConfirmSuccess', {
|
|
364
391
|
shipId,
|
|
365
392
|
});
|
|
366
|
-
if (
|
|
367
|
-
await this.features.cache.operate('ship', [{
|
|
368
|
-
id: await generateNewIdAsync(),
|
|
369
|
-
action: 'succeedReceiving',
|
|
370
|
-
data: {},
|
|
371
|
-
filter: {
|
|
372
|
-
id: shipId,
|
|
373
|
-
},
|
|
374
|
-
}]);
|
|
375
|
-
this.reRender();
|
|
393
|
+
if (result) {
|
|
376
394
|
this.setMessage({
|
|
377
395
|
type: 'success',
|
|
378
396
|
content: this.t('ship.success')
|
|
379
397
|
});
|
|
380
398
|
}
|
|
381
399
|
else {
|
|
382
|
-
console.log(mpShipState);
|
|
383
|
-
// this.setMessage({
|
|
384
|
-
// type: 'warning',
|
|
385
|
-
// content: this.t('ship.wait'),
|
|
386
|
-
// })
|
|
387
400
|
this.reRender();
|
|
388
401
|
}
|
|
389
402
|
},
|
|
@@ -422,16 +435,27 @@ export default OakComponent({
|
|
|
422
435
|
const unsub = await this.subDataEvents([
|
|
423
436
|
`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`,
|
|
424
437
|
`${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`
|
|
425
|
-
])
|
|
438
|
+
], async (event, opRecords) => {
|
|
439
|
+
for (const record of opRecords) {
|
|
440
|
+
console.log(record);
|
|
441
|
+
if (record.e === 'pay' || record.e === 'deposit') {
|
|
442
|
+
const { f } = record;
|
|
443
|
+
const [pay] = this.features.cache.get('pay', {
|
|
444
|
+
data: baseProjection,
|
|
445
|
+
filter: f,
|
|
446
|
+
});
|
|
447
|
+
console.log(JSON.stringify(pay));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
let depositUnsub = undefined;
|
|
426
452
|
const { depositId } = this.state;
|
|
427
453
|
if (depositId) {
|
|
428
|
-
|
|
429
|
-
this.setState({
|
|
430
|
-
depositUnsub,
|
|
431
|
-
});
|
|
454
|
+
depositUnsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${depositId}`]);
|
|
432
455
|
}
|
|
433
456
|
this.setState({
|
|
434
457
|
unsub,
|
|
458
|
+
depositUnsub,
|
|
435
459
|
});
|
|
436
460
|
},
|
|
437
461
|
async mature() {
|
|
@@ -7,6 +7,8 @@ export type OpSchema = EntityShape & {
|
|
|
7
7
|
when?: Datetime | null;
|
|
8
8
|
orderId: ForeignKey<"order">;
|
|
9
9
|
price: Price;
|
|
10
|
+
settledAt?: Datetime | null;
|
|
11
|
+
closedAt?: Datetime | null;
|
|
10
12
|
iState?: IState | null;
|
|
11
13
|
} & {
|
|
12
14
|
[A in ExpressionKey]?: any;
|
|
@@ -20,6 +22,8 @@ export type OpFilter = {
|
|
|
20
22
|
when: Q_DateValue;
|
|
21
23
|
orderId: Q_StringValue;
|
|
22
24
|
price: Q_NumberValue;
|
|
25
|
+
settledAt: Q_DateValue;
|
|
26
|
+
closedAt: Q_DateValue;
|
|
23
27
|
iState: Q_EnumValue<IState>;
|
|
24
28
|
} & ExprOp<OpAttr | string>;
|
|
25
29
|
export type OpProjection = {
|
|
@@ -32,6 +36,8 @@ export type OpProjection = {
|
|
|
32
36
|
when?: number;
|
|
33
37
|
orderId?: number;
|
|
34
38
|
price?: number;
|
|
39
|
+
settledAt?: number;
|
|
40
|
+
closedAt?: number;
|
|
35
41
|
iState?: number;
|
|
36
42
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
37
43
|
export type OpSortAttr = Partial<{
|
|
@@ -42,6 +48,8 @@ export type OpSortAttr = Partial<{
|
|
|
42
48
|
when: number;
|
|
43
49
|
orderId: number;
|
|
44
50
|
price: number;
|
|
51
|
+
settledAt: number;
|
|
52
|
+
closedAt: number;
|
|
45
53
|
iState: number;
|
|
46
54
|
[k: string]: any;
|
|
47
55
|
} | ExprOp<OpAttr | string>>;
|
package/es/timers/ship.js
CHANGED
|
@@ -8,7 +8,7 @@ const timers = [
|
|
|
8
8
|
filter: {
|
|
9
9
|
type: 'express',
|
|
10
10
|
iState: {
|
|
11
|
-
$nin: ['received', 'cancelled', 'rejected', 'receiving'],
|
|
11
|
+
$nin: ['received', 'cancelled', 'rejected', 'receiving', 'unshipped'],
|
|
12
12
|
},
|
|
13
13
|
entity: {
|
|
14
14
|
$exists: true
|
|
@@ -41,7 +41,7 @@ const timers = [
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
name: '同步微信小程序虚拟、自提ship状态',
|
|
44
|
-
cron: '0
|
|
44
|
+
cron: '0 * * * * ?',
|
|
45
45
|
entity: 'ship',
|
|
46
46
|
filter: {
|
|
47
47
|
type: {
|
|
@@ -53,6 +53,7 @@ const timers = [
|
|
|
53
53
|
},
|
|
54
54
|
projection: {
|
|
55
55
|
id: 1,
|
|
56
|
+
iState: 1,
|
|
56
57
|
},
|
|
57
58
|
fn: async (context, data) => {
|
|
58
59
|
const results = [];
|
|
@@ -68,21 +69,21 @@ const timers = [
|
|
|
68
69
|
return results.reduce((prev, cur) => mergeOperationResult(prev, cur));
|
|
69
70
|
},
|
|
70
71
|
},
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
72
|
+
// {
|
|
73
|
+
// name: '对虚拟或自提类型的ship自动发货',
|
|
74
|
+
// cron: '0 * * * * ?',
|
|
75
|
+
// entity: 'ship',
|
|
76
|
+
// filter: {
|
|
77
|
+
// type: {
|
|
78
|
+
// $in: ['virtual', 'pickup'],
|
|
79
|
+
// },
|
|
80
|
+
// iState: 'unshipped',
|
|
81
|
+
// },
|
|
82
|
+
// projection: {
|
|
83
|
+
// id: 1,
|
|
84
|
+
// },
|
|
85
|
+
// action: 'ship',
|
|
86
|
+
// actionData: {},
|
|
87
|
+
// },
|
|
87
88
|
];
|
|
88
89
|
export default timers;
|