oak-pay-business 3.0.3 → 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.
@@ -319,10 +319,10 @@ export default OakComponent({
319
319
  });
320
320
  const ship = deposit?.ship;
321
321
  if (ship && ship.id) {
322
- if (ship.iState === 'receiving') {
323
- const transactionId = deposit?.pay$deposit?.[0]?.meta?.transaction_id;
324
- console.log('transaction_id', transactionId);
325
- 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') {
326
326
  await this.features.cache.operate('ship', [{
327
327
  id: await generateNewIdAsync(),
328
328
  action: 'succeedReceiving',
@@ -331,92 +331,74 @@ export default OakComponent({
331
331
  id: ship.id,
332
332
  },
333
333
  }]);
334
- await this.features.cache.refresh('deposit', {
335
- data: {
336
- id: 1,
337
- iState: 1,
338
- },
339
- filter: {
340
- id: unreceivedDepositId,
341
- }
342
- });
343
334
  this.setMessage({
344
335
  type: 'success',
345
336
  content: this.t('ship.success')
346
337
  });
347
338
  return;
348
339
  }
349
- if (transactionId) {
350
- if (wx.openBusinessView) {
351
- wx.openBusinessView({
352
- businessType: 'weappOrderConfirm',
353
- extraData: {
354
- transaction_id: transactionId,
355
- },
356
- success: async () => {
357
- console.log('success');
358
- const { result: mpShipState } = await this.features.cache.exec('getMpShipState', {
359
- shipId: ship.id,
360
- });
361
- if (mpShipState === 'received') {
362
- await this.features.cache.operate('ship', [{
363
- id: await generateNewIdAsync(),
364
- action: 'succeedReceiving',
365
- data: {},
366
- filter: {
367
- id: ship.id,
368
- },
369
- }]);
370
- this.setMessage({
371
- type: 'success',
372
- content: this.t('ship.success')
373
- });
374
- }
375
- else {
376
- console.log(mpShipState);
377
- this.reRender();
378
- // this.setMessage({
379
- // type: 'warning',
380
- // content: this.t('ship.wait'),
381
- // })
382
- }
383
- },
384
- fail() {
385
- 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
+ }]);
386
362
  this.setMessage({
387
- type: 'warning',
388
- content: this.t('ship.fail'),
363
+ type: 'success',
364
+ content: this.t('ship.success')
389
365
  });
390
- },
391
- complete() {
392
366
  }
393
- });
394
- }
395
- else {
396
- //引导用户升级微信版本
397
- this.setMessage({
398
- type: 'warning',
399
- content: this.t('ship.update wechat'),
400
- });
401
- }
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
+ });
402
386
  }
403
387
  else {
404
- if (!noMessage) {
405
- this.setMessage({
406
- type: 'warning',
407
- content: this.t('no transactionId'),
408
- });
409
- }
388
+ //引导用户升级微信版本
389
+ this.setMessage({
390
+ type: 'warning',
391
+ content: this.t('ship.update wechat'),
392
+ });
410
393
  }
411
394
  }
412
395
  else {
413
- // if (!noMessage) {
414
- // this.setMessage({
415
- // content: this.t('ship.wait'),
416
- // type: 'warning',
417
- // })
418
- // }
419
- this.reRender();
396
+ if (!noMessage) {
397
+ this.setMessage({
398
+ type: 'warning',
399
+ content: this.t('no transactionId'),
400
+ });
401
+ }
420
402
  }
421
403
  }
422
404
  }
@@ -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
@@ -136,11 +136,12 @@ export default OakComponent({
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
+ let showDepositConfirm = false, depositConfirmLoading = false;
140
140
  if (data?.depositId && data?.deposit?.shipId && data?.deposit?.iState === 'shipped') {
141
141
  iStateStr = this.t('ship.shipped');
142
142
  iStateColor = this.features.style.getColor('deposit', 'iState', data?.deposit?.iState);
143
143
  showDepositConfirm = true;
144
+ depositConfirmLoading = data?.deposit?.ship?.iState !== 'receiving';
144
145
  }
145
146
  const startPayable = iState === 'paying' && !['account', 'offlineAccount'].includes(data.entity) && (PayRoutineDict[data.entity] && PayRoutineDict[data.entity].judgeCanPay(data, this.features));
146
147
  const { mode } = this.props;
@@ -183,6 +184,7 @@ export default OakComponent({
183
184
  ship: data?.deposit?.ship,
184
185
  depositId: data?.depositId,
185
186
  showDepositConfirm,
187
+ depositConfirmLoading,
186
188
  };
187
189
  },
188
190
  features: [{
@@ -332,8 +334,8 @@ export default OakComponent({
332
334
  if (process.env.OAK_PLATFORM === 'wechatMp') {
333
335
  const shipId = ship.id;
334
336
  const shipState = ship.iState;
335
- if (shipId && shipState === 'receiving') {
336
- if (process.env.NODE_ENV === 'development') {
337
+ if (process.env.NODE_ENV === 'development') {
338
+ if (shipId && shipState === 'receiving') {
337
339
  await this.features.cache.operate('ship', [{
338
340
  id: await generateNewIdAsync(),
339
341
  action: 'succeedReceiving',
@@ -342,85 +344,73 @@ export default OakComponent({
342
344
  id: shipId,
343
345
  },
344
346
  }]);
345
- await this.features.cache.refresh('deposit', {
346
- data: {
347
- id: 1,
348
- iState: 1,
349
- },
350
- filter: {
351
- id: depositId,
352
- }
353
- });
354
347
  this.setMessage({
355
348
  type: 'success',
356
349
  content: this.t('ship.success')
357
350
  });
358
351
  return;
359
352
  }
360
- if (pay.meta.transaction_id) {
361
- if (wx.openBusinessView) {
362
- wx.openBusinessView({
363
- businessType: 'weappOrderConfirm',
364
- extraData: {
365
- transaction_id: pay.meta.transaction_id,
366
- },
367
- async success() {
368
- console.log('success');
369
- const mpShipState = await this.features.cache.exec('getMpShipState', {
370
- shipId,
371
- });
372
- if (mpShipState === 'received') {
373
- await this.features.cache.operate('ship', [{
374
- id: await generateNewIdAsync(),
375
- action: 'succeedReceiving',
376
- data: {},
377
- filter: {
378
- id: shipId,
379
- },
380
- }]);
381
- this.reRender();
382
- this.setMessage({
383
- type: 'success',
384
- content: this.t('ship.success')
385
- });
386
- }
387
- else {
388
- console.log(mpShipState);
389
- // this.setMessage({
390
- // type: 'warning',
391
- // content: this.t('ship.wait'),
392
- // })
393
- this.reRender();
394
- }
395
- },
396
- fail() {
397
- 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();
398
376
  this.setMessage({
399
- type: 'warning',
400
- content: this.t('ship.fail'),
377
+ type: 'success',
378
+ content: this.t('ship.success')
401
379
  });
402
- },
403
- complete() {
404
380
  }
405
- });
406
- }
407
- else {
408
- //引导用户升级微信版本
409
- this.setMessage({
410
- type: 'warning',
411
- content: this.t('ship.update wechat'),
412
- });
413
- }
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
+ });
414
400
  }
415
401
  else {
402
+ //引导用户升级微信版本
416
403
  this.setMessage({
417
404
  type: 'warning',
418
- content: this.t('no transactionId'),
405
+ content: this.t('ship.update wechat'),
419
406
  });
420
407
  }
421
408
  }
422
409
  else {
423
- this.reRender();
410
+ this.setMessage({
411
+ type: 'warning',
412
+ content: this.t('no transactionId'),
413
+ });
424
414
  }
425
415
  }
426
416
  }
@@ -204,16 +204,18 @@
204
204
  flex-direction: column;
205
205
  align-items: center;
206
206
  justify-content: center;
207
- row-gap: 32rpx;
208
- padding: 12rpx;
207
+ row-gap: 80rpx;
208
+ padding: 24rpx;
209
209
  box-sizing: border-box;
210
210
  margin-top: 24rpx;
211
211
  background-color: #fff;
212
212
  border-radius: 16rpx;
213
+ height: 30vh;
213
214
 
214
215
  .depositConfrimText {
215
216
  display: flex;
216
217
  gap: 18rpx;
217
- line-height: 36rpx;
218
+ line-height: 48rpx;
219
+ font-size: 32rpx;
218
220
  }
219
221
  }
@@ -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>
@@ -110,15 +110,16 @@
110
110
  <view class="padding">
111
111
  <view wx:if="{{showDepositConfirm}}" class="depositConfrimBox">
112
112
  <view class="depositConfrimText">
113
- <l-icon name='warning' size="32" />
114
- <span>微信支付成功,请点击下方「充值确认」按钮,确认后即可正常使用余额!</span>
113
+ <l-icon name='warning' size="36" color="#faad14" />
114
+ <span>{{depositConfirmLoading ? t('ship.waiting.tip') : t('ship.confirming.tip')}}</span>
115
115
  </view>
116
116
  <l-button
117
- plain="{{true}}"
118
- shape="semicircle"
117
+ size="long"
119
118
  bind:lintap="confirmShipMp"
119
+ loading="{{depositConfirmLoading}}"
120
+ style="width:100%"
120
121
  >
121
- 充值确认
122
+ {{depositConfirmLoading ? t('ship.waiting.confirm') : t('ship.confirming.confirm')}}
122
123
  </l-button>
123
124
  </view>
124
125
  </view>
@@ -169,7 +170,7 @@
169
170
  </l-button>
170
171
  </view>
171
172
  </block>
172
- <block wx:elif="{{!closable}}">
173
+ <block wx:elif="{{!closable && !showDepositConfirm}}">
173
174
  <l-button
174
175
  type="default"
175
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": "登记转账时间",
package/es/data/i18n.js CHANGED
@@ -218,7 +218,15 @@ const i18ns = [
218
218
  "wait": "状态核验中,请等待",
219
219
  "fail": "确认失败,请稍后重试",
220
220
  "update wechat": "请升级微信版本",
221
- "no transactionId": "暂无相关信息,请联系管理员"
221
+ "no transactionId": "暂无相关信息,请联系管理员",
222
+ "waiting": {
223
+ "tip": "由于微信支付限制,充值后必须用户确认收货,正在通知微信服务器……",
224
+ "confirm": "通知微信中……"
225
+ },
226
+ "confirming": {
227
+ "tip": "由于微信支付限制,充值后必须用户确认收货,充值方可完成",
228
+ "confirm": "确认收货"
229
+ }
222
230
  },
223
231
  "successAt": {
224
232
  "title": "登记转账时间",
package/es/utils/ship.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { actionDefDict } from '../oak-app-domain';
1
2
  import { WechatSDK } from 'oak-external-sdk';
2
3
  import { assert } from 'oak-domain/lib/utils/assert';
3
4
  import { generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
@@ -298,7 +299,7 @@ export async function getOrderShipState(context, shipId) {
298
299
  const { orderState, inComplaint } = result;
299
300
  if (!inComplaint) {
300
301
  //未处于纠纷中
301
- let state = undefined;
302
+ let state = 'unknow';
302
303
  // let action = undefined;
303
304
  switch (orderState) {
304
305
  case 1: //待发货
@@ -346,35 +347,29 @@ export async function refreshMpOrderShipState(shipId, context) {
346
347
  blockTrigger: true,
347
348
  forUpdate: true
348
349
  });
350
+ const currentState = ship.iState;
349
351
  const mpState = await getOrderShipState(context, shipId);
350
- // let action = undefined;
351
- // switch (mpState) {
352
- // case 'shipping': //已发货
353
- // action = 'ship';
354
- // break;
355
- // case 'receiving': //已收货
356
- // action = 'startReceiving';
357
- // break;
358
- // case 'received': //已确认
359
- // action = 'succeedReceiving';
360
- // break;
361
- // case 'unknow': //不明
362
- // action = 'unknow';
363
- // break;
364
- // default:
365
- // action = undefined;
366
- // }
367
- if (ship.iState !== mpState) {
368
- return await context.operate('ship', {
369
- id: await generateNewIdAsync(),
370
- action: 'update',
371
- data: {
372
- iState: mpState,
373
- },
374
- filter: {
375
- id: ship.id,
352
+ if (currentState !== mpState) {
353
+ let action = undefined;
354
+ const shipActionDef = actionDefDict.ship.iState.stm;
355
+ for (const a of Object.keys(shipActionDef)) {
356
+ const pState = shipActionDef[a][0];
357
+ const nState = shipActionDef[a][1];
358
+ if (mpState === nState && pState.includes(currentState)) {
359
+ action = a;
360
+ break;
376
361
  }
377
- }, {});
362
+ }
363
+ if (action) {
364
+ return await context.operate('ship', {
365
+ id: await generateNewIdAsync(),
366
+ action,
367
+ data: {},
368
+ filter: {
369
+ id: ship.id,
370
+ }
371
+ }, {});
372
+ }
378
373
  }
379
374
  }
380
375
  /**
package/lib/data/i18n.js CHANGED
@@ -220,7 +220,15 @@ const i18ns = [
220
220
  "wait": "状态核验中,请等待",
221
221
  "fail": "确认失败,请稍后重试",
222
222
  "update wechat": "请升级微信版本",
223
- "no transactionId": "暂无相关信息,请联系管理员"
223
+ "no transactionId": "暂无相关信息,请联系管理员",
224
+ "waiting": {
225
+ "tip": "由于微信支付限制,充值后必须用户确认收货,正在通知微信服务器……",
226
+ "confirm": "通知微信中……"
227
+ },
228
+ "confirming": {
229
+ "tip": "由于微信支付限制,充值后必须用户确认收货,充值方可完成",
230
+ "confirm": "确认收货"
231
+ }
224
232
  },
225
233
  "successAt": {
226
234
  "title": "登记转账时间",
package/lib/utils/ship.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.notifyConfirmReceive = exports.refreshShipState = exports.refreshMpOrderShipState = exports.getOrderShipState = exports.uploadShippingInfo = exports.maskPhone = exports.shipProjection = void 0;
4
+ const oak_app_domain_1 = require("../oak-app-domain");
4
5
  const oak_external_sdk_1 = require("oak-external-sdk");
5
6
  const assert_1 = require("oak-domain/lib/utils/assert");
6
7
  const uuid_1 = require("oak-domain/lib/utils/uuid");
@@ -303,7 +304,7 @@ async function getOrderShipState(context, shipId) {
303
304
  const { orderState, inComplaint } = result;
304
305
  if (!inComplaint) {
305
306
  //未处于纠纷中
306
- let state = undefined;
307
+ let state = 'unknow';
307
308
  // let action = undefined;
308
309
  switch (orderState) {
309
310
  case 1: //待发货
@@ -352,35 +353,29 @@ async function refreshMpOrderShipState(shipId, context) {
352
353
  blockTrigger: true,
353
354
  forUpdate: true
354
355
  });
356
+ const currentState = ship.iState;
355
357
  const mpState = await getOrderShipState(context, shipId);
356
- // let action = undefined;
357
- // switch (mpState) {
358
- // case 'shipping': //已发货
359
- // action = 'ship';
360
- // break;
361
- // case 'receiving': //已收货
362
- // action = 'startReceiving';
363
- // break;
364
- // case 'received': //已确认
365
- // action = 'succeedReceiving';
366
- // break;
367
- // case 'unknow': //不明
368
- // action = 'unknow';
369
- // break;
370
- // default:
371
- // action = undefined;
372
- // }
373
- if (ship.iState !== mpState) {
374
- return await context.operate('ship', {
375
- id: await (0, uuid_1.generateNewIdAsync)(),
376
- action: 'update',
377
- data: {
378
- iState: mpState,
379
- },
380
- filter: {
381
- id: ship.id,
358
+ if (currentState !== mpState) {
359
+ let action = undefined;
360
+ const shipActionDef = oak_app_domain_1.actionDefDict.ship.iState.stm;
361
+ for (const a of Object.keys(shipActionDef)) {
362
+ const pState = shipActionDef[a][0];
363
+ const nState = shipActionDef[a][1];
364
+ if (mpState === nState && pState.includes(currentState)) {
365
+ action = a;
366
+ break;
382
367
  }
383
- }, {});
368
+ }
369
+ if (action) {
370
+ return await context.operate('ship', {
371
+ id: await (0, uuid_1.generateNewIdAsync)(),
372
+ action,
373
+ data: {},
374
+ filter: {
375
+ id: ship.id,
376
+ }
377
+ }, {});
378
+ }
384
379
  }
385
380
  }
386
381
  exports.refreshMpOrderShipState = refreshMpOrderShipState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-pay-business",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -30,9 +30,9 @@
30
30
  "dependencies": {
31
31
  "classnames": "^2.3.1",
32
32
  "dayjs": "^1.11.5",
33
- "oak-domain": "^5.1.24",
33
+ "oak-domain": "^5.1.25",
34
34
  "oak-external-sdk": "^2.3.6",
35
- "oak-frontend-base": "^5.3.31",
35
+ "oak-frontend-base": "^5.3.32",
36
36
  "oak-general-business": "~5.7.5",
37
37
  "react-markdown": "^9.0.3",
38
38
  "wechat-pay-nodejs": "^0.2.3"