@pisell/pisellos 3.0.1 → 3.0.3
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/Cart/utils.js +2 -2
- package/dist/modules/Date/index.js +3 -2
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -1
- package/dist/solution/BookingByStep/index.js +12 -8
- package/dist/solution/ShopDiscount/index.js +32 -23
- package/lib/modules/Cart/utils.js +2 -2
- package/lib/modules/Date/index.js +16 -2
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -1
- package/lib/solution/BookingByStep/index.js +43 -34
- package/lib/solution/ShopDiscount/index.js +15 -7
- package/package.json +2 -2
|
@@ -157,7 +157,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
157
157
|
return this.request.get(fetchUrl, {
|
|
158
158
|
start_date: start_date,
|
|
159
159
|
end_date: end_date,
|
|
160
|
-
resource_ids: resource_ids
|
|
160
|
+
resource_ids: resource_ids,
|
|
161
|
+
front_end_cache_id: this.cacheId
|
|
161
162
|
}, {
|
|
162
163
|
useCache: true
|
|
163
164
|
});
|
|
@@ -206,7 +207,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
207
|
cacheId: this.cacheId,
|
|
207
208
|
fatherModule: this.fatherModule,
|
|
208
209
|
store: this.store,
|
|
209
|
-
cacheKey: [
|
|
210
|
+
cacheKey: ["dateRange", "dateList"]
|
|
210
211
|
});
|
|
211
212
|
}
|
|
212
213
|
}
|
|
@@ -16,6 +16,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
16
16
|
private shopStore;
|
|
17
17
|
private store;
|
|
18
18
|
private otherParams;
|
|
19
|
+
private cacheId;
|
|
19
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
20
21
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
21
22
|
getCurrentStep(): {
|
|
@@ -106,7 +107,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
106
107
|
timeSlots: any[];
|
|
107
108
|
selectedResource: any;
|
|
108
109
|
} | undefined;
|
|
109
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap }: {
|
|
110
|
+
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, }: {
|
|
110
111
|
holder_id: string;
|
|
111
112
|
resources_code: string | number;
|
|
112
113
|
timeSlots?: TimeSliceItem;
|
|
@@ -49,6 +49,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
49
49
|
_defineProperty(_assertThisInitialized(_this), "shopStore", void 0);
|
|
50
50
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
51
51
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
52
53
|
return _this;
|
|
53
54
|
}
|
|
54
55
|
_createClass(BookingByStepImpl, [{
|
|
@@ -56,6 +57,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
57
|
value: function () {
|
|
57
58
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
58
59
|
var _this$otherParams,
|
|
60
|
+
_this$otherParams2,
|
|
59
61
|
_this2 = this;
|
|
60
62
|
var targetCacheData, sessionData, data, moduleArr;
|
|
61
63
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -78,7 +80,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
80
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
79
81
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
80
82
|
targetCacheData = {};
|
|
81
|
-
|
|
83
|
+
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
84
|
+
if ((_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.cacheId) {
|
|
82
85
|
sessionData = this.window.sessionStorage.getItem(this.name);
|
|
83
86
|
if (sessionData) {
|
|
84
87
|
data = JSON.parse(sessionData); // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
|
|
@@ -105,7 +108,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
105
108
|
}
|
|
106
109
|
});
|
|
107
110
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
108
|
-
case
|
|
111
|
+
case 15:
|
|
109
112
|
case "end":
|
|
110
113
|
return _context.stop();
|
|
111
114
|
}
|
|
@@ -183,7 +186,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
183
186
|
skip: 1,
|
|
184
187
|
category_ids: category_ids,
|
|
185
188
|
ids: product_ids,
|
|
186
|
-
collection: collection
|
|
189
|
+
collection: collection,
|
|
190
|
+
front_end_cache_id: this.cacheId
|
|
187
191
|
}, {
|
|
188
192
|
useCache: true
|
|
189
193
|
});
|
|
@@ -368,7 +372,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
368
372
|
key: "getAvailableDate",
|
|
369
373
|
value: function () {
|
|
370
374
|
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
371
|
-
var _this$
|
|
375
|
+
var _this$otherParams3, _this$otherParams4;
|
|
372
376
|
var params,
|
|
373
377
|
products,
|
|
374
378
|
startDate,
|
|
@@ -391,8 +395,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
391
395
|
tempProducts = products || this.store.cart.getItems().map(function (p) {
|
|
392
396
|
return p._productOrigin;
|
|
393
397
|
});
|
|
394
|
-
tempStartDate = startDate || ((_this$
|
|
395
|
-
tempEndDate = endDate || ((_this$
|
|
398
|
+
tempStartDate = startDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[0]);
|
|
399
|
+
tempEndDate = endDate || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dateRange) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4[1]);
|
|
396
400
|
if (tempProducts.length) {
|
|
397
401
|
_context8.next = 7;
|
|
398
402
|
break;
|
|
@@ -1055,7 +1059,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1055
1059
|
timeSlots: recordTimeSlots,
|
|
1056
1060
|
countMap: selectResourcesMap
|
|
1057
1061
|
});
|
|
1058
|
-
// // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
1062
|
+
// // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
1059
1063
|
// if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
|
|
1060
1064
|
// return
|
|
1061
1065
|
// }
|
|
@@ -1089,7 +1093,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1089
1093
|
})) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
|
|
1090
1094
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1091
1095
|
var _item$_origin$resourc2;
|
|
1092
|
-
// 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
1096
|
+
// 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
1093
1097
|
if ((_item$_origin$resourc2 = item._origin.resources) !== null && _item$_origin$resourc2 !== void 0 && _item$_origin$resourc2.some(function (n) {
|
|
1094
1098
|
return n.form_id === targetRenderList[0].form_id;
|
|
1095
1099
|
})) {
|
|
@@ -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;
|
|
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
|
-
if (!(this.isWalkIn() && resultDiscountList.length)) {
|
|
347
|
-
_context5.next =
|
|
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')) {
|
|
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);
|
|
@@ -89,7 +89,16 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
89
89
|
return (0, import_utils.disableAllDates)(dates);
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
92
|
-
const res = await this.request.get(
|
|
92
|
+
const res = await this.request.get(
|
|
93
|
+
fetchUrl,
|
|
94
|
+
{
|
|
95
|
+
start_date,
|
|
96
|
+
end_date,
|
|
97
|
+
resource_ids,
|
|
98
|
+
front_end_cache_id: this.cacheId
|
|
99
|
+
},
|
|
100
|
+
{ useCache: true }
|
|
101
|
+
);
|
|
93
102
|
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
94
103
|
return (0, import_utils.disableAllDates)(dates);
|
|
95
104
|
}
|
|
@@ -108,7 +117,12 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
108
117
|
}
|
|
109
118
|
storeChange() {
|
|
110
119
|
if (this.openCache) {
|
|
111
|
-
this.checkSaveCache({
|
|
120
|
+
this.checkSaveCache({
|
|
121
|
+
cacheId: this.cacheId,
|
|
122
|
+
fatherModule: this.fatherModule,
|
|
123
|
+
store: this.store,
|
|
124
|
+
cacheKey: ["dateRange", "dateList"]
|
|
125
|
+
});
|
|
112
126
|
}
|
|
113
127
|
}
|
|
114
128
|
};
|
|
@@ -16,6 +16,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
16
16
|
private shopStore;
|
|
17
17
|
private store;
|
|
18
18
|
private otherParams;
|
|
19
|
+
private cacheId;
|
|
19
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
20
21
|
initStep(stepList: (keyof BookingByStepState)[]): void;
|
|
21
22
|
getCurrentStep(): {
|
|
@@ -106,7 +107,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
106
107
|
timeSlots: any[];
|
|
107
108
|
selectedResource: any;
|
|
108
109
|
} | undefined;
|
|
109
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap }: {
|
|
110
|
+
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, }: {
|
|
110
111
|
holder_id: string;
|
|
111
112
|
resources_code: string | number;
|
|
112
113
|
timeSlots?: TimeSliceItem;
|
|
@@ -48,7 +48,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
48
48
|
this.otherParams = {};
|
|
49
49
|
}
|
|
50
50
|
async initialize(core, options) {
|
|
51
|
-
var _a;
|
|
51
|
+
var _a, _b;
|
|
52
52
|
this.core = core;
|
|
53
53
|
this.store = options.store || {};
|
|
54
54
|
this.otherParams = options.otherParams || {};
|
|
@@ -60,34 +60,29 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
60
60
|
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
61
61
|
}
|
|
62
62
|
let targetCacheData = {};
|
|
63
|
-
|
|
63
|
+
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
64
|
+
if ((_b = this.otherParams) == null ? void 0 : _b.cacheId) {
|
|
64
65
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
65
66
|
if (sessionData) {
|
|
66
67
|
const data = JSON.parse(sessionData);
|
|
67
68
|
targetCacheData = data[this.otherParams.cacheId];
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
const moduleArr = [
|
|
71
|
-
"accountList",
|
|
72
|
-
"cart",
|
|
73
|
-
"summary",
|
|
74
|
-
"step",
|
|
75
|
-
"products",
|
|
76
|
-
"date",
|
|
77
|
-
"order",
|
|
78
|
-
"payment"
|
|
79
|
-
];
|
|
71
|
+
const moduleArr = ["accountList", "cart", "summary", "step", "products", "date", "order", "payment"];
|
|
80
72
|
moduleArr.forEach((step) => {
|
|
81
|
-
var _a2,
|
|
73
|
+
var _a2, _b2;
|
|
82
74
|
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
83
75
|
if (targetModule) {
|
|
84
76
|
this.store[step] = targetModule;
|
|
85
|
-
this.core.registerModule(targetModule, {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
this.core.registerModule(targetModule, {
|
|
78
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name],
|
|
79
|
+
otherParams: {
|
|
80
|
+
...this.otherParams,
|
|
81
|
+
fatherModule: this.name,
|
|
82
|
+
openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
|
|
83
|
+
cacheId: (_b2 = this.otherParams) == null ? void 0 : _b2.cacheId
|
|
84
|
+
}
|
|
85
|
+
});
|
|
91
86
|
} else {
|
|
92
87
|
throw new Error(`模块 ${step} 不存在`);
|
|
93
88
|
}
|
|
@@ -130,18 +125,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
130
125
|
product_ids = [],
|
|
131
126
|
collection = []
|
|
132
127
|
}) {
|
|
133
|
-
const productsData = await this.request.post(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
128
|
+
const productsData = await this.request.post(
|
|
129
|
+
`/product/query`,
|
|
130
|
+
{
|
|
131
|
+
open_quotation: 1,
|
|
132
|
+
open_bundle: 1,
|
|
133
|
+
extension_type: ["product_appointment", "appointment_ticket"],
|
|
134
|
+
with: ["category", "collection"],
|
|
135
|
+
status: "published",
|
|
136
|
+
num: 500,
|
|
137
|
+
skip: 1,
|
|
138
|
+
category_ids,
|
|
139
|
+
ids: product_ids,
|
|
140
|
+
collection,
|
|
141
|
+
front_end_cache_id: this.cacheId
|
|
142
|
+
},
|
|
143
|
+
{ useCache: true }
|
|
144
|
+
);
|
|
145
145
|
this.store.products.addProduct(productsData.data.list);
|
|
146
146
|
return productsData.data.list;
|
|
147
147
|
}
|
|
@@ -560,8 +560,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
560
560
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
561
561
|
if (timeSlots) {
|
|
562
562
|
if (index !== 0 && recordTimeSlots) {
|
|
563
|
-
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
564
|
-
|
|
563
|
+
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
564
|
+
((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0,
|
|
565
|
+
((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
|
|
566
|
+
);
|
|
567
|
+
let end_at = start_at.add(
|
|
568
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) ?? 0,
|
|
569
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.type) ?? "minutes"
|
|
570
|
+
);
|
|
565
571
|
recordTimeSlots = {
|
|
566
572
|
start_time: start_at.format("HH:mm"),
|
|
567
573
|
end_time: end_at.format("HH:mm"),
|
|
@@ -680,7 +686,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
680
686
|
newResources.forEach((resource) => {
|
|
681
687
|
var _a, _b, _c, _d;
|
|
682
688
|
resource.startTime = currentStartTime;
|
|
683
|
-
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
689
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
690
|
+
((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0,
|
|
691
|
+
((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
|
|
692
|
+
).format("YYYY-MM-DD HH:mm");
|
|
684
693
|
delete resource.times;
|
|
685
694
|
});
|
|
686
695
|
this.store.cart.updateItem({
|
|
@@ -186,7 +186,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
186
186
|
}
|
|
187
187
|
// 扫码输入code
|
|
188
188
|
async scanCode(code) {
|
|
189
|
-
var _a;
|
|
189
|
+
var _a, _b;
|
|
190
190
|
try {
|
|
191
191
|
const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code)) || [];
|
|
192
192
|
const rulesModule = this.store.rules;
|
|
@@ -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 || [],
|
|
@@ -213,7 +219,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
213
219
|
if (isAvailable) {
|
|
214
220
|
this.setDiscountList(newDiscountList || []);
|
|
215
221
|
this.setProductList(newProductList || []);
|
|
216
|
-
if (this.isWalkIn() && resultDiscountList.length) {
|
|
222
|
+
if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
|
|
217
223
|
await this.getCustomerWallet(
|
|
218
224
|
resultDiscountList[0].customer_id
|
|
219
225
|
);
|
|
@@ -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);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.3",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"docs": "typedoc --out docs src/index.ts",
|
|
22
22
|
"sync": "node sync.js",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
|
-
"deploy": "yarn run build && yarn run changeset && yarn run version &&
|
|
24
|
+
"deploy": "yarn run build && yarn run changeset && yarn run version && npm run release"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|