@pisell/pisellos 0.0.34 → 0.0.35
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.
|
@@ -301,7 +301,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
301
|
key: "scanCode",
|
|
302
302
|
value: function () {
|
|
303
303
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code) {
|
|
304
|
-
var _this$store$discount3, resultDiscountList, rulesModule, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
304
|
+
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
305
305
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
306
306
|
while (1) switch (_context5.prev = _context5.next) {
|
|
307
307
|
case 0:
|
|
@@ -328,35 +328,40 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
328
|
discountList: this.getDiscountList()
|
|
329
329
|
});
|
|
330
330
|
case 10:
|
|
331
|
+
withScanList = resultDiscountList.map(function (item) {
|
|
332
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
333
|
+
isScan: true
|
|
334
|
+
});
|
|
335
|
+
});
|
|
331
336
|
_ref3 = rulesModule.isDiscountListAvailable({
|
|
332
337
|
productList: this.store.productList || [],
|
|
333
338
|
oldDiscountList: this.getDiscountList(),
|
|
334
|
-
newDiscountList:
|
|
339
|
+
newDiscountList: withScanList
|
|
335
340
|
}) || {
|
|
336
341
|
isAvailable: false,
|
|
337
342
|
productList: this.store.productList || [],
|
|
338
343
|
discountList: this.getDiscountList()
|
|
339
344
|
}, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
|
|
340
345
|
if (!isAvailable) {
|
|
341
|
-
_context5.next =
|
|
346
|
+
_context5.next = 18;
|
|
342
347
|
break;
|
|
343
348
|
}
|
|
344
349
|
this.setDiscountList(newDiscountList || []);
|
|
345
350
|
this.setProductList(newProductList || []);
|
|
346
351
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
347
|
-
_context5.next =
|
|
352
|
+
_context5.next = 18;
|
|
348
353
|
break;
|
|
349
354
|
}
|
|
350
|
-
_context5.next =
|
|
355
|
+
_context5.next = 18;
|
|
351
356
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
352
|
-
case
|
|
357
|
+
case 18:
|
|
353
358
|
return _context5.abrupt("return", {
|
|
354
359
|
isAvailable: isAvailable || false,
|
|
355
360
|
productList: newProductList || this.store.productList || [],
|
|
356
361
|
discountList: newDiscountList || this.getDiscountList()
|
|
357
362
|
});
|
|
358
|
-
case
|
|
359
|
-
_context5.prev =
|
|
363
|
+
case 21:
|
|
364
|
+
_context5.prev = 21;
|
|
360
365
|
_context5.t1 = _context5["catch"](0);
|
|
361
366
|
console.error("[ShopDiscount] 扫码出错:", _context5.t1);
|
|
362
367
|
return _context5.abrupt("return", {
|
|
@@ -364,11 +369,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
369
|
productList: this.store.productList || [],
|
|
365
370
|
discountList: this.getDiscountList()
|
|
366
371
|
});
|
|
367
|
-
case
|
|
372
|
+
case 25:
|
|
368
373
|
case "end":
|
|
369
374
|
return _context5.stop();
|
|
370
375
|
}
|
|
371
|
-
}, _callee5, this, [[0,
|
|
376
|
+
}, _callee5, this, [[0, 21]]);
|
|
372
377
|
}));
|
|
373
378
|
function scanCode(_x4) {
|
|
374
379
|
return _scanCode.apply(this, arguments);
|
|
@@ -503,7 +508,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
503
508
|
key: "loadPrepareConfig",
|
|
504
509
|
value: function () {
|
|
505
510
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
506
|
-
var _this$getCustomer2, _this$store$discount7, _this$store$productLi, customerId, goodPassList, result;
|
|
511
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi, customerId, goodPassList, scanDiscount, newDiscountList, result;
|
|
507
512
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
508
513
|
while (1) switch (_context8.prev = _context8.next) {
|
|
509
514
|
case 0:
|
|
@@ -519,29 +524,33 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
519
524
|
});
|
|
520
525
|
case 4:
|
|
521
526
|
goodPassList = _context8.sent;
|
|
522
|
-
this.
|
|
527
|
+
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
528
|
+
return item.isScan;
|
|
529
|
+
});
|
|
530
|
+
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(goodPassList || []));
|
|
531
|
+
this.setDiscountList(newDiscountList || []);
|
|
523
532
|
if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
|
|
524
|
-
_context8.next =
|
|
533
|
+
_context8.next = 12;
|
|
525
534
|
break;
|
|
526
535
|
}
|
|
527
536
|
result = this.calcDiscount(this.store.productList);
|
|
528
|
-
_context8.next = 10;
|
|
529
|
-
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
530
|
-
case 10:
|
|
531
537
|
_context8.next = 12;
|
|
532
|
-
return this.core.effects.emit(ShopDiscountHooks.
|
|
538
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
533
539
|
case 12:
|
|
534
|
-
_context8.next =
|
|
535
|
-
|
|
540
|
+
_context8.next = 14;
|
|
541
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
536
542
|
case 14:
|
|
537
|
-
_context8.
|
|
543
|
+
_context8.next = 19;
|
|
544
|
+
break;
|
|
545
|
+
case 16:
|
|
546
|
+
_context8.prev = 16;
|
|
538
547
|
_context8.t0 = _context8["catch"](0);
|
|
539
548
|
console.error("[ShopDiscount] 加载准备配置出错:", _context8.t0);
|
|
540
|
-
case
|
|
549
|
+
case 19:
|
|
541
550
|
case "end":
|
|
542
551
|
return _context8.stop();
|
|
543
552
|
}
|
|
544
|
-
}, _callee8, this, [[0,
|
|
553
|
+
}, _callee8, this, [[0, 16]]);
|
|
545
554
|
}));
|
|
546
555
|
function loadPrepareConfig(_x7) {
|
|
547
556
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -197,6 +197,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
197
197
|
discountList: this.getDiscountList()
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
+
const withScanList = resultDiscountList.map((item) => {
|
|
201
|
+
return {
|
|
202
|
+
...item,
|
|
203
|
+
isScan: true
|
|
204
|
+
};
|
|
205
|
+
});
|
|
200
206
|
const {
|
|
201
207
|
productList: newProductList,
|
|
202
208
|
discountList: newDiscountList,
|
|
@@ -204,7 +210,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
204
210
|
} = rulesModule.isDiscountListAvailable({
|
|
205
211
|
productList: this.store.productList || [],
|
|
206
212
|
oldDiscountList: this.getDiscountList(),
|
|
207
|
-
newDiscountList:
|
|
213
|
+
newDiscountList: withScanList
|
|
208
214
|
}) || {
|
|
209
215
|
isAvailable: false,
|
|
210
216
|
productList: this.store.productList || [],
|
|
@@ -308,7 +314,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
308
314
|
}
|
|
309
315
|
// 加载准备配置
|
|
310
316
|
async loadPrepareConfig(params) {
|
|
311
|
-
var _a, _b, _c;
|
|
317
|
+
var _a, _b, _c, _d;
|
|
312
318
|
try {
|
|
313
319
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
314
320
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
@@ -316,8 +322,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
316
322
|
action: "create",
|
|
317
323
|
with_good_pass: 1
|
|
318
324
|
}));
|
|
319
|
-
this.
|
|
320
|
-
|
|
325
|
+
const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter((item) => item.isScan);
|
|
326
|
+
const newDiscountList = [...scanDiscount, ...goodPassList || []];
|
|
327
|
+
this.setDiscountList(newDiscountList || []);
|
|
328
|
+
if ((_d = this.store.productList) == null ? void 0 : _d.length) {
|
|
321
329
|
const result = this.calcDiscount(this.store.productList);
|
|
322
330
|
await this.core.effects.emit(
|
|
323
331
|
import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
|
|
@@ -326,7 +334,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
326
334
|
}
|
|
327
335
|
await this.core.effects.emit(
|
|
328
336
|
import_types.ShopDiscountHooks.onLoadDiscountList,
|
|
329
|
-
|
|
337
|
+
newDiscountList
|
|
330
338
|
);
|
|
331
339
|
} catch (error) {
|
|
332
340
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|