@pisell/pisellos 0.10.58 → 0.10.60
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inventory/index.d.ts +92 -0
- package/dist/inventory/index.js +500 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +25 -2
- package/dist/modules/Order/holderRelations.d.ts +14 -0
- package/dist/modules/Order/holderRelations.js +154 -0
- package/dist/modules/Order/index.d.ts +21 -4
- package/dist/modules/Order/index.js +1453 -1060
- package/dist/modules/Order/types.d.ts +24 -1
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
- package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
- package/dist/modules/Order/utils.d.ts +1 -1
- package/dist/modules/Order/utils.js +35 -9
- package/dist/modules/ProductList/index.d.ts +1 -3
- package/dist/modules/ProductList/index.js +120 -192
- package/dist/modules/ProductList/types.d.ts +0 -8
- package/dist/modules/ProductList/types.js +0 -2
- package/dist/server/index.js +18 -12
- package/dist/server/modules/order/index.d.ts +4 -0
- package/dist/server/modules/order/index.js +255 -190
- package/dist/server/modules/order/types.d.ts +3 -0
- package/dist/shared/receipt/small-ticket.js +17 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +8 -0
- package/dist/solution/BaseSales/index.js +1478 -1233
- package/dist/solution/BaseSales/types.d.ts +2 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/BookingTicket/index.js +7 -4
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +6 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -7
- package/dist/solution/UnifiedBookingSales/index.js +446 -586
- package/lib/index.d.ts +1 -0
- package/lib/index.js +12 -0
- package/lib/inventory/index.d.ts +92 -0
- package/lib/inventory/index.js +280 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +16 -1
- package/lib/modules/Order/holderRelations.d.ts +14 -0
- package/lib/modules/Order/holderRelations.js +98 -0
- package/lib/modules/Order/index.d.ts +21 -4
- package/lib/modules/Order/index.js +155 -31
- package/lib/modules/Order/types.d.ts +24 -1
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
- package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
- package/lib/modules/Order/utils.d.ts +1 -1
- package/lib/modules/Order/utils.js +27 -6
- package/lib/modules/ProductList/index.d.ts +1 -3
- package/lib/modules/ProductList/index.js +22 -31
- package/lib/modules/ProductList/types.d.ts +0 -8
- package/lib/modules/ProductList/types.js +0 -1
- package/lib/server/index.js +6 -0
- package/lib/server/modules/order/index.d.ts +4 -0
- package/lib/server/modules/order/index.js +46 -4
- package/lib/server/modules/order/types.d.ts +3 -0
- package/lib/shared/receipt/small-ticket.js +15 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +8 -0
- package/lib/solution/BaseSales/index.js +121 -9
- package/lib/solution/BaseSales/types.d.ts +2 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/BookingTicket/index.js +4 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +7 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -7
- package/lib/solution/UnifiedBookingSales/index.js +12 -80
- package/package.json +1 -1
|
@@ -99,105 +99,27 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
99
99
|
}, {
|
|
100
100
|
key: "updateOtherParams",
|
|
101
101
|
value: function updateOtherParams(params) {
|
|
102
|
+
var previousScope = this.otherParams.catalogScopeKey;
|
|
102
103
|
this.otherParams = params || {};
|
|
104
|
+
if (previousScope !== this.otherParams.catalogScopeKey && (previousScope || this.otherParams.catalogScopeKey)) {
|
|
105
|
+
this.store.list = [];
|
|
106
|
+
this.rawProductPriceSources.clear();
|
|
107
|
+
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
108
|
+
}
|
|
103
109
|
}
|
|
104
110
|
}, {
|
|
105
|
-
key: "
|
|
111
|
+
key: "storeChange",
|
|
106
112
|
value: function () {
|
|
107
|
-
var
|
|
108
|
-
var _context$signal, _context$signal2;
|
|
109
|
-
var enrich, result;
|
|
113
|
+
var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
|
|
110
114
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
111
115
|
while (1) switch (_context2.prev = _context2.next) {
|
|
112
116
|
case 0:
|
|
113
|
-
enrich = this.otherParams.enrichProducts;
|
|
114
|
-
if (enrich) {
|
|
115
|
-
_context2.next = 3;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
return _context2.abrupt("return", products);
|
|
119
|
-
case 3:
|
|
120
|
-
if (!((_context$signal = context.signal) !== null && _context$signal !== void 0 && _context$signal.aborted)) {
|
|
121
|
-
_context2.next = 5;
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
throw new Error('Product enrichment cancelled');
|
|
125
|
-
case 5:
|
|
126
|
-
_context2.next = 7;
|
|
127
|
-
return enrich(cloneDeep(products), _objectSpread({
|
|
128
|
-
businessCode: this.otherParams.businessCode,
|
|
129
|
-
channel: this.otherParams.channel
|
|
130
|
-
}, context));
|
|
131
|
-
case 7:
|
|
132
|
-
result = _context2.sent;
|
|
133
|
-
if (!((_context$signal2 = context.signal) !== null && _context$signal2 !== void 0 && _context$signal2.aborted)) {
|
|
134
|
-
_context2.next = 10;
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
throw new Error('Product enrichment cancelled');
|
|
138
|
-
case 10:
|
|
139
|
-
if (Array.isArray(result)) {
|
|
140
|
-
_context2.next = 12;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
throw new Error('Product enrichment must return an array');
|
|
144
|
-
case 12:
|
|
145
|
-
return _context2.abrupt("return", result);
|
|
146
|
-
case 13:
|
|
147
117
|
case "end":
|
|
148
118
|
return _context2.stop();
|
|
149
119
|
}
|
|
150
|
-
}, _callee2
|
|
151
|
-
}));
|
|
152
|
-
function enrichProducts(_x3, _x4) {
|
|
153
|
-
return _enrichProducts.apply(this, arguments);
|
|
154
|
-
}
|
|
155
|
-
return enrichProducts;
|
|
156
|
-
}()
|
|
157
|
-
}, {
|
|
158
|
-
key: "enrichCatalog",
|
|
159
|
-
value: function () {
|
|
160
|
-
var _enrichCatalog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(products, reason) {
|
|
161
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
162
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
163
|
-
case 0:
|
|
164
|
-
_context3.prev = 0;
|
|
165
|
-
_context3.next = 3;
|
|
166
|
-
return this.enrichProducts(products, {
|
|
167
|
-
reason: reason
|
|
168
|
-
});
|
|
169
|
-
case 3:
|
|
170
|
-
return _context3.abrupt("return", _context3.sent);
|
|
171
|
-
case 6:
|
|
172
|
-
_context3.prev = 6;
|
|
173
|
-
_context3.t0 = _context3["catch"](0);
|
|
174
|
-
// An unavailable supplementary source is not zero stock or an empty catalog.
|
|
175
|
-
console.warn('[ProductList] Supplementary product data could not be refreshed');
|
|
176
|
-
return _context3.abrupt("return", products);
|
|
177
|
-
case 10:
|
|
178
|
-
case "end":
|
|
179
|
-
return _context3.stop();
|
|
180
|
-
}
|
|
181
|
-
}, _callee3, this, [[0, 6]]);
|
|
182
|
-
}));
|
|
183
|
-
function enrichCatalog(_x5, _x6) {
|
|
184
|
-
return _enrichCatalog.apply(this, arguments);
|
|
185
|
-
}
|
|
186
|
-
return enrichCatalog;
|
|
187
|
-
}()
|
|
188
|
-
}, {
|
|
189
|
-
key: "storeChange",
|
|
190
|
-
value: function () {
|
|
191
|
-
var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, value) {
|
|
192
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
193
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
case "end":
|
|
196
|
-
return _context4.stop();
|
|
197
|
-
}
|
|
198
|
-
}, _callee4);
|
|
120
|
+
}, _callee2);
|
|
199
121
|
}));
|
|
200
|
-
function storeChange(
|
|
122
|
+
function storeChange(_x3, _x4) {
|
|
201
123
|
return _storeChange.apply(this, arguments);
|
|
202
124
|
}
|
|
203
125
|
return storeChange;
|
|
@@ -211,14 +133,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
133
|
}, {
|
|
212
134
|
key: "getAddTimeProducts",
|
|
213
135
|
value: (function () {
|
|
214
|
-
var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
136
|
+
var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
215
137
|
var params,
|
|
216
|
-
|
|
217
|
-
return _regeneratorRuntime().wrap(function
|
|
218
|
-
while (1) switch (
|
|
138
|
+
_args3 = arguments;
|
|
139
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
140
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
219
141
|
case 0:
|
|
220
|
-
params =
|
|
221
|
-
return
|
|
142
|
+
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
143
|
+
return _context3.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
|
|
222
144
|
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
223
145
|
status: 'published'
|
|
224
146
|
}, params), {}, {
|
|
@@ -226,9 +148,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
226
148
|
})));
|
|
227
149
|
case 2:
|
|
228
150
|
case "end":
|
|
229
|
-
return
|
|
151
|
+
return _context3.stop();
|
|
230
152
|
}
|
|
231
|
-
},
|
|
153
|
+
}, _callee3, this);
|
|
232
154
|
}));
|
|
233
155
|
function getAddTimeProducts() {
|
|
234
156
|
return _getAddTimeProducts.apply(this, arguments);
|
|
@@ -238,13 +160,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
160
|
}, {
|
|
239
161
|
key: "loadProducts",
|
|
240
162
|
value: function () {
|
|
241
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
242
|
-
var
|
|
163
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
164
|
+
var _this2 = this,
|
|
165
|
+
_this$otherParams,
|
|
243
166
|
_this$otherParams$bus,
|
|
244
167
|
_this$otherParams2,
|
|
245
168
|
_this$otherParams3,
|
|
246
|
-
_this$otherParams4
|
|
247
|
-
_this2 = this;
|
|
169
|
+
_this$otherParams4;
|
|
248
170
|
var _ref,
|
|
249
171
|
_ref$category_ids,
|
|
250
172
|
category_ids,
|
|
@@ -266,6 +188,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
266
188
|
status,
|
|
267
189
|
strategy_context,
|
|
268
190
|
options,
|
|
191
|
+
scope,
|
|
192
|
+
assertScope,
|
|
269
193
|
userPlugin,
|
|
270
194
|
customer_id,
|
|
271
195
|
_userPlugin$get,
|
|
@@ -280,15 +204,21 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
280
204
|
subscriptionCallback,
|
|
281
205
|
productsData,
|
|
282
206
|
resolvedList,
|
|
283
|
-
enrichedList,
|
|
284
207
|
sortedList,
|
|
285
|
-
|
|
286
|
-
return _regeneratorRuntime().wrap(function
|
|
287
|
-
while (1) switch (
|
|
208
|
+
_args5 = arguments;
|
|
209
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
210
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
288
211
|
case 0:
|
|
289
|
-
_ref =
|
|
290
|
-
options =
|
|
291
|
-
|
|
212
|
+
_ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
|
|
213
|
+
options = _args5.length > 1 ? _args5[1] : undefined;
|
|
214
|
+
scope = this.otherParams.catalogScopeKey;
|
|
215
|
+
assertScope = function assertScope() {
|
|
216
|
+
if (scope !== _this2.otherParams.catalogScopeKey) {
|
|
217
|
+
throw Object.assign(new Error('Product catalog context changed'), {
|
|
218
|
+
name: 'AbortError'
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}; // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
292
222
|
// if (!schedule_ids?.length) {
|
|
293
223
|
// const schedule_ids_data = this.store.schedule
|
|
294
224
|
// .getScheduleListByIds(schedule_ids)
|
|
@@ -359,63 +289,67 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
359
289
|
handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
|
|
360
290
|
originalCallback = typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? options.callback : undefined;
|
|
361
291
|
subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
|
|
362
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
292
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
|
|
363
293
|
var _result$data;
|
|
364
|
-
var callbackList,
|
|
365
|
-
return _regeneratorRuntime().wrap(function
|
|
366
|
-
while (1) switch (
|
|
294
|
+
var callbackList, products;
|
|
295
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
296
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
367
297
|
case 0:
|
|
298
|
+
if (!(scope !== _this2.otherParams.catalogScopeKey)) {
|
|
299
|
+
_context4.next = 2;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
return _context4.abrupt("return");
|
|
303
|
+
case 2:
|
|
368
304
|
callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
|
|
369
305
|
if (Array.isArray(callbackList)) {
|
|
370
|
-
|
|
306
|
+
_context4.next = 6;
|
|
371
307
|
break;
|
|
372
308
|
}
|
|
373
309
|
originalCallback(result);
|
|
374
|
-
return
|
|
375
|
-
case
|
|
310
|
+
return _context4.abrupt("return");
|
|
311
|
+
case 6:
|
|
376
312
|
if (!handledByOsServer) {
|
|
377
313
|
// Subscription payloads may contain only changed products, so keep
|
|
378
314
|
// the existing raw catalog scope and upsert the changed records.
|
|
379
315
|
_this2.rememberRawProductQueryResult(callbackList);
|
|
380
316
|
}
|
|
381
|
-
|
|
317
|
+
products = resolveClientDataVariants({
|
|
382
318
|
core: _this2.core,
|
|
383
319
|
otherParams: _this2.otherParams,
|
|
384
320
|
products: callbackList,
|
|
385
321
|
queryPayload: queryPayload,
|
|
386
322
|
handledByOsServer: handledByOsServer
|
|
387
323
|
});
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
enrichedCallbackList = _context6.sent;
|
|
392
|
-
_context6.next = 11;
|
|
393
|
-
return _this2.addProduct(enrichedCallbackList);
|
|
324
|
+
assertScope();
|
|
325
|
+
_context4.next = 11;
|
|
326
|
+
return _this2.addProduct(products);
|
|
394
327
|
case 11:
|
|
395
|
-
originalCallback(
|
|
328
|
+
originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
|
|
396
329
|
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
397
|
-
list:
|
|
330
|
+
list: products
|
|
398
331
|
})
|
|
399
332
|
}));
|
|
400
333
|
case 12:
|
|
401
334
|
case "end":
|
|
402
|
-
return
|
|
335
|
+
return _context4.stop();
|
|
403
336
|
}
|
|
404
|
-
},
|
|
337
|
+
}, _callee4);
|
|
405
338
|
}));
|
|
406
|
-
return function (
|
|
339
|
+
return function (_x5) {
|
|
407
340
|
return _ref2.apply(this, arguments);
|
|
408
341
|
};
|
|
409
342
|
}()) : undefined;
|
|
410
|
-
|
|
343
|
+
_context5.next = 18;
|
|
411
344
|
return this.request.post("/product/query", queryPayload, {
|
|
412
345
|
osServer: true,
|
|
413
346
|
callback: subscriptionCallback,
|
|
414
347
|
subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
|
|
415
348
|
customToast: function customToast() {}
|
|
416
349
|
});
|
|
417
|
-
case
|
|
418
|
-
productsData =
|
|
350
|
+
case 18:
|
|
351
|
+
productsData = _context5.sent;
|
|
352
|
+
assertScope();
|
|
419
353
|
if (!handledByOsServer && Array.isArray(productsData.data.list)) {
|
|
420
354
|
this.replaceRawProductQueryResult(productsData.data.list, product_ids);
|
|
421
355
|
}
|
|
@@ -426,11 +360,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
426
360
|
queryPayload: queryPayload,
|
|
427
361
|
handledByOsServer: handledByOsServer
|
|
428
362
|
});
|
|
429
|
-
|
|
430
|
-
return this.enrichCatalog(resolvedList, 'catalog');
|
|
431
|
-
case 21:
|
|
432
|
-
enrichedList = _context7.sent;
|
|
433
|
-
sortedList = enrichedList.slice().sort(function (a, b) {
|
|
363
|
+
sortedList = resolvedList.slice().sort(function (a, b) {
|
|
434
364
|
return Number(b.sort) - Number(a.sort);
|
|
435
365
|
}); // if (sortedList.length) {
|
|
436
366
|
// sortedList.forEach((n: any) => {
|
|
@@ -439,15 +369,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
369
|
// }
|
|
440
370
|
// })
|
|
441
371
|
// }
|
|
442
|
-
|
|
443
|
-
return
|
|
372
|
+
this.addProduct(sortedList);
|
|
373
|
+
return _context5.abrupt("return", sortedList);
|
|
444
374
|
case 25:
|
|
445
|
-
return _context7.abrupt("return", sortedList);
|
|
446
|
-
case 26:
|
|
447
375
|
case "end":
|
|
448
|
-
return
|
|
376
|
+
return _context5.stop();
|
|
449
377
|
}
|
|
450
|
-
},
|
|
378
|
+
}, _callee5, this);
|
|
451
379
|
}));
|
|
452
380
|
function loadProducts() {
|
|
453
381
|
return _loadProducts.apply(this, arguments);
|
|
@@ -457,13 +385,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
457
385
|
}, {
|
|
458
386
|
key: "loadProductsPrice",
|
|
459
387
|
value: function () {
|
|
460
|
-
var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
388
|
+
var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
|
|
461
389
|
var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
|
|
462
|
-
return _regeneratorRuntime().wrap(function
|
|
463
|
-
while (1) switch (
|
|
390
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
391
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
464
392
|
case 0:
|
|
465
393
|
_ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
|
|
466
|
-
|
|
394
|
+
_context6.next = 3;
|
|
467
395
|
return this.request.post("/product/query/price", {
|
|
468
396
|
ids: ids,
|
|
469
397
|
customer_id: customer_id,
|
|
@@ -473,15 +401,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
473
401
|
useCache: true
|
|
474
402
|
});
|
|
475
403
|
case 3:
|
|
476
|
-
productsData =
|
|
477
|
-
return
|
|
404
|
+
productsData = _context6.sent;
|
|
405
|
+
return _context6.abrupt("return", productsData.data);
|
|
478
406
|
case 5:
|
|
479
407
|
case "end":
|
|
480
|
-
return
|
|
408
|
+
return _context6.stop();
|
|
481
409
|
}
|
|
482
|
-
},
|
|
410
|
+
}, _callee6, this);
|
|
483
411
|
}));
|
|
484
|
-
function loadProductsPrice(
|
|
412
|
+
function loadProductsPrice(_x6) {
|
|
485
413
|
return _loadProductsPrice.apply(this, arguments);
|
|
486
414
|
}
|
|
487
415
|
return loadProductsPrice;
|
|
@@ -543,19 +471,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
543
471
|
}, {
|
|
544
472
|
key: "getProducts",
|
|
545
473
|
value: function () {
|
|
546
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
547
|
-
return _regeneratorRuntime().wrap(function
|
|
548
|
-
while (1) switch (
|
|
474
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
475
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
476
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
549
477
|
case 0:
|
|
550
|
-
|
|
478
|
+
_context7.next = 2;
|
|
551
479
|
return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
|
|
552
480
|
case 2:
|
|
553
|
-
return
|
|
481
|
+
return _context7.abrupt("return", cloneDeep(this.store.list));
|
|
554
482
|
case 3:
|
|
555
483
|
case "end":
|
|
556
|
-
return
|
|
484
|
+
return _context7.stop();
|
|
557
485
|
}
|
|
558
|
-
},
|
|
486
|
+
}, _callee7, this);
|
|
559
487
|
}));
|
|
560
488
|
function getProducts() {
|
|
561
489
|
return _getProducts.apply(this, arguments);
|
|
@@ -565,25 +493,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
565
493
|
}, {
|
|
566
494
|
key: "getProduct",
|
|
567
495
|
value: function () {
|
|
568
|
-
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
496
|
+
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
|
|
569
497
|
var product;
|
|
570
|
-
return _regeneratorRuntime().wrap(function
|
|
571
|
-
while (1) switch (
|
|
498
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
499
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
572
500
|
case 0:
|
|
573
|
-
|
|
501
|
+
_context8.next = 2;
|
|
574
502
|
return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
|
|
575
503
|
case 2:
|
|
576
504
|
product = this.store.list.find(function (product) {
|
|
577
505
|
return product.id === id;
|
|
578
506
|
});
|
|
579
|
-
return
|
|
507
|
+
return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
|
|
580
508
|
case 4:
|
|
581
509
|
case "end":
|
|
582
|
-
return
|
|
510
|
+
return _context8.stop();
|
|
583
511
|
}
|
|
584
|
-
},
|
|
512
|
+
}, _callee8, this);
|
|
585
513
|
}));
|
|
586
|
-
function getProduct(
|
|
514
|
+
function getProduct(_x7) {
|
|
587
515
|
return _getProduct.apply(this, arguments);
|
|
588
516
|
}
|
|
589
517
|
return getProduct;
|
|
@@ -591,7 +519,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
591
519
|
}, {
|
|
592
520
|
key: "queryProducts",
|
|
593
521
|
value: function () {
|
|
594
|
-
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
522
|
+
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
595
523
|
var params,
|
|
596
524
|
includeIds,
|
|
597
525
|
excludeIds,
|
|
@@ -602,11 +530,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
602
530
|
channelApplications,
|
|
603
531
|
codeOrBarcode,
|
|
604
532
|
products,
|
|
605
|
-
|
|
606
|
-
return _regeneratorRuntime().wrap(function
|
|
607
|
-
while (1) switch (
|
|
533
|
+
_args9 = arguments;
|
|
534
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
535
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
608
536
|
case 0:
|
|
609
|
-
params =
|
|
537
|
+
params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
610
538
|
includeIds = normalizeQuerySet(params.includeIds);
|
|
611
539
|
excludeIds = normalizeQuerySet(params.excludeIds);
|
|
612
540
|
categoryIds = normalizeQuerySet(params.categoryIds);
|
|
@@ -645,12 +573,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
645
573
|
}
|
|
646
574
|
return true;
|
|
647
575
|
});
|
|
648
|
-
return
|
|
576
|
+
return _context9.abrupt("return", cloneDeep(products));
|
|
649
577
|
case 11:
|
|
650
578
|
case "end":
|
|
651
|
-
return
|
|
579
|
+
return _context9.stop();
|
|
652
580
|
}
|
|
653
|
-
},
|
|
581
|
+
}, _callee9, this);
|
|
654
582
|
}));
|
|
655
583
|
function queryProducts() {
|
|
656
584
|
return _queryProducts.apply(this, arguments);
|
|
@@ -660,23 +588,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
588
|
}, {
|
|
661
589
|
key: "getProductByIds",
|
|
662
590
|
value: function () {
|
|
663
|
-
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
664
|
-
return _regeneratorRuntime().wrap(function
|
|
665
|
-
while (1) switch (
|
|
591
|
+
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
593
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
666
594
|
case 0:
|
|
667
|
-
|
|
595
|
+
_context10.next = 2;
|
|
668
596
|
return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
|
|
669
597
|
case 2:
|
|
670
|
-
return
|
|
598
|
+
return _context10.abrupt("return", this.queryProducts({
|
|
671
599
|
includeIds: ids
|
|
672
600
|
}));
|
|
673
601
|
case 3:
|
|
674
602
|
case "end":
|
|
675
|
-
return
|
|
603
|
+
return _context10.stop();
|
|
676
604
|
}
|
|
677
|
-
},
|
|
605
|
+
}, _callee10, this);
|
|
678
606
|
}));
|
|
679
|
-
function getProductByIds(
|
|
607
|
+
function getProductByIds(_x8) {
|
|
680
608
|
return _getProductByIds.apply(this, arguments);
|
|
681
609
|
}
|
|
682
610
|
return getProductByIds;
|
|
@@ -684,10 +612,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
684
612
|
}, {
|
|
685
613
|
key: "addProduct",
|
|
686
614
|
value: function () {
|
|
687
|
-
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
615
|
+
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
|
|
688
616
|
var _this6 = this;
|
|
689
|
-
return _regeneratorRuntime().wrap(function
|
|
690
|
-
while (1) switch (
|
|
617
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
618
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
691
619
|
case 0:
|
|
692
620
|
// list 需要根据 id 去重
|
|
693
621
|
if (!this.store.list) {
|
|
@@ -710,11 +638,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
710
638
|
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
711
639
|
case 4:
|
|
712
640
|
case "end":
|
|
713
|
-
return
|
|
641
|
+
return _context11.stop();
|
|
714
642
|
}
|
|
715
|
-
},
|
|
643
|
+
}, _callee11, this);
|
|
716
644
|
}));
|
|
717
|
-
function addProduct(
|
|
645
|
+
function addProduct(_x9) {
|
|
718
646
|
return _addProduct.apply(this, arguments);
|
|
719
647
|
}
|
|
720
648
|
return addProduct;
|
|
@@ -722,18 +650,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
722
650
|
}, {
|
|
723
651
|
key: "selectProducts",
|
|
724
652
|
value: function () {
|
|
725
|
-
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
726
|
-
return _regeneratorRuntime().wrap(function
|
|
727
|
-
while (1) switch (
|
|
653
|
+
var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(products) {
|
|
654
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
655
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
728
656
|
case 0:
|
|
729
657
|
this.store.selectProducts = products;
|
|
730
658
|
case 1:
|
|
731
659
|
case "end":
|
|
732
|
-
return
|
|
660
|
+
return _context12.stop();
|
|
733
661
|
}
|
|
734
|
-
},
|
|
662
|
+
}, _callee12, this);
|
|
735
663
|
}));
|
|
736
|
-
function selectProducts(
|
|
664
|
+
function selectProducts(_x10) {
|
|
737
665
|
return _selectProducts.apply(this, arguments);
|
|
738
666
|
}
|
|
739
667
|
return selectProducts;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { ProductData } from '../Product/types';
|
|
2
|
-
/** Runtime-only enrichment; never serialized into a product query. */
|
|
3
|
-
export interface ProductEnrichmentContext {
|
|
4
|
-
reason: 'catalog' | 'catalog-update' | 'detail-open';
|
|
5
|
-
businessCode?: string;
|
|
6
|
-
channel?: string;
|
|
7
|
-
signal?: AbortSignal;
|
|
8
|
-
}
|
|
9
|
-
export type ProductEnricher = (products: ProductData[], context: ProductEnrichmentContext) => Promise<ProductData[]>;
|
|
10
2
|
export interface ProductListLoadProductsParams {
|
|
11
3
|
category_ids?: number[];
|
|
12
4
|
product_ids?: number[];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Runtime-only enrichment; never serialized into a product query. */
|
|
2
|
-
|
|
3
1
|
export var ProductListHooks = /*#__PURE__*/function (ProductListHooks) {
|
|
4
2
|
ProductListHooks["onGetProducts"] = "productList:onGetProducts";
|
|
5
3
|
ProductListHooks["onGetProduct"] = "productList:onGetProduct";
|
package/dist/server/index.js
CHANGED
|
@@ -2845,7 +2845,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2845
2845
|
backendPath = params.backendPath, checkoutData = params.checkoutData, externalSaleNumber = params.externalSaleNumber, fresh = params.fresh, title = params.title, persistCheckoutDataWithResponse = params.persistCheckoutDataWithResponse;
|
|
2846
2846
|
shouldMergeRemoteOrder = fresh ? this.isMergeableCheckoutOrder(fresh, externalSaleNumber) : false;
|
|
2847
2847
|
if (!(this.order && fresh && (shouldMergeRemoteOrder || persistCheckoutDataWithResponse))) {
|
|
2848
|
-
_context34.next =
|
|
2848
|
+
_context34.next = 10;
|
|
2849
2849
|
break;
|
|
2850
2850
|
}
|
|
2851
2851
|
syncedOrder = persistCheckoutDataWithResponse ? _objectSpread(_objectSpread(_objectSpread({}, checkoutData), this.mergeCheckoutSyncPayments(checkoutData, fresh, title)), {}, {
|
|
@@ -2857,9 +2857,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
2857
2857
|
need_sync: 0,
|
|
2858
2858
|
is_draft_order: 0
|
|
2859
2859
|
});
|
|
2860
|
-
|
|
2860
|
+
if (!Array.isArray(fresh.holder_relations) && Array.isArray(checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.holder_relations)) {
|
|
2861
|
+
syncedOrder.holder_relations = cloneDeep(checkoutData.holder_relations);
|
|
2862
|
+
}
|
|
2863
|
+
_context34.next = 7;
|
|
2861
2864
|
return this.order.upsertOrdersFromRemote([syncedOrder], 'checkoutSync');
|
|
2862
|
-
case
|
|
2865
|
+
case 7:
|
|
2863
2866
|
this.logInfo("".concat(title, ": sync_sales \u5B8C\u6574\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u672C\u5730"), {
|
|
2864
2867
|
order_id: fresh.order_id,
|
|
2865
2868
|
external_sale_number: syncedOrder.external_sale_number,
|
|
@@ -2867,20 +2870,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
2867
2870
|
mergedRemoteOrder: shouldMergeRemoteOrder,
|
|
2868
2871
|
persistedCheckoutDataWithResponse: persistCheckoutDataWithResponse
|
|
2869
2872
|
});
|
|
2870
|
-
_context34.next =
|
|
2873
|
+
_context34.next = 20;
|
|
2871
2874
|
break;
|
|
2872
|
-
case
|
|
2875
|
+
case 10:
|
|
2873
2876
|
if (!(this.order && externalSaleNumber && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
2874
|
-
_context34.next =
|
|
2877
|
+
_context34.next = 19;
|
|
2875
2878
|
break;
|
|
2876
2879
|
}
|
|
2877
2880
|
patch = this.buildCheckoutSyncSuccessPatch(fresh);
|
|
2878
|
-
_context34.next =
|
|
2881
|
+
_context34.next = 14;
|
|
2879
2882
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
2880
2883
|
externalSaleNumber: externalSaleNumber,
|
|
2881
2884
|
patch: patch
|
|
2882
2885
|
});
|
|
2883
|
-
case
|
|
2886
|
+
case 14:
|
|
2884
2887
|
result = _context34.sent;
|
|
2885
2888
|
syncedOrder = (result === null || result === void 0 ? void 0 : result.order) || _objectSpread(_objectSpread(_objectSpread({}, checkoutData), patch), {}, {
|
|
2886
2889
|
external_sale_number: externalSaleNumber,
|
|
@@ -2893,17 +2896,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
2893
2896
|
hasRemoteOrder: !!fresh,
|
|
2894
2897
|
mergedRemoteOrder: false
|
|
2895
2898
|
});
|
|
2896
|
-
_context34.next =
|
|
2899
|
+
_context34.next = 20;
|
|
2897
2900
|
break;
|
|
2898
|
-
case
|
|
2901
|
+
case 19:
|
|
2899
2902
|
this.logWarning("".concat(title, ": sync_sales Order \u6A21\u5757\u672A\u6CE8\u518C"), {
|
|
2900
2903
|
backendPath: backendPath,
|
|
2901
2904
|
external_sale_number: externalSaleNumber,
|
|
2902
2905
|
order_id: fresh === null || fresh === void 0 ? void 0 : fresh.order_id
|
|
2903
2906
|
});
|
|
2904
|
-
case 19:
|
|
2905
|
-
return _context34.abrupt("return", syncedOrder);
|
|
2906
2907
|
case 20:
|
|
2908
|
+
return _context34.abrupt("return", syncedOrder);
|
|
2909
|
+
case 21:
|
|
2907
2910
|
case "end":
|
|
2908
2911
|
return _context34.stop();
|
|
2909
2912
|
}
|
|
@@ -8002,6 +8005,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8002
8005
|
if (fresh.order_number !== undefined && fresh.order_number !== null) {
|
|
8003
8006
|
patch.order_number = fresh.order_number;
|
|
8004
8007
|
}
|
|
8008
|
+
if (Array.isArray(fresh.holder_relations)) {
|
|
8009
|
+
patch.holder_relations = cloneDeep(fresh.holder_relations);
|
|
8010
|
+
}
|
|
8005
8011
|
return patch;
|
|
8006
8012
|
}
|
|
8007
8013
|
}, {
|