oak-pay-business 3.0.2 → 3.0.3
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/components/account/detail/index.js +55 -55
- package/es/components/deposit/new/index.d.ts +1 -1
- package/es/components/deposit/new/index.js +11 -3
- package/es/components/pay/detail/index.js +38 -54
- package/es/components/pay/detail/index.less +21 -2
- package/es/components/pay/detail/index.xml +16 -2
- package/es/triggers/deposit.js +44 -5
- package/es/triggers/ship.js +125 -19
- package/lib/aspects/withdraw.js +2 -1
- package/lib/triggers/deposit.js +44 -5
- package/lib/triggers/ship.js +125 -19
- package/package.json +2 -2
|
@@ -16,6 +16,7 @@ export default OakComponent({
|
|
|
16
16
|
$entity: 'deposit',
|
|
17
17
|
data: {
|
|
18
18
|
id: 1,
|
|
19
|
+
iState: 1,
|
|
19
20
|
pay$deposit: {
|
|
20
21
|
$entity: 'pay',
|
|
21
22
|
data: {
|
|
@@ -64,9 +65,36 @@ export default OakComponent({
|
|
|
64
65
|
preWithdraw: () => true,
|
|
65
66
|
onGoToHistory: () => undefined,
|
|
66
67
|
},
|
|
67
|
-
formData({ data }) {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
formData({ data, features }) {
|
|
69
|
+
let unfinishedDepositId = data?.deposit$account?.filter((ele) => ele.iState === 'depositing')?.[0]?.id; //未完成支付的充值
|
|
70
|
+
let unreceivedDepositId = data?.deposit$account?.filter((ele) => ele.iState === 'shipped')?.[0]?.id; //未确认收货的充值
|
|
71
|
+
if (data?.id) {
|
|
72
|
+
const deposits = features.cache.get('deposit', {
|
|
73
|
+
data: {
|
|
74
|
+
id: 1,
|
|
75
|
+
iState: 1,
|
|
76
|
+
pay$deposit: {
|
|
77
|
+
$entity: 'pay',
|
|
78
|
+
data: {
|
|
79
|
+
id: 1,
|
|
80
|
+
},
|
|
81
|
+
filter: {
|
|
82
|
+
iState: 'paying',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
filter: {
|
|
87
|
+
iState: {
|
|
88
|
+
$in: ['depositing', 'shipped'],
|
|
89
|
+
},
|
|
90
|
+
accountId: data?.id,
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (deposits && deposits.length > 0) {
|
|
94
|
+
unfinishedDepositId = deposits?.filter((ele) => ele.iState === 'depositing')?.[0]?.id; //未完成支付的充值
|
|
95
|
+
unreceivedDepositId = deposits?.filter((ele) => ele.iState === 'shipped')?.[0]?.id; //未确认收货的充值
|
|
96
|
+
}
|
|
97
|
+
}
|
|
70
98
|
return {
|
|
71
99
|
account: data,
|
|
72
100
|
availStr: data?.avail && CentToString(data.avail, 2),
|
|
@@ -186,7 +214,8 @@ export default OakComponent({
|
|
|
186
214
|
this.setState({ depPrice }, () => this.setDepositLoss());
|
|
187
215
|
},
|
|
188
216
|
setDepositChannel(depositChannel) {
|
|
189
|
-
|
|
217
|
+
const channel = depositChannel ? depositChannel : null;
|
|
218
|
+
this.setState({ depositChannel: channel }, () => this.setDepositLoss());
|
|
190
219
|
},
|
|
191
220
|
setDepositLoss() {
|
|
192
221
|
const { depPrice, depositChannel } = this.state;
|
|
@@ -302,6 +331,15 @@ export default OakComponent({
|
|
|
302
331
|
id: ship.id,
|
|
303
332
|
},
|
|
304
333
|
}]);
|
|
334
|
+
await this.features.cache.refresh('deposit', {
|
|
335
|
+
data: {
|
|
336
|
+
id: 1,
|
|
337
|
+
iState: 1,
|
|
338
|
+
},
|
|
339
|
+
filter: {
|
|
340
|
+
id: unreceivedDepositId,
|
|
341
|
+
}
|
|
342
|
+
});
|
|
305
343
|
this.setMessage({
|
|
306
344
|
type: 'success',
|
|
307
345
|
content: this.t('ship.success')
|
|
@@ -336,10 +374,11 @@ export default OakComponent({
|
|
|
336
374
|
}
|
|
337
375
|
else {
|
|
338
376
|
console.log(mpShipState);
|
|
339
|
-
this.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
377
|
+
this.reRender();
|
|
378
|
+
// this.setMessage({
|
|
379
|
+
// type: 'warning',
|
|
380
|
+
// content: this.t('ship.wait'),
|
|
381
|
+
// })
|
|
343
382
|
}
|
|
344
383
|
},
|
|
345
384
|
fail() {
|
|
@@ -371,12 +410,13 @@ export default OakComponent({
|
|
|
371
410
|
}
|
|
372
411
|
}
|
|
373
412
|
else {
|
|
374
|
-
if (!noMessage) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
413
|
+
// if (!noMessage) {
|
|
414
|
+
// this.setMessage({
|
|
415
|
+
// content: this.t('ship.wait'),
|
|
416
|
+
// type: 'warning',
|
|
417
|
+
// })
|
|
418
|
+
// }
|
|
419
|
+
this.reRender();
|
|
380
420
|
}
|
|
381
421
|
}
|
|
382
422
|
}
|
|
@@ -398,47 +438,7 @@ export default OakComponent({
|
|
|
398
438
|
async ready() {
|
|
399
439
|
const { oakId } = this.props;
|
|
400
440
|
assert(typeof oakId === 'string');
|
|
401
|
-
const unsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`]
|
|
402
|
-
for (const record of opRecords) {
|
|
403
|
-
if (record.a === 'succeed') {
|
|
404
|
-
const { e, d } = record;
|
|
405
|
-
if (e === 'deposit') {
|
|
406
|
-
await this.features.cache.refresh('deposit', {
|
|
407
|
-
data: {
|
|
408
|
-
id: 1,
|
|
409
|
-
accountId: 1,
|
|
410
|
-
iState: 1,
|
|
411
|
-
pay$deposit: {
|
|
412
|
-
$entity: 'pay',
|
|
413
|
-
data: {
|
|
414
|
-
id: 1,
|
|
415
|
-
meta: 1,
|
|
416
|
-
iState: 1,
|
|
417
|
-
entity: 1,
|
|
418
|
-
entityId: 1,
|
|
419
|
-
},
|
|
420
|
-
filter: {
|
|
421
|
-
entity: 'wpProduct',
|
|
422
|
-
iState: 'paid',
|
|
423
|
-
}
|
|
424
|
-
},
|
|
425
|
-
shipId: 1,
|
|
426
|
-
ship: {
|
|
427
|
-
id: 1,
|
|
428
|
-
iState: 1,
|
|
429
|
-
}
|
|
430
|
-
},
|
|
431
|
-
filter: {
|
|
432
|
-
accountId: oakId,
|
|
433
|
-
iState: {
|
|
434
|
-
$in: ['depositing', 'shipped'],
|
|
435
|
-
},
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
});
|
|
441
|
+
const unsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`]);
|
|
442
442
|
this.setState({
|
|
443
443
|
unsub,
|
|
444
444
|
});
|
|
@@ -4,7 +4,7 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|
|
4
4
|
depositMinCent: number;
|
|
5
5
|
depositMaxCent: number;
|
|
6
6
|
price: number | null;
|
|
7
|
-
channel: PayChannel |
|
|
7
|
+
channel: PayChannel | undefined;
|
|
8
8
|
onSetPrice: (price: null | number) => void;
|
|
9
9
|
onSetChannel: (channel: PayChannel) => void;
|
|
10
10
|
loss: [number, string, any];
|
|
@@ -5,7 +5,7 @@ export default OakComponent({
|
|
|
5
5
|
depositMinCent: 0,
|
|
6
6
|
depositMaxCent: 1000000,
|
|
7
7
|
price: 0,
|
|
8
|
-
channel:
|
|
8
|
+
channel: undefined,
|
|
9
9
|
onSetPrice: (price) => undefined,
|
|
10
10
|
onSetChannel: (channel) => undefined,
|
|
11
11
|
loss: [0, '', {}],
|
|
@@ -30,11 +30,19 @@ export default OakComponent({
|
|
|
30
30
|
},
|
|
31
31
|
lifetimes: {
|
|
32
32
|
ready() {
|
|
33
|
-
const { depositMinCent } = this.props;
|
|
33
|
+
const { depositMinCent, channel, onSetChannel } = this.props;
|
|
34
34
|
if (depositMinCent) {
|
|
35
35
|
this.onPriceChange(ToYuan(depositMinCent), true);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
if (!channel && process.env.OAK_PLATFORM === 'wechatMp') {
|
|
38
|
+
//小程序环境下默认选择微信支付
|
|
39
|
+
const { payChannels } = this.state;
|
|
40
|
+
const wpProduct = payChannels?.find((ele) => ele.entity === 'wpProduct');
|
|
41
|
+
if (wpProduct) {
|
|
42
|
+
onSetChannel && onSetChannel(wpProduct);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
38
46
|
},
|
|
39
47
|
listeners: {
|
|
40
48
|
price() {
|
|
@@ -129,16 +129,18 @@ export default OakComponent({
|
|
|
129
129
|
showCloseConfirmMp: false,
|
|
130
130
|
showChannelSelectMp: false,
|
|
131
131
|
unsub: undefined,
|
|
132
|
-
|
|
132
|
+
depositUnsub: undefined,
|
|
133
133
|
},
|
|
134
134
|
formData({ data, props }) {
|
|
135
135
|
const application = this.features.application.getApplication();
|
|
136
136
|
const iState = data?.iState;
|
|
137
137
|
let iStateStr = this.t(`pay:v.iState.${iState}`);
|
|
138
138
|
let iStateColor = iState && this.features.style.getColor('pay', 'iState', iState);
|
|
139
|
+
let showDepositConfirm = false;
|
|
139
140
|
if (data?.depositId && data?.deposit?.shipId && data?.deposit?.iState === 'shipped') {
|
|
140
141
|
iStateStr = this.t('ship.shipped');
|
|
141
142
|
iStateColor = this.features.style.getColor('deposit', 'iState', data?.deposit?.iState);
|
|
143
|
+
showDepositConfirm = true;
|
|
142
144
|
}
|
|
143
145
|
const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
|
|
144
146
|
const { mode } = this.props;
|
|
@@ -180,6 +182,7 @@ export default OakComponent({
|
|
|
180
182
|
shipId: data?.deposit?.shipId,
|
|
181
183
|
ship: data?.deposit?.ship,
|
|
182
184
|
depositId: data?.depositId,
|
|
185
|
+
showDepositConfirm,
|
|
183
186
|
};
|
|
184
187
|
},
|
|
185
188
|
features: [{
|
|
@@ -323,10 +326,12 @@ export default OakComponent({
|
|
|
323
326
|
externalId: null,
|
|
324
327
|
});
|
|
325
328
|
},
|
|
326
|
-
async confirmShipMp(
|
|
329
|
+
async confirmShipMp() {
|
|
327
330
|
//小程序唤起确认收货组件
|
|
331
|
+
const { pay, ship, depositId } = this.state;
|
|
328
332
|
if (process.env.OAK_PLATFORM === 'wechatMp') {
|
|
329
|
-
const
|
|
333
|
+
const shipId = ship.id;
|
|
334
|
+
const shipState = ship.iState;
|
|
330
335
|
if (shipId && shipState === 'receiving') {
|
|
331
336
|
if (process.env.NODE_ENV === 'development') {
|
|
332
337
|
await this.features.cache.operate('ship', [{
|
|
@@ -337,6 +342,15 @@ export default OakComponent({
|
|
|
337
342
|
id: shipId,
|
|
338
343
|
},
|
|
339
344
|
}]);
|
|
345
|
+
await this.features.cache.refresh('deposit', {
|
|
346
|
+
data: {
|
|
347
|
+
id: 1,
|
|
348
|
+
iState: 1,
|
|
349
|
+
},
|
|
350
|
+
filter: {
|
|
351
|
+
id: depositId,
|
|
352
|
+
}
|
|
353
|
+
});
|
|
340
354
|
this.setMessage({
|
|
341
355
|
type: 'success',
|
|
342
356
|
content: this.t('ship.success')
|
|
@@ -364,6 +378,7 @@ export default OakComponent({
|
|
|
364
378
|
id: shipId,
|
|
365
379
|
},
|
|
366
380
|
}]);
|
|
381
|
+
this.reRender();
|
|
367
382
|
this.setMessage({
|
|
368
383
|
type: 'success',
|
|
369
384
|
content: this.t('ship.success')
|
|
@@ -371,10 +386,11 @@ export default OakComponent({
|
|
|
371
386
|
}
|
|
372
387
|
else {
|
|
373
388
|
console.log(mpShipState);
|
|
374
|
-
this.setMessage({
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
})
|
|
389
|
+
// this.setMessage({
|
|
390
|
+
// type: 'warning',
|
|
391
|
+
// content: this.t('ship.wait'),
|
|
392
|
+
// })
|
|
393
|
+
this.reRender();
|
|
378
394
|
}
|
|
379
395
|
},
|
|
380
396
|
fail() {
|
|
@@ -404,10 +420,7 @@ export default OakComponent({
|
|
|
404
420
|
}
|
|
405
421
|
}
|
|
406
422
|
else {
|
|
407
|
-
this.
|
|
408
|
-
type: 'warning',
|
|
409
|
-
content: this.t('ship.wait'),
|
|
410
|
-
});
|
|
423
|
+
this.reRender();
|
|
411
424
|
}
|
|
412
425
|
}
|
|
413
426
|
}
|
|
@@ -416,21 +429,17 @@ export default OakComponent({
|
|
|
416
429
|
async ready() {
|
|
417
430
|
const { oakId } = this.props;
|
|
418
431
|
assert(typeof oakId === 'string');
|
|
419
|
-
const unsub = await this.subDataEvents([
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
});
|
|
432
|
+
const unsub = await this.subDataEvents([
|
|
433
|
+
`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`,
|
|
434
|
+
`${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`
|
|
435
|
+
]);
|
|
436
|
+
const { depositId } = this.state;
|
|
437
|
+
if (depositId) {
|
|
438
|
+
const depositUnsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${depositId}`]);
|
|
439
|
+
this.setState({
|
|
440
|
+
depositUnsub,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
434
443
|
this.setState({
|
|
435
444
|
unsub,
|
|
436
445
|
});
|
|
@@ -438,13 +447,13 @@ export default OakComponent({
|
|
|
438
447
|
async mature() {
|
|
439
448
|
const { ship } = this.state;
|
|
440
449
|
if (ship?.id && ship?.iState === 'receiving') {
|
|
441
|
-
await this.confirmShipMp(
|
|
450
|
+
await this.confirmShipMp();
|
|
442
451
|
}
|
|
443
452
|
},
|
|
444
453
|
detached() {
|
|
445
|
-
const { unsub,
|
|
454
|
+
const { unsub, depositUnsub } = this.state;
|
|
446
455
|
unsub && unsub();
|
|
447
|
-
|
|
456
|
+
depositUnsub && depositUnsub();
|
|
448
457
|
},
|
|
449
458
|
},
|
|
450
459
|
listeners: {
|
|
@@ -458,30 +467,5 @@ export default OakComponent({
|
|
|
458
467
|
this.refreshOfflineAccounts();
|
|
459
468
|
}
|
|
460
469
|
},
|
|
461
|
-
async shipId(prev, next) {
|
|
462
|
-
const { depositId } = this.state;
|
|
463
|
-
if (depositId && prev.shipId !== next.shipId && next.shipId) {
|
|
464
|
-
if (prev.shipId) {
|
|
465
|
-
const { unsubShip } = this.state;
|
|
466
|
-
unsubShip && unsubShip();
|
|
467
|
-
}
|
|
468
|
-
const unsubShip = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${next.shipId}`], async (event, opRecords) => {
|
|
469
|
-
if (process.env.OAK_PLATFORM === 'wechatMp') {
|
|
470
|
-
//在充值虚拟发货成功后,小程序唤起确认收货组件
|
|
471
|
-
for (const record of opRecords) {
|
|
472
|
-
if (record.a === 'startReceiving') {
|
|
473
|
-
const { e, d } = record;
|
|
474
|
-
if (e === 'ship' && d.iState === 'receiving') {
|
|
475
|
-
await this.confirmShipMp(next.shipId, d.iState);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
this.setState({
|
|
482
|
-
unsubShip,
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
470
|
},
|
|
487
471
|
});
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
.meta {
|
|
49
|
-
margin-top:
|
|
49
|
+
margin-top: 18px;
|
|
50
50
|
display: flex;
|
|
51
51
|
flex-direction: column;
|
|
52
52
|
align-items: center;
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
flex-direction: column;
|
|
167
167
|
align-items: center;
|
|
168
168
|
padding: 24rpx;
|
|
169
|
-
margin-top:
|
|
169
|
+
margin-top: 50rpx;
|
|
170
170
|
|
|
171
171
|
text {
|
|
172
172
|
margin-top: 40rpx;
|
|
@@ -197,4 +197,23 @@
|
|
|
197
197
|
grid-template-columns: 1fr 1fr;
|
|
198
198
|
gap: 32rpx;
|
|
199
199
|
flex: 1;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.depositConfrimBox {
|
|
203
|
+
display: flex;
|
|
204
|
+
flex-direction: column;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
row-gap: 32rpx;
|
|
208
|
+
padding: 12rpx;
|
|
209
|
+
box-sizing: border-box;
|
|
210
|
+
margin-top: 24rpx;
|
|
211
|
+
background-color: #fff;
|
|
212
|
+
border-radius: 16rpx;
|
|
213
|
+
|
|
214
|
+
.depositConfrimText {
|
|
215
|
+
display: flex;
|
|
216
|
+
gap: 18rpx;
|
|
217
|
+
line-height: 36rpx;
|
|
218
|
+
}
|
|
200
219
|
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<view class="wariningAlert">{{t('notSameApp')}}</view>
|
|
19
19
|
</block>
|
|
20
20
|
<block wx:elif="{{pay.entity === 'offlineAccount'}}">
|
|
21
|
-
<view wx:if="{{pay.iState === 'paying'}}" class="infoAlert" style="margin-bottom:20rpx;">{{t('code.help' +
|
|
21
|
+
<view wx:if="{{pay.iState === 'paying'}}" class="infoAlert" style="margin-bottom:20rpx;">{{t('code.help.' + mode)}}</view>
|
|
22
22
|
<l-popup wx:if="{{showChannelSelectMp}}" show="{{showChannelSelectMp}}" content-align="bottom" bind:lintap="closeChannelSelectMp">
|
|
23
23
|
<view class="my-panel-class">
|
|
24
24
|
<l-radio-group
|
|
@@ -107,7 +107,21 @@
|
|
|
107
107
|
</block>
|
|
108
108
|
</block>
|
|
109
109
|
</view>
|
|
110
|
-
<view class="padding"
|
|
110
|
+
<view class="padding">
|
|
111
|
+
<view wx:if="{{showDepositConfirm}}" class="depositConfrimBox">
|
|
112
|
+
<view class="depositConfrimText">
|
|
113
|
+
<l-icon name='warning' size="32" />
|
|
114
|
+
<span>微信支付成功,请点击下方「充值确认」按钮,确认后即可正常使用余额!</span>
|
|
115
|
+
</view>
|
|
116
|
+
<l-button
|
|
117
|
+
plain="{{true}}"
|
|
118
|
+
shape="semicircle"
|
|
119
|
+
bind:lintap="confirmShipMp"
|
|
120
|
+
>
|
|
121
|
+
充值确认
|
|
122
|
+
</l-button>
|
|
123
|
+
</view>
|
|
124
|
+
</view>
|
|
111
125
|
<view style="display:flex; align-items: center;justify-content: space-between;gap:16rpx;">
|
|
112
126
|
<block wx:if="{{closable && !oakExecutable}}">
|
|
113
127
|
<l-button
|
package/es/triggers/deposit.js
CHANGED
|
@@ -158,16 +158,55 @@ const triggers = [
|
|
|
158
158
|
data: {
|
|
159
159
|
id: 1,
|
|
160
160
|
accountId: 1,
|
|
161
|
+
iState: 1,
|
|
162
|
+
pay$deposit: {
|
|
163
|
+
$entity: 'pay',
|
|
164
|
+
data: {
|
|
165
|
+
id: 1,
|
|
166
|
+
iState: 1,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
161
169
|
},
|
|
162
170
|
filter: {
|
|
163
171
|
id: depositId,
|
|
164
172
|
}
|
|
165
|
-
}, {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
173
|
+
}, {});
|
|
174
|
+
const { accountId, pay$deposit } = deposit;
|
|
175
|
+
const payId = pay$deposit?.[0].id;
|
|
176
|
+
const selectionId = await generateNewIdAsync();
|
|
177
|
+
await context.select('deposit', {
|
|
178
|
+
id: selectionId,
|
|
179
|
+
data: {
|
|
180
|
+
id: 1,
|
|
181
|
+
accountId: 1,
|
|
182
|
+
account: {
|
|
183
|
+
id: 1,
|
|
184
|
+
avail: 1,
|
|
185
|
+
total: 1,
|
|
186
|
+
},
|
|
187
|
+
iState: 1,
|
|
188
|
+
shipId: 1,
|
|
189
|
+
ship: {
|
|
190
|
+
id: 1,
|
|
191
|
+
iState: 1,
|
|
192
|
+
},
|
|
193
|
+
pay$deposit: {
|
|
194
|
+
$entity: 'pay',
|
|
195
|
+
data: {
|
|
196
|
+
id: 1,
|
|
197
|
+
iState: 1,
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
filter: {
|
|
202
|
+
id: depositId,
|
|
203
|
+
}
|
|
204
|
+
}, {});
|
|
205
|
+
if (payId) {
|
|
206
|
+
context.saveOperationToEvent(selectionId, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${payId}`);
|
|
207
|
+
}
|
|
169
208
|
if (accountId) {
|
|
170
|
-
context.saveOperationToEvent(
|
|
209
|
+
context.saveOperationToEvent(selectionId, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${accountId}`);
|
|
171
210
|
}
|
|
172
211
|
return 1;
|
|
173
212
|
}
|
package/es/triggers/ship.js
CHANGED
|
@@ -158,9 +158,70 @@ const triggers = [
|
|
|
158
158
|
fn: async ({ operation }, context, option) => {
|
|
159
159
|
const { filter, id } = operation;
|
|
160
160
|
const { id: shipId } = filter;
|
|
161
|
+
const [ship] = await context.select('ship', {
|
|
162
|
+
data: {
|
|
163
|
+
id: 1,
|
|
164
|
+
deposit$ship: {
|
|
165
|
+
$entity: 'deposit',
|
|
166
|
+
data: {
|
|
167
|
+
id: 1,
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
shipOrder$ship: {
|
|
171
|
+
$entity: 'shipOrder',
|
|
172
|
+
data: {
|
|
173
|
+
id: 1,
|
|
174
|
+
orderId: 1,
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
filter,
|
|
179
|
+
}, {});
|
|
180
|
+
const { deposit$ship: deposits, shipOrder$ship: shipOrders } = ship || {};
|
|
181
|
+
const depositIds = deposits?.map((ele) => ele.id);
|
|
182
|
+
const orderIds = shipOrders?.map((ele) => ele.orderId);
|
|
161
183
|
if (shipId) {
|
|
162
184
|
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${shipId}`);
|
|
163
185
|
}
|
|
186
|
+
const selectionId = await generateNewIdAsync();
|
|
187
|
+
await context.select('ship', {
|
|
188
|
+
id: selectionId,
|
|
189
|
+
data: {
|
|
190
|
+
id: 1,
|
|
191
|
+
iState: 1,
|
|
192
|
+
deposit$ship: {
|
|
193
|
+
$entity: 'deposit',
|
|
194
|
+
data: {
|
|
195
|
+
id: 1,
|
|
196
|
+
iState: 1,
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
shipOrder$ship: {
|
|
200
|
+
$entity: 'shipOrder',
|
|
201
|
+
data: {
|
|
202
|
+
id: 1,
|
|
203
|
+
orderId: 1,
|
|
204
|
+
order: {
|
|
205
|
+
id: 1,
|
|
206
|
+
iState: 1,
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
filter: {
|
|
212
|
+
id: shipId,
|
|
213
|
+
}
|
|
214
|
+
}, {});
|
|
215
|
+
if (depositIds && depositIds.length > 0) {
|
|
216
|
+
depositIds.forEach((depositId) => {
|
|
217
|
+
context.saveOperationToEvent(selectionId, `${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${depositId}`);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (orderIds && orderIds.length > 0) {
|
|
221
|
+
orderIds.forEach((orderId) => {
|
|
222
|
+
context.saveOperationToEvent(selectionId, `${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${orderId}`);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
164
225
|
return 1;
|
|
165
226
|
}
|
|
166
227
|
},
|
|
@@ -330,7 +391,7 @@ const triggers = [
|
|
|
330
391
|
filter: {
|
|
331
392
|
id
|
|
332
393
|
}
|
|
333
|
-
}, {
|
|
394
|
+
}, { forUpdate: true });
|
|
334
395
|
const { type, shipOrder$ship } = ship;
|
|
335
396
|
const wpPay = shipOrder$ship?.map((shipOrder) => shipOrder?.order?.pay$order).flat();
|
|
336
397
|
if (type === 'virtual' || (type === 'pickup' && wpPay && wpPay.length > 0)) {
|
|
@@ -350,27 +411,26 @@ const triggers = [
|
|
|
350
411
|
name: '当虚拟ship确认收货后更新deposit状态',
|
|
351
412
|
entity: 'ship',
|
|
352
413
|
action: 'succeedReceiving',
|
|
353
|
-
when: '
|
|
414
|
+
when: 'after',
|
|
354
415
|
asRoot: true,
|
|
355
|
-
fn: async ({
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
iState: 1,
|
|
367
|
-
}
|
|
416
|
+
fn: async ({ operation }, context, option) => {
|
|
417
|
+
const { filter, id, data } = operation;
|
|
418
|
+
const ships = await context.select('ship', {
|
|
419
|
+
data: {
|
|
420
|
+
id: 1,
|
|
421
|
+
type: 1,
|
|
422
|
+
deposit$ship: {
|
|
423
|
+
$entity: 'deposit',
|
|
424
|
+
data: {
|
|
425
|
+
id: 1,
|
|
426
|
+
iState: 1,
|
|
368
427
|
}
|
|
369
|
-
},
|
|
370
|
-
filter: {
|
|
371
|
-
id
|
|
372
428
|
}
|
|
373
|
-
},
|
|
429
|
+
},
|
|
430
|
+
filter,
|
|
431
|
+
}, { forUpdate: true });
|
|
432
|
+
let count = 0;
|
|
433
|
+
for (const ship of ships) {
|
|
374
434
|
const { type, deposit$ship: deposits } = ship;
|
|
375
435
|
if (type === 'virtual' && deposits && deposits.length > 0) {
|
|
376
436
|
const [deposit] = deposits;
|
|
@@ -382,9 +442,55 @@ const triggers = [
|
|
|
382
442
|
id: deposit.id,
|
|
383
443
|
}
|
|
384
444
|
}, option);
|
|
445
|
+
count++;
|
|
385
446
|
}
|
|
386
447
|
}
|
|
448
|
+
return count;
|
|
387
449
|
},
|
|
388
450
|
},
|
|
451
|
+
{
|
|
452
|
+
name: '当虚拟ship自动确认收货后更新deposit状态',
|
|
453
|
+
entity: 'ship',
|
|
454
|
+
action: 'update',
|
|
455
|
+
when: 'after',
|
|
456
|
+
asRoot: true,
|
|
457
|
+
fn: async ({ operation }, context, option) => {
|
|
458
|
+
const { filter, id, data } = operation;
|
|
459
|
+
const ships = await context.select('ship', {
|
|
460
|
+
data: {
|
|
461
|
+
id: 1,
|
|
462
|
+
iState: 1,
|
|
463
|
+
type: 1,
|
|
464
|
+
deposit$ship: {
|
|
465
|
+
$entity: 'deposit',
|
|
466
|
+
data: {
|
|
467
|
+
id: 1,
|
|
468
|
+
iState: 1,
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
filter,
|
|
473
|
+
}, { forUpdate: true });
|
|
474
|
+
let count = 0;
|
|
475
|
+
const virtualShips = ships?.filter((ele) => ele.type === 'virtual');
|
|
476
|
+
if (virtualShips && virtualShips.length > 0) {
|
|
477
|
+
for (const ship of virtualShips) {
|
|
478
|
+
const deposit = ship.deposit$ship?.[0];
|
|
479
|
+
if (deposit && deposit.iState === 'shipped') {
|
|
480
|
+
await context.operate('deposit', {
|
|
481
|
+
id: await generateNewIdAsync(),
|
|
482
|
+
action: 'succeed',
|
|
483
|
+
data: {},
|
|
484
|
+
filter: {
|
|
485
|
+
id: deposit.id,
|
|
486
|
+
}
|
|
487
|
+
}, option);
|
|
488
|
+
count++;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return count;
|
|
493
|
+
}
|
|
494
|
+
},
|
|
389
495
|
];
|
|
390
496
|
export default triggers;
|
package/lib/aspects/withdraw.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWithdrawCreateData =
|
|
3
|
+
exports.getWithdrawCreateData = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const types_1 = require("oak-domain/lib/types");
|
|
6
6
|
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
@@ -211,3 +211,4 @@ async function getWithdrawCreateData(params, context) {
|
|
|
211
211
|
data.loss = totalLoss;
|
|
212
212
|
return data;
|
|
213
213
|
}
|
|
214
|
+
exports.getWithdrawCreateData = getWithdrawCreateData;
|
package/lib/triggers/deposit.js
CHANGED
|
@@ -161,16 +161,55 @@ const triggers = [
|
|
|
161
161
|
data: {
|
|
162
162
|
id: 1,
|
|
163
163
|
accountId: 1,
|
|
164
|
+
iState: 1,
|
|
165
|
+
pay$deposit: {
|
|
166
|
+
$entity: 'pay',
|
|
167
|
+
data: {
|
|
168
|
+
id: 1,
|
|
169
|
+
iState: 1,
|
|
170
|
+
}
|
|
171
|
+
}
|
|
164
172
|
},
|
|
165
173
|
filter: {
|
|
166
174
|
id: depositId,
|
|
167
175
|
}
|
|
168
|
-
}, {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
176
|
+
}, {});
|
|
177
|
+
const { accountId, pay$deposit } = deposit;
|
|
178
|
+
const payId = pay$deposit?.[0].id;
|
|
179
|
+
const selectionId = await (0, uuid_1.generateNewIdAsync)();
|
|
180
|
+
await context.select('deposit', {
|
|
181
|
+
id: selectionId,
|
|
182
|
+
data: {
|
|
183
|
+
id: 1,
|
|
184
|
+
accountId: 1,
|
|
185
|
+
account: {
|
|
186
|
+
id: 1,
|
|
187
|
+
avail: 1,
|
|
188
|
+
total: 1,
|
|
189
|
+
},
|
|
190
|
+
iState: 1,
|
|
191
|
+
shipId: 1,
|
|
192
|
+
ship: {
|
|
193
|
+
id: 1,
|
|
194
|
+
iState: 1,
|
|
195
|
+
},
|
|
196
|
+
pay$deposit: {
|
|
197
|
+
$entity: 'pay',
|
|
198
|
+
data: {
|
|
199
|
+
id: 1,
|
|
200
|
+
iState: 1,
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
filter: {
|
|
205
|
+
id: depositId,
|
|
206
|
+
}
|
|
207
|
+
}, {});
|
|
208
|
+
if (payId) {
|
|
209
|
+
context.saveOperationToEvent(selectionId, `${constants_1.DATA_SUBSCRIBER_KEYS.depositStateChanged}-${payId}`);
|
|
210
|
+
}
|
|
172
211
|
if (accountId) {
|
|
173
|
-
context.saveOperationToEvent(
|
|
212
|
+
context.saveOperationToEvent(selectionId, `${constants_1.DATA_SUBSCRIBER_KEYS.depositStateChanged}-${accountId}`);
|
|
174
213
|
}
|
|
175
214
|
return 1;
|
|
176
215
|
}
|
package/lib/triggers/ship.js
CHANGED
|
@@ -161,9 +161,70 @@ const triggers = [
|
|
|
161
161
|
fn: async ({ operation }, context, option) => {
|
|
162
162
|
const { filter, id } = operation;
|
|
163
163
|
const { id: shipId } = filter;
|
|
164
|
+
const [ship] = await context.select('ship', {
|
|
165
|
+
data: {
|
|
166
|
+
id: 1,
|
|
167
|
+
deposit$ship: {
|
|
168
|
+
$entity: 'deposit',
|
|
169
|
+
data: {
|
|
170
|
+
id: 1,
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
shipOrder$ship: {
|
|
174
|
+
$entity: 'shipOrder',
|
|
175
|
+
data: {
|
|
176
|
+
id: 1,
|
|
177
|
+
orderId: 1,
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
filter,
|
|
182
|
+
}, {});
|
|
183
|
+
const { deposit$ship: deposits, shipOrder$ship: shipOrders } = ship || {};
|
|
184
|
+
const depositIds = deposits?.map((ele) => ele.id);
|
|
185
|
+
const orderIds = shipOrders?.map((ele) => ele.orderId);
|
|
164
186
|
if (shipId) {
|
|
165
187
|
context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.shipStateChanged}-${shipId}`);
|
|
166
188
|
}
|
|
189
|
+
const selectionId = await (0, uuid_1.generateNewIdAsync)();
|
|
190
|
+
await context.select('ship', {
|
|
191
|
+
id: selectionId,
|
|
192
|
+
data: {
|
|
193
|
+
id: 1,
|
|
194
|
+
iState: 1,
|
|
195
|
+
deposit$ship: {
|
|
196
|
+
$entity: 'deposit',
|
|
197
|
+
data: {
|
|
198
|
+
id: 1,
|
|
199
|
+
iState: 1,
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
shipOrder$ship: {
|
|
203
|
+
$entity: 'shipOrder',
|
|
204
|
+
data: {
|
|
205
|
+
id: 1,
|
|
206
|
+
orderId: 1,
|
|
207
|
+
order: {
|
|
208
|
+
id: 1,
|
|
209
|
+
iState: 1,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
filter: {
|
|
215
|
+
id: shipId,
|
|
216
|
+
}
|
|
217
|
+
}, {});
|
|
218
|
+
if (depositIds && depositIds.length > 0) {
|
|
219
|
+
depositIds.forEach((depositId) => {
|
|
220
|
+
context.saveOperationToEvent(selectionId, `${constants_1.DATA_SUBSCRIBER_KEYS.shipStateChanged}-${depositId}`);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
if (orderIds && orderIds.length > 0) {
|
|
224
|
+
orderIds.forEach((orderId) => {
|
|
225
|
+
context.saveOperationToEvent(selectionId, `${constants_1.DATA_SUBSCRIBER_KEYS.shipStateChanged}-${orderId}`);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
167
228
|
return 1;
|
|
168
229
|
}
|
|
169
230
|
},
|
|
@@ -333,7 +394,7 @@ const triggers = [
|
|
|
333
394
|
filter: {
|
|
334
395
|
id
|
|
335
396
|
}
|
|
336
|
-
}, {
|
|
397
|
+
}, { forUpdate: true });
|
|
337
398
|
const { type, shipOrder$ship } = ship;
|
|
338
399
|
const wpPay = shipOrder$ship?.map((shipOrder) => shipOrder?.order?.pay$order).flat();
|
|
339
400
|
if (type === 'virtual' || (type === 'pickup' && wpPay && wpPay.length > 0)) {
|
|
@@ -353,27 +414,26 @@ const triggers = [
|
|
|
353
414
|
name: '当虚拟ship确认收货后更新deposit状态',
|
|
354
415
|
entity: 'ship',
|
|
355
416
|
action: 'succeedReceiving',
|
|
356
|
-
when: '
|
|
417
|
+
when: 'after',
|
|
357
418
|
asRoot: true,
|
|
358
|
-
fn: async ({
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
iState: 1,
|
|
370
|
-
}
|
|
419
|
+
fn: async ({ operation }, context, option) => {
|
|
420
|
+
const { filter, id, data } = operation;
|
|
421
|
+
const ships = await context.select('ship', {
|
|
422
|
+
data: {
|
|
423
|
+
id: 1,
|
|
424
|
+
type: 1,
|
|
425
|
+
deposit$ship: {
|
|
426
|
+
$entity: 'deposit',
|
|
427
|
+
data: {
|
|
428
|
+
id: 1,
|
|
429
|
+
iState: 1,
|
|
371
430
|
}
|
|
372
|
-
},
|
|
373
|
-
filter: {
|
|
374
|
-
id
|
|
375
431
|
}
|
|
376
|
-
},
|
|
432
|
+
},
|
|
433
|
+
filter,
|
|
434
|
+
}, { forUpdate: true });
|
|
435
|
+
let count = 0;
|
|
436
|
+
for (const ship of ships) {
|
|
377
437
|
const { type, deposit$ship: deposits } = ship;
|
|
378
438
|
if (type === 'virtual' && deposits && deposits.length > 0) {
|
|
379
439
|
const [deposit] = deposits;
|
|
@@ -385,9 +445,55 @@ const triggers = [
|
|
|
385
445
|
id: deposit.id,
|
|
386
446
|
}
|
|
387
447
|
}, option);
|
|
448
|
+
count++;
|
|
388
449
|
}
|
|
389
450
|
}
|
|
451
|
+
return count;
|
|
390
452
|
},
|
|
391
453
|
},
|
|
454
|
+
{
|
|
455
|
+
name: '当虚拟ship自动确认收货后更新deposit状态',
|
|
456
|
+
entity: 'ship',
|
|
457
|
+
action: 'update',
|
|
458
|
+
when: 'after',
|
|
459
|
+
asRoot: true,
|
|
460
|
+
fn: async ({ operation }, context, option) => {
|
|
461
|
+
const { filter, id, data } = operation;
|
|
462
|
+
const ships = await context.select('ship', {
|
|
463
|
+
data: {
|
|
464
|
+
id: 1,
|
|
465
|
+
iState: 1,
|
|
466
|
+
type: 1,
|
|
467
|
+
deposit$ship: {
|
|
468
|
+
$entity: 'deposit',
|
|
469
|
+
data: {
|
|
470
|
+
id: 1,
|
|
471
|
+
iState: 1,
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
filter,
|
|
476
|
+
}, { forUpdate: true });
|
|
477
|
+
let count = 0;
|
|
478
|
+
const virtualShips = ships?.filter((ele) => ele.type === 'virtual');
|
|
479
|
+
if (virtualShips && virtualShips.length > 0) {
|
|
480
|
+
for (const ship of virtualShips) {
|
|
481
|
+
const deposit = ship.deposit$ship?.[0];
|
|
482
|
+
if (deposit && deposit.iState === 'shipped') {
|
|
483
|
+
await context.operate('deposit', {
|
|
484
|
+
id: await (0, uuid_1.generateNewIdAsync)(),
|
|
485
|
+
action: 'succeed',
|
|
486
|
+
data: {},
|
|
487
|
+
filter: {
|
|
488
|
+
id: deposit.id,
|
|
489
|
+
}
|
|
490
|
+
}, option);
|
|
491
|
+
count++;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return count;
|
|
496
|
+
}
|
|
497
|
+
},
|
|
392
498
|
];
|
|
393
499
|
exports.default = triggers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-pay-business",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib/**/*",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"oak-domain": "^5.1.24",
|
|
34
34
|
"oak-external-sdk": "^2.3.6",
|
|
35
35
|
"oak-frontend-base": "^5.3.31",
|
|
36
|
-
"oak-general-business": "~5.7.
|
|
36
|
+
"oak-general-business": "~5.7.5",
|
|
37
37
|
"react-markdown": "^9.0.3",
|
|
38
38
|
"wechat-pay-nodejs": "^0.2.3"
|
|
39
39
|
},
|