oak-pay-business 3.0.2 → 3.0.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.
@@ -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
- const unfinishedDepositId = data?.deposit$account?.filter((ele) => ele.iState === 'depositing')?.[0]?.id; //未完成支付的充值
69
- const unreceivedDepositId = data?.deposit$account?.filter((ele) => ele.iState === 'shipped')?.[0]?.id; //未确认收货的充值
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
- this.setState({ depositChannel }, () => this.setDepositLoss());
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;
@@ -290,10 +319,10 @@ export default OakComponent({
290
319
  });
291
320
  const ship = deposit?.ship;
292
321
  if (ship && ship.id) {
293
- if (ship.iState === 'receiving') {
294
- const transactionId = deposit?.pay$deposit?.[0]?.meta?.transaction_id;
295
- console.log('transaction_id', transactionId);
296
- if (process.env.NODE_ENV === 'development') {
322
+ const transactionId = deposit?.pay$deposit?.[0]?.meta?.transaction_id;
323
+ console.log('transaction_id', transactionId);
324
+ if (process.env.NODE_ENV === 'development') {
325
+ if (ship.iState === 'receiving') {
297
326
  await this.features.cache.operate('ship', [{
298
327
  id: await generateNewIdAsync(),
299
328
  action: 'succeedReceiving',
@@ -308,73 +337,66 @@ export default OakComponent({
308
337
  });
309
338
  return;
310
339
  }
311
- if (transactionId) {
312
- if (wx.openBusinessView) {
313
- wx.openBusinessView({
314
- businessType: 'weappOrderConfirm',
315
- extraData: {
316
- transaction_id: transactionId,
317
- },
318
- success: async () => {
319
- console.log('success');
320
- const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
321
- shipId: ship.id,
322
- });
323
- if (mpShipState === 'received') {
324
- await this.features.cache.operate('ship', [{
325
- id: await generateNewIdAsync(),
326
- action: 'succeedReceiving',
327
- data: {},
328
- filter: {
329
- id: ship.id,
330
- },
331
- }]);
332
- this.setMessage({
333
- type: 'success',
334
- content: this.t('ship.success')
335
- });
336
- }
337
- else {
338
- console.log(mpShipState);
339
- this.setMessage({
340
- type: 'warning',
341
- content: this.t('ship.wait'),
342
- });
343
- }
344
- },
345
- fail() {
346
- console.log('fail');
340
+ }
341
+ if (transactionId) {
342
+ if (wx.openBusinessView) {
343
+ wx.openBusinessView({
344
+ businessType: 'weappOrderConfirm',
345
+ extraData: {
346
+ transaction_id: transactionId,
347
+ },
348
+ success: async () => {
349
+ console.log('success');
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
+ id: await generateNewIdAsync(),
356
+ action: 'succeedReceiving',
357
+ data: {},
358
+ filter: {
359
+ id: ship.id,
360
+ },
361
+ }]);
347
362
  this.setMessage({
348
- type: 'warning',
349
- content: this.t('ship.fail'),
363
+ type: 'success',
364
+ content: this.t('ship.success')
350
365
  });
351
- },
352
- complete() {
353
366
  }
354
- });
355
- }
356
- else {
357
- //引导用户升级微信版本
358
- this.setMessage({
359
- type: 'warning',
360
- content: this.t('ship.update wechat'),
361
- });
362
- }
367
+ else {
368
+ console.log(mpShipState);
369
+ this.reRender();
370
+ // this.setMessage({
371
+ // type: 'warning',
372
+ // content: this.t('ship.wait'),
373
+ // })
374
+ }
375
+ },
376
+ fail: () => {
377
+ console.log('fail');
378
+ this.setMessage({
379
+ type: 'warning',
380
+ content: this.t('ship.fail'),
381
+ });
382
+ },
383
+ complete: () => {
384
+ }
385
+ });
363
386
  }
364
387
  else {
365
- if (!noMessage) {
366
- this.setMessage({
367
- type: 'warning',
368
- content: this.t('no transactionId'),
369
- });
370
- }
388
+ //引导用户升级微信版本
389
+ this.setMessage({
390
+ type: 'warning',
391
+ content: this.t('ship.update wechat'),
392
+ });
371
393
  }
372
394
  }
373
395
  else {
374
396
  if (!noMessage) {
375
397
  this.setMessage({
376
- content: this.t('ship.wait'),
377
398
  type: 'warning',
399
+ content: this.t('no transactionId'),
378
400
  });
379
401
  }
380
402
  }
@@ -398,47 +420,7 @@ export default OakComponent({
398
420
  async ready() {
399
421
  const { oakId } = this.props;
400
422
  assert(typeof oakId === 'string');
401
- const unsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`], async (event, opRecords) => {
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
- });
423
+ const unsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${oakId}`, `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`]);
442
424
  this.setState({
443
425
  unsub,
444
426
  });
@@ -1,7 +1,7 @@
1
1
  <view class="container">
2
2
  <l-notice-bar show="{{!!unreceivedDepositId}}" front-icon-name="notification" end-icon-name="right"
3
3
  bind:lintap="onUnreceivedDepositClickMp" bind:linicontap="onUnreceivedDepositClickMp">
4
- {{t('ship.unconfirm')}}
4
+ <view style="width:100vw">{{t('ship.unconfirm')}}</view>
5
5
  </l-notice-bar>
6
6
  <view class="info" style="background-color:{{bgColor}};color:{{textColor}};">
7
7
  <view
@@ -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 | null;
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,19 @@ export default OakComponent({
129
129
  showCloseConfirmMp: false,
130
130
  showChannelSelectMp: false,
131
131
  unsub: undefined,
132
- unsubShip: undefined,
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, depositConfirmLoading = 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;
144
+ depositConfirmLoading = data?.deposit?.ship?.iState !== 'receiving';
142
145
  }
143
146
  const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
144
147
  const { mode } = this.props;
@@ -180,6 +183,8 @@ export default OakComponent({
180
183
  shipId: data?.deposit?.shipId,
181
184
  ship: data?.deposit?.ship,
182
185
  depositId: data?.depositId,
186
+ showDepositConfirm,
187
+ depositConfirmLoading,
183
188
  };
184
189
  },
185
190
  features: [{
@@ -323,12 +328,14 @@ export default OakComponent({
323
328
  externalId: null,
324
329
  });
325
330
  },
326
- async confirmShipMp(shipId, shipState) {
331
+ async confirmShipMp() {
327
332
  //小程序唤起确认收货组件
333
+ const { pay, ship, depositId } = this.state;
328
334
  if (process.env.OAK_PLATFORM === 'wechatMp') {
329
- const { pay, } = this.state;
330
- if (shipId && shipState === 'receiving') {
331
- if (process.env.NODE_ENV === 'development') {
335
+ const shipId = ship.id;
336
+ const shipState = ship.iState;
337
+ if (process.env.NODE_ENV === 'development') {
338
+ if (shipId && shipState === 'receiving') {
332
339
  await this.features.cache.operate('ship', [{
333
340
  id: await generateNewIdAsync(),
334
341
  action: 'succeedReceiving',
@@ -343,70 +350,66 @@ export default OakComponent({
343
350
  });
344
351
  return;
345
352
  }
346
- if (pay.meta.transaction_id) {
347
- if (wx.openBusinessView) {
348
- wx.openBusinessView({
349
- businessType: 'weappOrderConfirm',
350
- extraData: {
351
- transaction_id: pay.meta.transaction_id,
352
- },
353
- async success() {
354
- console.log('success');
355
- const mpShipState = await this.features.cache.exec('getMpShipState', {
356
- shipId,
357
- });
358
- if (mpShipState === 'received') {
359
- await this.features.cache.operate('ship', [{
360
- id: await generateNewIdAsync(),
361
- action: 'succeedReceiving',
362
- data: {},
363
- filter: {
364
- id: shipId,
365
- },
366
- }]);
367
- this.setMessage({
368
- type: 'success',
369
- content: this.t('ship.success')
370
- });
371
- }
372
- else {
373
- console.log(mpShipState);
374
- this.setMessage({
375
- type: 'warning',
376
- content: this.t('ship.wait'),
377
- });
378
- }
379
- },
380
- fail() {
381
- console.log('fail');
353
+ }
354
+ if (pay.meta.transaction_id) {
355
+ if (wx.openBusinessView) {
356
+ wx.openBusinessView({
357
+ businessType: 'weappOrderConfirm',
358
+ extraData: {
359
+ transaction_id: pay.meta.transaction_id,
360
+ },
361
+ success: async () => {
362
+ console.log('success');
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
+ id: await generateNewIdAsync(),
369
+ action: 'succeedReceiving',
370
+ data: {},
371
+ filter: {
372
+ id: shipId,
373
+ },
374
+ }]);
375
+ this.reRender();
382
376
  this.setMessage({
383
- type: 'warning',
384
- content: this.t('ship.fail'),
377
+ type: 'success',
378
+ content: this.t('ship.success')
385
379
  });
386
- },
387
- complete() {
388
380
  }
389
- });
390
- }
391
- else {
392
- //引导用户升级微信版本
393
- this.setMessage({
394
- type: 'warning',
395
- content: this.t('ship.update wechat'),
396
- });
397
- }
381
+ else {
382
+ console.log(mpShipState);
383
+ // this.setMessage({
384
+ // type: 'warning',
385
+ // content: this.t('ship.wait'),
386
+ // })
387
+ this.reRender();
388
+ }
389
+ },
390
+ fail: () => {
391
+ console.log('fail');
392
+ this.setMessage({
393
+ type: 'warning',
394
+ content: this.t('ship.fail'),
395
+ });
396
+ },
397
+ complete: () => {
398
+ }
399
+ });
398
400
  }
399
401
  else {
402
+ //引导用户升级微信版本
400
403
  this.setMessage({
401
404
  type: 'warning',
402
- content: this.t('no transactionId'),
405
+ content: this.t('ship.update wechat'),
403
406
  });
404
407
  }
405
408
  }
406
409
  else {
407
410
  this.setMessage({
408
411
  type: 'warning',
409
- content: this.t('ship.wait'),
412
+ content: this.t('no transactionId'),
410
413
  });
411
414
  }
412
415
  }
@@ -416,21 +419,17 @@ export default OakComponent({
416
419
  async ready() {
417
420
  const { oakId } = this.props;
418
421
  assert(typeof oakId === 'string');
419
- const unsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`], async (event, opRecords) => {
420
- for (const record of opRecords) {
421
- if (record.a === 'succeedPaying') {
422
- const { e, d } = record;
423
- if (e === 'pay' && d.iState === 'paid') {
424
- await this.features.cache.refresh('pay', {
425
- data: baseProjection,
426
- filter: {
427
- id: oakId,
428
- }
429
- });
430
- }
431
- }
432
- }
433
- });
422
+ const unsub = await this.subDataEvents([
423
+ `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${oakId}`,
424
+ `${DATA_SUBSCRIBER_KEYS.depositStateChanged}-${oakId}`
425
+ ]);
426
+ const { depositId } = this.state;
427
+ if (depositId) {
428
+ const depositUnsub = await this.subDataEvents([`${DATA_SUBSCRIBER_KEYS.shipStateChanged}-${depositId}`]);
429
+ this.setState({
430
+ depositUnsub,
431
+ });
432
+ }
434
433
  this.setState({
435
434
  unsub,
436
435
  });
@@ -438,13 +437,13 @@ export default OakComponent({
438
437
  async mature() {
439
438
  const { ship } = this.state;
440
439
  if (ship?.id && ship?.iState === 'receiving') {
441
- await this.confirmShipMp(ship.id, ship.iState);
440
+ await this.confirmShipMp();
442
441
  }
443
442
  },
444
443
  detached() {
445
- const { unsub, unsubShip } = this.state;
444
+ const { unsub, depositUnsub } = this.state;
446
445
  unsub && unsub();
447
- unsubShip && unsubShip();
446
+ depositUnsub && depositUnsub();
448
447
  },
449
448
  },
450
449
  listeners: {
@@ -458,30 +457,5 @@ export default OakComponent({
458
457
  this.refreshOfflineAccounts();
459
458
  }
460
459
  },
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
460
  },
487
461
  });
@@ -46,7 +46,7 @@
46
46
  }
47
47
 
48
48
  .meta {
49
- margin-top: 40px;
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: 90rpx;
169
+ margin-top: 50rpx;
170
170
 
171
171
  text {
172
172
  margin-top: 40rpx;
@@ -197,4 +197,25 @@
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: 80rpx;
208
+ padding: 24rpx;
209
+ box-sizing: border-box;
210
+ margin-top: 24rpx;
211
+ background-color: #fff;
212
+ border-radius: 16rpx;
213
+ height: 30vh;
214
+
215
+ .depositConfrimText {
216
+ display: flex;
217
+ gap: 18rpx;
218
+ line-height: 48rpx;
219
+ font-size: 32rpx;
220
+ }
200
221
  }
@@ -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' + '.mode')}}</view>
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
@@ -91,7 +91,7 @@
91
91
  </l-form>
92
92
  </block>
93
93
  <block wx:elif="{{pay.entity === 'wpProduct'}}">
94
- <view wx:if="{{pay.iState === 'paid'}}" class="paid">
94
+ <view wx:if="{{pay.iState === 'paid' && !showDepositConfirm}}" class="paid">
95
95
  <l-icon name="success" color="green" size="140" />
96
96
  <view class="text">{{t('success')}}</view>
97
97
  </view>
@@ -107,7 +107,22 @@
107
107
  </block>
108
108
  </block>
109
109
  </view>
110
- <view class="padding"></view>
110
+ <view class="padding">
111
+ <view wx:if="{{showDepositConfirm}}" class="depositConfrimBox">
112
+ <view class="depositConfrimText">
113
+ <l-icon name='warning' size="36" color="#faad14" />
114
+ <span>{{depositConfirmLoading ? t('ship.waiting.tip') : t('ship.confirming.tip')}}</span>
115
+ </view>
116
+ <l-button
117
+ size="long"
118
+ bind:lintap="confirmShipMp"
119
+ loading="{{depositConfirmLoading}}"
120
+ style="width:100%"
121
+ >
122
+ {{depositConfirmLoading ? t('ship.waiting.confirm') : t('ship.confirming.confirm')}}
123
+ </l-button>
124
+ </view>
125
+ </view>
111
126
  <view style="display:flex; align-items: center;justify-content: space-between;gap:16rpx;">
112
127
  <block wx:if="{{closable && !oakExecutable}}">
113
128
  <l-button
@@ -155,7 +170,7 @@
155
170
  </l-button>
156
171
  </view>
157
172
  </block>
158
- <block wx:elif="{{!closable}}">
173
+ <block wx:elif="{{!closable && !showDepositConfirm}}">
159
174
  <l-button
160
175
  type="default"
161
176
  size="long"
@@ -47,7 +47,15 @@
47
47
  "wait": "状态核验中,请等待",
48
48
  "fail": "确认失败,请稍后重试",
49
49
  "update wechat": "请升级微信版本",
50
- "no transactionId": "暂无相关信息,请联系管理员"
50
+ "no transactionId": "暂无相关信息,请联系管理员",
51
+ "waiting": {
52
+ "tip": "由于微信支付限制,充值后必须用户确认收货,正在通知微信服务器……",
53
+ "confirm": "通知微信中……"
54
+ },
55
+ "confirming": {
56
+ "tip": "由于微信支付限制,充值后必须用户确认收货,充值方可完成",
57
+ "confirm": "确认收货"
58
+ }
51
59
  },
52
60
  "successAt": {
53
61
  "title": "登记转账时间",