@pisell/pisellos 0.10.39 → 0.10.41
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/modules/BookingContext/index.js +4 -4
- package/dist/modules/Customer/index.js +4 -2
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Payment/types.d.ts +21 -1
- package/dist/modules/Payment/types.js +2 -0
- package/dist/modules/Payment/walletpass.d.ts +1 -1
- package/dist/modules/Payment/walletpass.js +80 -47
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +64 -43
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -2
- package/dist/solution/BookingTicket/index.js +60 -63
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +266 -150
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +5 -3
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +8 -4
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.js +10 -10
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.js +3 -3
- package/lib/modules/Customer/index.js +4 -1
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Payment/types.d.ts +21 -1
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +1 -1
- package/lib/modules/Payment/walletpass.js +29 -9
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +18 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -2
- package/lib/solution/BookingTicket/index.js +36 -33
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +2 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +127 -42
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +5 -3
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +7 -3
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.js +4 -4
- package/package.json +1 -1
|
@@ -11,10 +11,24 @@ 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";
|
|
15
14
|
import { countScanVariantMatches, genScanProductValues, isScanProductBundle, isScanProductOption } from "./scanProductValues";
|
|
16
15
|
|
|
17
16
|
/** 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
|
+
|
|
18
32
|
/**
|
|
19
33
|
* 处理单条扫码商品的加车决策(含弹窗链)。
|
|
20
34
|
*/
|
|
@@ -191,300 +205,402 @@ export function applyGlobalScan(_x14, _x15, _x16) {
|
|
|
191
205
|
return _applyGlobalScan.apply(this, arguments);
|
|
192
206
|
}
|
|
193
207
|
function _applyGlobalScan() {
|
|
194
|
-
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
195
|
-
var searchType, data, scanCode, _bridge$
|
|
196
|
-
return _regeneratorRuntime().wrap(function
|
|
197
|
-
while (1) switch (
|
|
208
|
+
_applyGlobalScan = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(host, formatted, bridge) {
|
|
209
|
+
var searchType, data, scanCode, formattedCustomerId, isCrossShopWallet, _getRealCustomerId, _bridge$onNotify4, currentCustomer, _customer, sourceCustomerId, _bridge$onNotify, _bridge$onNotify2, _customerId, _bridge$onNotify3, orderCustomer, _promotionResult$isAc, snapshot, currentCustomerIsWalkIn, activeCustomer, bindWalletPassCustomer, trySelectWalletAsset, walletSelection, promotionResult, list, _bridge$onNotify10, addedCount, _iterator, _step, _item, outcome, _bridge$onNotify11, _data$order_id, _data$business_code, orderId, _bridge$onNotify12;
|
|
210
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
211
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
198
212
|
case 0:
|
|
199
|
-
searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode;
|
|
213
|
+
searchType = formatted.searchType, data = formatted.data, scanCode = formatted.scanCode, formattedCustomerId = formatted.customerId, isCrossShopWallet = formatted.isCrossShopWallet;
|
|
200
214
|
if (!(searchType === 'wallet')) {
|
|
201
|
-
|
|
215
|
+
_context6.next = 29;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
currentCustomer = host.getOrderCustomerSnapshot();
|
|
219
|
+
if (!(getRealCustomerId(currentCustomer) !== undefined)) {
|
|
220
|
+
_context6.next = 5;
|
|
202
221
|
break;
|
|
203
222
|
}
|
|
204
|
-
|
|
205
|
-
|
|
223
|
+
return _context6.abrupt("return", {
|
|
224
|
+
status: 'success',
|
|
225
|
+
kind: 'customer'
|
|
226
|
+
});
|
|
227
|
+
case 5:
|
|
228
|
+
_customer = data;
|
|
229
|
+
if (!isCrossShopWallet) {
|
|
230
|
+
_context6.next = 21;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
sourceCustomerId = getRealCustomerId({
|
|
234
|
+
id: formattedCustomerId
|
|
235
|
+
});
|
|
236
|
+
if (!(sourceCustomerId === undefined || !host.resolveCustomerById)) {
|
|
237
|
+
_context6.next = 11;
|
|
206
238
|
break;
|
|
207
239
|
}
|
|
208
240
|
bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
209
|
-
return
|
|
241
|
+
return _context6.abrupt("return", {
|
|
210
242
|
status: 'failed',
|
|
211
243
|
reason: 'invalid_data'
|
|
212
244
|
});
|
|
213
|
-
case
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return
|
|
245
|
+
case 11:
|
|
246
|
+
_context6.prev = 11;
|
|
247
|
+
_context6.next = 14;
|
|
248
|
+
return host.resolveCustomerById(sourceCustomerId);
|
|
249
|
+
case 14:
|
|
250
|
+
_customer = _context6.sent;
|
|
251
|
+
_context6.next = 21;
|
|
252
|
+
break;
|
|
253
|
+
case 17:
|
|
254
|
+
_context6.prev = 17;
|
|
255
|
+
_context6.t0 = _context6["catch"](11);
|
|
256
|
+
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');
|
|
257
|
+
return _context6.abrupt("return", {
|
|
258
|
+
status: 'failed',
|
|
259
|
+
reason: 'invalid_data'
|
|
260
|
+
});
|
|
261
|
+
case 21:
|
|
262
|
+
_customerId = (_getRealCustomerId = getRealCustomerId(_customer)) !== null && _getRealCustomerId !== void 0 ? _getRealCustomerId : !isCrossShopWallet ? getRealCustomerId({
|
|
263
|
+
id: formattedCustomerId
|
|
264
|
+
}) : undefined;
|
|
265
|
+
if (!(!_customer || _customerId === undefined)) {
|
|
266
|
+
_context6.next = 25;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
270
|
+
return _context6.abrupt("return", {
|
|
271
|
+
status: 'failed',
|
|
272
|
+
reason: 'invalid_data'
|
|
273
|
+
});
|
|
274
|
+
case 25:
|
|
275
|
+
orderCustomer = _customer.id === undefined || _customer.id === null ? _objectSpread(_objectSpread({}, _customer), {}, {
|
|
276
|
+
id: _customerId
|
|
277
|
+
}) : _customer;
|
|
278
|
+
host.setOrderCustomer(orderCustomer);
|
|
279
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify4 = bridge.onNotify) === null || _bridge$onNotify4 === void 0 || _bridge$onNotify4.call(bridge, 'success', 'pisell2.text.add-client-success');
|
|
280
|
+
return _context6.abrupt("return", {
|
|
217
281
|
status: 'success',
|
|
218
282
|
kind: 'customer'
|
|
219
283
|
});
|
|
220
|
-
case
|
|
284
|
+
case 29:
|
|
221
285
|
if (!(searchType === 'walletPass')) {
|
|
222
|
-
|
|
286
|
+
_context6.next = 50;
|
|
223
287
|
break;
|
|
224
288
|
}
|
|
225
289
|
snapshot = host.getOrderCustomerSnapshot();
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var
|
|
290
|
+
currentCustomerIsWalkIn = getRealCustomerId(snapshot) === undefined;
|
|
291
|
+
activeCustomer = snapshot;
|
|
292
|
+
bindWalletPassCustomer = /*#__PURE__*/function () {
|
|
293
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(asset) {
|
|
294
|
+
var _getWalletAssetCustom, _host$refreshWalletAs;
|
|
295
|
+
var assetCustomerId, customer, _bridge$onNotify5, _bridge$onNotify6, customerId, _bridge$onNotify7, orderCustomer;
|
|
231
296
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
232
297
|
while (1) switch (_context4.prev = _context4.next) {
|
|
233
298
|
case 0:
|
|
234
|
-
if (
|
|
299
|
+
if (currentCustomerIsWalkIn) {
|
|
235
300
|
_context4.next = 2;
|
|
236
301
|
break;
|
|
237
302
|
}
|
|
238
|
-
return _context4.abrupt("return",
|
|
303
|
+
return _context4.abrupt("return", {
|
|
304
|
+
resolveFailed: false
|
|
305
|
+
});
|
|
239
306
|
case 2:
|
|
240
|
-
|
|
307
|
+
assetCustomerId = (_getWalletAssetCustom = getWalletAssetCustomerId(asset)) !== null && _getWalletAssetCustom !== void 0 ? _getWalletAssetCustom : getRealCustomerId({
|
|
308
|
+
id: formattedCustomerId
|
|
309
|
+
});
|
|
310
|
+
customer = null;
|
|
311
|
+
if (!(assetCustomerId !== undefined)) {
|
|
312
|
+
_context4.next = 19;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
if (host.resolveCustomerById) {
|
|
316
|
+
_context4.next = 8;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify5 = bridge.onNotify) === null || _bridge$onNotify5 === void 0 || _bridge$onNotify5.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
320
|
+
return _context4.abrupt("return", {
|
|
321
|
+
resolveFailed: true
|
|
322
|
+
});
|
|
323
|
+
case 8:
|
|
324
|
+
_context4.prev = 8;
|
|
325
|
+
_context4.next = 11;
|
|
326
|
+
return host.resolveCustomerById(assetCustomerId);
|
|
327
|
+
case 11:
|
|
328
|
+
customer = _context4.sent;
|
|
329
|
+
_context4.next = 19;
|
|
330
|
+
break;
|
|
331
|
+
case 14:
|
|
332
|
+
_context4.prev = 14;
|
|
333
|
+
_context4.t0 = _context4["catch"](8);
|
|
334
|
+
console.warn('[GlobalScan] Wallet asset customer lookup failed', _context4.t0);
|
|
335
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify6 = bridge.onNotify) === null || _bridge$onNotify6 === void 0 || _bridge$onNotify6.call(bridge, 'fail', getErrorMessage(_context4.t0) || 'pisell2.text.scan-global-failed');
|
|
336
|
+
return _context4.abrupt("return", {
|
|
337
|
+
resolveFailed: true
|
|
338
|
+
});
|
|
339
|
+
case 19:
|
|
340
|
+
customerId = getRealCustomerId(customer);
|
|
341
|
+
if (!(!customer || customerId === undefined)) {
|
|
342
|
+
_context4.next = 23;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (assetCustomerId !== undefined) {
|
|
346
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify7 = bridge.onNotify) === null || _bridge$onNotify7 === void 0 || _bridge$onNotify7.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
347
|
+
}
|
|
348
|
+
return _context4.abrupt("return", {
|
|
349
|
+
resolveFailed: assetCustomerId !== undefined
|
|
350
|
+
});
|
|
351
|
+
case 23:
|
|
352
|
+
orderCustomer = customer.id === undefined || customer.id === null ? _objectSpread(_objectSpread({}, customer), {}, {
|
|
353
|
+
id: customerId
|
|
354
|
+
}) : customer;
|
|
355
|
+
host.setOrderCustomer(orderCustomer);
|
|
356
|
+
activeCustomer = orderCustomer;
|
|
357
|
+
_context4.next = 28;
|
|
358
|
+
return (_host$refreshWalletAs = host.refreshWalletAssets) === null || _host$refreshWalletAs === void 0 ? void 0 : _host$refreshWalletAs.call(host, {
|
|
359
|
+
preserveSelection: false,
|
|
360
|
+
retainSearchResultCodes: [scanCode]
|
|
361
|
+
});
|
|
362
|
+
case 28:
|
|
363
|
+
return _context4.abrupt("return", {
|
|
364
|
+
resolveFailed: false
|
|
365
|
+
});
|
|
366
|
+
case 29:
|
|
367
|
+
case "end":
|
|
368
|
+
return _context4.stop();
|
|
369
|
+
}
|
|
370
|
+
}, _callee4, null, [[8, 14]]);
|
|
371
|
+
}));
|
|
372
|
+
return function bindWalletPassCustomer(_x17) {
|
|
373
|
+
return _ref2.apply(this, arguments);
|
|
374
|
+
};
|
|
375
|
+
}();
|
|
376
|
+
trySelectWalletAsset = /*#__PURE__*/function () {
|
|
377
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
378
|
+
var walletResult, bindResult, _bridge$onNotify8, _bridge$onNotify9;
|
|
379
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
380
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
381
|
+
case 0:
|
|
382
|
+
if (host.scanWalletAsset) {
|
|
383
|
+
_context5.next = 2;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
return _context5.abrupt("return", null);
|
|
387
|
+
case 2:
|
|
388
|
+
_context5.next = 4;
|
|
241
389
|
return host.scanWalletAsset(scanCode).catch(function (error) {
|
|
242
390
|
console.warn('[GlobalScan] Wallet asset lookup failed', error);
|
|
243
391
|
return null;
|
|
244
392
|
});
|
|
245
393
|
case 4:
|
|
246
|
-
walletResult =
|
|
394
|
+
walletResult = _context5.sent;
|
|
247
395
|
if (walletResult) {
|
|
248
|
-
|
|
396
|
+
_context5.next = 7;
|
|
249
397
|
break;
|
|
250
398
|
}
|
|
251
|
-
return
|
|
399
|
+
return _context5.abrupt("return", null);
|
|
252
400
|
case 7:
|
|
253
401
|
if (!(walletResult.type !== 'normalCode' || !walletResult.asset)) {
|
|
254
|
-
|
|
402
|
+
_context5.next = 9;
|
|
255
403
|
break;
|
|
256
404
|
}
|
|
257
|
-
return
|
|
405
|
+
return _context5.abrupt("return", null);
|
|
258
406
|
case 9:
|
|
407
|
+
_context5.next = 11;
|
|
408
|
+
return bindWalletPassCustomer(walletResult.asset);
|
|
409
|
+
case 11:
|
|
410
|
+
bindResult = _context5.sent;
|
|
259
411
|
if (!walletResult.selected) {
|
|
260
|
-
|
|
412
|
+
_context5.next = 15;
|
|
261
413
|
break;
|
|
262
414
|
}
|
|
263
|
-
|
|
264
|
-
|
|
415
|
+
if (!bindResult.resolveFailed) {
|
|
416
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify8 = bridge.onNotify) === null || _bridge$onNotify8 === void 0 || _bridge$onNotify8.call(bridge, 'success');
|
|
417
|
+
}
|
|
418
|
+
return _context5.abrupt("return", {
|
|
265
419
|
status: 'success',
|
|
266
420
|
kind: 'promotion'
|
|
267
421
|
});
|
|
268
|
-
case
|
|
422
|
+
case 15:
|
|
269
423
|
// 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
|
|
270
|
-
|
|
271
|
-
|
|
424
|
+
if (!bindResult.resolveFailed) {
|
|
425
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify9 = bridge.onNotify) === null || _bridge$onNotify9 === void 0 || _bridge$onNotify9.call(bridge, 'fail', 'pisell2.text.goodpass.code-invalid-cart');
|
|
426
|
+
}
|
|
427
|
+
return _context5.abrupt("return", {
|
|
272
428
|
status: 'failed',
|
|
273
429
|
reason: 'invalid_data'
|
|
274
430
|
});
|
|
275
|
-
case
|
|
431
|
+
case 17:
|
|
276
432
|
case "end":
|
|
277
|
-
return
|
|
433
|
+
return _context5.stop();
|
|
278
434
|
}
|
|
279
|
-
},
|
|
435
|
+
}, _callee5);
|
|
280
436
|
}));
|
|
281
437
|
return function trySelectWalletAsset() {
|
|
282
|
-
return
|
|
438
|
+
return _ref3.apply(this, arguments);
|
|
283
439
|
};
|
|
284
440
|
}();
|
|
285
|
-
|
|
286
|
-
_context5.next = 26;
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
_context5.next = 15;
|
|
441
|
+
_context6.next = 37;
|
|
290
442
|
return trySelectWalletAsset();
|
|
291
|
-
case
|
|
292
|
-
|
|
293
|
-
if (!
|
|
294
|
-
|
|
443
|
+
case 37:
|
|
444
|
+
walletSelection = _context6.sent;
|
|
445
|
+
if (!walletSelection) {
|
|
446
|
+
_context6.next = 40;
|
|
295
447
|
break;
|
|
296
448
|
}
|
|
297
|
-
return
|
|
298
|
-
case
|
|
449
|
+
return _context6.abrupt("return", walletSelection);
|
|
450
|
+
case 40:
|
|
451
|
+
_context6.next = 42;
|
|
452
|
+
return bindWalletPassCustomer();
|
|
453
|
+
case 42:
|
|
299
454
|
if (bridge !== null && bridge !== void 0 && bridge.applyPromotionCode) {
|
|
300
|
-
|
|
455
|
+
_context6.next = 44;
|
|
301
456
|
break;
|
|
302
457
|
}
|
|
303
|
-
return
|
|
458
|
+
return _context6.abrupt("return", {
|
|
304
459
|
status: 'failed',
|
|
305
460
|
reason: 'no_bridge'
|
|
306
461
|
});
|
|
307
|
-
case
|
|
308
|
-
|
|
309
|
-
return bridge.applyPromotionCode(scanCode);
|
|
310
|
-
case
|
|
311
|
-
|
|
312
|
-
if (!((
|
|
313
|
-
|
|
462
|
+
case 44:
|
|
463
|
+
_context6.next = 46;
|
|
464
|
+
return bridge.applyPromotionCode(scanCode, getRealCustomerId(activeCustomer));
|
|
465
|
+
case 46:
|
|
466
|
+
promotionResult = _context6.sent;
|
|
467
|
+
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)) {
|
|
468
|
+
_context6.next = 49;
|
|
314
469
|
break;
|
|
315
470
|
}
|
|
316
|
-
return
|
|
471
|
+
return _context6.abrupt("return", {
|
|
317
472
|
status: 'success',
|
|
318
473
|
kind: 'promotion'
|
|
319
474
|
});
|
|
320
|
-
case
|
|
321
|
-
return
|
|
475
|
+
case 49:
|
|
476
|
+
return _context6.abrupt("return", {
|
|
322
477
|
status: 'failed',
|
|
323
478
|
reason: 'invalid_data'
|
|
324
479
|
});
|
|
325
|
-
case
|
|
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;
|
|
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)) {
|
|
351
|
-
_context5.next = 40;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
return _context5.abrupt("return", {
|
|
355
|
-
status: 'success',
|
|
356
|
-
kind: 'promotion'
|
|
357
|
-
});
|
|
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", {
|
|
361
|
-
status: 'success',
|
|
362
|
-
kind: 'customer'
|
|
363
|
-
});
|
|
364
|
-
case 42:
|
|
480
|
+
case 50:
|
|
365
481
|
if (!(searchType === 'product' || searchType === 'local_product')) {
|
|
366
|
-
|
|
482
|
+
_context6.next = 83;
|
|
367
483
|
break;
|
|
368
484
|
}
|
|
369
485
|
list = data === null || data === void 0 ? void 0 : data.list;
|
|
370
486
|
if (!(!Array.isArray(list) || list.length === 0)) {
|
|
371
|
-
|
|
487
|
+
_context6.next = 55;
|
|
372
488
|
break;
|
|
373
489
|
}
|
|
374
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
375
|
-
return
|
|
490
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify10 = bridge.onNotify) === null || _bridge$onNotify10 === void 0 || _bridge$onNotify10.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
491
|
+
return _context6.abrupt("return", {
|
|
376
492
|
status: 'failed',
|
|
377
493
|
reason: 'invalid_data'
|
|
378
494
|
});
|
|
379
|
-
case
|
|
495
|
+
case 55:
|
|
380
496
|
addedCount = 0;
|
|
381
497
|
_iterator = _createForOfIteratorHelper(list);
|
|
382
|
-
|
|
498
|
+
_context6.prev = 57;
|
|
383
499
|
_iterator.s();
|
|
384
|
-
case
|
|
500
|
+
case 59:
|
|
385
501
|
if ((_step = _iterator.n()).done) {
|
|
386
|
-
|
|
502
|
+
_context6.next = 71;
|
|
387
503
|
break;
|
|
388
504
|
}
|
|
389
505
|
_item = _step.value;
|
|
390
|
-
|
|
506
|
+
_context6.next = 63;
|
|
391
507
|
return processScannedProductItem(host, _item, scanCode, bridge);
|
|
392
|
-
case
|
|
393
|
-
outcome =
|
|
508
|
+
case 63:
|
|
509
|
+
outcome = _context6.sent;
|
|
394
510
|
if (outcome === 'added') {
|
|
395
511
|
addedCount += 1;
|
|
396
512
|
}
|
|
397
513
|
if (!(outcome === 'cancelled')) {
|
|
398
|
-
|
|
514
|
+
_context6.next = 67;
|
|
399
515
|
break;
|
|
400
516
|
}
|
|
401
|
-
return
|
|
517
|
+
return _context6.abrupt("return", {
|
|
402
518
|
status: 'cancelled'
|
|
403
519
|
});
|
|
404
|
-
case
|
|
520
|
+
case 67:
|
|
405
521
|
if (!(outcome === 'pending')) {
|
|
406
|
-
|
|
522
|
+
_context6.next = 69;
|
|
407
523
|
break;
|
|
408
524
|
}
|
|
409
|
-
return
|
|
525
|
+
return _context6.abrupt("return", {
|
|
410
526
|
status: 'pending',
|
|
411
527
|
kind: 'requiresDetail'
|
|
412
528
|
});
|
|
413
|
-
case
|
|
414
|
-
|
|
529
|
+
case 69:
|
|
530
|
+
_context6.next = 59;
|
|
415
531
|
break;
|
|
416
|
-
case
|
|
417
|
-
|
|
532
|
+
case 71:
|
|
533
|
+
_context6.next = 76;
|
|
418
534
|
break;
|
|
419
|
-
case
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
_iterator.e(
|
|
423
|
-
case
|
|
424
|
-
|
|
535
|
+
case 73:
|
|
536
|
+
_context6.prev = 73;
|
|
537
|
+
_context6.t1 = _context6["catch"](57);
|
|
538
|
+
_iterator.e(_context6.t1);
|
|
539
|
+
case 76:
|
|
540
|
+
_context6.prev = 76;
|
|
425
541
|
_iterator.f();
|
|
426
|
-
return
|
|
427
|
-
case
|
|
542
|
+
return _context6.finish(76);
|
|
543
|
+
case 79:
|
|
428
544
|
if (!(addedCount > 0)) {
|
|
429
|
-
|
|
545
|
+
_context6.next = 82;
|
|
430
546
|
break;
|
|
431
547
|
}
|
|
432
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
433
|
-
return
|
|
548
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify11 = bridge.onNotify) === null || _bridge$onNotify11 === void 0 || _bridge$onNotify11.call(bridge, 'success');
|
|
549
|
+
return _context6.abrupt("return", {
|
|
434
550
|
status: 'success',
|
|
435
551
|
kind: 'products',
|
|
436
552
|
meta: {
|
|
437
553
|
count: addedCount
|
|
438
554
|
}
|
|
439
555
|
});
|
|
440
|
-
case
|
|
441
|
-
return
|
|
556
|
+
case 82:
|
|
557
|
+
return _context6.abrupt("return", {
|
|
442
558
|
status: 'failed',
|
|
443
559
|
reason: 'no_bridge'
|
|
444
560
|
});
|
|
445
|
-
case
|
|
561
|
+
case 83:
|
|
446
562
|
if (!(searchType === 'order')) {
|
|
447
|
-
|
|
563
|
+
_context6.next = 92;
|
|
448
564
|
break;
|
|
449
565
|
}
|
|
450
566
|
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;
|
|
451
567
|
if (orderId) {
|
|
452
|
-
|
|
568
|
+
_context6.next = 88;
|
|
453
569
|
break;
|
|
454
570
|
}
|
|
455
|
-
bridge === null || bridge === void 0 || (_bridge$
|
|
456
|
-
return
|
|
571
|
+
bridge === null || bridge === void 0 || (_bridge$onNotify12 = bridge.onNotify) === null || _bridge$onNotify12 === void 0 || _bridge$onNotify12.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
|
|
572
|
+
return _context6.abrupt("return", {
|
|
457
573
|
status: 'failed',
|
|
458
574
|
reason: 'invalid_data'
|
|
459
575
|
});
|
|
460
|
-
case
|
|
576
|
+
case 88:
|
|
461
577
|
if (bridge !== null && bridge !== void 0 && bridge.openOrder) {
|
|
462
|
-
|
|
578
|
+
_context6.next = 90;
|
|
463
579
|
break;
|
|
464
580
|
}
|
|
465
|
-
return
|
|
581
|
+
return _context6.abrupt("return", {
|
|
466
582
|
status: 'pending',
|
|
467
583
|
kind: 'openOrder'
|
|
468
584
|
});
|
|
469
|
-
case
|
|
585
|
+
case 90:
|
|
470
586
|
bridge.openOrder({
|
|
471
587
|
order_id: Number(orderId),
|
|
472
588
|
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()
|
|
473
589
|
});
|
|
474
|
-
return
|
|
590
|
+
return _context6.abrupt("return", {
|
|
475
591
|
status: 'pending',
|
|
476
592
|
kind: 'openOrder'
|
|
477
593
|
});
|
|
478
|
-
case
|
|
479
|
-
return
|
|
594
|
+
case 92:
|
|
595
|
+
return _context6.abrupt("return", {
|
|
480
596
|
status: 'failed',
|
|
481
597
|
reason: 'invalid_data'
|
|
482
598
|
});
|
|
483
|
-
case
|
|
599
|
+
case 93:
|
|
484
600
|
case "end":
|
|
485
|
-
return
|
|
601
|
+
return _context6.stop();
|
|
486
602
|
}
|
|
487
|
-
},
|
|
603
|
+
}, _callee6, null, [[11, 17], [57, 73, 76, 79]]);
|
|
488
604
|
}));
|
|
489
605
|
return _applyGlobalScan.apply(this, arguments);
|
|
490
606
|
}
|
|
@@ -17,6 +17,7 @@ export var searchWalletPass = /*#__PURE__*/function () {
|
|
|
17
17
|
// 翻译识别码名称 0:不翻译 1:翻译
|
|
18
18
|
relation_product: 1,
|
|
19
19
|
// 组装关联商品: 0不处理 1处理
|
|
20
|
+
with_franchisor_data: 1,
|
|
20
21
|
with: ['customer'],
|
|
21
22
|
tags: ['point_card',
|
|
22
23
|
// 积分卡
|
|
@@ -74,14 +75,15 @@ export var searchWallet = /*#__PURE__*/function () {
|
|
|
74
75
|
case 0:
|
|
75
76
|
params = {
|
|
76
77
|
code: code,
|
|
77
|
-
with_customer: 1
|
|
78
|
+
with_customer: 1,
|
|
79
|
+
with_franchisor_data: 1
|
|
78
80
|
};
|
|
79
81
|
_context2.prev = 1;
|
|
80
82
|
_context2.next = 4;
|
|
81
83
|
return request === null || request === void 0 ? void 0 : request.post('/wallet/detail/search', params);
|
|
82
84
|
case 4:
|
|
83
85
|
res = _context2.sent;
|
|
84
|
-
if (!((res === null || res === void 0 ? void 0 : res.code)
|
|
86
|
+
if (!((res === null || res === void 0 ? void 0 : res.status) === true && (res === null || res === void 0 ? void 0 : res.code) === 200 && !!(res !== null && res !== void 0 && res.data))) {
|
|
85
87
|
_context2.next = 7;
|
|
86
88
|
break;
|
|
87
89
|
}
|
|
@@ -90,7 +92,7 @@ export var searchWallet = /*#__PURE__*/function () {
|
|
|
90
92
|
response: res
|
|
91
93
|
});
|
|
92
94
|
case 7:
|
|
93
|
-
throw new Error('没有找到对应的识别码');
|
|
95
|
+
throw new Error((res === null || res === void 0 ? void 0 : res.message) || '没有找到对应的识别码');
|
|
94
96
|
case 10:
|
|
95
97
|
_context2.prev = 10;
|
|
96
98
|
_context2.t0 = _context2["catch"](1);
|
|
@@ -6,6 +6,10 @@ export interface GlobalScanFormattedResult {
|
|
|
6
6
|
searchType: GlobalScanSearchType;
|
|
7
7
|
data: any;
|
|
8
8
|
scanCode: string;
|
|
9
|
+
/** Wallet / Wallet Pass 来源客户 ID;跨店时必须先解析为当前店客户。 */
|
|
10
|
+
customerId?: string | number;
|
|
11
|
+
/** 仅 Wallet 返回;true 时禁止直接使用响应内的来源客户。 */
|
|
12
|
+
isCrossShopWallet?: boolean;
|
|
9
13
|
}
|
|
10
14
|
interface RawScanSearchResult {
|
|
11
15
|
searchType?: GlobalScanSearchType;
|
|
@@ -27,15 +27,19 @@ export function formatGlobalScanResult(raw, scanCode) {
|
|
|
27
27
|
return {
|
|
28
28
|
searchType: searchType,
|
|
29
29
|
data: resultData === null || resultData === void 0 ? void 0 : resultData.customer,
|
|
30
|
-
scanCode: scanCode
|
|
30
|
+
scanCode: scanCode,
|
|
31
|
+
customerId: resultData === null || resultData === void 0 ? void 0 : resultData.customer_id,
|
|
32
|
+
isCrossShopWallet: (resultData === null || resultData === void 0 ? void 0 : resultData.is_cross_shop_wallet) === true || Number(resultData === null || resultData === void 0 ? void 0 : resultData.is_cross_shop_wallet) === 1
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
if (searchType === 'walletPass') {
|
|
34
|
-
var
|
|
36
|
+
var _ref2, _ref3, _firstResult$customer, _firstResult$holder, _firstResult$customer2, _firstResult$customer3;
|
|
37
|
+
var firstResult = resultData === null || resultData === void 0 ? void 0 : resultData[0];
|
|
35
38
|
return {
|
|
36
39
|
searchType: searchType,
|
|
37
|
-
data:
|
|
38
|
-
scanCode: scanCode
|
|
40
|
+
data: firstResult === null || firstResult === void 0 ? void 0 : firstResult.customer,
|
|
41
|
+
scanCode: scanCode,
|
|
42
|
+
customerId: (_ref2 = (_ref3 = (_firstResult$customer = firstResult === null || firstResult === void 0 ? void 0 : firstResult.customer_id) !== null && _firstResult$customer !== void 0 ? _firstResult$customer : firstResult === null || firstResult === void 0 || (_firstResult$holder = firstResult.holder) === null || _firstResult$holder === void 0 ? void 0 : _firstResult$holder.customer_id) !== null && _ref3 !== void 0 ? _ref3 : firstResult === null || firstResult === void 0 || (_firstResult$customer2 = firstResult.customer) === null || _firstResult$customer2 === void 0 ? void 0 : _firstResult$customer2.id) !== null && _ref2 !== void 0 ? _ref2 : firstResult === null || firstResult === void 0 || (_firstResult$customer3 = firstResult.customer) === null || _firstResult$customer3 === void 0 ? void 0 : _firstResult$customer3.customer_id
|
|
39
43
|
};
|
|
40
44
|
}
|
|
41
45
|
if (searchType === 'product' || searchType === 'local_product') {
|