oak-pay-business 2.2.10 → 2.3.2

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.
Files changed (61) hide show
  1. package/es/aspects/withdraw.d.ts +8 -8
  2. package/es/components/AbstractComponents.d.ts +3 -8
  3. package/es/components/account/detail/index.js +8 -5
  4. package/es/components/pay/detail/index.js +8 -5
  5. package/es/configuration/attrUpdateMatrix.js +8 -0
  6. package/es/context/BackendRuntimeContext.d.ts +1 -1
  7. package/es/entities/Order.d.ts +1 -1
  8. package/es/oak-app-domain/Application/Schema.d.ts +2 -2
  9. package/es/oak-app-domain/Application/Storage.js +0 -1
  10. package/es/oak-app-domain/Article/locales/zh_CN.json +1 -1
  11. package/es/oak-app-domain/ArticleMenu/locales/zh_CN.json +1 -1
  12. package/es/oak-app-domain/ExtraFile/Schema.d.ts +2 -2
  13. package/es/oak-app-domain/ExtraFile/Storage.js +1 -1
  14. package/es/oak-app-domain/Order/Action.d.ts +1 -1
  15. package/es/oak-app-domain/Order/Storage.js +1 -1
  16. package/es/oak-app-domain/Platform/Schema.d.ts +2 -2
  17. package/es/oak-app-domain/Platform/Storage.js +0 -1
  18. package/es/oak-app-domain/SmsTemplate/Schema.d.ts +6 -5
  19. package/es/oak-app-domain/SmsTemplate/Storage.js +2 -4
  20. package/es/oak-app-domain/SmsTemplate/Style.d.ts +3 -0
  21. package/es/oak-app-domain/SmsTemplate/Style.js +10 -0
  22. package/es/oak-app-domain/SmsTemplate/locales/zh_CN.json +1 -1
  23. package/es/oak-app-domain/StyleDict.js +2 -0
  24. package/es/oak-app-domain/System/Schema.d.ts +4 -4
  25. package/es/oak-app-domain/System/Storage.js +0 -2
  26. package/es/oak-app-domain/WechatTemplate/locales/zh_CN.json +1 -1
  27. package/es/triggers/pay.js +50 -47
  28. package/es/triggers/withdraw.d.ts +1 -1
  29. package/es/utils/application.d.ts +1 -1
  30. package/es/utils/pay.js +4 -1
  31. package/es/utils/payClazz/WechatPay/index.d.ts +1 -1
  32. package/es/watchers/pay.js +1 -1
  33. package/lib/aspects/withdraw.d.ts +12 -12
  34. package/lib/components/pay/detail/index.js +8 -5
  35. package/lib/configuration/attrUpdateMatrix.js +8 -0
  36. package/lib/entities/Order.d.ts +1 -1
  37. package/lib/oak-app-domain/Application/Schema.d.ts +2 -2
  38. package/lib/oak-app-domain/Application/Storage.js +0 -1
  39. package/lib/oak-app-domain/Article/locales/zh_CN.json +1 -1
  40. package/lib/oak-app-domain/ArticleMenu/locales/zh_CN.json +1 -1
  41. package/lib/oak-app-domain/ExtraFile/Schema.d.ts +2 -2
  42. package/lib/oak-app-domain/ExtraFile/Storage.js +1 -1
  43. package/lib/oak-app-domain/Order/Action.d.ts +1 -1
  44. package/lib/oak-app-domain/Order/Storage.js +1 -1
  45. package/lib/oak-app-domain/Platform/Schema.d.ts +2 -2
  46. package/lib/oak-app-domain/Platform/Storage.js +0 -1
  47. package/lib/oak-app-domain/SmsTemplate/Schema.d.ts +6 -5
  48. package/lib/oak-app-domain/SmsTemplate/Storage.js +2 -4
  49. package/lib/oak-app-domain/SmsTemplate/Style.d.ts +3 -0
  50. package/lib/oak-app-domain/SmsTemplate/Style.js +13 -0
  51. package/lib/oak-app-domain/SmsTemplate/locales/zh_CN.json +1 -1
  52. package/lib/oak-app-domain/StyleDict.js +52 -50
  53. package/lib/oak-app-domain/System/Schema.d.ts +4 -4
  54. package/lib/oak-app-domain/System/Storage.js +0 -2
  55. package/lib/oak-app-domain/WechatTemplate/locales/zh_CN.json +1 -1
  56. package/lib/triggers/pay.js +50 -47
  57. package/lib/utils/pay.js +4 -1
  58. package/lib/utils/payClazz/WechatPay/index.d.ts +1 -1
  59. package/lib/watchers/pay.js +1 -1
  60. package/package.json +4 -4
  61. package/src/entities/Order.ts +1 -1
@@ -270,8 +270,7 @@ const triggers = [
270
270
  priority: 99,
271
271
  fn: async ({ operation }, context, option) => {
272
272
  const { data, filter, action, id } = operation;
273
- (0, assert_1.default)(typeof filter.id === 'string');
274
- const [pay] = await context.select('pay', {
273
+ const pays = await context.select('pay', {
275
274
  data: {
276
275
  id: 1,
277
276
  orderId: 1,
@@ -291,11 +290,14 @@ const triggers = [
291
290
  },
292
291
  filter,
293
292
  }, { dontCollect: true });
294
- const { orderId, depositId, iState, deposit, application } = pay;
295
- context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
296
- if (orderId) {
297
- return await changeOrderStateByPay({ id: orderId }, context, option);
293
+ for (const pay of pays) {
294
+ const { orderId, depositId, iState, deposit, application } = pay;
295
+ context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
296
+ if (orderId) {
297
+ await changeOrderStateByPay({ id: orderId }, context, option);
298
+ }
298
299
  }
300
+ return pays.length;
299
301
  },
300
302
  },
301
303
  {
@@ -332,26 +334,26 @@ const triggers = [
332
334
  data: pay_1.fullPayProjection,
333
335
  filter,
334
336
  }, {});
335
- (0, assert_1.default)(pays.length === 1);
336
- const [pay] = pays;
337
- const { applicationId, entity, entityId, iState, depositId } = pay;
338
- (0, assert_1.default)(iState === 'unpaid' || iState === 'paying');
339
337
  let cnt = 0;
340
- if (iState === 'paying') {
341
- const payClazz = await (0, payClazz_1.getPayClazz)(entity, entityId, context);
342
- await payClazz.close(pay);
343
- cnt++;
344
- }
345
- if (depositId) {
346
- await context.operate('deposit', {
347
- id: await (0, uuid_1.generateNewIdAsync)(),
348
- action: 'fail',
349
- data: {},
350
- filter: {
351
- id: depositId,
352
- },
353
- }, {});
354
- cnt++;
338
+ for (const pay of pays) {
339
+ const { applicationId, entity, entityId, iState, depositId } = pay;
340
+ (0, assert_1.default)(iState === 'unpaid' || iState === 'paying');
341
+ if (iState === 'paying') {
342
+ const payClazz = await (0, payClazz_1.getPayClazz)(entity, entityId, context);
343
+ await payClazz.close(pay);
344
+ cnt++;
345
+ }
346
+ if (depositId) {
347
+ await context.operate('deposit', {
348
+ id: await (0, uuid_1.generateNewIdAsync)(),
349
+ action: 'fail',
350
+ data: {},
351
+ filter: {
352
+ id: depositId,
353
+ },
354
+ }, {});
355
+ cnt++;
356
+ }
355
357
  }
356
358
  return cnt;
357
359
  },
@@ -591,9 +593,7 @@ const triggers = [
591
593
  when: 'after',
592
594
  fn: async ({ operation }, context, option) => {
593
595
  const { filter } = operation;
594
- const ids = (0, filter_1.getRelevantIds)(filter);
595
- (0, assert_1.default)(ids.length === 1);
596
- const [pay] = await context.select('pay', {
596
+ const pays = await context.select('pay', {
597
597
  data: {
598
598
  id: 1,
599
599
  price: 1,
@@ -601,28 +601,31 @@ const triggers = [
601
601
  entity: 1,
602
602
  entityId: 1,
603
603
  },
604
- filter: {
605
- id: ids[0],
606
- },
604
+ filter,
607
605
  }, {});
608
- if (pay.entity === 'account') {
609
- await context.operate('accountOper', {
610
- id: await (0, uuid_1.generateNewIdAsync)(),
611
- action: 'create',
612
- data: {
606
+ let cnt = 0;
607
+ for (const pay of pays) {
608
+ if (pay.entity === 'account') {
609
+ await context.operate('accountOper', {
613
610
  id: await (0, uuid_1.generateNewIdAsync)(),
614
- accountId: pay.entityId,
615
- entity: 'pay',
616
- entityId: ids[0],
617
- type: 'consumeBack',
618
- totalPlus: pay.paid,
619
- availPlus: pay.paid,
620
- },
621
- }, {});
622
- }
623
- else {
624
- return tryCompleteAccountPay(ids[0], context);
611
+ action: 'create',
612
+ data: {
613
+ id: await (0, uuid_1.generateNewIdAsync)(),
614
+ accountId: pay.entityId,
615
+ entity: 'pay',
616
+ entityId: pay.id,
617
+ type: 'consumeBack',
618
+ totalPlus: pay.paid,
619
+ availPlus: pay.paid,
620
+ },
621
+ }, {});
622
+ cnt++;
623
+ }
624
+ else {
625
+ cnt += await tryCompleteAccountPay(pay.id, context);
626
+ }
625
627
  }
628
+ return cnt;
626
629
  }
627
630
  },
628
631
  /* 影响的地方有点多,先不做了
package/lib/utils/pay.js CHANGED
@@ -161,7 +161,10 @@ async function refreshPayState(pay, context) {
161
161
  filter: {
162
162
  id: pay.id,
163
163
  }
164
- }, { blockTrigger: true });
164
+ }, {
165
+ blockTrigger: true,
166
+ forUpdate: true,
167
+ });
165
168
  pay2 = pays[0];
166
169
  }
167
170
  const { entity, entityId, timeoutAt, price } = pay2;
@@ -1,4 +1,4 @@
1
1
  import WechatPay from './WechatPay';
2
2
  import WechatPayDebug from './WechatPay.debug';
3
- declare const _default: typeof WechatPay | typeof WechatPayDebug;
3
+ declare const _default: typeof WechatPayDebug | typeof WechatPay;
4
4
  export default _default;
@@ -52,7 +52,7 @@ const watchers = [
52
52
  }
53
53
  },
54
54
  {
55
- name: '当pay达到禁止退款期限时,关闭退款允许',
55
+ name: '当pay达到过期期限时,关闭pay',
56
56
  entity: 'pay',
57
57
  filter: () => {
58
58
  const now = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-pay-business",
3
- "version": "2.2.10",
3
+ "version": "2.3.2",
4
4
  "description": "",
5
5
  "files": [
6
6
  "lib/**/*",
@@ -29,9 +29,9 @@
29
29
  "dependencies": {
30
30
  "classnames": "^2.3.1",
31
31
  "dayjs": "^1.11.5",
32
- "oak-domain": "~5.0.15",
33
- "oak-frontend-base": "~5.2.11",
34
- "oak-general-business": "~5.2.6",
32
+ "oak-domain": "~5.0.19",
33
+ "oak-frontend-base": "~5.3.4",
34
+ "oak-general-business": "~5.2.11",
35
35
  "wechat-pay-nodejs": "^0.2.3"
36
36
  },
37
37
  "peerDependencies": {
@@ -28,7 +28,7 @@ export interface Schema extends EntityShape {
28
28
  };
29
29
 
30
30
  export type IAction = 'startPaying' | 'payAll' | 'payPartially' | 'payNone' | 'timeout' | 'cancel' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'refundNone';
31
- export type IState = 'paid' | 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded';
31
+ export type IState = 'unpaid' | 'timeout' | 'cancelled' | 'paying' | 'partiallyPaid' | 'paid' | 'refunding' | 'partiallyRefunded' | 'refunded';
32
32
 
33
33
  export const IActionDef: ActionDef<IAction, IState> = {
34
34
  stm: {