@nuskin/ns-shop 7.0.5-cx1-13272.7 → 7.0.5-cx1-13272.8
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/package.json +1 -1
- package/src/salesEventService.js +60 -45
package/package.json
CHANGED
package/src/salesEventService.js
CHANGED
|
@@ -139,28 +139,41 @@ function getActiveTicketEvents() {
|
|
|
139
139
|
return events;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
async function getEventStatus(eventsToCheck = []
|
|
142
|
+
async function getEventStatus(eventsToCheck = []) {
|
|
143
143
|
const eventStatus = {};
|
|
144
144
|
const promises = [];
|
|
145
145
|
|
|
146
146
|
eventsToCheck.forEach((toCheck) => {
|
|
147
|
-
promises.push(
|
|
147
|
+
promises.push(_checkForMissingTicket(toCheck));
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
await Promise.allSettled(promises);
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
eventsToCheck.forEach((eventName) => {
|
|
153
153
|
let activeStatus = false;
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
const ticketInfo = eventTicketInfoMap[eventName];
|
|
155
|
+
if (ticketInfo.ticket) {
|
|
156
|
+
const status = _decodeStatus(ticketInfo.ticket.status);
|
|
156
157
|
if ((status.eventStatus === PRE_EVENT && status.preWaitTime <= 30000) ||
|
|
157
158
|
status.eventStatus === IN_EVENT) {
|
|
158
159
|
activeStatus = true;
|
|
159
160
|
}
|
|
160
|
-
eventStatus[response.value.eventName] = activeStatus;
|
|
161
161
|
}
|
|
162
|
+
eventStatus[eventName] = activeStatus;
|
|
162
163
|
});
|
|
163
164
|
|
|
165
|
+
// responses.forEach((response) => {
|
|
166
|
+
// let activeStatus = false;
|
|
167
|
+
// if (response.status === 'fulfilled' && response.value) {
|
|
168
|
+
// const status = _decodeStatus(response.value.status);
|
|
169
|
+
// if ((status.eventStatus === PRE_EVENT && status.preWaitTime <= 30000) ||
|
|
170
|
+
// status.eventStatus === IN_EVENT) {
|
|
171
|
+
// activeStatus = true;
|
|
172
|
+
// }
|
|
173
|
+
// eventStatus[response.value.eventName] = activeStatus;
|
|
174
|
+
// }
|
|
175
|
+
// });
|
|
176
|
+
|
|
164
177
|
return eventStatus;
|
|
165
178
|
}
|
|
166
179
|
|
|
@@ -172,35 +185,35 @@ async function getEventStatus(eventsToCheck = [], externalId = 'none') {
|
|
|
172
185
|
* @returns {Promise<*>} a new or updated ticket for the specified event
|
|
173
186
|
* @private
|
|
174
187
|
*/
|
|
175
|
-
async function _getTempTicket(eventName, externalId) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
188
|
+
// async function _getTempTicket(eventName, externalId) {
|
|
189
|
+
// let ticket;
|
|
190
|
+
|
|
191
|
+
// try {
|
|
192
|
+
// let method = 'POST',
|
|
193
|
+
// seParams = _getSeParams(eventName, false),
|
|
194
|
+
// response = await axios({
|
|
195
|
+
// method: method,
|
|
196
|
+
// url: `${_getAwsUrl(eventName, null)}?orderEventCheck=${externalId}${seParams}`,
|
|
197
|
+
// headers: _getHeaders(),
|
|
198
|
+
// timeout: 7000
|
|
199
|
+
// });
|
|
200
|
+
|
|
201
|
+
// ticket = response.data.salesEventResponse;
|
|
202
|
+
// } catch (err) {
|
|
203
|
+
// if (err.response && err.response.data.status === 404) {
|
|
204
|
+
// console.error(`getTempTicket - unable to get a temporary ticket for ${eventName}`);
|
|
205
|
+
// throw err;
|
|
206
|
+
// } else {
|
|
207
|
+
// console.error(`getTempTicket error or timeout - waiting to try again for ${eventName}`);
|
|
208
|
+
// // Timed out or some other error
|
|
209
|
+
// // Wait and then call again.
|
|
210
|
+
// await _wait(3000);
|
|
211
|
+
// ticket = await _getTempTicket(eventName);
|
|
212
|
+
// }
|
|
213
|
+
// }
|
|
214
|
+
|
|
215
|
+
// return ticket;
|
|
216
|
+
// }
|
|
204
217
|
|
|
205
218
|
function logAnalyticInfo(tag, eventName, data = {}) {
|
|
206
219
|
const user = UserService.getUser();
|
|
@@ -813,6 +826,12 @@ function getStorageItem(key) {
|
|
|
813
826
|
return item;
|
|
814
827
|
}
|
|
815
828
|
|
|
829
|
+
async function _checkForMissingTicket(eventName) {
|
|
830
|
+
if (mktEventConfigMap[eventName] && !eventTicketInfoMap[eventName]) {
|
|
831
|
+
await _initEventTicketInfo(eventName);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
816
835
|
/**
|
|
817
836
|
* This initializes an interval timer which checks to see if the browser (computer)
|
|
818
837
|
* went to sleep. It's intention is to update the wait timer if it has.
|
|
@@ -828,7 +847,7 @@ async function _initializePolling() {
|
|
|
828
847
|
const slept = now > (lastTime + TIMEOUT + 3000)
|
|
829
848
|
|
|
830
849
|
// if polling market config, only reload it every 30 seconds
|
|
831
|
-
if (slept || pollMarketConfig && intervalCnt %
|
|
850
|
+
if (slept || pollMarketConfig && intervalCnt % 6 === 0) {
|
|
832
851
|
await _loadMarketEventConfig(true);
|
|
833
852
|
_marketStatusCheck();
|
|
834
853
|
}
|
|
@@ -849,16 +868,12 @@ async function _initializePolling() {
|
|
|
849
868
|
});
|
|
850
869
|
|
|
851
870
|
// check for missing tickets
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (mktEventConfigMap[eventInfo.eventName] && !eventTicketInfoMap[eventInfo.eventName]) {
|
|
856
|
-
await _initEventTicketInfo(eventInfo.eventName);
|
|
857
|
-
}
|
|
858
|
-
}
|
|
871
|
+
const activeEvents = await _getActiveEvents();
|
|
872
|
+
for (const eventInfo of activeEvents) {
|
|
873
|
+
await _checkForMissingTicket(eventInfo.eventName);
|
|
859
874
|
}
|
|
860
875
|
|
|
861
|
-
lastTime =
|
|
876
|
+
lastTime = now;
|
|
862
877
|
}, TIMEOUT);
|
|
863
878
|
}
|
|
864
879
|
}
|