@pisell/pisellos 2.3.127 → 2.3.128
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/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +19 -58
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +12 -24
- package/dist/modules/Customer/index.js +3 -6
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +2 -2
- package/dist/modules/Discount/index.js +151 -37
- package/dist/modules/Discount/types.d.ts +5 -36
- package/dist/modules/Order/index.d.ts +2 -7
- package/dist/modules/Order/index.js +331 -480
- package/dist/modules/Order/utils/orderCollectionIdentity.js +12 -16
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Order/utils/weighedProduct.js +94 -0
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +65 -104
- package/dist/modules/Payment/types.d.ts +1 -21
- package/dist/modules/Payment/types.js +0 -2
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +47 -80
- package/dist/modules/Rules/index.d.ts +2 -2
- package/dist/modules/Rules/index.js +190 -482
- package/dist/modules/Rules/types.d.ts +2 -4
- package/dist/server/modules/order/types.d.ts +0 -2
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -3
- package/dist/solution/BaseSales/index.js +77 -44
- package/dist/solution/BaseSales/types.d.ts +7 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +126 -141
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
- package/dist/solution/BaseSales/utils.js +3 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +3 -2
- package/dist/solution/BookingTicket/index.js +63 -60
- package/dist/solution/BookingTicket/types.d.ts +1 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +147 -338
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +6 -19
- package/dist/solution/ScanOrder/utils.js +3 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -2
- package/dist/solution/ShopDiscount/index.js +42 -99
- package/dist/solution/ShopDiscount/utils.d.ts +2 -4
- package/dist/solution/ShopDiscount/utils.js +23 -43
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -35
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -13
- package/lib/modules/Customer/index.js +1 -5
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +2 -2
- package/lib/modules/Discount/index.js +129 -23
- package/lib/modules/Discount/types.d.ts +5 -36
- package/lib/modules/Order/index.d.ts +2 -7
- package/lib/modules/Order/index.js +109 -222
- package/lib/modules/Order/utils/orderCollectionIdentity.js +11 -14
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Order/utils/weighedProduct.js +89 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +6 -41
- package/lib/modules/Payment/types.d.ts +1 -21
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +9 -29
- package/lib/modules/Rules/index.d.ts +2 -2
- package/lib/modules/Rules/index.js +114 -359
- package/lib/modules/Rules/types.d.ts +2 -4
- package/lib/server/modules/order/types.d.ts +0 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -3
- package/lib/solution/BaseSales/index.js +17 -11
- package/lib/solution/BaseSales/types.d.ts +7 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +4 -12
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
- package/lib/solution/BaseSales/utils.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +3 -2
- package/lib/solution/BookingTicket/index.js +33 -36
- package/lib/solution/BookingTicket/types.d.ts +1 -5
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -2
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +42 -174
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +4 -8
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -6
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +3 -11
- package/lib/solution/ScanOrder/utils.js +2 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -2
- package/lib/solution/ShopDiscount/index.js +9 -55
- package/lib/solution/ShopDiscount/utils.d.ts +2 -4
- package/lib/solution/ShopDiscount/utils.js +25 -42
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -49
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -43
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -141
|
@@ -11,24 +11,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
import { buildRequiresDetailPayload } from "../addProductDecision";
|
|
14
|
+
import { isWalkInCustomer } from "../cartView";
|
|
14
15
|
import { countScanVariantMatches, genScanProductValues, isScanProductBundle, isScanProductOption } from "./scanProductValues";
|
|
15
16
|
|
|
16
17
|
/** applyGlobalScan 所需的 BookingTicket 运行时能力 */
|
|
17
|
-
|
|
18
|
-
function getRealCustomerId(customer) {
|
|
19
|
-
var _customer$id;
|
|
20
|
-
var customerId = Number((_customer$id = customer === null || customer === void 0 ? void 0 : customer.id) !== null && _customer$id !== void 0 ? _customer$id : customer === null || customer === void 0 ? void 0 : customer.customer_id);
|
|
21
|
-
return Number.isInteger(customerId) && customerId > 1 ? customerId : undefined;
|
|
22
|
-
}
|
|
23
|
-
function getWalletAssetCustomerId(asset) {
|
|
24
|
-
var _asset$customer_id, _asset$holder;
|
|
25
|
-
var customerId = Number((_asset$customer_id = asset === null || asset === void 0 ? void 0 : asset.customer_id) !== null && _asset$customer_id !== void 0 ? _asset$customer_id : asset === null || asset === void 0 || (_asset$holder = asset.holder) === null || _asset$holder === void 0 ? void 0 : _asset$holder.customer_id);
|
|
26
|
-
return Number.isInteger(customerId) && customerId > 1 ? customerId : undefined;
|
|
27
|
-
}
|
|
28
|
-
function getErrorMessage(error) {
|
|
29
|
-
return error instanceof Error ? error.message : String(error || '');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
18
|
/**
|
|
33
19
|
* 处理单条扫码商品的加车决策(含弹窗链)。
|
|
34
20
|
*/
|
|
@@ -205,477 +191,300 @@ export function applyGlobalScan(_x14, _x15, _x16) {
|
|
|
205
191
|
return _applyGlobalScan.apply(this, arguments);
|
|
206
192
|
}
|
|
207
193
|
function _applyGlobalScan() {
|
|
208
|
-
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
209
|
-
var searchType, data, scanCode,
|
|
210
|
-
return _regeneratorRuntime().wrap(function
|
|
211
|
-
while (1) switch (
|
|
194
|
+
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(host, formatted, bridge) {
|
|
195
|
+
var searchType, data, scanCode, _bridge$onNotify2, _bridge$onNotify, _host$refreshWalletAs, _bridge$onNotify5, snapshot, scannedCustomerIsWalkIn, trySelectWalletAsset, _result$isAccepted, _walletSelection, result, walletSelection, _data$id, _promotionResult$isAc, promotionResult, list, _bridge$onNotify6, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify7, _data$order_id, _data$business_code, orderId, _bridge$onNotify8;
|
|
196
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
197
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
212
198
|
case 0:
|
|
213
|
-
searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode
|
|
199
|
+
searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
|
|
214
200
|
if (!(searchType === 'wallet')) {
|
|
215
|
-
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
currentCustomer = host.getOrderCustomerSnapshot();
|
|
219
|
-
currentCustomerId = getRealCustomerId(currentCustomer);
|
|
220
|
-
_customer = data;
|
|
221
|
-
if (!isCrossShopWallet) {
|
|
222
|
-
_context6.next = 20;
|
|
201
|
+
_context5.next = 8;
|
|
223
202
|
break;
|
|
224
203
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
228
|
-
if (!(sourceCustomerId === undefined || !host.resolveCustomerById)) {
|
|
229
|
-
_context6.next = 10;
|
|
204
|
+
if (data) {
|
|
205
|
+
_context5.next = 5;
|
|
230
206
|
break;
|
|
231
207
|
}
|
|
232
208
|
bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
233
|
-
return
|
|
234
|
-
status: 'failed',
|
|
235
|
-
reason: 'invalid_data'
|
|
236
|
-
});
|
|
237
|
-
case 10:
|
|
238
|
-
_context6.prev = 10;
|
|
239
|
-
_context6.next = 13;
|
|
240
|
-
return host.resolveCustomerById(sourceCustomerId);
|
|
241
|
-
case 13:
|
|
242
|
-
_customer = _context6.sent;
|
|
243
|
-
_context6.next = 20;
|
|
244
|
-
break;
|
|
245
|
-
case 16:
|
|
246
|
-
_context6.prev = 16;
|
|
247
|
-
_context6.t0 = _context6["catch"](10);
|
|
248
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', getErrorMessage(_context6.t0) || 'pisell2.text.scan-global-failed');
|
|
249
|
-
return _context6.abrupt("return", {
|
|
250
|
-
status: 'failed',
|
|
251
|
-
reason: 'invalid_data'
|
|
252
|
-
});
|
|
253
|
-
case 20:
|
|
254
|
-
_customerId = (_getRealCustomerId = getRealCustomerId(_customer)) !== null && _getRealCustomerId !== void 0 ? _getRealCustomerId : !isCrossShopWallet ? getRealCustomerId({
|
|
255
|
-
id: formattedCustomerId
|
|
256
|
-
}) : undefined;
|
|
257
|
-
if (!(!_customer || _customerId === undefined)) {
|
|
258
|
-
_context6.next = 24;
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
262
|
-
return _context6.abrupt("return", {
|
|
263
|
-
status: 'failed',
|
|
264
|
-
reason: 'invalid_data'
|
|
265
|
-
});
|
|
266
|
-
case 24:
|
|
267
|
-
orderCustomer = _customer.id === undefined || _customer.id === null ? _objectSpread(_objectSpread({}, _customer), {}, {
|
|
268
|
-
id: _customerId
|
|
269
|
-
}) : _customer;
|
|
270
|
-
if (!(currentCustomerId === _customerId)) {
|
|
271
|
-
_context6.next = 27;
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
return _context6.abrupt("return", {
|
|
275
|
-
status: 'success',
|
|
276
|
-
kind: 'customer'
|
|
277
|
-
});
|
|
278
|
-
case 27:
|
|
279
|
-
if (!(currentCustomerId !== undefined)) {
|
|
280
|
-
_context6.next = 41;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
if (bridge !== null && bridge !== void 0 && bridge.requestCustomerSwitch) {
|
|
284
|
-
_context6.next = 30;
|
|
285
|
-
break;
|
|
286
|
-
}
|
|
287
|
-
return _context6.abrupt("return", {
|
|
288
|
-
status: 'success',
|
|
289
|
-
kind: 'customer'
|
|
290
|
-
});
|
|
291
|
-
case 30:
|
|
292
|
-
_context6.prev = 30;
|
|
293
|
-
_context6.next = 33;
|
|
294
|
-
return bridge.requestCustomerSwitch(orderCustomer);
|
|
295
|
-
case 33:
|
|
296
|
-
switched = _context6.sent;
|
|
297
|
-
return _context6.abrupt("return", switched ? {
|
|
298
|
-
status: 'success',
|
|
299
|
-
kind: 'customer'
|
|
300
|
-
} : {
|
|
301
|
-
status: 'cancelled'
|
|
302
|
-
});
|
|
303
|
-
case 37:
|
|
304
|
-
_context6.prev = 37;
|
|
305
|
-
_context6.t1 = _context6["catch"](30);
|
|
306
|
-
(_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'fail', getErrorMessage(_context6.t1) || 'pisell2.text.scan-global-failed');
|
|
307
|
-
return _context6.abrupt("return", {
|
|
209
|
+
return _context5.abrupt("return", {
|
|
308
210
|
status: 'failed',
|
|
309
211
|
reason: 'invalid_data'
|
|
310
212
|
});
|
|
311
|
-
case
|
|
312
|
-
host.setOrderCustomer(
|
|
313
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
314
|
-
return
|
|
213
|
+
case 5:
|
|
214
|
+
host.setOrderCustomer(data);
|
|
215
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'success', 'pisell2.text.add-client-success');
|
|
216
|
+
return _context5.abrupt("return", {
|
|
315
217
|
status: 'success',
|
|
316
218
|
kind: 'customer'
|
|
317
219
|
});
|
|
318
|
-
case
|
|
220
|
+
case 8:
|
|
319
221
|
if (!(searchType === 'walletPass')) {
|
|
320
|
-
|
|
321
|
-
break;
|
|
322
|
-
}
|
|
323
|
-
if (!isWalletPassUnavailableAtStore) {
|
|
324
|
-
_context6.next = 48;
|
|
222
|
+
_context5.next = 42;
|
|
325
223
|
break;
|
|
326
224
|
}
|
|
327
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', 'pisell2.text.wallet-pass-not-available-at-store');
|
|
328
|
-
return _context6.abrupt("return", {
|
|
329
|
-
status: 'failed',
|
|
330
|
-
reason: 'invalid_data'
|
|
331
|
-
});
|
|
332
|
-
case 48:
|
|
333
225
|
snapshot = host.getOrderCustomerSnapshot();
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(
|
|
337
|
-
var
|
|
338
|
-
var
|
|
226
|
+
scannedCustomerIsWalkIn = isWalkInCustomer(data);
|
|
227
|
+
trySelectWalletAsset = /*#__PURE__*/function () {
|
|
228
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
229
|
+
var _bridge$onNotify4;
|
|
230
|
+
var walletResult, _bridge$onNotify3;
|
|
339
231
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
340
232
|
while (1) switch (_context4.prev = _context4.next) {
|
|
341
|
-
case 0:
|
|
342
|
-
if (!(getRealCustomerId(activeCustomer) !== undefined)) {
|
|
343
|
-
_context4.next = 2;
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
return _context4.abrupt("return", {
|
|
347
|
-
resolveFailed: false,
|
|
348
|
-
customerBound: false
|
|
349
|
-
});
|
|
350
|
-
case 2:
|
|
351
|
-
assetCustomerId = (_getWalletAssetCustom = getWalletAssetCustomerId(asset)) !== null && _getWalletAssetCustom !== void 0 ? _getWalletAssetCustom : getRealCustomerId({
|
|
352
|
-
id: formattedCustomerId
|
|
353
|
-
});
|
|
354
|
-
customer = null;
|
|
355
|
-
if (!(assetCustomerId !== undefined)) {
|
|
356
|
-
_context4.next = 19;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
if (host.resolveCustomerById) {
|
|
360
|
-
_context4.next = 8;
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
364
|
-
return _context4.abrupt("return", {
|
|
365
|
-
resolveFailed: true,
|
|
366
|
-
customerBound: false
|
|
367
|
-
});
|
|
368
|
-
case 8:
|
|
369
|
-
_context4.prev = 8;
|
|
370
|
-
_context4.next = 11;
|
|
371
|
-
return host.resolveCustomerById(assetCustomerId);
|
|
372
|
-
case 11:
|
|
373
|
-
customer = _context4.sent;
|
|
374
|
-
_context4.next = 19;
|
|
375
|
-
break;
|
|
376
|
-
case 14:
|
|
377
|
-
_context4.prev = 14;
|
|
378
|
-
_context4.t0 = _context4["catch"](8);
|
|
379
|
-
console.warn('[GlobalScan] Wallet asset customer lookup failed', _context4.t0);
|
|
380
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'fail', getErrorMessage(_context4.t0) || 'pisell2.text.scan-global-failed');
|
|
381
|
-
return _context4.abrupt("return", {
|
|
382
|
-
resolveFailed: true,
|
|
383
|
-
customerBound: false
|
|
384
|
-
});
|
|
385
|
-
case 19:
|
|
386
|
-
customerId = getRealCustomerId(customer);
|
|
387
|
-
if (!(!customer || customerId === undefined)) {
|
|
388
|
-
_context4.next = 23;
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
if (assetCustomerId !== undefined) {
|
|
392
|
-
bridge === null || bridge === void 0 || (_bridge$onNotify9 = bridge.onNotify) === null || _bridge$onNotify9 === void 0 || _bridge$onNotify9.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
393
|
-
}
|
|
394
|
-
return _context4.abrupt("return", {
|
|
395
|
-
resolveFailed: assetCustomerId !== undefined,
|
|
396
|
-
customerBound: false
|
|
397
|
-
});
|
|
398
|
-
case 23:
|
|
399
|
-
orderCustomer = customer.id === undefined || customer.id === null ? _objectSpread(_objectSpread({}, customer), {}, {
|
|
400
|
-
id: customerId
|
|
401
|
-
}) : customer;
|
|
402
|
-
host.setOrderCustomer(orderCustomer);
|
|
403
|
-
activeCustomer = orderCustomer;
|
|
404
|
-
_context4.next = 28;
|
|
405
|
-
return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
|
|
406
|
-
preserveSelection: false,
|
|
407
|
-
retainSearchResultCodes: [scanCode]
|
|
408
|
-
});
|
|
409
|
-
case 28:
|
|
410
|
-
return _context4.abrupt("return", {
|
|
411
|
-
resolveFailed: false,
|
|
412
|
-
customerBound: true
|
|
413
|
-
});
|
|
414
|
-
case 29:
|
|
415
|
-
case "end":
|
|
416
|
-
return _context4.stop();
|
|
417
|
-
}
|
|
418
|
-
}, _callee4, null, [[8, 14]]);
|
|
419
|
-
}));
|
|
420
|
-
return function bindWalletPassCustomer(_x17) {
|
|
421
|
-
return _ref2.apply(this, arguments);
|
|
422
|
-
};
|
|
423
|
-
}();
|
|
424
|
-
trySelectWalletAsset = /*#__PURE__*/function () {
|
|
425
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
426
|
-
var walletResult, bindResult, _bridge$onNotify10, _bridge$onNotify11;
|
|
427
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
428
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
429
233
|
case 0:
|
|
430
234
|
if (host.scanWalletAsset) {
|
|
431
|
-
|
|
235
|
+
_context4.next = 2;
|
|
432
236
|
break;
|
|
433
237
|
}
|
|
434
|
-
return
|
|
238
|
+
return _context4.abrupt("return", null);
|
|
435
239
|
case 2:
|
|
436
|
-
|
|
240
|
+
_context4.next = 4;
|
|
437
241
|
return host.scanWalletAsset(scanCode).catch(function (error) {
|
|
438
242
|
console.warn('[GlobalScan] Wallet asset lookup failed', error);
|
|
439
243
|
return null;
|
|
440
244
|
});
|
|
441
245
|
case 4:
|
|
442
|
-
walletResult =
|
|
246
|
+
walletResult = _context4.sent;
|
|
443
247
|
if (walletResult) {
|
|
444
|
-
|
|
248
|
+
_context4.next = 7;
|
|
445
249
|
break;
|
|
446
250
|
}
|
|
447
|
-
return
|
|
251
|
+
return _context4.abrupt("return", null);
|
|
448
252
|
case 7:
|
|
449
253
|
if (!(walletResult.type !== 'normalCode' || !walletResult.asset)) {
|
|
450
|
-
|
|
254
|
+
_context4.next = 9;
|
|
451
255
|
break;
|
|
452
256
|
}
|
|
453
|
-
return
|
|
257
|
+
return _context4.abrupt("return", null);
|
|
454
258
|
case 9:
|
|
455
|
-
_context5.next = 11;
|
|
456
|
-
return bindWalletPassCustomer(walletResult.asset);
|
|
457
|
-
case 11:
|
|
458
|
-
bindResult = _context5.sent;
|
|
459
259
|
if (!walletResult.selected) {
|
|
460
|
-
|
|
260
|
+
_context4.next = 12;
|
|
461
261
|
break;
|
|
462
262
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
return _context5.abrupt("return", {
|
|
263
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'success');
|
|
264
|
+
return _context4.abrupt("return", {
|
|
467
265
|
status: 'success',
|
|
468
266
|
kind: 'promotion'
|
|
469
267
|
});
|
|
470
|
-
case
|
|
268
|
+
case 12:
|
|
471
269
|
// 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
return _context5.abrupt("return", {
|
|
270
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
|
|
271
|
+
return _context4.abrupt("return", {
|
|
476
272
|
status: 'failed',
|
|
477
273
|
reason: 'invalid_data'
|
|
478
274
|
});
|
|
479
|
-
case
|
|
275
|
+
case 14:
|
|
480
276
|
case "end":
|
|
481
|
-
return
|
|
277
|
+
return _context4.stop();
|
|
482
278
|
}
|
|
483
|
-
},
|
|
279
|
+
}, _callee4);
|
|
484
280
|
}));
|
|
485
281
|
return function trySelectWalletAsset() {
|
|
486
|
-
return
|
|
282
|
+
return _ref2.apply(this, arguments);
|
|
487
283
|
};
|
|
488
|
-
}();
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
_context6.next = 57;
|
|
284
|
+
}();
|
|
285
|
+
if (!(isWalkInCustomer(snapshot) || scannedCustomerIsWalkIn)) {
|
|
286
|
+
_context5.next = 26;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
_context5.next = 15;
|
|
495
290
|
return trySelectWalletAsset();
|
|
496
|
-
case
|
|
497
|
-
|
|
498
|
-
if (!
|
|
499
|
-
|
|
291
|
+
case 15:
|
|
292
|
+
_walletSelection = _context5.sent;
|
|
293
|
+
if (!_walletSelection) {
|
|
294
|
+
_context5.next = 18;
|
|
500
295
|
break;
|
|
501
296
|
}
|
|
502
|
-
return
|
|
503
|
-
case
|
|
297
|
+
return _context5.abrupt("return", _walletSelection);
|
|
298
|
+
case 18:
|
|
504
299
|
if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
|
|
505
|
-
|
|
300
|
+
_context5.next = 20;
|
|
506
301
|
break;
|
|
507
302
|
}
|
|
508
|
-
return
|
|
303
|
+
return _context5.abrupt("return", {
|
|
509
304
|
status: 'failed',
|
|
510
305
|
reason: 'no_bridge'
|
|
511
306
|
});
|
|
512
|
-
case
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
307
|
+
case 20:
|
|
308
|
+
_context5.next = 22;
|
|
309
|
+
return bridge.applyPromotionCode(scanCode);
|
|
310
|
+
case 22:
|
|
311
|
+
result = _context5.sent;
|
|
312
|
+
if (!((_result$isAccepted = result === null || result === void 0 ? void 0 : result.isAccepted) !== null && _result$isAccepted !== void 0 ? _result$isAccepted : result === null || result === void 0 ? void 0 : result.isAvailable)) {
|
|
313
|
+
_context5.next = 25;
|
|
516
314
|
break;
|
|
517
315
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
316
|
+
return _context5.abrupt("return", {
|
|
317
|
+
status: 'success',
|
|
318
|
+
kind: 'promotion'
|
|
521
319
|
});
|
|
522
|
-
case
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
320
|
+
case 25:
|
|
321
|
+
return _context5.abrupt("return", {
|
|
322
|
+
status: 'failed',
|
|
323
|
+
reason: 'invalid_data'
|
|
324
|
+
});
|
|
325
|
+
case 26:
|
|
326
|
+
host.setOrderCustomer(data);
|
|
327
|
+
_context5.next = 29;
|
|
328
|
+
return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
|
|
329
|
+
preserveSelection: false
|
|
330
|
+
});
|
|
331
|
+
case 29:
|
|
332
|
+
_context5.next = 31;
|
|
333
|
+
return trySelectWalletAsset();
|
|
334
|
+
case 31:
|
|
335
|
+
walletSelection = _context5.sent;
|
|
336
|
+
if (!walletSelection) {
|
|
337
|
+
_context5.next = 34;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
return _context5.abrupt("return", walletSelection);
|
|
341
|
+
case 34:
|
|
342
|
+
if (!(bridge !== null && bridge !== void 0 && bridge.applyPromotionCode)) {
|
|
343
|
+
_context5.next = 40;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
_context5.next = 37;
|
|
347
|
+
return bridge.applyPromotionCode(scanCode, Number((_data$id = data === null || data === void 0 ? void 0 : data.id) !== null && _data$id !== void 0 ? _data$id : data === null || data === void 0 ? void 0 : data.customer_id) || undefined);
|
|
348
|
+
case 37:
|
|
349
|
+
promotionResult = _context5.sent;
|
|
533
350
|
if (!((_promotionResult$isAc = promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAccepted) !== null && _promotionResult$isAc !== void 0 ? _promotionResult$isAc : promotionResult === null || promotionResult === void 0 ? void 0 : promotionResult.isAvailable)) {
|
|
534
|
-
|
|
351
|
+
_context5.next = 40;
|
|
535
352
|
break;
|
|
536
353
|
}
|
|
537
|
-
return
|
|
354
|
+
return _context5.abrupt("return", {
|
|
538
355
|
status: 'success',
|
|
539
356
|
kind: 'promotion'
|
|
540
357
|
});
|
|
541
|
-
case
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
break;
|
|
545
|
-
}
|
|
546
|
-
return _context6.abrupt("return", {
|
|
358
|
+
case 40:
|
|
359
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'success', 'pisell2.text.add-client-success');
|
|
360
|
+
return _context5.abrupt("return", {
|
|
547
361
|
status: 'success',
|
|
548
362
|
kind: 'customer'
|
|
549
363
|
});
|
|
550
|
-
case
|
|
551
|
-
return _context6.abrupt("return", {
|
|
552
|
-
status: 'failed',
|
|
553
|
-
reason: 'invalid_data'
|
|
554
|
-
});
|
|
555
|
-
case 78:
|
|
364
|
+
case 42:
|
|
556
365
|
if (!(searchType === 'product' || searchType === 'local_product')) {
|
|
557
|
-
|
|
366
|
+
_context5.next = 75;
|
|
558
367
|
break;
|
|
559
368
|
}
|
|
560
369
|
list = data === null || data === void 0 ? void 0 : data.list;
|
|
561
370
|
if (!(!Array.isArray(list) || list.length === 0)) {
|
|
562
|
-
|
|
371
|
+
_context5.next = 47;
|
|
563
372
|
break;
|
|
564
373
|
}
|
|
565
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
566
|
-
return
|
|
374
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
375
|
+
return _context5.abrupt("return", {
|
|
567
376
|
status: 'failed',
|
|
568
377
|
reason: 'invalid_data'
|
|
569
378
|
});
|
|
570
|
-
case
|
|
379
|
+
case 47:
|
|
571
380
|
addedCount = 0;
|
|
572
381
|
_iterator = _createForOfIteratorHelper(list);
|
|
573
|
-
|
|
382
|
+
_context5.prev = 49;
|
|
574
383
|
_iterator.s();
|
|
575
|
-
case
|
|
384
|
+
case 51:
|
|
576
385
|
if ((_step = _iterator.n()).done) {
|
|
577
|
-
|
|
386
|
+
_context5.next = 63;
|
|
578
387
|
break;
|
|
579
388
|
}
|
|
580
389
|
_item = _step.value;
|
|
581
|
-
|
|
390
|
+
_context5.next = 55;
|
|
582
391
|
return processScannedProductItem(host, _item, scanCode, bridge);
|
|
583
|
-
case
|
|
584
|
-
outcome =
|
|
392
|
+
case 55:
|
|
393
|
+
outcome = _context5.sent;
|
|
585
394
|
if (outcome === 'added') {
|
|
586
395
|
addedCount += 1;
|
|
587
396
|
}
|
|
588
397
|
if (!(outcome === 'cancelled')) {
|
|
589
|
-
|
|
398
|
+
_context5.next = 59;
|
|
590
399
|
break;
|
|
591
400
|
}
|
|
592
|
-
return
|
|
401
|
+
return _context5.abrupt("return", {
|
|
593
402
|
status: 'cancelled'
|
|
594
403
|
});
|
|
595
|
-
case
|
|
404
|
+
case 59:
|
|
596
405
|
if (!(outcome === 'pending')) {
|
|
597
|
-
|
|
406
|
+
_context5.next = 61;
|
|
598
407
|
break;
|
|
599
408
|
}
|
|
600
|
-
return
|
|
409
|
+
return _context5.abrupt("return", {
|
|
601
410
|
status: 'pending',
|
|
602
411
|
kind: 'requiresDetail'
|
|
603
412
|
});
|
|
604
|
-
case
|
|
605
|
-
|
|
413
|
+
case 61:
|
|
414
|
+
_context5.next = 51;
|
|
606
415
|
break;
|
|
607
|
-
case
|
|
608
|
-
|
|
416
|
+
case 63:
|
|
417
|
+
_context5.next = 68;
|
|
609
418
|
break;
|
|
610
|
-
case
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
_iterator.e(
|
|
614
|
-
case
|
|
615
|
-
|
|
419
|
+
case 65:
|
|
420
|
+
_context5.prev = 65;
|
|
421
|
+
_context5.t0 = _context5["catch"](49);
|
|
422
|
+
_iterator.e(_context5.t0);
|
|
423
|
+
case 68:
|
|
424
|
+
_context5.prev = 68;
|
|
616
425
|
_iterator.f();
|
|
617
|
-
return
|
|
618
|
-
case
|
|
426
|
+
return _context5.finish(68);
|
|
427
|
+
case 71:
|
|
619
428
|
if (!(addedCount > 0)) {
|
|
620
|
-
|
|
429
|
+
_context5.next = 74;
|
|
621
430
|
break;
|
|
622
431
|
}
|
|
623
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
624
|
-
return
|
|
432
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'success');
|
|
433
|
+
return _context5.abrupt("return", {
|
|
625
434
|
status: 'success',
|
|
626
435
|
kind: 'products',
|
|
627
436
|
meta: {
|
|
628
437
|
count: addedCount
|
|
629
438
|
}
|
|
630
439
|
});
|
|
631
|
-
case
|
|
632
|
-
return
|
|
440
|
+
case 74:
|
|
441
|
+
return _context5.abrupt("return", {
|
|
633
442
|
status: 'failed',
|
|
634
443
|
reason: 'no_bridge'
|
|
635
444
|
});
|
|
636
|
-
case
|
|
445
|
+
case 75:
|
|
637
446
|
if (!(searchType === 'order')) {
|
|
638
|
-
|
|
447
|
+
_context5.next = 84;
|
|
639
448
|
break;
|
|
640
449
|
}
|
|
641
450
|
orderId = (_data$order_id = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id !== void 0 ? _data$order_id : data === null || data === void 0 ? void 0 : data.id;
|
|
642
451
|
if (orderId) {
|
|
643
|
-
|
|
452
|
+
_context5.next = 80;
|
|
644
453
|
break;
|
|
645
454
|
}
|
|
646
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
647
|
-
return
|
|
455
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
456
|
+
return _context5.abrupt("return", {
|
|
648
457
|
status: 'failed',
|
|
649
458
|
reason: 'invalid_data'
|
|
650
459
|
});
|
|
651
|
-
case
|
|
460
|
+
case 80:
|
|
652
461
|
if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
|
|
653
|
-
|
|
462
|
+
_context5.next = 82;
|
|
654
463
|
break;
|
|
655
464
|
}
|
|
656
|
-
return
|
|
465
|
+
return _context5.abrupt("return", {
|
|
657
466
|
status: 'pending',
|
|
658
467
|
kind: 'openOrder'
|
|
659
468
|
});
|
|
660
|
-
case
|
|
469
|
+
case 82:
|
|
661
470
|
bridge.openOrder({
|
|
662
471
|
order_id: Number(orderId),
|
|
663
472
|
business_code: (_data$business_code = data === null || data === void 0 ? void 0 : data.business_code) !== null && _data$business_code !== void 0 ? _data$business_code : host.getBusinessCode()
|
|
664
473
|
});
|
|
665
|
-
return
|
|
474
|
+
return _context5.abrupt("return", {
|
|
666
475
|
status: 'pending',
|
|
667
476
|
kind: 'openOrder'
|
|
668
477
|
});
|
|
669
|
-
case
|
|
670
|
-
return
|
|
478
|
+
case 84:
|
|
479
|
+
return _context5.abrupt("return", {
|
|
671
480
|
status: 'failed',
|
|
672
481
|
reason: 'invalid_data'
|
|
673
482
|
});
|
|
674
|
-
case
|
|
483
|
+
case 85:
|
|
675
484
|
case "end":
|
|
676
|
-
return
|
|
485
|
+
return _context5.stop();
|
|
677
486
|
}
|
|
678
|
-
},
|
|
487
|
+
}, _callee5, null, [[49, 65, 68, 71]]);
|
|
679
488
|
}));
|
|
680
489
|
return _applyGlobalScan.apply(this, arguments);
|
|
681
490
|
}
|