@jetthai/cuora 1.1.41 → 1.1.43

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.43](https://github.com/jetthai/cuora-module/compare/v1.1.42...v1.1.43) (2023-01-20)
6
+
7
+ ### [1.1.42](https://github.com/jetthai/cuora-module/compare/v1.1.41...v1.1.42) (2023-01-19)
8
+
5
9
  ### [1.1.41](https://github.com/jetthai/cuora-module/compare/v1.1.40...v1.1.41) (2023-01-19)
6
10
 
7
11
  ### [1.1.40](https://github.com/jetthai/cuora-module/compare/v1.1.34-2...v1.1.40) (2023-01-16)
package/dist/bundle.mjs CHANGED
@@ -3780,25 +3780,25 @@ var payment = {
3780
3780
  method: 'post',
3781
3781
  params: { transferType },
3782
3782
  }),
3783
- getDepositExpectedResult: ({ method, amount, cryptoCurrency }) => ({
3783
+ getDepositExpectedResult: ({ method, amount, cryptoCurrency, promotionsNo }) => ({
3784
3784
  url: `payment/v2/${method}/expected/result`,
3785
3785
  method: 'post',
3786
- params: { transferType: 'DEPOSIT', amount, cryptoCurrency },
3786
+ params: { transferType: 'DEPOSIT', amount, cryptoCurrency, promotionsNo },
3787
3787
  }),
3788
3788
  getWithdrawExpectedResult: ({ method, amount, cryptoNetwork }) => ({
3789
3789
  url: `payment/v2/${method}/expected/result`,
3790
3790
  method: 'post',
3791
3791
  params: { transferType: 'WITHDRAW', amount, cryptoNetwork },
3792
3792
  }),
3793
- submitDepositTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress }) => ({
3793
+ submitDepositTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo }) => ({
3794
3794
  url: `payment/v2/${method}/transaction`,
3795
3795
  method: 'post',
3796
- params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress },
3796
+ params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo },
3797
3797
  }),
3798
- submitDepositTransactionLoadcard: ({ method, amount, card_type, card_code, card_seri }) => ({
3798
+ submitDepositTransactionLoadcard: ({ method, amount, card_type, card_code, card_seri, promotionsNo }) => ({
3799
3799
  url: `payment/v2/${method}/transaction`,
3800
3800
  method: 'post',
3801
- params: { transferType: 'DEPOSIT', amount, card_type, card_code, card_seri },
3801
+ params: { transferType: 'DEPOSIT', amount, card_type, card_code, card_seri, promotionsNo },
3802
3802
  }),
3803
3803
  submitDepositTransactionBank: ({
3804
3804
  method,
@@ -3810,6 +3810,7 @@ var payment = {
3810
3810
  targetAccountNumber,
3811
3811
  depositTime = '1234567890',
3812
3812
  receipt,
3813
+ promotionsNo,
3813
3814
  }) => ({
3814
3815
  url: `payment/v2/${method}/transaction`,
3815
3816
  method: 'post',
@@ -3823,12 +3824,13 @@ var payment = {
3823
3824
  targetAccountNumber,
3824
3825
  depositTime,
3825
3826
  receipt,
3827
+ promotionsNo,
3826
3828
  },
3827
3829
  }),
3828
- submitDepositTransaction: ({ method, amount }) => ({
3830
+ submitDepositTransaction: ({ method, amount, promotionsNo }) => ({
3829
3831
  url: `payment/v2/${method}/transaction`,
3830
3832
  method: 'post',
3831
- params: { transferType: 'DEPOSIT', amount },
3833
+ params: { transferType: 'DEPOSIT', amount, promotionsNo },
3832
3834
  }),
3833
3835
  submitWithdrawTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress }) => ({
3834
3836
  url: `payment/v2/${method}/transaction`,
@@ -3838,7 +3840,14 @@ var payment = {
3838
3840
  submitWithdrawTransactionVN: ({ method, amount, applyerBankCode, applyerAccountNumber, branch, holderName }) => ({
3839
3841
  url: `payment/v2/${method}/transaction`,
3840
3842
  method: 'post',
3841
- params: { transferType: 'WITHDRAW', amount, applyerBankCode, applyerAccountNumber, branch, holderName },
3843
+ params: {
3844
+ transferType: 'WITHDRAW',
3845
+ amount,
3846
+ applyerBankCode,
3847
+ applyerAccountNumber,
3848
+ branch,
3849
+ holderName,
3850
+ },
3842
3851
  }),
3843
3852
  submitWithdrawTransactionAmb: ({ method, amount }) => ({
3844
3853
  url: `payment/v2/${method}/transaction`,
@@ -16222,6 +16231,9 @@ function manual_vn (request) {
16222
16231
 
16223
16232
  calculation: null,
16224
16233
  processing: null,
16234
+
16235
+ // use for wallet mode 3
16236
+ promotion: null,
16225
16237
  },
16226
16238
  states: {
16227
16239
  loading: {
@@ -16260,8 +16272,20 @@ function manual_vn (request) {
16260
16272
  },
16261
16273
  },
16262
16274
  step1: {
16263
- initial: 'idle',
16275
+ initial: 'promotion',
16264
16276
  states: {
16277
+ promotion: {
16278
+ always: [
16279
+ {
16280
+ target: 'calculating',
16281
+ actions: 'setPromotionDefaultAmount',
16282
+ cond: 'hasMinPromotionDeposit',
16283
+ },
16284
+ {
16285
+ target: 'idle',
16286
+ },
16287
+ ],
16288
+ },
16265
16289
  idle: {},
16266
16290
  calculating: {
16267
16291
  invoke: {
@@ -16374,6 +16398,11 @@ function manual_vn (request) {
16374
16398
  submitted: {},
16375
16399
  fail: {},
16376
16400
  },
16401
+ on: {
16402
+ SET_PROMOTION: {
16403
+ actions: 'setPromotion',
16404
+ },
16405
+ },
16377
16406
  },
16378
16407
  {
16379
16408
  actions: {
@@ -16475,6 +16504,16 @@ function manual_vn (request) {
16475
16504
  receipt: event.data,
16476
16505
  }
16477
16506
  }),
16507
+ setPromotion: assign((context, event) => {
16508
+ return {
16509
+ promotion: event.data,
16510
+ }
16511
+ }),
16512
+ setPromotionDefaultAmount: assign((context, event) => {
16513
+ return {
16514
+ amount: context.promotion.minimumAmount,
16515
+ }
16516
+ }),
16478
16517
  },
16479
16518
  guards: {
16480
16519
  isCalculable: (context, event) => {
@@ -16494,6 +16533,9 @@ function manual_vn (request) {
16494
16533
  isProcessing: (context, event) => {
16495
16534
  return context.processing
16496
16535
  },
16536
+ hasMinPromotionDeposit: (context, event) => {
16537
+ return context.promotion?.minimumAmount
16538
+ },
16497
16539
  },
16498
16540
  services: {
16499
16541
  fetchInitData: async (context, event) => {
@@ -16511,11 +16553,17 @@ function manual_vn (request) {
16511
16553
  return await request.send(payment.getBankList(method))
16512
16554
  },
16513
16555
  fetchCalculation: async (context, event) => {
16514
- const { method, amount } = context;
16515
- return await request.send(payment.getDepositExpectedResult({ method, amount }))
16556
+ const { method, amount, promotion } = context;
16557
+ return await request.send(
16558
+ payment.getDepositExpectedResult({
16559
+ method,
16560
+ amount,
16561
+ promotionsNo: promotion.activityNo,
16562
+ })
16563
+ )
16516
16564
  },
16517
16565
  submitDeposit: async (context, event) => {
16518
- const { method, amount, selectedHouseBank, selectedUserBank, userAccountNumber, userAccountName, depositTime, receipt } = context;
16566
+ const { method, amount, selectedHouseBank, selectedUserBank, userAccountNumber, userAccountName, depositTime, receipt, promotion } = context;
16519
16567
  return await request.send(
16520
16568
  payment.submitDepositTransactionBank({
16521
16569
  method,
@@ -16527,6 +16575,7 @@ function manual_vn (request) {
16527
16575
  applyerHolderName: userAccountName,
16528
16576
  depositTime,
16529
16577
  receipt,
16578
+ promotionsNo: promotion.activityNo,
16530
16579
  })
16531
16580
  )
16532
16581
  },
@@ -16937,6 +16986,9 @@ function qrcode_v2 (request) {
16937
16986
  result: null,
16938
16987
 
16939
16988
  grandTotalEnable: 1,
16989
+
16990
+ // use for wallet mode 3
16991
+ promotion: null,
16940
16992
  },
16941
16993
  states: {
16942
16994
  loading: {
@@ -16952,7 +17004,15 @@ function qrcode_v2 (request) {
16952
17004
  },
16953
17005
  },
16954
17006
  checking: {
16955
- always: [{ target: 'newWalletMode', cond: 'isNewWalletMode' }, { target: 'defaultMode' }],
17007
+ always: [
17008
+ { target: 'newWalletMode', cond: 'isNewWalletMode' },
17009
+ {
17010
+ target: 'debouncing',
17011
+ actions: 'setPromotionDefaultAmount',
17012
+ cond: 'hasMinPromotionDeposit',
17013
+ },
17014
+ { target: 'defaultMode' },
17015
+ ],
16956
17016
  },
16957
17017
  newWalletMode: {
16958
17018
  initial: 'loaded',
@@ -17091,9 +17151,16 @@ function qrcode_v2 (request) {
17091
17151
  defaultMode: {
17092
17152
  entry: 'reset',
17093
17153
  on: {
17094
- SELECT_QRCODE: {
17095
- actions: 'setQrcode',
17096
- },
17154
+ SELECT_QRCODE: [
17155
+ {
17156
+ target: 'debouncing',
17157
+ actions: ['setQrcode', 'setPromotionDefaultAmount'],
17158
+ cond: 'hasMinPromotionDeposit',
17159
+ },
17160
+ {
17161
+ actions: 'setQrcode',
17162
+ },
17163
+ ],
17097
17164
  SELECT_AMOUNT: [
17098
17165
  {
17099
17166
  target: 'debouncing',
@@ -17227,6 +17294,11 @@ function qrcode_v2 (request) {
17227
17294
  },
17228
17295
  },
17229
17296
  },
17297
+ on: {
17298
+ SET_PROMOTION: {
17299
+ actions: 'setPromotion',
17300
+ },
17301
+ },
17230
17302
  },
17231
17303
  {
17232
17304
  actions: {
@@ -17284,11 +17356,25 @@ function qrcode_v2 (request) {
17284
17356
  result: event.data,
17285
17357
  }
17286
17358
  }),
17359
+ setPromotion: assign((context, event) => {
17360
+ const promotion = event.data;
17361
+ return {
17362
+ promotion,
17363
+ }
17364
+ }),
17365
+ setPromotionDefaultAmount: assign((context, event) => {
17366
+ return {
17367
+ selectedAmount: context.promotion.minimumAmount,
17368
+ }
17369
+ }),
17287
17370
  },
17288
17371
  guards: {
17289
17372
  isNewWalletMode: (context, event) => {
17290
17373
  return context.siteConfig?.walletMode === '2'
17291
17374
  },
17375
+ hasMinPromotionDeposit: (context, event) => {
17376
+ return context.promotion?.minimumAmount
17377
+ },
17292
17378
  },
17293
17379
  services: {
17294
17380
  fetchInitData: async (context, event) => {
@@ -17300,20 +17386,22 @@ function qrcode_v2 (request) {
17300
17386
  return { siteConfig, paymentDetail }
17301
17387
  },
17302
17388
  fetchCalculation: async (context, event) => {
17303
- const { currentMethod, selectedAmount } = context;
17389
+ const { currentMethod, selectedAmount, promotion } = context;
17304
17390
  return await request.send(
17305
17391
  payment.getDepositExpectedResult({
17306
17392
  method: currentMethod,
17307
17393
  amount: selectedAmount,
17394
+ promotionsNo: promotion.activityNo,
17308
17395
  })
17309
17396
  )
17310
17397
  },
17311
17398
  submitDeposit: async (context, event) => {
17312
- const { currentMethod, selectedAmount } = context;
17399
+ const { currentMethod, selectedAmount, promotion } = context;
17313
17400
  return await request.send(
17314
17401
  payment.submitDepositTransaction({
17315
17402
  method: currentMethod,
17316
17403
  amount: selectedAmount,
17404
+ promotionsNo: promotion.activityNo,
17317
17405
  })
17318
17406
  )
17319
17407
  },
@@ -18651,6 +18739,9 @@ function direct (request) {
18651
18739
  currentMethod: null,
18652
18740
  amount: null,
18653
18741
  result: null,
18742
+
18743
+ // use for wallet mode 3
18744
+ promotion: null,
18654
18745
  },
18655
18746
  states: {
18656
18747
  loading: {
@@ -18672,7 +18763,7 @@ function direct (request) {
18672
18763
  invoke: {
18673
18764
  src: 'fetchBanksList',
18674
18765
  onDone: {
18675
- target: '#direct.loaded',
18766
+ target: '#direct.promotion',
18676
18767
  actions: 'setBanks',
18677
18768
  },
18678
18769
  onError: {
@@ -18682,6 +18773,18 @@ function direct (request) {
18682
18773
  },
18683
18774
  },
18684
18775
  },
18776
+ promotion: {
18777
+ always: [
18778
+ {
18779
+ target: 'calculating',
18780
+ actions: 'setPromotionDefaultAmount',
18781
+ cond: 'hasMinPromotionDeposit',
18782
+ },
18783
+ {
18784
+ target: 'loaded',
18785
+ },
18786
+ ],
18787
+ },
18685
18788
  loaded: {
18686
18789
  on: {
18687
18790
  SELECT_DIRECT: {
@@ -18734,6 +18837,11 @@ function direct (request) {
18734
18837
  submitted: {},
18735
18838
  fail: {},
18736
18839
  },
18840
+ on: {
18841
+ SET_PROMOTION: {
18842
+ actions: 'setPromotion',
18843
+ },
18844
+ },
18737
18845
  },
18738
18846
  {
18739
18847
  actions: {
@@ -18795,6 +18903,16 @@ function direct (request) {
18795
18903
  result: event.data,
18796
18904
  }
18797
18905
  }),
18906
+ setPromotion: assign((context, event) => {
18907
+ return {
18908
+ promotion: event.data,
18909
+ }
18910
+ }),
18911
+ setPromotionDefaultAmount: assign((context, event) => {
18912
+ return {
18913
+ amount: context.promotion.minimumAmount,
18914
+ }
18915
+ }),
18798
18916
  },
18799
18917
  guards: {
18800
18918
  isCalculable: (context, event) => {
@@ -18809,6 +18927,9 @@ function direct (request) {
18809
18927
  const { amount, currentMethod, selectedBank } = context;
18810
18928
  return amount && currentMethod && selectedBank?.bankCode
18811
18929
  },
18930
+ hasMinPromotionDeposit: (context, event) => {
18931
+ return context.promotion?.minimumAmount
18932
+ },
18812
18933
  },
18813
18934
  services: {
18814
18935
  fetchInitData: async (context, event) => {
@@ -18820,22 +18941,24 @@ function direct (request) {
18820
18941
  return await request.send(payment.getBankList(method))
18821
18942
  },
18822
18943
  fetchCalculation: async (context, event) => {
18823
- const { currentMethod, amount } = context;
18944
+ const { currentMethod, amount, promotion } = context;
18824
18945
 
18825
18946
  return await request.send(
18826
18947
  payment.getDepositExpectedResult({
18827
18948
  method: currentMethod,
18828
18949
  amount,
18950
+ promotionsNo: promotion.activityNo,
18829
18951
  })
18830
18952
  )
18831
18953
  },
18832
18954
  submitDeposit: async (context, event) => {
18833
- const { currentMethod, amount, selectedBank } = context;
18955
+ const { currentMethod, amount, selectedBank, promotion } = context;
18834
18956
  return await request.send(
18835
18957
  payment.submitDepositTransactionBank({
18836
18958
  method: currentMethod,
18837
18959
  amount,
18838
18960
  applyerBankCode: selectedBank.bankCode,
18961
+ promotionsNo: promotion.activityNo,
18839
18962
  })
18840
18963
  )
18841
18964
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.41",
3
+ "version": "1.1.43",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -49,25 +49,25 @@ export default {
49
49
  method: 'post',
50
50
  params: { transferType },
51
51
  }),
52
- getDepositExpectedResult: ({ method, amount, cryptoCurrency }) => ({
52
+ getDepositExpectedResult: ({ method, amount, cryptoCurrency, promotionsNo }) => ({
53
53
  url: `payment/v2/${method}/expected/result`,
54
54
  method: 'post',
55
- params: { transferType: 'DEPOSIT', amount, cryptoCurrency },
55
+ params: { transferType: 'DEPOSIT', amount, cryptoCurrency, promotionsNo },
56
56
  }),
57
57
  getWithdrawExpectedResult: ({ method, amount, cryptoNetwork }) => ({
58
58
  url: `payment/v2/${method}/expected/result`,
59
59
  method: 'post',
60
60
  params: { transferType: 'WITHDRAW', amount, cryptoNetwork },
61
61
  }),
62
- submitDepositTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress }) => ({
62
+ submitDepositTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo }) => ({
63
63
  url: `payment/v2/${method}/transaction`,
64
64
  method: 'post',
65
- params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress },
65
+ params: { transferType: 'DEPOSIT', amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo },
66
66
  }),
67
- submitDepositTransactionLoadcard: ({ method, amount, card_type, card_code, card_seri }) => ({
67
+ submitDepositTransactionLoadcard: ({ method, amount, card_type, card_code, card_seri, promotionsNo }) => ({
68
68
  url: `payment/v2/${method}/transaction`,
69
69
  method: 'post',
70
- params: { transferType: 'DEPOSIT', amount, card_type, card_code, card_seri },
70
+ params: { transferType: 'DEPOSIT', amount, card_type, card_code, card_seri, promotionsNo },
71
71
  }),
72
72
  submitDepositTransactionBank: ({
73
73
  method,
@@ -79,6 +79,7 @@ export default {
79
79
  targetAccountNumber,
80
80
  depositTime = '1234567890',
81
81
  receipt,
82
+ promotionsNo,
82
83
  }) => ({
83
84
  url: `payment/v2/${method}/transaction`,
84
85
  method: 'post',
@@ -92,12 +93,13 @@ export default {
92
93
  targetAccountNumber,
93
94
  depositTime,
94
95
  receipt,
96
+ promotionsNo,
95
97
  },
96
98
  }),
97
- submitDepositTransaction: ({ method, amount }) => ({
99
+ submitDepositTransaction: ({ method, amount, promotionsNo }) => ({
98
100
  url: `payment/v2/${method}/transaction`,
99
101
  method: 'post',
100
- params: { transferType: 'DEPOSIT', amount },
102
+ params: { transferType: 'DEPOSIT', amount, promotionsNo },
101
103
  }),
102
104
  submitWithdrawTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, targetAddress }) => ({
103
105
  url: `payment/v2/${method}/transaction`,
@@ -107,7 +109,14 @@ export default {
107
109
  submitWithdrawTransactionVN: ({ method, amount, applyerBankCode, applyerAccountNumber, branch, holderName }) => ({
108
110
  url: `payment/v2/${method}/transaction`,
109
111
  method: 'post',
110
- params: { transferType: 'WITHDRAW', amount, applyerBankCode, applyerAccountNumber, branch, holderName },
112
+ params: {
113
+ transferType: 'WITHDRAW',
114
+ amount,
115
+ applyerBankCode,
116
+ applyerAccountNumber,
117
+ branch,
118
+ holderName,
119
+ },
111
120
  }),
112
121
  submitWithdrawTransactionAmb: ({ method, amount }) => ({
113
122
  url: `payment/v2/${method}/transaction`,
@@ -17,6 +17,9 @@ export default function (request) {
17
17
  currentMethod: null,
18
18
  amount: null,
19
19
  result: null,
20
+
21
+ // use for wallet mode 3
22
+ promotion: null,
20
23
  },
21
24
  states: {
22
25
  loading: {
@@ -38,7 +41,7 @@ export default function (request) {
38
41
  invoke: {
39
42
  src: 'fetchBanksList',
40
43
  onDone: {
41
- target: '#direct.loaded',
44
+ target: '#direct.promotion',
42
45
  actions: 'setBanks',
43
46
  },
44
47
  onError: {
@@ -48,6 +51,18 @@ export default function (request) {
48
51
  },
49
52
  },
50
53
  },
54
+ promotion: {
55
+ always: [
56
+ {
57
+ target: 'calculating',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: 'hasMinPromotionDeposit',
60
+ },
61
+ {
62
+ target: 'loaded',
63
+ },
64
+ ],
65
+ },
51
66
  loaded: {
52
67
  on: {
53
68
  SELECT_DIRECT: {
@@ -100,6 +115,11 @@ export default function (request) {
100
115
  submitted: {},
101
116
  fail: {},
102
117
  },
118
+ on: {
119
+ SET_PROMOTION: {
120
+ actions: 'setPromotion',
121
+ },
122
+ },
103
123
  },
104
124
  {
105
125
  actions: {
@@ -161,6 +181,16 @@ export default function (request) {
161
181
  result: event.data,
162
182
  }
163
183
  }),
184
+ setPromotion: assign((context, event) => {
185
+ return {
186
+ promotion: event.data,
187
+ }
188
+ }),
189
+ setPromotionDefaultAmount: assign((context, event) => {
190
+ return {
191
+ amount: context.promotion.minimumAmount,
192
+ }
193
+ }),
164
194
  },
165
195
  guards: {
166
196
  isCalculable: (context, event) => {
@@ -175,6 +205,9 @@ export default function (request) {
175
205
  const { amount, currentMethod, selectedBank } = context
176
206
  return amount && currentMethod && selectedBank?.bankCode
177
207
  },
208
+ hasMinPromotionDeposit: (context, event) => {
209
+ return context.promotion?.minimumAmount
210
+ },
178
211
  },
179
212
  services: {
180
213
  fetchInitData: async (context, event) => {
@@ -186,22 +219,24 @@ export default function (request) {
186
219
  return await request.send(payment.getBankList(method))
187
220
  },
188
221
  fetchCalculation: async (context, event) => {
189
- const { currentMethod, amount } = context
222
+ const { currentMethod, amount, promotion } = context
190
223
 
191
224
  return await request.send(
192
225
  payment.getDepositExpectedResult({
193
226
  method: currentMethod,
194
227
  amount,
228
+ promotionsNo: promotion.activityNo,
195
229
  })
196
230
  )
197
231
  },
198
232
  submitDeposit: async (context, event) => {
199
- const { currentMethod, amount, selectedBank } = context
233
+ const { currentMethod, amount, selectedBank, promotion } = context
200
234
  return await request.send(
201
235
  payment.submitDepositTransactionBank({
202
236
  method: currentMethod,
203
237
  amount,
204
238
  applyerBankCode: selectedBank.bankCode,
239
+ promotionsNo: promotion.activityNo,
205
240
  })
206
241
  )
207
242
  },
@@ -28,6 +28,9 @@ export default function (request) {
28
28
 
29
29
  calculation: null,
30
30
  processing: null,
31
+
32
+ // use for wallet mode 3
33
+ promotion: null,
31
34
  },
32
35
  states: {
33
36
  loading: {
@@ -66,8 +69,20 @@ export default function (request) {
66
69
  },
67
70
  },
68
71
  step1: {
69
- initial: 'idle',
72
+ initial: 'promotion',
70
73
  states: {
74
+ promotion: {
75
+ always: [
76
+ {
77
+ target: 'calculating',
78
+ actions: 'setPromotionDefaultAmount',
79
+ cond: 'hasMinPromotionDeposit',
80
+ },
81
+ {
82
+ target: 'idle',
83
+ },
84
+ ],
85
+ },
71
86
  idle: {},
72
87
  calculating: {
73
88
  invoke: {
@@ -180,6 +195,11 @@ export default function (request) {
180
195
  submitted: {},
181
196
  fail: {},
182
197
  },
198
+ on: {
199
+ SET_PROMOTION: {
200
+ actions: 'setPromotion',
201
+ },
202
+ },
183
203
  },
184
204
  {
185
205
  actions: {
@@ -281,6 +301,16 @@ export default function (request) {
281
301
  receipt: event.data,
282
302
  }
283
303
  }),
304
+ setPromotion: assign((context, event) => {
305
+ return {
306
+ promotion: event.data,
307
+ }
308
+ }),
309
+ setPromotionDefaultAmount: assign((context, event) => {
310
+ return {
311
+ amount: context.promotion.minimumAmount,
312
+ }
313
+ }),
284
314
  },
285
315
  guards: {
286
316
  isCalculable: (context, event) => {
@@ -300,6 +330,9 @@ export default function (request) {
300
330
  isProcessing: (context, event) => {
301
331
  return context.processing
302
332
  },
333
+ hasMinPromotionDeposit: (context, event) => {
334
+ return context.promotion?.minimumAmount
335
+ },
303
336
  },
304
337
  services: {
305
338
  fetchInitData: async (context, event) => {
@@ -317,11 +350,17 @@ export default function (request) {
317
350
  return await request.send(payment.getBankList(method))
318
351
  },
319
352
  fetchCalculation: async (context, event) => {
320
- const { method, amount } = context
321
- return await request.send(payment.getDepositExpectedResult({ method, amount }))
353
+ const { method, amount, promotion } = context
354
+ return await request.send(
355
+ payment.getDepositExpectedResult({
356
+ method,
357
+ amount,
358
+ promotionsNo: promotion.activityNo,
359
+ })
360
+ )
322
361
  },
323
362
  submitDeposit: async (context, event) => {
324
- const { method, amount, selectedHouseBank, selectedUserBank, userAccountNumber, userAccountName, depositTime, receipt } = context
363
+ const { method, amount, selectedHouseBank, selectedUserBank, userAccountNumber, userAccountName, depositTime, receipt, promotion } = context
325
364
  return await request.send(
326
365
  payment.submitDepositTransactionBank({
327
366
  method,
@@ -333,6 +372,7 @@ export default function (request) {
333
372
  applyerHolderName: userAccountName,
334
373
  depositTime,
335
374
  receipt,
375
+ promotionsNo: promotion.activityNo,
336
376
  })
337
377
  )
338
378
  },
@@ -25,6 +25,9 @@ export default function (request) {
25
25
  result: null,
26
26
 
27
27
  grandTotalEnable: 1,
28
+
29
+ // use for wallet mode 3
30
+ promotion: null,
28
31
  },
29
32
  states: {
30
33
  loading: {
@@ -40,7 +43,15 @@ export default function (request) {
40
43
  },
41
44
  },
42
45
  checking: {
43
- always: [{ target: 'newWalletMode', cond: 'isNewWalletMode' }, { target: 'defaultMode' }],
46
+ always: [
47
+ { target: 'newWalletMode', cond: 'isNewWalletMode' },
48
+ {
49
+ target: 'debouncing',
50
+ actions: 'setPromotionDefaultAmount',
51
+ cond: 'hasMinPromotionDeposit',
52
+ },
53
+ { target: 'defaultMode' },
54
+ ],
44
55
  },
45
56
  newWalletMode: {
46
57
  initial: 'loaded',
@@ -179,9 +190,16 @@ export default function (request) {
179
190
  defaultMode: {
180
191
  entry: 'reset',
181
192
  on: {
182
- SELECT_QRCODE: {
183
- actions: 'setQrcode',
184
- },
193
+ SELECT_QRCODE: [
194
+ {
195
+ target: 'debouncing',
196
+ actions: ['setQrcode', 'setPromotionDefaultAmount'],
197
+ cond: 'hasMinPromotionDeposit',
198
+ },
199
+ {
200
+ actions: 'setQrcode',
201
+ },
202
+ ],
185
203
  SELECT_AMOUNT: [
186
204
  {
187
205
  target: 'debouncing',
@@ -315,6 +333,11 @@ export default function (request) {
315
333
  },
316
334
  },
317
335
  },
336
+ on: {
337
+ SET_PROMOTION: {
338
+ actions: 'setPromotion',
339
+ },
340
+ },
318
341
  },
319
342
  {
320
343
  actions: {
@@ -372,11 +395,25 @@ export default function (request) {
372
395
  result: event.data,
373
396
  }
374
397
  }),
398
+ setPromotion: assign((context, event) => {
399
+ const promotion = event.data
400
+ return {
401
+ promotion,
402
+ }
403
+ }),
404
+ setPromotionDefaultAmount: assign((context, event) => {
405
+ return {
406
+ selectedAmount: context.promotion.minimumAmount,
407
+ }
408
+ }),
375
409
  },
376
410
  guards: {
377
411
  isNewWalletMode: (context, event) => {
378
412
  return context.siteConfig?.walletMode === '2'
379
413
  },
414
+ hasMinPromotionDeposit: (context, event) => {
415
+ return context.promotion?.minimumAmount
416
+ },
380
417
  },
381
418
  services: {
382
419
  fetchInitData: async (context, event) => {
@@ -388,20 +425,22 @@ export default function (request) {
388
425
  return { siteConfig, paymentDetail }
389
426
  },
390
427
  fetchCalculation: async (context, event) => {
391
- const { currentMethod, selectedAmount } = context
428
+ const { currentMethod, selectedAmount, promotion } = context
392
429
  return await request.send(
393
430
  payment.getDepositExpectedResult({
394
431
  method: currentMethod,
395
432
  amount: selectedAmount,
433
+ promotionsNo: promotion.activityNo,
396
434
  })
397
435
  )
398
436
  },
399
437
  submitDeposit: async (context, event) => {
400
- const { currentMethod, selectedAmount } = context
438
+ const { currentMethod, selectedAmount, promotion } = context
401
439
  return await request.send(
402
440
  payment.submitDepositTransaction({
403
441
  method: currentMethod,
404
442
  amount: selectedAmount,
443
+ promotionsNo: promotion.activityNo,
405
444
  })
406
445
  )
407
446
  },